sel4-sys: merge more stuff from capdl

Change-Id: If7a7b4ab4e6fee1d0df3fd5f6e84ccdfaca6275b
GitOrigin-RevId: 2db9e128e347c19030d280141949e4831681e6c7
This commit is contained in:
Sam Leffler 2021-11-10 21:46:22 +00:00
parent 87caf7e4a8
commit c36bae9f1f
3 changed files with 44 additions and 17 deletions

View File

@ -77,6 +77,11 @@ pub enum seL4_RISCV_VMAttributes {
ExecuteNever = 0x1,
Default_VMAttributes = 0,
}
impl From<u32> for seL4_RISCV_VMAttributes {
fn from(val: u32) -> seL4_RISCV_VMAttributes {
unsafe { ::core::mem::transmute(val & 1) }
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

View File

@ -17,8 +17,10 @@ fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let cargo_target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let cargo_target_pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();
println!("target_arch = {} target_pointer_width = {}",
cargo_target_arch, cargo_target_pointer_width);
println!(
"target_arch = {} target_pointer_width = {}",
cargo_target_arch, cargo_target_pointer_width
);
// Default to python3 (maybe necessary for code divergence)
let python_bin = env::var("PYTHON").unwrap_or_else(|_| "python3".to_string());
@ -31,16 +33,20 @@ fn main() {
// to select the target architecture;
// NB: this mimics the logic in lib.rs
let (arch, archdir) = match cargo_target_arch.as_str() {
"x86" => ("ia32", "x86"),
"x86_64" => ("x86_64", "x86"),
"x86" => ("ia32", "x86"),
"x86_64" => ("x86_64", "x86"),
"arm" => match cargo_target_pointer_width.as_str() {
"32" => ("aarch32", "arm"),
"64" => ("aarch64", "arm"),
_ => { panic!("Unsupported arm word size {}", cargo_target_pointer_width); }
}
_ => {
panic!("Unsupported arm word size {}", cargo_target_pointer_width);
}
},
"riscv32" => ("riscv32", "riscv"),
"riscv64" => ("riscv64", "riscv"),
_ => { panic!("Unsupported architecture {}", cargo_target_arch); }
_ => {
panic!("Unsupported architecture {}", cargo_target_arch);
}
};
let xml_interfaces_file = format!("{}/libsel4/include/interfaces/sel4.xml", sel4_dir);
@ -116,7 +122,11 @@ fn main() {
))
.unwrap();
println!("{}/types{}.rs", out_dir, cargo_target_pointer_width);
let bfout = File::create(&*format!("{}/types{}.rs", out_dir, cargo_target_pointer_width)).unwrap();
let bfout = File::create(&*format!(
"{}/types{}.rs",
out_dir, cargo_target_pointer_width
))
.unwrap();
let mut cmd = Command::new("/usr/bin/env");
cmd.arg(&python_bin)
.arg("tools/bitfield_gen.py")

View File

@ -132,18 +132,17 @@ include!(concat!(env!("OUT_DIR"), "/syscalls.rs"));
// Well-known types from libsel4/include/sel4/types.h
pub type seL4_CNode = seL4_CPtr;
pub type seL4_Domain = seL4_Word;
pub type seL4_DomainSet = seL4_CPtr;
pub type seL4_IRQControl = seL4_CPtr;
pub type seL4_IRQHandler = seL4_CPtr;
pub type seL4_NodeId = seL4_Word;
pub type seL4_PAddr = seL4_Word;
pub type seL4_Domain = seL4_Word;
pub type seL4_CNode = seL4_CPtr;
pub type seL4_IRQHandler = seL4_CPtr;
pub type seL4_IRQControl = seL4_CPtr;
pub type seL4_TCB = seL4_CPtr;
pub type seL4_Untyped = seL4_CPtr;
pub type seL4_DomainSet = seL4_CPtr;
pub type seL4_SchedContext = seL4_CPtr;
pub type seL4_SchedControl = seL4_CPtr;
pub type seL4_TCB = seL4_CPtr;
pub type seL4_Untyped = seL4_CPtr;
// TODO(sleffler): seL4 uses seL4_Uint64 but it's not defined for us
pub type seL4_Time = u64;
@ -154,7 +153,7 @@ pub const seL4_MsgExtraCapBits: usize = 2;
pub const seL4_MsgMaxExtraCaps: usize = (1usize << seL4_MsgExtraCapBits) - 1;
// Syscall stubs are generated to return seL4_Result unless they return
// an APi struct with an embedded error code. The latter should be replaced
// an API struct with an embedded error code. The latter should be replaced
// too but for now we leave it as-is.
pub type seL4_Result = Result<(), seL4_Error>;
@ -210,6 +209,19 @@ impl ::core::clone::Clone for seL4_IPCBuffer {
}
}
// From libsel4/include/sel4/shared_types.h; this is defined in C as an enum
// but we use pub const because the C code intentionally declares overlapping
// values which Rust rejects. Nothing (atm) uses the actual enum type so this
// should be compatible.
pub const seL4_CapFault_IP: seL4_Word = 0;
pub const seL4_CapFault_Addr: seL4_Word = 1;
pub const seL4_CapFault_InRecvPhase: seL4_Word = 2;
pub const seL4_CapFault_LookupFailureType: seL4_Word = 3;
pub const seL4_CapFault_BitsLeft: seL4_Word = 4;
pub const seL4_CapFault_DepthMismatch_BitsFound: seL4_Word = 5;
pub const seL4_CapFault_GuardMismatch_GuardFound: seL4_Word = seL4_CapFault_DepthMismatch_BitsFound;
pub const seL4_CapFault_GuardMismatch_BitsFound: seL4_Word = 6;
// Bootinfo
// Fixed cap slots for root thread.