-MD and TRAPFRAME
This commit is contained in:
parent
5eab649255
commit
6b379e4707
4
Makefile
4
Makefile
|
@ -53,8 +53,8 @@ LD = $(TOOLPREFIX)ld
|
||||||
OBJCOPY = $(TOOLPREFIX)objcopy
|
OBJCOPY = $(TOOLPREFIX)objcopy
|
||||||
OBJDUMP = $(TOOLPREFIX)objdump
|
OBJDUMP = $(TOOLPREFIX)objdump
|
||||||
|
|
||||||
# CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O
|
|
||||||
CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb
|
CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb
|
||||||
|
CFLAGS += -MD
|
||||||
CFLAGS += -mcmodel=medany
|
CFLAGS += -mcmodel=medany
|
||||||
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax
|
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax
|
||||||
CFLAGS += -I.
|
CFLAGS += -I.
|
||||||
|
@ -133,7 +133,7 @@ UPROGS=\
|
||||||
fs.img: mkfs/mkfs README $(UPROGS)
|
fs.img: mkfs/mkfs README $(UPROGS)
|
||||||
mkfs/mkfs fs.img README $(UPROGS)
|
mkfs/mkfs fs.img README $(UPROGS)
|
||||||
|
|
||||||
-include *.d
|
-include kernel/*.d user/*.d
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \
|
rm -f *.tex *.dvi *.idx *.aux *.log *.ind *.ilg \
|
||||||
|
|
|
@ -53,4 +53,15 @@
|
||||||
// map the trampoline page to the highest address,
|
// map the trampoline page to the highest address,
|
||||||
// in both user and kernel space.
|
// in both user and kernel space.
|
||||||
#define TRAMPOLINE (MAXVA - PGSIZE)
|
#define TRAMPOLINE (MAXVA - PGSIZE)
|
||||||
#define KSTACK(p) (TRAMPOLINE - (p+1)* 2*PGSIZE)
|
#define KSTACK(p) (TRAMPOLINE - ((p)+1)* 2*PGSIZE)
|
||||||
|
|
||||||
|
// User memory layout.
|
||||||
|
// Address zero first:
|
||||||
|
// text
|
||||||
|
// original data and bss
|
||||||
|
// fixed-size stack
|
||||||
|
// expandable heap
|
||||||
|
// ...
|
||||||
|
// TRAPFRAME (p->tf, used by the trampoline)
|
||||||
|
// TRAMPOLINE (the same page as in the kernel)
|
||||||
|
#define TRAPFRAME (TRAMPOLINE - PGSIZE)
|
||||||
|
|
|
@ -156,8 +156,8 @@ proc_pagetable(struct proc *p)
|
||||||
mappages(pagetable, TRAMPOLINE, PGSIZE,
|
mappages(pagetable, TRAMPOLINE, PGSIZE,
|
||||||
(uint64)trampout, PTE_R | PTE_X);
|
(uint64)trampout, PTE_R | PTE_X);
|
||||||
|
|
||||||
// map the trapframe, for trampoline.S.
|
// map the trapframe just below TRAMPOLINE, for trampoline.S.
|
||||||
mappages(pagetable, (TRAMPOLINE - PGSIZE), PGSIZE,
|
mappages(pagetable, TRAPFRAME, PGSIZE,
|
||||||
(uint64)(p->tf), PTE_R | PTE_W);
|
(uint64)(p->tf), PTE_R | PTE_W);
|
||||||
|
|
||||||
return pagetable;
|
return pagetable;
|
||||||
|
@ -169,7 +169,7 @@ void
|
||||||
proc_freepagetable(pagetable_t pagetable, uint64 sz)
|
proc_freepagetable(pagetable_t pagetable, uint64 sz)
|
||||||
{
|
{
|
||||||
unmappages(pagetable, TRAMPOLINE, PGSIZE, 0);
|
unmappages(pagetable, TRAMPOLINE, PGSIZE, 0);
|
||||||
unmappages(pagetable, TRAMPOLINE-PGSIZE, PGSIZE, 0);
|
unmappages(pagetable, TRAPFRAME, PGSIZE, 0);
|
||||||
if(sz > 0)
|
if(sz > 0)
|
||||||
uvmfree(pagetable, sz);
|
uvmfree(pagetable, sz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,9 +105,3 @@ struct proc {
|
||||||
struct inode *cwd; // Current directory
|
struct inode *cwd; // Current directory
|
||||||
char name[16]; // Process name (debugging)
|
char name[16]; // Process name (debugging)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process memory is laid out contiguously, low addresses first:
|
|
||||||
// text
|
|
||||||
// original data and bss
|
|
||||||
// fixed-size stack
|
|
||||||
// expandable heap
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ trampin:
|
||||||
# user page table.
|
# user page table.
|
||||||
#
|
#
|
||||||
# sscratch points to where the process's p->tf is
|
# sscratch points to where the process's p->tf is
|
||||||
# mapped into user space (TRAMPOLINE - 4096).
|
# mapped into user space, at TRAPFRAME.
|
||||||
#
|
#
|
||||||
|
|
||||||
# swap a0 and sscratch
|
# swap a0 and sscratch
|
||||||
|
|
Loading…
Reference in a new issue