Skip to content

Commit 7c5687f

Browse files
committed
merged Yukang changes
2 parents 5dd0f13 + 4cd3fa5 commit 7c5687f

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

kernel/kalloc.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct KmemT {
3232

3333

3434
static mut kmem : KmemT = KmemT{ lock: DUMMY_LOCK, use_lock: 0} ;
35+
static mut end : Address = 0;
3536

3637
pub fn kinit1(vstart: Address, vend: Address) {
3738
unsafe {
@@ -50,6 +51,10 @@ fn free_range(vstart: Address, vend: Address) {
5051
// asm!("mov $0 , %rbx" : /* no outputs */ : "r"(address) : "eax");
5152
//}
5253

54+
unsafe {
55+
end = vstart;
56+
}
57+
5358
loop {
5459
kfree(address);
5560
address = address + PG_SIZE;
@@ -59,25 +64,25 @@ fn free_range(vstart: Address, vend: Address) {
5964
}
6065
}
6166

62-
fn kfree(a : Address){
63-
/*
64-
struct run *r;
65-
66-
if((uintp)v % PGSIZE || v < end || v2p(v) >= PHYSTOP)
67-
panic("kfree");
68-
69-
// Fill with junk to catch dangling refs.
70-
memset(v, 1, PGSIZE);
71-
72-
if(kmem.use_lock)
73-
acquire(&kmem.lock);
74-
r = (struct run*)v;
75-
r->next = kmem.freelist;
76-
kmem.freelist = r;
77-
if(kmem.use_lock)
78-
release(&kmem.lock);
67+
fn kfree(v : Address) {
7968

69+
//struct run *r;
8070

81-
82-
*/
71+
// if(v % PG_SIZE || v < end || v2p(v) >= PHYSTOP)
72+
// panic("kfree");
73+
//
74+
// // Fill with junk to catch dangling refs.
75+
// memset(v, 1, PGSIZE);
76+
//
77+
// if(kmem.use_lock)
78+
// acquire(&kmem.lock);
79+
// r = (struct run*)v;
80+
// r->next = kmem.freelist;
81+
// kmem.freelist = r;
82+
// if(kmem.use_lock)
83+
// release(&kmem.lock);
84+
//
85+
//
86+
//
87+
// */
8388
}

kernel/memlayout.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use super::mmu::Address;
2424

2525
pub const KERBASE : Address = 0xFFFFFFFF80000000;
26+
pub const PHYSTOP : Address = 0xE000000;
2627

2728
//TODO - in C this is a macro - need to figure out the right thing in RUST
2829
pub fn P2V(address : Address) -> Address {

0 commit comments

Comments
 (0)