@@ -3,6 +3,8 @@ use core::fmt;
33use num_derive:: FromPrimitive ;
44
55use super :: { command:: * , input_deck:: INPUT_DECK_SLOTS } ;
6+ #[ cfg( feature = "uefi" ) ]
7+ use core:: prelude:: rust_2021:: derive;
68
79#[ repr( C , packed) ]
810pub struct EcRequestGetVersion { }
@@ -60,6 +62,98 @@ impl EcRequest<EcResponseGetCmdVersionsV1> for EcRequestGetCmdVersionsV1 {
6062 }
6163}
6264
65+ pub struct EcRequestFlashInfo { }
66+
67+ #[ repr( C , packed) ]
68+ #[ derive( Clone , Copy , Debug ) ]
69+ pub struct EcResponseFlashInfo {
70+ pub flash_size : u32 ,
71+ pub write_block_size : u32 ,
72+ pub erase_block_size : u32 ,
73+ pub protect_block_size : u32 ,
74+ // New fields in version 1 of the command
75+ pub write_ideal_size : u32 ,
76+ pub flags : u32 ,
77+ }
78+
79+ impl EcRequest < EcResponseFlashInfo > for EcRequestFlashInfo {
80+ fn command_version ( ) -> u8 {
81+ 1
82+ }
83+ fn command_id ( ) -> EcCommands {
84+ EcCommands :: FlashInfo
85+ }
86+ }
87+
88+ pub struct EcRequestFlashRead {
89+ pub offset : u32 ,
90+ pub size : u32 ,
91+ }
92+
93+ impl EcRequest < ( ) > for EcRequestFlashRead {
94+ fn command_id ( ) -> EcCommands {
95+ EcCommands :: FlashRead
96+ }
97+ }
98+
99+ #[ repr( C , packed) ]
100+ pub struct EcRequestFlashWrite {
101+ pub offset : u32 ,
102+ pub size : u32 ,
103+ /// Dynamically sized array (data copied after this struct)
104+ pub data : [ u8 ; 0 ] ,
105+ }
106+ impl EcRequest < ( ) > for EcRequestFlashWrite {
107+ fn command_id ( ) -> EcCommands {
108+ EcCommands :: FlashWrite
109+ }
110+ }
111+
112+ #[ repr( C , packed) ]
113+ pub struct EcRequestFlashErase {
114+ pub offset : u32 ,
115+ pub size : u32 ,
116+ }
117+
118+ impl EcRequest < ( ) > for EcRequestFlashErase {
119+ fn command_id ( ) -> EcCommands {
120+ EcCommands :: FlashErase
121+ }
122+ }
123+
124+ #[ derive( Debug , PartialEq , Clone , Copy ) ]
125+ pub enum FlashProtectFlags {
126+ ProtectRoAtBoot = 1 << 0 ,
127+ ProtectRoNow = 1 << 1 ,
128+ ProtectAllNow = 1 << 2 ,
129+ ProtectGpioAsserted = 1 << 3 ,
130+ /// At least one flash bank is stuck and can't be unlocked
131+ ErrorStruck = 1 << 4 ,
132+ ErrorInconsistent = 1 << 5 ,
133+ ProtectAllAtBoot = 1 << 6 ,
134+ }
135+
136+ #[ repr( C , packed) ]
137+ pub struct EcRequestFlashProtect {
138+ pub mask : u32 ,
139+ pub flags : u32 ,
140+ }
141+
142+ pub struct EcResponseFlashProtect {
143+ /// Current flash protect flags
144+ pub flags : u32 ,
145+ /// Flags that are valid on this platform
146+ pub valid_flags : u32 ,
147+ /// Flags that can be currently written (depending on protection status)
148+ pub writeable_flags : u32 ,
149+ }
150+
151+ impl EcRequest < EcResponseFlashProtect > for EcRequestFlashProtect {
152+ fn command_id ( ) -> EcCommands {
153+ EcCommands :: FlashProtect
154+ }
155+ }
156+
63157#[ repr( C , packed) ]
64158pub struct EcRequestPwmSetKeyboardBacklight {
65159 pub percent : u8 ,
0 commit comments