Skip to content

Commit

Permalink
一些修剪
Browse files Browse the repository at this point in the history
	修改:     .vscode/settings.json
	修改:     lab2/.gdb.in
	修改:     lab2/.qemu.out
	修改:     lab2/bin/kernel
	修改:     lab2/bin/ucore.img
	修改:     lab2/kern/mm/buddy_pmm.c
	修改:     lab2/kern/mm/pmm.c
	修改:     lab2/obj/kern/mm/buddy_pmm.o
	删除:     lab2/obj/kern/mm/buddy_pmm_.d
	删除:     lab2/obj/kern/mm/buddy_pmm_.o
	修改:     lab2/obj/kern/mm/pmm.d
	修改:     lab2/obj/kern/mm/pmm.o
	修改:     lab2/obj/kernel.asm
	修改:     lab2/obj/kernel.sym
  • Loading branch information
shockstove committed Oct 15, 2023
1 parent 3b67833 commit 762b2de
Show file tree
Hide file tree
Showing 14 changed files with 2,070 additions and 1,842 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"files.associations": {
"memlayout.h": "c",
"error.h": "c"
"error.h": "c",
"sbi.h": "c"
}
}
2 changes: 1 addition & 1 deletion lab2/.gdb.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
target remote localhost:1234
break *0xffffffffc0201968
break *0xffffffffc020197e
continue
7 changes: 2 additions & 5 deletions lab2/.qemu.out
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
(THU.CST) os is loading ...
Special kernel symbols:
entry 0xffffffffc0200036 (virtual)
etext 0xffffffffc0201afc (virtual)
etext 0xffffffffc0201b12 (virtual)
edata 0xffffffffc0206010 (virtual)
end 0xffffffffc0206478 (virtual)
Kernel executable memory footprint: 26KB
memory management: best_fit_pmm_manager
physcial memory map:
memory: 0x0000000007e00000, [0x0000000080200000, 0x0000000087ffffff].
check_alloc_page() succeeded!
size_t n is 31929check_alloc_page() succeeded!
satp virtual address: 0xffffffffc0205000
satp physical address: 0x0000000080205000
++ setup timer interrupts
Expand Down Expand Up @@ -76,6 +76,3 @@ satp physical address: 0x0000000080205000
100 ticks
100 ticks
100 ticks
100 ticks
100 ticks
100 ticks
Binary file modified lab2/bin/kernel
Binary file not shown.
Binary file modified lab2/bin/ucore.img
Binary file not shown.
15 changes: 9 additions & 6 deletions lab2/kern/mm/buddy_pmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static struct Page* GET_BUDDY(struct Page *page)
{
uint32_t power=page->property;
size_t ppn=fppn+((1<<power)^(page2ppn(page)-fppn));//得到伙伴块的物理页号,fppn为buddy system起始的物理页号
//cprintf("page ppn is %d;buddy ppn is %d",page2ppn(page),ppn);
return page+(ppn-page2ppn(page));
}
//展示空闲页面情况
Expand Down Expand Up @@ -143,6 +144,7 @@ static void buddy_free_pages(struct Page *base, size_t n)
//将释放的块接入到对应的项的空闲链表上
list_add(&(free_array[free_page->property]),&(free_page->page_link));
//当其伙伴块没有被使用且不大于设定的最大块时
//SHOW_BUDDY_ARRAY();
while(!PageProperty(free_page_buddy)&&free_page->property<14)
{
//cprintf("in while\n");
Expand All @@ -168,7 +170,7 @@ static void buddy_free_pages(struct Page *base, size_t n)
//cprintf("buddy's property is %d\n",free_page_buddy->property);
//show_buddy_array();
}
//ClearPageProperty(free_page);
ClearPageProperty(free_page);
return;
}
static size_t
Expand All @@ -193,10 +195,11 @@ buddy_nr_free_pages(void) {
SHOW_BUDDY_ARRAY();
// 释放 p0, p1, 和 p2,然后检查 nr_free 是否为3。
free_page(p0);
//cprintf("p0 free\n");
cprintf("p0 free\n");
free_page(p1);
//cprintf("p1 free\n");
cprintf("p1 free\n");
free_page(p2);
cprintf("p2 free\n");
//show_buddy_array();
//cprintf("nr_free is %d",nr_free);
SHOW_BUDDY_ARRAY();
Expand All @@ -208,12 +211,12 @@ buddy_nr_free_pages(void) {
assert((p2 = alloc_pages(1)) != NULL);
cprintf("%p,%p,%p\n",page2pa(p0),page2pa(p1),page2pa(p2));SHOW_BUDDY_ARRAY();
free_pages(p0, 4);
cprintf("p0 free\n");SHOW_BUDDY_ARRAY();
cprintf("p0 free\n");
free_pages(p1, 2);
SHOW_BUDDY_ARRAY();
cprintf("p1 free\n");SHOW_BUDDY_ARRAY();
cprintf("p1 free\n");
free_pages(p2, 1);
cprintf("p2 free\n");SHOW_BUDDY_ARRAY();
cprintf("p2 free\n");
SHOW_BUDDY_ARRAY();

assert((p0 = alloc_pages(3)) != NULL);
Expand Down
3 changes: 1 addition & 2 deletions lab2/kern/mm/pmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ static void check_alloc_page(void);

// init_pmm_manager - initialize a pmm_manager instance
static void init_pmm_manager(void) {
//pmm_manager = &best_fit_pmm_manager;
pmm_manager = &best_fit_pmm_manager;
//pmm_manager=&buddy_pmm_manager;
pmm_manager=&buddy_pmm_manager;
cprintf("memory management: %s\n", pmm_manager->name);
pmm_manager->init();
}
Expand Down
Binary file modified lab2/obj/kern/mm/buddy_pmm.o
Binary file not shown.
4 changes: 0 additions & 4 deletions lab2/obj/kern/mm/buddy_pmm_.d

This file was deleted.

Binary file removed lab2/obj/kern/mm/buddy_pmm_.o
Binary file not shown.
2 changes: 1 addition & 1 deletion lab2/obj/kern/mm/pmm.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
obj/kern/mm/pmm.o obj/kern/mm/pmm.d: kern/mm/pmm.c kern/mm/default_pmm.h \
kern/mm/pmm.h kern/debug/assert.h libs/defs.h libs/atomic.h \
kern/mm/memlayout.h libs/list.h kern/mm/mmu.h libs/riscv.h \
kern/mm/best_fit_pmm.h kern/mm/buddy_pmm_.h libs/error.h libs/sbi.h \
kern/mm/best_fit_pmm.h kern/mm/buddy_pmm.h libs/error.h libs/sbi.h \
libs/stdio.h libs/stdarg.h libs/string.h kern/mm/../sync/sync.h \
kern/driver/intr.h
Binary file modified lab2/obj/kern/mm/pmm.o
Binary file not shown.
3,804 changes: 2,018 additions & 1,786 deletions lab2/obj/kernel.asm

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions lab2/obj/kernel.sym
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ffffffffc0200000 .text
ffffffffc02018c8 .rodata
ffffffffc02026c0 .sdata2.nbase
ffffffffc0201b18 .rodata
ffffffffc0202970 .sdata2.nbase
ffffffffc0203000 .data
ffffffffc0206000 .sdata
ffffffffc0206010 .bss
Expand All @@ -18,88 +18,88 @@ ffffffffc0206010 .bss
ffffffffc020007c cputch
0000000000000000 kdebug.c
0000000000000000 kmonitor.c
ffffffffc02019e8 commands
ffffffffc0201c38 commands
0000000000000000 panic.c
ffffffffc0206410 is_panic
0000000000000000 clock.c
0000000000000000 console.c
0000000000000000 intr.c
0000000000000000 trap.c
0000000000000000 buddy_pmm_.c
ffffffffc020081e buddy_init
ffffffffc020084a buddy_nr_free_pages
ffffffffc0200854 show_buddy_array
ffffffffc02008ea buddy_free_pages
ffffffffc0200a6a buddy_alloc_pages
ffffffffc0200c38 buddy_check
ffffffffc0200fda buddy_init_memmap
0000000000000000 best_fit_pmm.c
ffffffffc020081e best_fit_init
ffffffffc0200830 best_fit_nr_free_pages
ffffffffc020083a best_fit_alloc_pages
ffffffffc0200904 best_fit_check
ffffffffc0201014 best_fit_free_pages
ffffffffc02011b8 best_fit_init_memmap
0000000000000000 pmm.c
0000000000000000 printfmt.c
ffffffffc020133a printnum
ffffffffc02025d0 error_string
ffffffffc0201586 printnum
ffffffffc0202880 error_string
0000000000000000 readline.c
ffffffffc0206010 buf
0000000000000000 sbi.c
0000000000000000 string.c
ffffffffc020013e print_kerninfo
ffffffffc0201828 sbi_console_getchar
ffffffffc0201a74 sbi_console_getchar
ffffffffc0205000 boot_page_table_sv39
ffffffffc0200000 kern_entry
ffffffffc020025a mon_backtrace
ffffffffc020180c sbi_set_timer
ffffffffc0201a58 sbi_set_timer
ffffffffc020064a print_trapframe
ffffffffc02013a6 vprintfmt
ffffffffc02015f2 vprintfmt
ffffffffc0200768 __alltraps
ffffffffc020045a cons_getc
ffffffffc02001ce print_stackframe
ffffffffc0206428 SBI_SET_TIMER
ffffffffc0206548 satp_physical
ffffffffc0206450 satp_physical
ffffffffc02000b6 cprintf
ffffffffc0206550 fppn
ffffffffc0201732 readline
ffffffffc0206458 fppn
ffffffffc020197e readline
ffffffffc0200036 kern_init
ffffffffc02010fa free_pages
ffffffffc0201306 free_pages
ffffffffc0206010 edata
ffffffffc0200450 cons_init
ffffffffc0206558 pmm_manager
ffffffffc0202298 buddy_pmm_manager_
ffffffffc0206460 pmm_manager
ffffffffc02003ac __panic
ffffffffc0200440 clock_set_next_event
ffffffffc0206560 va_pa_offset
ffffffffc0201846 strnlen
ffffffffc0206468 va_pa_offset
ffffffffc0201a92 strnlen
ffffffffc020046a idt_init
ffffffffc0200000 BASE_ADDRESS
ffffffffc0206418 npage
ffffffffc020026a kmonitor
ffffffffc020040c clock_init
ffffffffc0206570 end
ffffffffc020134c nr_free_pages
ffffffffc0206478 end
ffffffffc0200452 cons_putc
ffffffffc02018c6 etext
ffffffffc0201b12 etext
ffffffffc020045e intr_enable
ffffffffc0206000 SBI_CONSOLE_GETCHAR
ffffffffc02025a0 best_fit_pmm_manager
ffffffffc0200464 intr_disable
ffffffffc020047c print_regs
ffffffffc0206438 free_buddy
ffffffffc02000ea cputchar
ffffffffc02018b4 memset
ffffffffc0201b00 memset
ffffffffc0206008 SBI_CONSOLE_PUTCHAR
ffffffffc020012e getchar
ffffffffc0206420 satp_virtual
ffffffffc0201712 printfmt
ffffffffc020195e printfmt
ffffffffc020075a trap
ffffffffc020186c strcmp
ffffffffc0201ab8 strcmp
ffffffffc02006ac interrupt_handler
ffffffffc02017f0 sbi_console_putchar
ffffffffc0201140 pmm_init
ffffffffc0201a3c sbi_console_putchar
ffffffffc020138c pmm_init
ffffffffc0206430 ticks
ffffffffc02010b6 alloc_pages
ffffffffc02012c2 alloc_pages
ffffffffc02007d0 __trapret
ffffffffc0200096 vcprintf
ffffffffc02000ee cputs
ffffffffc0205000 bootstacktop
ffffffffc0203000 bootstack
ffffffffc02026c0 nbase
ffffffffc0201896 strchr
ffffffffc0202970 nbase
ffffffffc0206438 free_area
ffffffffc0201ae2 strchr
ffffffffc020024a mon_kerninfo
ffffffffc0206568 pages
ffffffffc0206470 pages
ffffffffc02001ea mon_help

0 comments on commit 762b2de

Please sign in to comment.