mm: add full page in flag for get physical

This commit is contained in:
Matheus
2026-09-15 14:45:56 -03:00
parent 79262a7c83
commit b9a5ead597
2 changed files with 4 additions and 2 deletions
+1
View File
@@ -92,6 +92,7 @@ void mm_switch_context(mm_context_t *ctx);
#define MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK 2 #define MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK 2
#define MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_READ 4 #define MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_READ 4
#define MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_WRITE 8 #define MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_WRITE 8
#define MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_FULL 16
void *mm_get_physical_address(void *addr, int flags); void *mm_get_physical_address(void *addr, int flags);
void mm_apinit(); void mm_apinit();
void mm_init(); void mm_init();
+3 -2
View File
@@ -323,6 +323,7 @@ static int lock_page(mm_space_t *space, void *vaddr, int hint) {
mm_range_t *range = mm_get_range(space, vaddr); mm_range_t *range = mm_get_range(space, vaddr);
bool read_hint = hint & MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_READ; bool read_hint = hint & MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_READ;
bool write_hint = hint & MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_WRITE; bool write_hint = hint & MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_HINT_WRITE;
bool full = hint & MM_GET_PHYSICAL_ADDRESS_FLAGS_LOCK_FULL;
if (!range || (write_hint && !(range->mmuflags & ARCH_MMU_FLAGS_WRITE)) || (read_hint && !(range->mmuflags & ARCH_MMU_FLAGS_READ))) if (!range || (write_hint && !(range->mmuflags & ARCH_MMU_FLAGS_WRITE)) || (read_hint && !(range->mmuflags & ARCH_MMU_FLAGS_READ)))
return EFAULT; return EFAULT;
@@ -335,10 +336,10 @@ static int lock_page(mm_space_t *space, void *vaddr, int hint) {
// we need to make sure the address is fully paged in before locking, as it needs // we need to make sure the address is fully paged in before locking, as it needs
// to affect the final state of the page // to affect the final state of the page
// the only exception to this is if we know this operation will be read-only, which can safely operate on a partial page. // the only exception to this is if we know this operation will be read-only and can safely operate on a partial page.
page_t *page; page_t *page;
int error; int error;
if (read_hint && !write_hint) if (read_hint && !write_hint && !full)
error = mm_partial_page_in(range, vaddr, &page); error = mm_partial_page_in(range, vaddr, &page);
else else
error = mm_full_page_in(range, vaddr, &page); error = mm_full_page_in(range, vaddr, &page);