File tree Expand file tree Collapse file tree 5 files changed +28
-15
lines changed
mock-gimlet-hf-server/src Expand file tree Collapse file tree 5 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -268,13 +268,13 @@ impl idl::InOrderHostFlashImpl for ServerImpl {
268268 & mut self ,
269269 _: & RecvMessage ,
270270 addr : u32 ,
271- dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
271+ dest : Leased < W , [ u8 ] > ,
272272 ) -> Result < ( ) , RequestError < HfError > > {
273273 self . drv . check_flash_mux_state ( ) ?;
274274 self . drv
275275 . flash_read (
276276 self . flash_addr ( addr) ,
277- & mut LeaseBufWriter :: < _ , 32 > :: from ( dest. into_inner ( ) ) ,
277+ & mut LeaseBufWriter :: < _ , 32 > :: from ( dest) ,
278278 )
279279 . map_err ( |_| RequestError :: went_away ( ) )
280280 }
@@ -483,7 +483,7 @@ impl idl::InOrderHostFlashImpl for FailServer {
483483 & mut self ,
484484 _: & RecvMessage ,
485485 _offset : u32 ,
486- _dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
486+ _dest : Leased < W , [ u8 ] > ,
487487 ) -> Result < ( ) , RequestError < HfError > > {
488488 Err ( self . err . into ( ) )
489489 }
Original file line number Diff line number Diff line change @@ -241,11 +241,11 @@ impl FlashDriver {
241241
242242 /// Reads data from the given address into a `BufWriter`
243243 ///
244- /// This function will only return an error if it fails to read from a
244+ /// This function will only return an error if it fails to write to a
245245 /// provided lease; when given a slice, it is infallible.
246246 fn flash_read (
247247 & mut self ,
248- offset : u32 ,
248+ mut offset : u32 ,
249249 dest : & mut dyn idol_runtime:: BufWriter < ' _ > ,
250250 ) -> Result < ( ) , ( ) > {
251251 loop {
@@ -269,6 +269,7 @@ impl FlashDriver {
269269 }
270270 }
271271 }
272+ offset += len as u32 ;
272273 }
273274 Ok ( ( ) )
274275 }
Original file line number Diff line number Diff line change @@ -505,14 +505,21 @@ impl idl::InOrderHostFlashImpl for ServerImpl {
505505 fn read (
506506 & mut self ,
507507 _: & RecvMessage ,
508- addr : u32 ,
509- dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
508+ mut addr : u32 ,
509+ dest : Leased < W , [ u8 ] > ,
510510 ) -> Result < ( ) , RequestError < HfError > > {
511511 self . check_muxed_to_sp ( ) ?;
512- self . qspi . read_memory ( addr, & mut self . block [ ..dest. len ( ) ] ) ;
512+ let mut offset = 0 ;
513+ for i in ( 0 ..dest. len ( ) ) . step_by ( self . block . len ( ) ) {
514+ let n = ( dest. len ( ) - i) . min ( self . block . len ( ) ) ;
513515
514- dest. write_range ( 0 ..dest. len ( ) , & self . block [ ..dest. len ( ) ] )
515- . map_err ( |_| RequestError :: Fail ( ClientError :: WentAway ) ) ?;
516+ self . qspi . read_memory ( addr, & mut self . block [ ..n] ) ;
517+
518+ dest. write_range ( offset..offset + n, & self . block [ ..n] )
519+ . map_err ( |_| RequestError :: Fail ( ClientError :: WentAway ) ) ?;
520+ addr += n as u32 ;
521+ offset += n;
522+ }
516523
517524 Ok ( ( ) )
518525 }
Original file line number Diff line number Diff line change @@ -89,12 +89,17 @@ impl idl::InOrderHostFlashImpl for ServerImpl {
8989 & mut self ,
9090 _: & RecvMessage ,
9191 _addr : u32 ,
92- dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
92+ dest : Leased < W , [ u8 ] > ,
9393 ) -> Result < ( ) , RequestError < HfError > > {
9494 let zero = [ 0 ; PAGE_SIZE_BYTES ] ;
95-
96- dest. write_range ( 0 ..dest. len ( ) , & zero[ ..dest. len ( ) ] )
97- . map_err ( |_| RequestError :: Fail ( ClientError :: WentAway ) ) ?;
95+ let mut offset = 0 ;
96+ for i in ( 0 ..dest. len ( ) ) . step_by ( zero. len ( ) ) {
97+ let n = ( dest. len ( ) - i) . min ( zero. len ( ) ) ;
98+
99+ dest. write_range ( offset..offset + n, & zero[ ..n] )
100+ . map_err ( |_| RequestError :: Fail ( ClientError :: WentAway ) ) ?;
101+ offset += n;
102+ }
98103
99104 Ok ( ( ) )
100105 }
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ Interface(
5858 "address": "u32",
5959 },
6060 leases: {
61- "data": (type: "[u8]", write: true, max_len: Some(256) ),
61+ "data": (type: "[u8]", write: true),
6262 },
6363 reply: Result(
6464 ok: "()",
You can’t perform that action at this time.
0 commit comments