33// SPDX-License-Identifier: Apache-2.0
44//
55
6- use zerocopy:: { byteorder, byteorder:: LE , AsBytes } ;
6+ use zerocopy:: {
7+ byteorder:: { self , LE } ,
8+ Immutable , IntoBytes ,
9+ } ;
710
811extern crate alloc;
912use alloc:: { boxed:: Box , vec:: Vec } ;
@@ -30,7 +33,7 @@ enum MadtStructureType {
3033}
3134
3235#[ repr( C , packed) ]
33- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
36+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
3437struct Header {
3538 table_header : TableHeader ,
3639 /// Must be ignored by OSPM for RISC-V
@@ -111,7 +114,7 @@ impl MADT {
111114
112115 pub fn add_structure < T > ( & mut self , t : T )
113116 where
114- T : Aml + AsBytes + Clone + ' static ,
117+ T : Aml + IntoBytes + Immutable + Clone + ' static ,
115118 {
116119 self . update_header ( t. as_bytes ( ) ) ;
117120 self . structures . push ( Box :: new ( t) ) ;
@@ -136,7 +139,7 @@ impl Aml for MADT {
136139
137140/// Processor-Local APIC
138141#[ repr( C , packed) ]
139- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
142+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
140143pub struct ProcessorLocalApic {
141144 r#type : u8 ,
142145 length : u8 ,
@@ -169,7 +172,7 @@ aml_as_bytes!(ProcessorLocalApic);
169172
170173/// I/O APIC
171174#[ repr( C , packed) ]
172- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
175+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
173176pub struct IoApic {
174177 r#type : u8 ,
175178 length : u8 ,
@@ -196,7 +199,7 @@ aml_as_bytes!(IoApic);
196199
197200/// GIC CPU Interface (GICC)
198201#[ repr( C , packed) ]
199- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
202+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
200203pub struct Gicc {
201204 r#type : u8 ,
202205 length : u8 ,
@@ -302,7 +305,7 @@ pub enum GicVersion {
302305
303306/// GIC Distributor (GICD) Structure
304307#[ repr( C , packed) ]
305- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
308+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
306309pub struct Gicd {
307310 r#type : u8 ,
308311 length : u8 ,
@@ -334,7 +337,7 @@ aml_as_bytes!(Gicd);
334337
335338/// GIC MSI Frame Structure
336339#[ repr( C , packed) ]
337- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
340+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
338341pub struct GicMsi {
339342 r#type : u8 ,
340343 length : u8 ,
@@ -372,7 +375,7 @@ aml_as_bytes!(GicMsi);
372375
373376/// GIC Redistributor (GICR) Structure
374377#[ repr( C , packed) ]
375- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
378+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
376379pub struct Gicr {
377380 r#type : u8 ,
378381 length : u8 ,
@@ -398,7 +401,7 @@ aml_as_bytes!(Gicr);
398401
399402/// GIC Interrupt Translation Service (ITS) Structure
400403#[ repr( C , packed) ]
401- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
404+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
402405pub struct GicIts {
403406 r#type : u8 ,
404407 length : u8 ,
@@ -428,7 +431,7 @@ aml_as_bytes!(GicIts);
428431/// RISC-V platforms need to have a simple, per-hart interrupt controller
429432/// available to supervisor mode.
430433#[ repr( C , packed) ]
431- #[ derive( Clone , Copy , Debug , Default , AsBytes ) ]
434+ #[ derive( Clone , Copy , Debug , Default , IntoBytes , Immutable ) ]
432435pub struct RINTC {
433436 r#type : u8 ,
434437 length : u8 ,
@@ -486,7 +489,7 @@ aml_as_bytes!(RINTC);
486489// provides information common across processors. The per-processor
487490// information will be provided by the RINTC structure.
488491#[ repr( C , packed) ]
489- #[ derive( Copy , Clone , Debug , Default , AsBytes ) ]
492+ #[ derive( Copy , Clone , Debug , Default , IntoBytes , Immutable ) ]
490493pub struct IMSIC {
491494 r#type : u8 ,
492495 length : u8 ,
@@ -547,7 +550,7 @@ aml_as_bytes!(IMSIC);
547550// interrupts only in the form of MSIs. In that case, the role of an
548551// APLIC is to convert wired interrupts into MSIs for harts.
549552#[ repr( C , packed) ]
550- #[ derive( Copy , Clone , Debug , AsBytes ) ]
553+ #[ derive( Copy , Clone , Debug , IntoBytes , Immutable ) ]
551554pub struct APLIC {
552555 r#type : u8 ,
553556 length : u8 ,
@@ -596,7 +599,7 @@ assert_same_size!(APLIC, [u8; 36]);
596599aml_as_bytes ! ( APLIC ) ;
597600
598601#[ repr( C , packed) ]
599- #[ derive( Copy , Clone , Debug , AsBytes ) ]
602+ #[ derive( Copy , Clone , Debug , IntoBytes , Immutable ) ]
600603pub struct PLIC {
601604 r#type : u8 ,
602605 length : u8 ,
0 commit comments