Function uacpi_kernel_map
void * uacpi_kernel_map(uacpi_phys_addr addr, uacpi_size len)
Description
Map a physical memory range starting at 'addr' with length 'len', and return
a virtual address that can be used to access it. NOTE: 'addr' may be misaligned, in this case the host is expected to round it down to the nearest page-aligned boundary and map that, while making sure that at least 'len' bytes are still mapped starting at 'addr'. The return value preserves the misaligned offset. Example for uacpi_kernel_map(0x1ABC, 0xF00):
- Round down the 'addr' we got to the nearest page boundary. Considering a PAGE_SIZE of 4096 (or 0x1000), 0x1ABC rounded down is 0x1000, offset within the page is 0x1ABC - 0x1000 => 0xABC
- Requested 'len' is 0xF00 bytes, but we just rounded the address down by 0xABC bytes, so add those on top. 0xF00 + 0xABC => 0x19BC
- Round up the final 'len' to the nearest PAGE_SIZE boundary, in this case 0x19BC is 0x2000 bytes (2 pages if PAGE_SIZE is 4096)
- Call the VMM to map the aligned address 0x1000 (from step 1) with length 0x2000 (from step 3). Let's assume the returned virtual address for the mapping is 0xF000.
- Add the original offset within page 0xABC (from step 1) to the resulting virtual address 0xF000 + 0xABC => 0xFABC. Return it to uACPI.