#os #amd64 #x86 #x86-64 #ia32

x86

Library to program x86 (amd64) hardware. Contains x86 specific data structure descriptions, data-tables, as well as convenience function to call assembly instructions typically not exposed in higher level languages.

73 releases (breaking)

0.51.0 Jul 15, 2022
0.49.0 Jun 4, 2022
0.47.0 Mar 3, 2022
0.43.0 Sep 30, 2021
0.0.1 Mar 28, 2015

#62 in Hardware support

Download history 3684/week @ 2022-04-21 3717/week @ 2022-04-28 4192/week @ 2022-05-05 5498/week @ 2022-05-12 3233/week @ 2022-05-19 4572/week @ 2022-05-26 4481/week @ 2022-06-02 4625/week @ 2022-06-09 3443/week @ 2022-06-16 4020/week @ 2022-06-23 4030/week @ 2022-06-30 2819/week @ 2022-07-07 4003/week @ 2022-07-14 4306/week @ 2022-07-21 3236/week @ 2022-07-28 2065/week @ 2022-08-04

14,100 downloads per month
Used in 22 crates (17 directly)

MIT license

2MB
8K SLoC

x86 / amd64 library Crates.io docs.rs/x86 Standard checks

Library to program x86 (amd64) hardware. Contains x86 specific data structure descriptions, data-tables, as well as convenience function to call assembly instructions typically not exposed in higher level languages.

Currently supports:

  • I/O registers
  • Control registers
  • Debug registers
  • MSR registers
  • Segmentation
  • Descriptor-tables (GDT, LDT, IDT)
  • IA32-e page table layout
  • Interrupts (with xAPIC and x2APIC, I/O APIC drivers)
  • Task state
  • Performance counter information
  • Intel SGX: Software Guard Extensions
  • Random numbers (rdrand, rdseed)
  • Time (rdtsc, rdtscp)
  • Querying CPUID (uses raw_cpuid library)
  • Transactional memory (Intel RTM and HLE)
  • Virtualization (Intel VMX)

This library depends on libcore so it can be used in kernel level code.

Testing

We use two forms of tests for the crate. Regular tests with #[test] that run in a ring 3 process and #[x86test] tests that run in a VM (and therefore grant a privileged execution environment, see x86test).

# To execute x86tests run:
$ RUSTFLAGS="-C relocation-model=dynamic-no-pic -C code-model=kernel" RUST_BACKTRACE=1 cargo test --features vmtest

# To execute the regular tests, run:
$ cargo test --features utest

Features

  • performance-counter: Includes the performance counter information. Note this feature can increase compilation time significantly due to large, statically generated hash-tables that are included in the source. Therefore, it is disabled by default.

Documentation

Dependencies