@@ -6401,18 +6401,83 @@ pub mod fch {
6401
6401
use crate :: struct_accessors:: { make_accessors, Getter , Setter , BU8 } ;
6402
6402
use crate :: types:: Result ;
6403
6403
6404
+ #[ repr( u8 ) ]
6405
+ #[ derive( Debug , PartialEq , FromPrimitive , ToPrimitive , Clone , Copy ) ]
6406
+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
6407
+ #[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
6408
+ #[ non_exhaustive]
6409
+ pub enum EspiInitDataBusSelect {
6410
+ OutputLow = 0 ,
6411
+ OutputHigh = 1 ,
6412
+ }
6413
+
6414
+ #[ repr( u8 ) ]
6415
+ #[ derive( Debug , PartialEq , FromPrimitive , ToPrimitive , Clone , Copy ) ]
6416
+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
6417
+ #[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
6418
+ #[ non_exhaustive]
6419
+ pub enum EspiInitClockPinSelect {
6420
+ Spi = 0 ,
6421
+ Gpio86 = 1 ,
6422
+ }
6423
+
6424
+ #[ repr( u8 ) ]
6425
+ #[ derive( Debug , PartialEq , FromPrimitive , ToPrimitive , Clone , Copy ) ]
6426
+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
6427
+ #[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
6428
+ #[ non_exhaustive]
6429
+ pub enum EspiInitCsPinSelect {
6430
+ Gpio30 = 0 ,
6431
+ Gpio31 = 1 ,
6432
+ }
6433
+
6434
+ #[ repr( u8 ) ]
6435
+ #[ derive( Debug , PartialEq , FromPrimitive , ToPrimitive , Clone , Copy ) ]
6436
+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
6437
+ #[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
6438
+ #[ non_exhaustive]
6439
+ pub enum EspiInitClockFrequency {
6440
+ #[ cfg_attr( feature = "serde" , serde( rename = "16.66 MHz" ) ) ]
6441
+ _16_66MHz = 0 ,
6442
+ #[ cfg_attr( feature = "serde" , serde( rename = "33.33 MHz" ) ) ]
6443
+ _33_33MHz = 1 ,
6444
+ #[ cfg_attr( feature = "serde" , serde( rename = "66.66 MHz" ) ) ]
6445
+ _66_66MHz = 2 ,
6446
+ }
6447
+
6448
+ #[ repr( u8 ) ]
6449
+ #[ derive( Debug , PartialEq , FromPrimitive , ToPrimitive , Clone , Copy ) ]
6450
+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
6451
+ #[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
6452
+ #[ non_exhaustive]
6453
+ pub enum EspiInitIoMode {
6454
+ Single = 0 ,
6455
+ Dual = 1 ,
6456
+ Quad = 2 ,
6457
+ }
6458
+
6459
+ #[ repr( u8 ) ]
6460
+ #[ derive( Debug , PartialEq , FromPrimitive , ToPrimitive , Clone , Copy ) ]
6461
+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
6462
+ #[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
6463
+ #[ non_exhaustive]
6464
+ pub enum EspiInitAlertMode {
6465
+ NoDedicatedAlertPin = 0 ,
6466
+ DedicatedAlertPin = 1 ,
6467
+ }
6468
+
6404
6469
make_accessors ! {
6405
6470
#[ derive( Default , FromBytes , AsBytes , Unaligned , PartialEq , Debug , Copy , Clone ) ]
6406
6471
#[ repr( C , packed) ]
6407
6472
pub struct EspiInit {
6408
6473
espi_enabled || bool : BU8 | pub get bool : pub set bool ,
6409
6474
6410
- data_bus_select || SerdeHex8 : u8 | pub get u8 : pub set u8 ,
6411
- clock_pin_select || SerdeHex8 : u8 | pub get u8 : pub set u8 ,
6412
- cs_pin_select || SerdeHex8 : u8 | pub get u8 : pub set u8 ,
6413
- clock_frequency || SerdeHex8 : u8 | pub get u8 : pub set u8 ,
6414
- io_mode || SerdeHex8 : u8 | pub get u8 : pub set u8 ,
6415
- alert_mode || SerdeHex8 : u8 | pub get u8 : pub set u8 ,
6475
+ data_bus_select || SerdeHex8 : u8 | pub get EspiInitDataBusSelect : pub set EspiInitDataBusSelect ,
6476
+ clock_pin_select || SerdeHex8 : u8 | pub get EspiInitClockPinSelect : pub set EspiInitClockPinSelect ,
6477
+ cs_pin_select || SerdeHex8 : u8 | pub get EspiInitCsPinSelect : pub set EspiInitCsPinSelect ,
6478
+ clock_frequency || SerdeHex8 : u8 | pub get EspiInitClockFrequency : pub set EspiInitClockFrequency ,
6479
+ io_mode || SerdeHex8 : u8 | pub get EspiInitIoMode : pub set EspiInitIoMode ,
6480
+ alert_mode || SerdeHex8 : u8 | pub get EspiInitAlertMode : pub set EspiInitAlertMode ,
6416
6481
6417
6482
pltrst_deassert || bool : BU8 | pub get bool : pub set bool ,
6418
6483
io80_decoding_enabled || bool : BU8 | pub get bool : pub set bool ,
@@ -6421,25 +6486,27 @@ pub mod fch {
6421
6486
/// The first entry is usually for IPMI.
6422
6487
/// The last two entries != 0 are the serial ports.
6423
6488
/// Use values 3 (32 bit) or 7 (64 bit).
6424
- io_range_size || [ SerdeHex8 ; 16 ] : [ u8 ; 16 ] | pub get [ u8 ; 16 ] : pub set [ u8 ; 16 ] ,
6489
+ io_range_sizes_minus_one || [ SerdeHex8 ; 16 ] : [ u8 ; 16 ] ,
6425
6490
/// The first entry is usually for IPMI.
6426
6491
/// The last two entries != 0 are the serial ports.
6427
- io_range_base || [ SerdeHex16 ; 16 ] : [ LU16 ; 16 ] | pub get [ u16 ; 16 ] : pub set [ u16 ; 16 ] ,
6492
+ io_range_bases || [ SerdeHex16 ; 16 ] : [ LU16 ; 16 ] ,
6428
6493
6429
- mmio_range_size || [ SerdeHex16 ; 5 ] : [ LU16 ; 5 ] | pub get [ u16 ; 5 ] : pub set [ u16 ; 5 ] ,
6430
- mmio_range_base || [ SerdeHex32 ; 5 ] : [ LU32 ; 5 ] | pub get [ u32 ; 5 ] : pub set [ u32 ; 5 ] ,
6494
+ mmio_range_sizes_minus_one || [ SerdeHex16 ; 5 ] : [ LU16 ; 5 ] ,
6495
+ mmio_range_bases || [ SerdeHex32 ; 5 ] : [ LU32 ; 5 ] ,
6431
6496
6432
- irq_mask || SerdeHex32 : LU32 , // | pub get LU32 : pub set u32, // FIXME bitmap
6433
- irq_polarity || SerdeHex32 : LU32 , // | pub get LU32 : pub set u32, // FIXME bitmap
6497
+ /// bitmap
6498
+ irq_mask || SerdeHex32 : LU32 | pub get u32 : pub set u32 ,
6499
+ /// bitmap
6500
+ irq_polarity || SerdeHex32 : LU32 | pub get u32 : pub set u32 ,
6434
6501
6435
6502
cputemp_rtctime_vw_enabled || bool : BU8 | pub get bool : pub set bool ,
6436
- cputemp_rtctime_vw_index_select || SerdeHex8 : u8 | pub get u8 : pub set u8 ,
6503
+ cputemp_rtctime_vw_index_select || SerdeHex8 : u8 | pub get u8 : pub set u8 , // FIXME what's that?
6437
6504
6438
6505
_dummy_1 : u8 ,
6439
6506
_dummy_2 : u8 ,
6440
6507
6441
- cpu_temp_mmio_base || SerdeHex32 : LU32 | pub get u32 : pub set u32 , // FIXME
6442
- rtc_time_mmio_base || SerdeHex32 : LU32 | pub get u32 : pub set u32 , // FIXME
6508
+ cpu_temp_mmio_base || SerdeHex32 : LU32 , // 0: none
6509
+ rtc_time_mmio_base || SerdeHex32 : LU32 , // 0: none
6443
6510
6444
6511
bus_master_enabled || bool : BU8 | pub get bool : pub set bool ,
6445
6512
@@ -6449,6 +6516,125 @@ pub mod fch {
6449
6516
}
6450
6517
}
6451
6518
6519
+ pub struct EspiInitIoRange {
6520
+ pub base : u16 ,
6521
+ /// Real size in bytes.
6522
+ pub size : u8 ,
6523
+ }
6524
+
6525
+ pub struct EspiInitMmioRange {
6526
+ pub base : u32 ,
6527
+ /// Real size in bytes.
6528
+ pub size : u16 ,
6529
+ }
6530
+
6531
+ impl EspiInit {
6532
+ pub fn io_range (
6533
+ & self ,
6534
+ index : usize ,
6535
+ ) -> Result < Option < EspiInitIoRange > > {
6536
+ if index < self . io_range_sizes_minus_one . len ( ) {
6537
+ Ok ( if self . io_range_bases [ index] . get ( ) == 0 {
6538
+ None
6539
+ } else {
6540
+ Some ( EspiInitIoRange {
6541
+ base : self . io_range_bases [ index] . get ( ) ,
6542
+ size : self . io_range_sizes_minus_one [ index] + 1 ,
6543
+ } )
6544
+ } )
6545
+ } else {
6546
+ Err ( Error :: EntryRange )
6547
+ }
6548
+ }
6549
+ pub fn set_io_range (
6550
+ & mut self ,
6551
+ index : usize ,
6552
+ value : Option < EspiInitIoRange > ,
6553
+ ) {
6554
+ if index < self . io_range_sizes_minus_one . len ( ) {
6555
+ match value {
6556
+ None => {
6557
+ self . io_range_sizes_minus_one [ index] = 0 . into ( ) ;
6558
+ self . io_range_bases [ index] = 0 . into ( ) ;
6559
+ }
6560
+ Some ( x) => {
6561
+ assert ! ( x. size > 0 ) ;
6562
+ self . io_range_sizes_minus_one [ index] = ( x. size - 1 ) . into ( ) ;
6563
+ self . io_range_bases [ index] = x. base . into ( ) ;
6564
+ }
6565
+ }
6566
+ }
6567
+ }
6568
+ pub fn io_range_count ( & self ) -> usize {
6569
+ self . io_range_sizes_minus_one . len ( )
6570
+ }
6571
+
6572
+ pub fn mmio_range (
6573
+ & self ,
6574
+ index : usize ,
6575
+ ) -> Result < Option < EspiInitMmioRange > > {
6576
+ if index < self . mmio_range_sizes_minus_one . len ( ) {
6577
+ Ok ( if self . mmio_range_bases [ index] . get ( ) == 0 {
6578
+ None
6579
+ } else {
6580
+ Some ( EspiInitMmioRange {
6581
+ base : self . mmio_range_bases [ index] . get ( ) ,
6582
+ size : self . mmio_range_sizes_minus_one [ index] . get ( ) + 1 ,
6583
+ } )
6584
+ } )
6585
+ } else {
6586
+ Err ( Error :: EntryRange )
6587
+ }
6588
+ }
6589
+ pub fn set_mmio_range (
6590
+ & mut self ,
6591
+ index : usize ,
6592
+ value : Option < EspiInitMmioRange > ,
6593
+ ) {
6594
+ if index < self . mmio_range_sizes_minus_one . len ( ) {
6595
+ match value {
6596
+ None => {
6597
+ self . mmio_range_sizes_minus_one [ index] = 0 . into ( ) ;
6598
+ self . mmio_range_bases [ index] = 0 . into ( ) ;
6599
+ }
6600
+ Some ( x) => {
6601
+ assert ! ( x. size > 0 ) ;
6602
+ self . mmio_range_sizes_minus_one [ index] = ( x. size - 1 ) . into ( ) ;
6603
+ self . mmio_range_bases [ index] = x. base . into ( ) ;
6604
+ }
6605
+ }
6606
+ }
6607
+ }
6608
+ pub fn mmio_range_count ( & self ) -> usize {
6609
+ self . mmio_range_sizes_minus_one . len ( )
6610
+ }
6611
+
6612
+ pub fn cpu_temp_mmio_base ( & self ) -> Result < Option < u32 > > {
6613
+ match self . cpu_temp_mmio_base . get ( ) {
6614
+ 0 => Ok ( None ) ,
6615
+ x => Ok ( Some ( x) ) ,
6616
+ }
6617
+ }
6618
+ pub fn set_cpu_temp_mmio_base ( & mut self , value : Option < u32 > ) {
6619
+ self . cpu_temp_mmio_base . set ( match value {
6620
+ None => 0 ,
6621
+ Some ( x) => x,
6622
+ } ) ;
6623
+ }
6624
+ pub fn rtc_time_mmio_base ( & self ) -> Result < Option < u32 > > {
6625
+ match self . rtc_time_mmio_base . get ( ) {
6626
+ 0 => Ok ( None ) ,
6627
+ x => Ok ( Some ( x) ) ,
6628
+ }
6629
+ }
6630
+ pub fn set_rtc_time_mmio_base ( & mut self , value : Option < u32 > ) {
6631
+ self . rtc_time_mmio_base . set ( match value {
6632
+ None => 0 ,
6633
+ Some ( x) => x,
6634
+ } ) ;
6635
+ }
6636
+ }
6637
+
6452
6638
impl EntryCompatible for EspiInit {
6453
6639
fn is_entry_compatible ( entry_id : EntryId , _prefix : & [ u8 ] ) -> bool {
6454
6640
matches ! ( entry_id, EntryId :: Fch ( FchEntryId :: EspiInit ) )
@@ -6474,10 +6660,10 @@ pub mod fch {
6474
6660
assert ! ( offset_of!( EspiInit , pltrst_deassert) == 7 ) ;
6475
6661
assert ! ( offset_of!( EspiInit , io80_decoding_enabled) == 8 ) ;
6476
6662
assert ! ( offset_of!( EspiInit , io6064_decoding_enabled) == 9 ) ;
6477
- assert ! ( offset_of!( EspiInit , io_range_size ) == 10 ) ;
6478
- assert ! ( offset_of!( EspiInit , io_range_base ) == 26 ) ;
6479
- assert ! ( offset_of!( EspiInit , mmio_range_size ) == 58 ) ;
6480
- assert ! ( offset_of!( EspiInit , mmio_range_base ) == 68 ) ;
6663
+ assert ! ( offset_of!( EspiInit , io_range_sizes_minus_one ) == 10 ) ;
6664
+ assert ! ( offset_of!( EspiInit , io_range_bases ) == 26 ) ;
6665
+ assert ! ( offset_of!( EspiInit , mmio_range_sizes_minus_one ) == 58 ) ;
6666
+ assert ! ( offset_of!( EspiInit , mmio_range_bases ) == 68 ) ;
6481
6667
assert ! ( offset_of!( EspiInit , irq_mask) == 88 ) ;
6482
6668
assert ! ( offset_of!( EspiInit , irq_polarity) == 92 ) ;
6483
6669
assert ! ( offset_of!( EspiInit , cputemp_rtctime_vw_enabled) == 96 ) ;
0 commit comments