Permalink
Browse files

fixed some weird codes which do not match the comments

  • Loading branch information...
1 parent d2b6e3d commit 442f161ca3039871b2b9ba8733d4fc8378a9d7f7 @Fleurer committed May 17, 2012
Showing with 10 additions and 9 deletions.
  1. +2 −2 src/boot/boot.S
  2. +1 −0 src/inc/param.h
  3. +3 −4 src/kern/fork.c
  4. +4 −3 src/mm/pm.c
View
4 src/boot/boot.S
@@ -113,8 +113,8 @@ _start_pm:
mov ss, ax
mov es, ax
mov gs, ax
- ; move stack to 0x2000, temporily
- mov esp, 2000h
+ ; move stack to 0x1000
+ mov esp, 1000h
; copy 0x10000 to 0x100000
cld
View
1 src/inc/param.h
@@ -9,6 +9,7 @@ typedef unsigned int uint;
#define PMEM 0x8000000 /* 128mb physical memory. */
#define KMEM_END 0x8000000 /* 128mb, the kernel's address space. */
#define KHEAP 0x300000 /* kernel's heap starts at 3mb. */
+#define KSTACK0 0x1000 /* proc0's stack, takes one page and grows downward. */
#define ROOTINO 1
View
7 src/kern/fork.c
@@ -15,8 +15,7 @@
*
* */
-/* the kernel stack of proc0, one page size */
-uchar kstack0[PAGE] __attribute__((aligned(PAGE)));
+struct proc proc0;
struct proc *proc[NPROC] = {NULL, };
struct proc *cu = NULL;
@@ -139,7 +138,7 @@ int do_fork(struct trap *tf){
void proc0_init(){
int fd;
- struct proc *p = cu = proc[0] = (struct proc *)(uint) kstack0;
+ struct proc *p = cu = proc[0] = &proc0;
p->p_pid = 0;
p->p_ppid = 0;
p->p_stat = SRUN;
@@ -158,7 +157,7 @@ void proc0_init(){
p->p_iroot = NULL;
// init tss
tss.ss0 = KERN_DS;
- tss.esp0 = (uint)p + PAGE;
+ tss.esp0 = KSTACK0;
for (fd=0; fd<NOFILE; fd++){
p->p_ofile[fd] = NULL;
}
View
7 src/mm/pm.c
@@ -96,9 +96,10 @@ int pm_init(){
uint pn;
// mark the reserved pages
- // 640kb ~ 1mb is system reserved, BIOS and blah
- // 1mb ~ __kend__ is kernel reserved.
- for (pn=0; pn<3; pn++) {
+ // 0~4kb is reserved for the kernel stack of proc0;
+ // 640kb ~ 1mb is system reserved, BIOS and blah;
+ // 1mb ~ __kend__ is reserved for the kernel image.;
+ for (pn=0; pn<1; pn++) {
coremap[pn].pg_num = pn;
coremap[pn].pg_flag = PG_RSVD;
coremap[pn].pg_count = 100;

0 comments on commit 442f161

Please sign in to comment.