Allocates a chunk of memory Returns - handle in RDI - starting virtual address in RSI - starting physical address in RDX
(
context_ptr: *mut Context,
num_pages: u64,
max_physaddr: u64
)
| 478 | /// - starting virtual address in RSI |
| 479 | /// - starting physical address in RDX |
| 480 | fn sys_malloc( |
| 481 | context_ptr: *mut Context, |
| 482 | num_pages: u64, |
| 483 | max_physaddr: u64 |
| 484 | ) { |
| 485 | let context = unsafe {&mut (*context_ptr)}; |
| 486 | |
| 487 | match process::new_memory_chunk( |
| 488 | num_pages, |
| 489 | max_physaddr) { |
| 490 | Ok((virtaddr, physaddr)) => { |
| 491 | context.rax = 0; // No error |
| 492 | context.rdi = virtaddr.as_u64() as usize; |
| 493 | context.rsi = physaddr.as_u64() as usize; |
| 494 | } |
| 495 | Err(code) => { |
| 496 | context.rax = code; |
| 497 | context.rdi = 0; |
| 498 | context.rsi = 0; |
| 499 | context.rdx = 0; |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | /// Free a memory chunk containing the given virtual address |
| 505 | fn sys_free( |
no test coverage detected