File tree 5 files changed +28
-15
lines changed
mock-gimlet-hf-server/src
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 {
268
268
& mut self ,
269
269
_: & RecvMessage ,
270
270
addr : u32 ,
271
- dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
271
+ dest : Leased < W , [ u8 ] > ,
272
272
) -> Result < ( ) , RequestError < HfError > > {
273
273
self . drv . check_flash_mux_state ( ) ?;
274
274
self . drv
275
275
. flash_read (
276
276
self . flash_addr ( addr) ,
277
- & mut LeaseBufWriter :: < _ , 32 > :: from ( dest. into_inner ( ) ) ,
277
+ & mut LeaseBufWriter :: < _ , 32 > :: from ( dest) ,
278
278
)
279
279
. map_err ( |_| RequestError :: went_away ( ) )
280
280
}
@@ -483,7 +483,7 @@ impl idl::InOrderHostFlashImpl for FailServer {
483
483
& mut self ,
484
484
_: & RecvMessage ,
485
485
_offset : u32 ,
486
- _dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
486
+ _dest : Leased < W , [ u8 ] > ,
487
487
) -> Result < ( ) , RequestError < HfError > > {
488
488
Err ( self . err . into ( ) )
489
489
}
Original file line number Diff line number Diff line change @@ -241,11 +241,11 @@ impl FlashDriver {
241
241
242
242
/// Reads data from the given address into a `BufWriter`
243
243
///
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
245
245
/// provided lease; when given a slice, it is infallible.
246
246
fn flash_read (
247
247
& mut self ,
248
- offset : u32 ,
248
+ mut offset : u32 ,
249
249
dest : & mut dyn idol_runtime:: BufWriter < ' _ > ,
250
250
) -> Result < ( ) , ( ) > {
251
251
loop {
@@ -269,6 +269,7 @@ impl FlashDriver {
269
269
}
270
270
}
271
271
}
272
+ offset += len as u32 ;
272
273
}
273
274
Ok ( ( ) )
274
275
}
Original file line number Diff line number Diff line change @@ -505,14 +505,21 @@ impl idl::InOrderHostFlashImpl for ServerImpl {
505
505
fn read (
506
506
& mut self ,
507
507
_: & RecvMessage ,
508
- addr : u32 ,
509
- dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
508
+ mut addr : u32 ,
509
+ dest : Leased < W , [ u8 ] > ,
510
510
) -> Result < ( ) , RequestError < HfError > > {
511
511
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 ( ) ) ;
513
515
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
+ }
516
523
517
524
Ok ( ( ) )
518
525
}
Original file line number Diff line number Diff line change @@ -89,12 +89,17 @@ impl idl::InOrderHostFlashImpl for ServerImpl {
89
89
& mut self ,
90
90
_: & RecvMessage ,
91
91
_addr : u32 ,
92
- dest : LenLimit < Leased < W , [ u8 ] > , PAGE_SIZE_BYTES > ,
92
+ dest : Leased < W , [ u8 ] > ,
93
93
) -> Result < ( ) , RequestError < HfError > > {
94
94
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
+ }
98
103
99
104
Ok ( ( ) )
100
105
}
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ Interface(
58
58
"address": "u32",
59
59
},
60
60
leases: {
61
- "data": (type: "[u8]", write: true, max_len: Some(256) ),
61
+ "data": (type: "[u8]", write: true),
62
62
},
63
63
reply: Result(
64
64
ok: "()",
You can’t perform that action at this time.
0 commit comments