@@ -2,14 +2,14 @@ use core::ffi::c_void;
2
2
use core:: fmt:: { Debug , Formatter } ;
3
3
use core:: marker:: PhantomData ;
4
4
use core:: ptr:: NonNull ;
5
- use core:: { ptr , slice} ;
5
+ use core:: slice;
6
6
7
7
use crate :: proto:: console:: text;
8
- use crate :: { CStr16 , Char16 , Handle , Result , Status , StatusExt } ;
8
+ use crate :: { CStr16 , Result , Status , StatusExt } ;
9
9
10
10
use super :: boot:: { BootServices , MemoryDescriptor , MemoryMap , MemoryType } ;
11
11
use super :: runtime:: { ResetType , RuntimeServices } ;
12
- use super :: { cfg, Header , Revision } ;
12
+ use super :: { cfg, Revision } ;
13
13
14
14
/// Marker trait used to provide different views of the UEFI System Table.
15
15
pub trait SystemTableView { }
@@ -47,7 +47,7 @@ impl SystemTableView for Runtime {}
47
47
/// will be provided to replace it.
48
48
#[ repr( transparent) ]
49
49
pub struct SystemTable < View : SystemTableView > {
50
- table : * const SystemTableImpl ,
50
+ table : * const uefi_raw :: table :: system :: SystemTable ,
51
51
_marker : PhantomData < View > ,
52
52
}
53
53
@@ -56,13 +56,13 @@ impl<View: SystemTableView> SystemTable<View> {
56
56
/// Return the firmware vendor string
57
57
#[ must_use]
58
58
pub fn firmware_vendor ( & self ) -> & CStr16 {
59
- unsafe { CStr16 :: from_ptr ( ( * self . table ) . fw_vendor ) }
59
+ unsafe { CStr16 :: from_ptr ( ( * self . table ) . firmware_vendor . cast ( ) ) }
60
60
}
61
61
62
62
/// Return the firmware revision
63
63
#[ must_use]
64
64
pub const fn firmware_revision ( & self ) -> u32 {
65
- unsafe { ( * self . table ) . fw_revision }
65
+ unsafe { ( * self . table ) . firmware_revision }
66
66
}
67
67
68
68
/// Returns the revision of this table, which is defined to be
@@ -80,9 +80,10 @@ impl<View: SystemTableView> SystemTable<View> {
80
80
unsafe {
81
81
let table = & * self . table ;
82
82
table
83
- . cfg_table
83
+ . configuration_table
84
+ . cast :: < cfg:: ConfigTableEntry > ( )
84
85
. as_ref ( )
85
- . map ( |ptr| slice:: from_raw_parts ( ptr, table. nr_cfg ) )
86
+ . map ( |ptr| slice:: from_raw_parts ( ptr, table. number_of_configuration_table_entries ) )
86
87
. unwrap_or ( & [ ] )
87
88
}
88
89
}
@@ -119,7 +120,7 @@ impl<View: SystemTableView> SystemTable<View> {
119
120
impl SystemTable < Boot > {
120
121
/// Returns the standard input protocol.
121
122
pub fn stdin ( & mut self ) -> & mut text:: Input {
122
- unsafe { & mut * ( * self . table ) . stdin }
123
+ unsafe { & mut * ( * self . table ) . stdin . cast ( ) }
123
124
}
124
125
125
126
/// Returns the standard output protocol.
@@ -135,13 +136,13 @@ impl SystemTable<Boot> {
135
136
/// Access runtime services
136
137
#[ must_use]
137
138
pub const fn runtime_services ( & self ) -> & RuntimeServices {
138
- unsafe { & * ( * self . table ) . runtime }
139
+ unsafe { & * ( * self . table ) . runtime_services . cast_const ( ) . cast ( ) }
139
140
}
140
141
141
142
/// Access boot services
142
143
#[ must_use]
143
144
pub const fn boot_services ( & self ) -> & BootServices {
144
- unsafe { & * ( * self . table ) . boot }
145
+ unsafe { & * ( * self . table ) . boot_services . cast_const ( ) . cast ( ) }
145
146
}
146
147
147
148
/// Get the size in bytes of the buffer to allocate for storing the memory
@@ -299,7 +300,7 @@ impl SystemTable<Runtime> {
299
300
/// "Calling Conventions" chapter of the UEFI specification for details.
300
301
#[ must_use]
301
302
pub const unsafe fn runtime_services ( & self ) -> & RuntimeServices {
302
- & * ( * self . table ) . runtime
303
+ & * ( * self . table ) . runtime_services . cast_const ( ) . cast ( )
303
304
}
304
305
305
306
/// Changes the runtime addressing mode of EFI firmware from physical to virtual.
@@ -325,11 +326,11 @@ impl SystemTable<Runtime> {
325
326
let entry_size = core:: mem:: size_of :: < MemoryDescriptor > ( ) ;
326
327
let entry_version = MemoryDescriptor :: VERSION ;
327
328
let map_ptr = map. as_mut_ptr ( ) ;
328
- ( * ( * self . table ) . runtime )
329
+ self . runtime_services ( )
329
330
. set_virtual_address_map ( map_size, entry_size, entry_version, map_ptr)
330
331
. to_result_with_val ( || {
331
- let new_table_ref =
332
- & mut * ( new_system_table_virtual_addr as usize as * mut SystemTableImpl ) ;
332
+ let new_table_ref = & mut * ( new_system_table_virtual_addr as usize
333
+ as * mut uefi_raw :: table :: system :: SystemTable ) ;
333
334
Self {
334
335
table : new_table_ref,
335
336
_marker : PhantomData ,
@@ -345,51 +346,6 @@ impl SystemTable<Runtime> {
345
346
}
346
347
}
347
348
348
- /// The actual UEFI system table
349
- #[ repr( C ) ]
350
- struct SystemTableImpl {
351
- header : Header ,
352
- /// Null-terminated string representing the firmware's vendor.
353
- fw_vendor : * const Char16 ,
354
- fw_revision : u32 ,
355
- stdin_handle : Handle ,
356
- stdin : * mut text:: Input ,
357
- stdout_handle : Handle ,
358
- stdout : * mut text:: Output ,
359
- stderr_handle : Handle ,
360
- stderr : * mut text:: Output ,
361
- /// Runtime services table.
362
- runtime : * const RuntimeServices ,
363
- /// Boot services table.
364
- boot : * const BootServices ,
365
- /// Number of entries in the configuration table.
366
- nr_cfg : usize ,
367
- /// Pointer to beginning of the array.
368
- cfg_table : * const cfg:: ConfigTableEntry ,
369
- }
370
-
371
349
impl < View : SystemTableView > super :: Table for SystemTable < View > {
372
350
const SIGNATURE : u64 = 0x5453_5953_2049_4249 ;
373
351
}
374
-
375
- impl Debug for SystemTableImpl {
376
- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> core:: fmt:: Result {
377
- f. debug_struct ( "UefiSystemTable" )
378
- . field ( "header" , & self . header )
379
- . field ( "fw_vendor" , & ( unsafe { CStr16 :: from_ptr ( self . fw_vendor ) } ) )
380
- . field ( "fw_revision" , & self . fw_revision )
381
- . field ( "stdin_handle" , & self . stdin_handle )
382
- . field ( "stdin" , & self . stdin )
383
- . field ( "stdout_handle" , & self . stdout_handle )
384
- . field ( "stdout" , & self . stdout )
385
- . field ( "stderr_handle" , & self . stderr_handle )
386
- . field ( "stderr" , & self . stderr )
387
- . field ( "runtime" , & self . runtime )
388
- // a little bit of extra work needed to call debug-fmt on the BootServices
389
- // instead of printing the raw pointer
390
- . field ( "boot" , & ( unsafe { ptr:: read ( self . boot ) } ) )
391
- . field ( "nf_cfg" , & self . nr_cfg )
392
- . field ( "cfg_table" , & self . cfg_table )
393
- . finish ( )
394
- }
395
- }
0 commit comments