mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-28 21:28:21 +00:00
pmm: full rewrite
I've decided to do a rewrite on it due to some plans that would make refcounting physical pages nescessary among other things. now instead of a bitmap it uses a list of pages with each physical page having a page_t associated with it
This commit is contained in:
@@ -1435,12 +1435,12 @@ static int ext2_symlink(vnode_t *vnode, char *name, vattr_t *attr, char *path, c
|
||||
#define MMAPTMPFLAGS (ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC | ARCH_MMU_FLAGS_WRITE)
|
||||
|
||||
static int ext2_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
||||
void *paddr = pmm_alloc(1, PMM_SECTION_DEFAULT);
|
||||
void *paddr = pmm_allocpage(PMM_SECTION_DEFAULT);
|
||||
if (paddr == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if (arch_mmu_map(_cpu()->vmmctx->pagetable, paddr, addr, MMAPTMPFLAGS) == false) {
|
||||
pmm_free(paddr, 1);
|
||||
pmm_release(paddr);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -1448,7 +1448,7 @@ static int ext2_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cre
|
||||
int e = ext2_read(node, addr, PAGE_SIZE, offset, flags, &readc, cred);
|
||||
if (e) {
|
||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
||||
pmm_free(paddr, 1);
|
||||
pmm_release(paddr);
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -1469,7 +1469,7 @@ static int ext2_munmap(vnode_t *node, void *addr, uintmax_t offset, int flags, c
|
||||
void *paddr = arch_mmu_getphysical(_cpu()->vmmctx->pagetable, addr);
|
||||
__assert(paddr);
|
||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
||||
pmm_free(paddr, 1);
|
||||
pmm_release(paddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ void initrd_unpack() {
|
||||
for (;;) {
|
||||
if (cleanupbytespassed >= PAGE_SIZE) {
|
||||
size_t pagec = cleanupbytespassed / PAGE_SIZE;
|
||||
pmm_free(FROM_HHDM(cleanupptr), pagec);
|
||||
pmm_makefree(FROM_HHDM(cleanupptr), pagec);
|
||||
cleanupptr = (void *)((uintptr_t)cleanupptr + ROUND_DOWN(cleanupbytespassed, PAGE_SIZE));
|
||||
cleanupbytespassed %= PAGE_SIZE;
|
||||
}
|
||||
@@ -174,5 +174,5 @@ void initrd_unpack() {
|
||||
}
|
||||
|
||||
// free remaining pages to be freed
|
||||
pmm_free(FROM_HHDM(cleanupptr), ROUND_UP(cleanupbytespassed, PAGE_SIZE) / PAGE_SIZE);
|
||||
pmm_makefree(FROM_HHDM(cleanupptr), ROUND_UP(cleanupbytespassed, PAGE_SIZE) / PAGE_SIZE);
|
||||
}
|
||||
|
||||
@@ -392,12 +392,12 @@ static int tmpfs_readlink(vnode_t *node, char **link, cred_t *cred) {
|
||||
#define MMAPTMPFLAGS (ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC | ARCH_MMU_FLAGS_WRITE)
|
||||
|
||||
static int tmpfs_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
||||
void *paddr = pmm_alloc(1, PMM_SECTION_DEFAULT);
|
||||
void *paddr = pmm_allocpage(PMM_SECTION_DEFAULT);
|
||||
if (paddr == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if (arch_mmu_map(_cpu()->vmmctx->pagetable, paddr, addr, MMAPTMPFLAGS) == false) {
|
||||
pmm_free(paddr, 1);
|
||||
pmm_release(paddr);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ static int tmpfs_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cr
|
||||
int e = tmpfs_read(node, addr, PAGE_SIZE, offset, flags, &readc, cred);
|
||||
if (e) {
|
||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
||||
pmm_free(paddr, 1);
|
||||
pmm_release(paddr);
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ static int tmpfs_munmap(vnode_t *node, void *addr, uintmax_t offset, int flags,
|
||||
void *paddr = arch_mmu_getphysical(_cpu()->vmmctx->pagetable, addr);
|
||||
__assert(paddr);
|
||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
||||
pmm_free(paddr, 1);
|
||||
pmm_release(paddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user