Function kernel::memop::memop

source ·
pub(crate) fn memop(
    process: &dyn Process,
    op_type: usize,
    r1: usize,
) -> SyscallReturn
Expand description

Handle the memop syscall.

§memop_num

  • 0: BRK. Change the location of the program break and return a SyscallReturn.
  • 1: SBRK. Change the location of the program break and return the previous break address.
  • 2: Get the address of the start of the application’s RAM allocation.
  • 3: Get the address pointing to the first address after the end of the application’s RAM allocation.
  • 4: Get the address of the start of the application’s flash region. This is where the TBF header is located.
  • 5: Get the address pointing to the first address after the end of the application’s flash region.
  • 6: Get the address of the lowest address of the grant region for the app.
  • 7: Get the number of writeable flash regions defined in the header of this app.
  • 8: Get the start address of the writeable region indexed from 0 by r1. Returns (void*) -1 on failure, meaning the selected writeable region does not exist.
  • 9: Get the end address of the writeable region indexed by r1. Returns (void*) -1 on failure, meaning the selected writeable region does not exist.
  • 10: Specify where the start of the app stack is. This tells the kernel where the app has put the start of its stack. This is not strictly necessary for correct operation, but allows for better debugging if the app crashes.
  • 11: Specify where the start of the app heap is. This tells the kernel where the app has put the start of its heap. This is not strictly necessary for correct operation, but allows for better debugging if the app crashes.