move jkstack to main.c

replace jstack with asm()s
This commit is contained in:
Robert Morris 2010-08-05 14:15:03 -04:00
parent eb18645f17
commit 2cf6b32d4d
6 changed files with 17 additions and 28 deletions

2
defs.h
View File

@ -110,7 +110,6 @@ void yield(void);
// swtch.S // swtch.S
void swtch(struct context**, struct context*); void swtch(struct context**, struct context*);
void jstack(uint);
// spinlock.c // spinlock.c
void acquire(struct spinlock*); void acquire(struct spinlock*);
@ -157,7 +156,6 @@ void pminit(void);
void ksegment(void); void ksegment(void);
void kvmalloc(void); void kvmalloc(void);
void vminit(void); void vminit(void);
void jkstack();
void printstack(void); void printstack(void);
void printpgdir(pde_t *); void printpgdir(pde_t *);
pde_t* setupkvm(void); pde_t* setupkvm(void);

22
main.c
View File

@ -7,7 +7,8 @@
static void bootothers(void); static void bootothers(void);
static void mpmain(void); static void mpmain(void);
void jkstack(void) __attribute__((noreturn)); void jkstack(void) __attribute__((noreturn));
void mainc(void);
// Bootstrap processor starts running C code here. // Bootstrap processor starts running C code here.
int int
@ -21,13 +22,24 @@ main(void)
consoleinit(); // I/O devices & their interrupts consoleinit(); // I/O devices & their interrupts
uartinit(); // serial port uartinit(); // serial port
pminit(); // physical memory for kernel pminit(); // physical memory for kernel
jkstack(); // Jump to mainc on a proper-allocated kernel stack jkstack(); // Jump to mainc on a properly-allocated stack
}
void
jkstack(void)
{
char *kstack = kalloc(PGSIZE);
if (!kstack)
panic("jkstack\n");
char *top = kstack + PGSIZE;
asm volatile("movl %0,%%esp" : : "r" (top));
asm volatile("call mainc");
panic("jkstack");
} }
void void
mainc(void) mainc(void)
{ {
cprintf("cpus %p cpu %p\n", cpus, cpu);
cprintf("\ncpu%d: starting xv6\n\n", cpu->id); cprintf("\ncpu%d: starting xv6\n\n", cpu->id);
kvmalloc(); // allocate the kernel page table kvmalloc(); // allocate the kernel page table
pinit(); // process table pinit(); // process table
@ -52,14 +64,12 @@ mpmain(void)
{ {
if(cpunum() != mpbcpu()) { if(cpunum() != mpbcpu()) {
ksegment(); ksegment();
cprintf("other cpu\n");
lapicinit(cpunum()); lapicinit(cpunum());
} }
vminit(); // Run with paging on each processor vminit(); // Run with paging on each processor
cprintf("cpu%d: mpmain\n", cpu->id); cprintf("cpu%d: starting\n", cpu->id);
idtinit(); idtinit();
xchg(&cpu->booted, 1); xchg(&cpu->booted, 1);
cprintf("cpu%d: scheduling\n", cpu->id);
scheduler(); scheduler();
} }

View File

@ -22,6 +22,7 @@ proc.h
proc.c proc.c
swtch.S swtch.S
kalloc.c kalloc.c
vm.c
# system calls # system calls
traps.h traps.h

1
sh.c
View File

@ -420,7 +420,6 @@ parseexec(char **ps, char *es)
int tok, argc; int tok, argc;
struct execcmd *cmd; struct execcmd *cmd;
struct cmd *ret; struct cmd *ret;
int *x = (int *) peek;
if(peek(ps, es, "(")) if(peek(ps, es, "("))
return parseblock(ps, es); return parseblock(ps, es);

View File

@ -26,11 +26,3 @@ swtch:
popl %ebx popl %ebx
popl %ebp popl %ebp
ret ret
# Jump on a new stack, fake C calling conventions
.globl jstack
jstack:
movl 4(%esp), %esp
subl $16, %esp # space for arguments
movl $0, %ebp # terminate functions that follow ebp's
call mainc # continue at mainc

11
vm.c
View File

@ -324,17 +324,6 @@ pminit(void)
kinit((char *)kernend, freesz); kinit((char *)kernend, freesz);
} }
// Jump to mainc on a properly-allocated kernel stack
void
jkstack(void)
{
char *kstack = kalloc(PGSIZE);
if (!kstack)
panic("jkstack\n");
char *top = kstack + PGSIZE;
jstack((uint) top);
}
// Allocate one page table for the machine for the kernel address // Allocate one page table for the machine for the kernel address
// space for scheduler processes. // space for scheduler processes.
void void