@@ -58,7 +58,7 @@ const SVC_FRAME_SIZE: usize = 32;
5858/// Values for encoding the stored state buffer in a binary slice.
5959const VERSION : usize = 1 ;
6060const STORED_STATE_SIZE : usize = size_of :: < CortexMStoredState > ( ) ;
61- const TAG : [ u8 ; 4 ] = [ b'c' , b't' , b'x' , b'm' ] ;
61+ const TAG : [ u8 ; 4 ] = * b"ctxm" ;
6262const METADATA_LEN : usize = 3 ;
6363
6464const VERSION_IDX : usize = 0 ;
@@ -181,7 +181,7 @@ impl<A: CortexMVariant> kernel::syscall::UserspaceKernelBoundary for SysCall<A>
181181 }
182182
183183 let sp = state. psp as * mut u32 ;
184- let ( r0, r1, r2, r3) = ( sp. offset ( 0 ) , sp. offset ( 1 ) , sp. offset ( 2 ) , sp. offset ( 3 ) ) ;
184+ let ( r0, r1, r2, r3) = ( sp. add ( 0 ) , sp. add ( 1 ) , sp. add ( 2 ) , sp. add ( 3 ) ) ;
185185
186186 // These operations are only safe so long as
187187 // - the pointers are properly aligned. This is guaranteed because the
@@ -245,13 +245,13 @@ impl<A: CortexMVariant> kernel::syscall::UserspaceKernelBoundary for SysCall<A>
245245 // - Instruction addresses require `|1` to indicate thumb code
246246 // - Stack offset 4 is R12, which the syscall interface ignores
247247 let stack_bottom = state. psp as * mut usize ;
248- ptr:: write ( stack_bottom. offset ( 7 ) , state. psr ) ; //......... -> APSR
249- ptr:: write ( stack_bottom. offset ( 6 ) , callback. pc . addr ( ) | 1 ) ; //... -> PC
250- ptr:: write ( stack_bottom. offset ( 5 ) , state. yield_pc | 1 ) ; // -> LR
251- ptr:: write ( stack_bottom. offset ( 3 ) , callback. argument3 . as_usize ( ) ) ; // -> R3
252- ptr:: write ( stack_bottom. offset ( 2 ) , callback. argument2 ) ; // -> R2
253- ptr:: write ( stack_bottom. offset ( 1 ) , callback. argument1 ) ; // -> R1
254- ptr:: write ( stack_bottom. offset ( 0 ) , callback. argument0 ) ; // -> R0
248+ ptr:: write ( stack_bottom. add ( 7 ) , state. psr ) ; //......... -> APSR
249+ ptr:: write ( stack_bottom. add ( 6 ) , callback. pc . addr ( ) | 1 ) ; //... -> PC
250+ ptr:: write ( stack_bottom. add ( 5 ) , state. yield_pc | 1 ) ; // -> LR
251+ ptr:: write ( stack_bottom. add ( 3 ) , callback. argument3 . as_usize ( ) ) ; // -> R3
252+ ptr:: write ( stack_bottom. add ( 2 ) , callback. argument2 ) ; // -> R2
253+ ptr:: write ( stack_bottom. add ( 1 ) , callback. argument1 ) ; // -> R1
254+ ptr:: write ( stack_bottom. add ( 0 ) , callback. argument0 ) ; // -> R0
255255
256256 Ok ( ( ) )
257257 }
@@ -296,26 +296,26 @@ impl<A: CortexMVariant> kernel::syscall::UserspaceKernelBoundary for SysCall<A>
296296 // syscall (i.e. we return a value to the app immediately) then this
297297 // will have no effect. If we are doing something like `yield()`,
298298 // however, then we need to have this state.
299- state. yield_pc = ptr:: read ( new_stack_pointer. offset ( 6 ) ) ;
300- state. psr = ptr:: read ( new_stack_pointer. offset ( 7 ) ) ;
299+ state. yield_pc = ptr:: read ( new_stack_pointer. add ( 6 ) ) ;
300+ state. psr = ptr:: read ( new_stack_pointer. add ( 7 ) ) ;
301301
302302 // Get the syscall arguments and return them along with the syscall.
303303 // It's possible the app did something invalid, in which case we put
304304 // the app in the fault state.
305- let r0 = ptr:: read ( new_stack_pointer. offset ( 0 ) ) ;
306- let r1 = ptr:: read ( new_stack_pointer. offset ( 1 ) ) ;
307- let r2 = ptr:: read ( new_stack_pointer. offset ( 2 ) ) ;
308- let r3 = ptr:: read ( new_stack_pointer. offset ( 3 ) ) ;
305+ let r0 = ptr:: read ( new_stack_pointer. add ( 0 ) ) ;
306+ let r1 = ptr:: read ( new_stack_pointer. add ( 1 ) ) ;
307+ let r2 = ptr:: read ( new_stack_pointer. add ( 2 ) ) ;
308+ let r3 = ptr:: read ( new_stack_pointer. add ( 3 ) ) ;
309309
310310 // Get the actual SVC number.
311311 // Read the PC from the stack as a *const u16 (i.e. we're treating instructions as
312312 // u16).
313313 let pcptr_ptr: * const usize = new_stack_pointer;
314314 let pcptr_ptr: * const * const u16 = pcptr_ptr. cast ( ) ;
315- let pcptr = ptr:: read ( pcptr_ptr. offset ( 6 ) ) ;
315+ let pcptr = ptr:: read ( pcptr_ptr. add ( 6 ) ) ;
316316 // The svc instruction is the last instruction before the PC, and should be 16 bits.
317317 // Read it by offsetting the PC.
318- let svc_instr = ptr:: read ( pcptr. offset ( - 1 ) ) ;
318+ let svc_instr = ptr:: read ( pcptr. sub ( 1 ) ) ;
319319 let svc_num = ( svc_instr & 0xff ) as u8 ;
320320
321321 // Use the helper function to convert these raw values into a Tock
@@ -367,14 +367,14 @@ impl<A: CortexMVariant> kernel::syscall::UserspaceKernelBoundary for SysCall<A>
367367 0xBAD00BAD ,
368368 )
369369 } else {
370- let r0 = ptr:: read ( stack_pointer. offset ( 0 ) ) ;
371- let r1 = ptr:: read ( stack_pointer. offset ( 1 ) ) ;
372- let r2 = ptr:: read ( stack_pointer. offset ( 2 ) ) ;
373- let r3 = ptr:: read ( stack_pointer. offset ( 3 ) ) ;
374- let r12 = ptr:: read ( stack_pointer. offset ( 4 ) ) ;
375- let lr = ptr:: read ( stack_pointer. offset ( 5 ) ) ;
376- let pc = ptr:: read ( stack_pointer. offset ( 6 ) ) ;
377- let xpsr = ptr:: read ( stack_pointer. offset ( 7 ) ) ;
370+ let r0 = ptr:: read ( stack_pointer. add ( 0 ) ) ;
371+ let r1 = ptr:: read ( stack_pointer. add ( 1 ) ) ;
372+ let r2 = ptr:: read ( stack_pointer. add ( 2 ) ) ;
373+ let r3 = ptr:: read ( stack_pointer. add ( 3 ) ) ;
374+ let r12 = ptr:: read ( stack_pointer. add ( 4 ) ) ;
375+ let lr = ptr:: read ( stack_pointer. add ( 5 ) ) ;
376+ let pc = ptr:: read ( stack_pointer. add ( 6 ) ) ;
377+ let xpsr = ptr:: read ( stack_pointer. add ( 7 ) ) ;
378378 ( r0, r1, r2, r3, r12, lr, pc, xpsr)
379379 } ;
380380
0 commit comments