version 1.38, 2006/04/12 13:48:52 |
version 1.47, 2007/02/19 11:46:10 |
|
|
|
|
#include "npx.h" |
#include "npx.h" |
#include "assym.h" |
#include "assym.h" |
#include "apm.h" |
|
#include "lapic.h" |
#include "lapic.h" |
#include "ioapic.h" |
#include "ioapic.h" |
#include "ksyms.h" |
#include "ksyms.h" |
|
|
.globl _C_LABEL(cpu) |
.globl _C_LABEL(cpu) |
.globl _C_LABEL(esym) |
.globl _C_LABEL(esym) |
.globl _C_LABEL(atdevbase) |
.globl _C_LABEL(atdevbase) |
.globl _C_LABEL(proc0paddr),_C_LABEL(PDPpaddr) |
.globl _C_LABEL(proc0uarea),_C_LABEL(PDPpaddr) |
.globl _C_LABEL(gdt) |
.globl _C_LABEL(gdt) |
#ifdef I586_CPU |
#ifdef I586_CPU |
.globl _C_LABEL(idt) |
.globl _C_LABEL(idt) |
Line 193 _C_LABEL(lapic_tpr): |
|
Line 192 _C_LABEL(lapic_tpr): |
|
_C_LABEL(cpu): .long 0 # are we 386, 386sx, or 486, |
_C_LABEL(cpu): .long 0 # are we 386, 386sx, or 486, |
# or Pentium, or.. |
# or Pentium, or.. |
_C_LABEL(atdevbase): .long 0 # location of start of iomem in virtual |
_C_LABEL(atdevbase): .long 0 # location of start of iomem in virtual |
_C_LABEL(proc0paddr): .long 0 |
_C_LABEL(proc0uarea): .long 0 |
_C_LABEL(PDPpaddr): .long 0 # paddr of PDP, for libkvm |
_C_LABEL(PDPpaddr): .long 0 # paddr of PDP, for libkvm |
|
|
.space 512 |
.space 512 |
Line 216 start: movw $0x1234,0x472 # warm boot |
|
Line 215 start: movw $0x1234,0x472 # warm boot |
|
.align 4 |
.align 4 |
.globl Multiboot_Header |
.globl Multiboot_Header |
_C_LABEL(Multiboot_Header): |
_C_LABEL(Multiboot_Header): |
#define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_HEADER_WANT_MEMORY | \ |
#define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_HEADER_WANT_MEMORY) |
MULTIBOOT_HEADER_HAS_ADDR) |
|
.long MULTIBOOT_HEADER_MAGIC |
.long MULTIBOOT_HEADER_MAGIC |
.long MULTIBOOT_HEADER_FLAGS |
.long MULTIBOOT_HEADER_FLAGS |
.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) |
.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) |
.long RELOC(Multiboot_Header) |
|
.long RELOC(start) |
|
.long RELOC(_edata) |
|
.long RELOC(_end) + MULTIBOOT_SYMTAB_SPACE |
|
.long RELOC(start) |
|
|
|
1: |
1: |
/* Check if we are being executed by a Multiboot-compliant boot |
/* Check if we are being executed by a Multiboot-compliant boot |
Line 233 _C_LABEL(Multiboot_Header): |
|
Line 226 _C_LABEL(Multiboot_Header): |
|
cmpl $MULTIBOOT_INFO_MAGIC,%eax |
cmpl $MULTIBOOT_INFO_MAGIC,%eax |
jne 1f |
jne 1f |
|
|
/* Indeed, a multiboot-compliat boot loader executed us. We copy |
/* |
|
* Indeed, a multiboot-compliant boot loader executed us. We copy |
* the received Multiboot information structure into kernel's data |
* the received Multiboot information structure into kernel's data |
* space to process it later -- after we are relocated. It will |
* space to process it later -- after we are relocated. It will |
* be safer to run complex C code than doing it at this point. */ |
* be safer to run complex C code than doing it at this point. |
|
*/ |
pushl %ebx # Address of Multiboot information |
pushl %ebx # Address of Multiboot information |
call _C_LABEL(multiboot_pre_reloc) |
call _C_LABEL(multiboot_pre_reloc) |
addl $4,%esp |
addl $4,%esp |
Line 247 _C_LABEL(Multiboot_Header): |
|
Line 242 _C_LABEL(Multiboot_Header): |
|
/* |
/* |
* At this point, we know that a NetBSD-specific boot loader |
* At this point, we know that a NetBSD-specific boot loader |
* booted this kernel. The stack carries the following parameters: |
* booted this kernel. The stack carries the following parameters: |
* (boothowto, [bootdev], bootinfo, esym, biosbasemem, biosextmem), |
* (boothowto, [bootdev], bootinfo, esym, biosextmem, biosbasemem), |
* 4 bytes each. |
* 4 bytes each. |
*/ |
*/ |
addl $4,%esp # Discard return address to boot loader |
addl $4,%esp # Discard return address to boot loader |
|
|
|
|
/* Set up bootstrap stack. */ |
/* Set up bootstrap stack. */ |
leal (PROC0STACK+KERNBASE)(%esi),%eax |
leal (PROC0STACK+KERNBASE)(%esi),%eax |
movl %eax,_C_LABEL(proc0paddr) |
movl %eax,_C_LABEL(proc0uarea) |
leal (USPACE-FRAMESIZE)(%eax),%esp |
leal (KSTACK_SIZE-FRAMESIZE)(%eax),%esp |
movl %esi,PCB_CR3(%eax) # pcb->pcb_cr3 |
movl %esi,(KSTACK_SIZE+PCB_CR3)(%eax) # pcb->pcb_cr3 |
xorl %ebp,%ebp # mark end of frames |
xorl %ebp,%ebp # mark end of frames |
|
|
#if defined(MULTIBOOT) |
#if defined(MULTIBOOT) |
|
|
pushl %eax |
pushl %eax |
lret |
lret |
|
|
|
NENTRY(x86_flush) |
|
/* Reload code selector by doing intersegment return. */ |
|
popl %eax |
|
pushl $GSEL(GCODE_SEL, SEL_KPL) |
|
pushl %eax |
|
lret |
|
|
/*****************************************************************************/ |
/*****************************************************************************/ |
|
|
/* |
/* |
Line 773 NENTRY(switch_error) |
|
Line 775 NENTRY(switch_error) |
|
|
|
/* |
/* |
* void cpu_switch(struct lwp *) |
* void cpu_switch(struct lwp *) |
* Find a runnable process and switch to it. Wait if necessary. If the new |
* Find a runnable lwp and switch to it. Wait if necessary. If the new |
* process is the same as the old one, we short-circuit the context save and |
* lwp is the same as the old one, we short-circuit the context save and |
* restore. |
* restore. |
* |
* |
* Note that the stack frame layout is known to "struct switchframe" |
* Note that the stack frame layout is known to "struct switchframe" |
Line 884 ENTRY(cpu_switch) |
|
Line 886 ENTRY(cpu_switch) |
|
xorl %esi,%esi |
xorl %esi,%esi |
sti |
sti |
idle_unlock: |
idle_unlock: |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
call _C_LABEL(sched_unlock_idle) |
call _C_LABEL(sched_unlock_idle) |
#endif |
|
/* Interrupts are okay again. */ |
/* Interrupts are okay again. */ |
pushl $IPL_NONE # spl0() |
pushl $IPL_NONE # spl0() |
call _C_LABEL(Xspllower) # process pending interrupts |
call _C_LABEL(spllower) # process pending interrupts |
addl $4,%esp |
addl $4,%esp |
jmp idle_start |
jmp idle_start |
idle_zero: |
idle_zero: |
|
|
idle_exit: |
idle_exit: |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh |
sti |
sti |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
call _C_LABEL(sched_lock_idle) |
call _C_LABEL(sched_lock_idle) |
#endif |
|
movl _C_LABEL(sched_whichqs),%ecx |
movl _C_LABEL(sched_whichqs),%ecx |
bsfl %ecx,%ebx |
bsfl %ecx,%ebx |
jz idle_unlock |
jz idle_unlock |
|
|
|
|
#if 0 |
#if 0 |
/* Don't bother with the rest if switching to a system process. */ |
/* Don't bother with the rest if switching to a system process. */ |
testl $P_SYSTEM,L_FLAG(%edi); XXX NJWLWP lwp's don't have P_SYSTEM! |
testl $PK_SYSTEM,L_FLAG(%edi); XXX NJWLWP lwp's don't have PK_SYSTEM! |
jnz switch_restored |
jnz switch_restored |
#endif |
#endif |
|
|
Line 1067 switch_restored: |
|
Line 1065 switch_restored: |
|
movl $1,%ebx |
movl $1,%ebx |
|
|
switch_return: |
switch_return: |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
call _C_LABEL(sched_unlock_idle) |
call _C_LABEL(sched_unlock_idle) |
#endif |
|
cmpl $0,CPUVAR(IPENDING) |
cmpl $0,CPUVAR(IPENDING) |
jz 3f |
jz 3f |
pushl $IPL_NONE # spl0() |
pushl $IPL_NONE # spl0() |
call _C_LABEL(Xspllower) # process pending interrupts |
call _C_LABEL(spllower) # process pending interrupts |
addl $4,%esp |
addl $4,%esp |
3: |
3: |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh() |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh() |
Line 1160 ENTRY(cpu_exit) |
|
Line 1156 ENTRY(cpu_exit) |
|
movl CPUVAR(IDLE_PCB),%esi |
movl CPUVAR(IDLE_PCB),%esi |
movl CPUVAR(IDLE_TSS_SEL),%edx |
movl CPUVAR(IDLE_TSS_SEL),%edx |
#endif |
#endif |
/* In case we fault... */ |
|
movl $0,CPUVAR(CURLWP) |
|
|
|
/* Restore the idle context. */ |
/* Restore the idle context. */ |
cli |
cli |
Line 1192 ENTRY(cpu_exit) |
|
Line 1186 ENTRY(cpu_exit) |
|
/* Record new pcb. */ |
/* Record new pcb. */ |
SET_CURPCB(%esi) |
SET_CURPCB(%esi) |
|
|
|
/* Now off the CPU. */ |
|
movl $0,CPUVAR(CURLWP) |
|
|
/* Interrupts are okay again. */ |
/* Interrupts are okay again. */ |
sti |
sti |
|
|
/* |
|
* Schedule the dead LWP's stack to be freed. |
|
*/ |
|
pushl %edi |
|
call _C_LABEL(lwp_exit2) |
|
addl $4,%esp |
|
|
|
/* Jump into cpu_switch() with the right state. */ |
/* Jump into cpu_switch() with the right state. */ |
xorl %esi,%esi |
xorl %esi,%esi |
movl %esi,CPUVAR(CURLWP) |
|
jmp idle_start |
jmp idle_start |
|
|
/* |
/* |
Line 1213 ENTRY(cpu_exit) |
|
Line 1202 ENTRY(cpu_exit) |
|
*/ |
*/ |
/* LINTSTUB: Func: void savectx(struct pcb *pcb) */ |
/* LINTSTUB: Func: void savectx(struct pcb *pcb) */ |
ENTRY(savectx) |
ENTRY(savectx) |
movl 4(%esp),%edx # edx = p->p_addr |
movl 4(%esp),%edx # edx = pcb |
|
|
/* Save stack pointers. */ |
/* Save stack pointers. */ |
movl %esp,PCB_ESP(%edx) |
movl %esp,PCB_ESP(%edx) |