From eec735afbf4d72450eb69e91cb42588f4b963f4f Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:30:29 +0800 Subject: [PATCH 01/14] Fix the unsuitable use of pa2page in lab2 --- labcodes/lab2/kern/mm/pmm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/labcodes/lab2/kern/mm/pmm.c b/labcodes/lab2/kern/mm/pmm.c index af54731..4cddcbc 100644 --- a/labcodes/lab2/kern/mm/pmm.c +++ b/labcodes/lab2/kern/mm/pmm.c @@ -390,7 +390,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -492,7 +492,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -510,7 +510,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -521,8 +521,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -556,7 +556,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); From d02c4afc809bfadb575d74d370b23bff82ace68c Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:32:37 +0800 Subject: [PATCH 02/14] Fix the unsuitable use of pa2page in lab2_result --- labcodes_answer/lab2_result/kern/mm/pmm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/labcodes_answer/lab2_result/kern/mm/pmm.c b/labcodes_answer/lab2_result/kern/mm/pmm.c index 020d14a..c61e506 100644 --- a/labcodes_answer/lab2_result/kern/mm/pmm.c +++ b/labcodes_answer/lab2_result/kern/mm/pmm.c @@ -402,7 +402,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -512,7 +512,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -530,7 +530,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -541,8 +541,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -576,7 +576,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); From 50905b1ec20577e9be0e677a2e36e86697319abe Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:37:36 +0800 Subject: [PATCH 03/14] Fix the unsuitable use of pa2page in lab3 --- labcodes/lab3/kern/mm/pmm.c | 12 ++++++------ labcodes/lab3/kern/mm/vmm.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/labcodes/lab3/kern/mm/pmm.c b/labcodes/lab3/kern/mm/pmm.c index 77633f2..d397abc 100644 --- a/labcodes/lab3/kern/mm/pmm.c +++ b/labcodes/lab3/kern/mm/pmm.c @@ -403,7 +403,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -528,7 +528,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -546,7 +546,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -557,8 +557,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -592,7 +592,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes/lab3/kern/mm/vmm.c b/labcodes/lab3/kern/mm/vmm.c index 2973e5b..9fa3301 100644 --- a/labcodes/lab3/kern/mm/vmm.c +++ b/labcodes/lab3/kern/mm/vmm.c @@ -266,7 +266,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 17057e1f1f50e0b8fd6a26137ffd00b249c5a46f Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:38:43 +0800 Subject: [PATCH 04/14] Fix the unsuitable use of pa2page in lab3_result --- labcodes_answer/lab3_result/kern/mm/pmm.c | 12 ++++++------ labcodes_answer/lab3_result/kern/mm/vmm.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/labcodes_answer/lab3_result/kern/mm/pmm.c b/labcodes_answer/lab3_result/kern/mm/pmm.c index fcb862e..379f1a4 100644 --- a/labcodes_answer/lab3_result/kern/mm/pmm.c +++ b/labcodes_answer/lab3_result/kern/mm/pmm.c @@ -415,7 +415,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -548,7 +548,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -566,7 +566,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -577,8 +577,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -612,7 +612,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes_answer/lab3_result/kern/mm/vmm.c b/labcodes_answer/lab3_result/kern/mm/vmm.c index 33228ee..33065c5 100644 --- a/labcodes_answer/lab3_result/kern/mm/vmm.c +++ b/labcodes_answer/lab3_result/kern/mm/vmm.c @@ -266,7 +266,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From bca0ff491c10478476ce7348ac486046bf49c9e6 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:44:13 +0800 Subject: [PATCH 05/14] Fix the unsuitable use of pa2page in lab4 --- labcodes/lab4/kern/mm/pmm.c | 12 ++++++------ labcodes/lab4/kern/mm/vmm.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/labcodes/lab4/kern/mm/pmm.c b/labcodes/lab4/kern/mm/pmm.c index 59c70d9..96e49e2 100644 --- a/labcodes/lab4/kern/mm/pmm.c +++ b/labcodes/lab4/kern/mm/pmm.c @@ -406,7 +406,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -531,7 +531,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -549,7 +549,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -560,8 +560,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -595,7 +595,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes/lab4/kern/mm/vmm.c b/labcodes/lab4/kern/mm/vmm.c index 7370361..b402145 100644 --- a/labcodes/lab4/kern/mm/vmm.c +++ b/labcodes/lab4/kern/mm/vmm.c @@ -263,7 +263,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 77d23ca51951a707c91b9d7baeeb982670130783 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:44:51 +0800 Subject: [PATCH 06/14] Fix the unsuitable use of pa2page in lab4_result --- labcodes_answer/lab4_result/kern/mm/pmm.c | 12 ++++++------ labcodes_answer/lab4_result/kern/mm/vmm.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/labcodes_answer/lab4_result/kern/mm/pmm.c b/labcodes_answer/lab4_result/kern/mm/pmm.c index b597c5d..ac4efd6 100644 --- a/labcodes_answer/lab4_result/kern/mm/pmm.c +++ b/labcodes_answer/lab4_result/kern/mm/pmm.c @@ -418,7 +418,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -551,7 +551,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -569,7 +569,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -580,8 +580,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -615,7 +615,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes_answer/lab4_result/kern/mm/vmm.c b/labcodes_answer/lab4_result/kern/mm/vmm.c index af221e3..5881a83 100644 --- a/labcodes_answer/lab4_result/kern/mm/vmm.c +++ b/labcodes_answer/lab4_result/kern/mm/vmm.c @@ -267,7 +267,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 2cde1118f4e0f3ec3df2cf5e71f250ad30fa6c86 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:45:53 +0800 Subject: [PATCH 07/14] Fix the unsuitable use of pa2page in lab5 --- labcodes/lab5/kern/mm/pmm.c | 12 ++++++------ labcodes/lab5/kern/mm/swap.c | 2 +- labcodes/lab5/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes/lab5/kern/mm/pmm.c b/labcodes/lab5/kern/mm/pmm.c index cb92075..7a2e95d 100644 --- a/labcodes/lab5/kern/mm/pmm.c +++ b/labcodes/lab5/kern/mm/pmm.c @@ -406,7 +406,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -625,7 +625,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -643,7 +643,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -654,8 +654,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -689,7 +689,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes/lab5/kern/mm/swap.c b/labcodes/lab5/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes/lab5/kern/mm/swap.c +++ b/labcodes/lab5/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes/lab5/kern/mm/vmm.c b/labcodes/lab5/kern/mm/vmm.c index 3727bbb..f2eb426 100644 --- a/labcodes/lab5/kern/mm/vmm.c +++ b/labcodes/lab5/kern/mm/vmm.c @@ -353,7 +353,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 89a9eb84d0b17f56b05b319a31da6fbefd3d57f1 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:50:34 +0800 Subject: [PATCH 08/14] Fix the unsuitable use of pa2page in lab5_result --- labcodes_answer/lab5_result/kern/mm/pmm.c | 12 ++++++------ labcodes_answer/lab5_result/kern/mm/swap.c | 2 +- labcodes_answer/lab5_result/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes_answer/lab5_result/kern/mm/pmm.c b/labcodes_answer/lab5_result/kern/mm/pmm.c index cf9fa77..b3d8aa1 100644 --- a/labcodes_answer/lab5_result/kern/mm/pmm.c +++ b/labcodes_answer/lab5_result/kern/mm/pmm.c @@ -418,7 +418,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -651,7 +651,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -669,7 +669,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -680,8 +680,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -715,7 +715,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes_answer/lab5_result/kern/mm/swap.c b/labcodes_answer/lab5_result/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes_answer/lab5_result/kern/mm/swap.c +++ b/labcodes_answer/lab5_result/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes_answer/lab5_result/kern/mm/vmm.c b/labcodes_answer/lab5_result/kern/mm/vmm.c index 4f4aaed..b54a8ae 100644 --- a/labcodes_answer/lab5_result/kern/mm/vmm.c +++ b/labcodes_answer/lab5_result/kern/mm/vmm.c @@ -357,7 +357,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 7f425b91b13f7d35d6b325f8740cfcb223171c86 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:51:34 +0800 Subject: [PATCH 09/14] Fix the unsuitable use of pa2page in lab6 --- labcodes/lab6/kern/mm/pmm.c | 12 ++++++------ labcodes/lab6/kern/mm/swap.c | 2 +- labcodes/lab6/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes/lab6/kern/mm/pmm.c b/labcodes/lab6/kern/mm/pmm.c index cb92075..7a2e95d 100644 --- a/labcodes/lab6/kern/mm/pmm.c +++ b/labcodes/lab6/kern/mm/pmm.c @@ -406,7 +406,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -625,7 +625,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -643,7 +643,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -654,8 +654,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -689,7 +689,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes/lab6/kern/mm/swap.c b/labcodes/lab6/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes/lab6/kern/mm/swap.c +++ b/labcodes/lab6/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes/lab6/kern/mm/vmm.c b/labcodes/lab6/kern/mm/vmm.c index 3727bbb..f2eb426 100644 --- a/labcodes/lab6/kern/mm/vmm.c +++ b/labcodes/lab6/kern/mm/vmm.c @@ -353,7 +353,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 9be5e162c0bf203fe108d6526f990497775d1f01 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:52:21 +0800 Subject: [PATCH 10/14] Fix the unsuitable use of pa2page in lab6_result --- labcodes_answer/lab6_result/kern/mm/pmm.c | 12 ++++++------ labcodes_answer/lab6_result/kern/mm/swap.c | 2 +- labcodes_answer/lab6_result/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes_answer/lab6_result/kern/mm/pmm.c b/labcodes_answer/lab6_result/kern/mm/pmm.c index cf9fa77..b3d8aa1 100644 --- a/labcodes_answer/lab6_result/kern/mm/pmm.c +++ b/labcodes_answer/lab6_result/kern/mm/pmm.c @@ -418,7 +418,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -651,7 +651,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -669,7 +669,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -680,8 +680,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -715,7 +715,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes_answer/lab6_result/kern/mm/swap.c b/labcodes_answer/lab6_result/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes_answer/lab6_result/kern/mm/swap.c +++ b/labcodes_answer/lab6_result/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes_answer/lab6_result/kern/mm/vmm.c b/labcodes_answer/lab6_result/kern/mm/vmm.c index 37d0ee6..877b033 100644 --- a/labcodes_answer/lab6_result/kern/mm/vmm.c +++ b/labcodes_answer/lab6_result/kern/mm/vmm.c @@ -357,7 +357,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 124dd65222485a9e7ed6f007996fc73a2f09e61c Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:52:35 +0800 Subject: [PATCH 11/14] Fix the unsuitable use of pa2page in lab7 --- labcodes/lab7/kern/mm/pmm.c | 12 ++++++------ labcodes/lab7/kern/mm/swap.c | 2 +- labcodes/lab7/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes/lab7/kern/mm/pmm.c b/labcodes/lab7/kern/mm/pmm.c index cb92075..7a2e95d 100644 --- a/labcodes/lab7/kern/mm/pmm.c +++ b/labcodes/lab7/kern/mm/pmm.c @@ -406,7 +406,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -625,7 +625,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -643,7 +643,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -654,8 +654,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -689,7 +689,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes/lab7/kern/mm/swap.c b/labcodes/lab7/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes/lab7/kern/mm/swap.c +++ b/labcodes/lab7/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes/lab7/kern/mm/vmm.c b/labcodes/lab7/kern/mm/vmm.c index 6799d1c..ce1a0bb 100644 --- a/labcodes/lab7/kern/mm/vmm.c +++ b/labcodes/lab7/kern/mm/vmm.c @@ -353,7 +353,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 47afad0cca0fb0e99c356fbbccc83307d4364a65 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:52:58 +0800 Subject: [PATCH 12/14] Fix the unsuitable use of pa2page in lab7_result --- labcodes_answer/lab7_result/kern/mm/pmm.c | 12 ++++++------ labcodes_answer/lab7_result/kern/mm/swap.c | 2 +- labcodes_answer/lab7_result/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes_answer/lab7_result/kern/mm/pmm.c b/labcodes_answer/lab7_result/kern/mm/pmm.c index cf9fa77..b3d8aa1 100644 --- a/labcodes_answer/lab7_result/kern/mm/pmm.c +++ b/labcodes_answer/lab7_result/kern/mm/pmm.c @@ -418,7 +418,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -651,7 +651,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -669,7 +669,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -680,8 +680,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -715,7 +715,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes_answer/lab7_result/kern/mm/swap.c b/labcodes_answer/lab7_result/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes_answer/lab7_result/kern/mm/swap.c +++ b/labcodes_answer/lab7_result/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes_answer/lab7_result/kern/mm/vmm.c b/labcodes_answer/lab7_result/kern/mm/vmm.c index 4802f65..04f514d 100644 --- a/labcodes_answer/lab7_result/kern/mm/vmm.c +++ b/labcodes_answer/lab7_result/kern/mm/vmm.c @@ -357,7 +357,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 6f0683e07d8d0dcfaaffc9a6539a457ca66ad1e0 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:53:18 +0800 Subject: [PATCH 13/14] Fix the unsuitable use of pa2page in lab8 --- labcodes/lab8/kern/mm/pmm.c | 12 ++++++------ labcodes/lab8/kern/mm/swap.c | 2 +- labcodes/lab8/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes/lab8/kern/mm/pmm.c b/labcodes/lab8/kern/mm/pmm.c index cb92075..7a2e95d 100644 --- a/labcodes/lab8/kern/mm/pmm.c +++ b/labcodes/lab8/kern/mm/pmm.c @@ -406,7 +406,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -625,7 +625,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -643,7 +643,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -654,8 +654,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -689,7 +689,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes/lab8/kern/mm/swap.c b/labcodes/lab8/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes/lab8/kern/mm/swap.c +++ b/labcodes/lab8/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes/lab8/kern/mm/vmm.c b/labcodes/lab8/kern/mm/vmm.c index 8cf880c..ed3021c 100644 --- a/labcodes/lab8/kern/mm/vmm.c +++ b/labcodes/lab8/kern/mm/vmm.c @@ -353,7 +353,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; From 08c31e9451ccc757e8eabfbdad7866e6e2f35e39 Mon Sep 17 00:00:00 2001 From: ArchStacker Date: Mon, 4 May 2015 19:54:09 +0800 Subject: [PATCH 14/14] Fix the unsuitable use of pa2page in lab8_result --- labcodes_answer/lab8_result/kern/mm/pmm.c | 12 ++++++------ labcodes_answer/lab8_result/kern/mm/swap.c | 2 +- labcodes_answer/lab8_result/kern/mm/vmm.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/labcodes_answer/lab8_result/kern/mm/pmm.c b/labcodes_answer/lab8_result/kern/mm/pmm.c index cf9fa77..b3d8aa1 100644 --- a/labcodes_answer/lab8_result/kern/mm/pmm.c +++ b/labcodes_answer/lab8_result/kern/mm/pmm.c @@ -418,7 +418,7 @@ get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) { *ptep_store = ptep; } if (ptep != NULL && *ptep & PTE_P) { - return pa2page(*ptep); + return pte2page(*ptep); } return NULL; } @@ -651,7 +651,7 @@ check_pgdir(void) { pte_t *ptep; assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert(page_ref(p1) == 1); ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1]; @@ -669,7 +669,7 @@ check_pgdir(void) { assert(page_ref(p1) == 2); assert(page_ref(p2) == 0); assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL); - assert(pa2page(*ptep) == p1); + assert(pte2page(*ptep) == p1); assert((*ptep & PTE_U) == 0); page_remove(boot_pgdir, 0x0); @@ -680,8 +680,8 @@ check_pgdir(void) { assert(page_ref(p1) == 0); assert(page_ref(p2) == 0); - assert(page_ref(pa2page(boot_pgdir[0])) == 1); - free_page(pa2page(boot_pgdir[0])); + assert(page_ref(pde2page(boot_pgdir[0])) == 1); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_pgdir() succeeded!\n"); @@ -715,7 +715,7 @@ check_boot_pgdir(void) { assert(strlen((const char *)0x100) == 0); free_page(p); - free_page(pa2page(PDE_ADDR(boot_pgdir[0]))); + free_page(pde2page(boot_pgdir[0])); boot_pgdir[0] = 0; cprintf("check_boot_pgdir() succeeded!\n"); diff --git a/labcodes_answer/lab8_result/kern/mm/swap.c b/labcodes_answer/lab8_result/kern/mm/swap.c index d2b5952..704ec18 100644 --- a/labcodes_answer/lab8_result/kern/mm/swap.c +++ b/labcodes_answer/lab8_result/kern/mm/swap.c @@ -262,7 +262,7 @@ check_swap(void) } //free_page(pte2page(*temp_ptep)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL; mm_destroy(mm); diff --git a/labcodes_answer/lab8_result/kern/mm/vmm.c b/labcodes_answer/lab8_result/kern/mm/vmm.c index 9f37163..9b12b3f 100644 --- a/labcodes_answer/lab8_result/kern/mm/vmm.c +++ b/labcodes_answer/lab8_result/kern/mm/vmm.c @@ -357,7 +357,7 @@ check_pgfault(void) { assert(sum == 0); page_remove(pgdir, ROUNDDOWN(addr, PGSIZE)); - free_page(pa2page(pgdir[0])); + free_page(pde2page(pgdir[0])); pgdir[0] = 0; mm->pgdir = NULL;