MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / init

Function init

framework_lib/src/chromium_ec/windows.rs:30–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28}
29
30fn init() -> bool {
31 let mut device = DEVICE.lock().unwrap();
32 if (*device).is_some() {
33 return true;
34 }
35
36 let path = w!(r"\\.\GLOBALROOT\Device\CrosEC");
37 let res = unsafe {
38 CreateFileW(
39 path,
40 FILE_GENERIC_READ.0 | FILE_GENERIC_WRITE.0,
41 FILE_SHARE_READ | FILE_SHARE_WRITE,
42 None,
43 OPEN_EXISTING,
44 FILE_FLAGS_AND_ATTRIBUTES(0),
45 None,
46 )
47 };
48 let handle = match res {
49 Ok(h) => h,
50 Err(err) => {
51 let platform = smbios::get_platform();
52 match platform {
53 Some(platform @ Platform::IntelGen11)
54 | Some(platform @ Platform::IntelGen12)
55 | Some(platform @ Platform::IntelGen13) => {
56 println!("The windows driver is not enabled on {:?}.", platform);
57 println!("Please stay tuned for future BIOS and driver updates.");
58 println!();
59 }
60 Some(Platform::IntelCoreUltra1) => {
61 println!("The windows driver has been enabled since BIOS 3.06.");
62 println!("Please install the latest BIOS and drivers");
63 println!();
64 }
65 Some(Platform::Framework13Amd7080) => {
66 println!("The windows driver has been enabled since BIOS 3.16.");
67 println!("Please install the latest BIOS and drivers");
68 println!();
69 }
70 Some(Platform::Framework16Amd7080) => {
71 println!("The windows driver has been enabled since BIOS 3.06.");
72 println!("Please install the latest BIOS and drivers");
73 println!();
74 }
75 _ => (),
76 }
77
78 error!("Failed to find Windows driver. {:?}", err);
79 return false;
80 }
81 };
82
83 *device = Some(DevHandle(handle));
84 true
85}
86
87pub fn read_memory(offset: u16, length: u16) -> EcResult<Vec<u8>> {

Callers 2

read_memoryFunction · 0.70
send_commandFunction · 0.70

Calls 2

get_platformFunction · 0.85
DevHandleClass · 0.85

Tested by

no test coverage detected