version 1.8, 2003/04/26 18:13:16 |
version 1.18, 2003/09/12 12:39:59 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* 3. Neither the name of the University nor the names of its contributors |
* must display the following acknowledgement: |
|
* This product includes software developed by the University of |
|
* California, Berkeley and its contributors. |
|
* 4. Neither the name of the University nor the names of its contributors |
|
* may be used to endorse or promote products derived from this software |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* without specific prior written permission. |
* |
* |
|
|
* @(#)locore.s 7.3 (Berkeley) 5/13/91 |
* @(#)locore.s 7.3 (Berkeley) 5/13/91 |
*/ |
*/ |
|
|
|
#include "opt_compat_netbsd.h" |
|
#include "opt_compat_oldboot.h" |
#include "opt_cputype.h" |
#include "opt_cputype.h" |
#include "opt_ddb.h" |
#include "opt_ddb.h" |
#include "opt_ipkdb.h" |
|
#include "opt_vm86.h" |
|
#include "opt_user_ldt.h" |
|
#include "opt_dummy_nops.h" |
#include "opt_dummy_nops.h" |
#include "opt_compat_oldboot.h" |
#include "opt_ipkdb.h" |
#include "opt_multiprocessor.h" |
|
#include "opt_lockdebug.h" |
#include "opt_lockdebug.h" |
|
#include "opt_multiprocessor.h" |
#include "opt_realmem.h" |
#include "opt_realmem.h" |
|
#include "opt_user_ldt.h" |
|
#include "opt_vm86.h" |
|
|
#include "npx.h" |
#include "npx.h" |
#include "assym.h" |
#include "assym.h" |
|
|
.data |
.data |
|
|
.globl _C_LABEL(cpu) |
.globl _C_LABEL(cpu) |
.globl _C_LABEL(cpu_feature) |
|
.globl _C_LABEL(esym),_C_LABEL(boothowto) |
.globl _C_LABEL(esym),_C_LABEL(boothowto) |
.globl _C_LABEL(bootinfo),_C_LABEL(atdevbase) |
.globl _C_LABEL(bootinfo),_C_LABEL(atdevbase) |
#ifdef COMPAT_OLDBOOT |
#ifdef COMPAT_OLDBOOT |
Line 224 _C_LABEL(lapic_tpr): |
|
Line 220 _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(cpu_feature): .long 0 # feature flags from 'cpuid' |
|
# instruction |
|
_C_LABEL(esym): .long 0 # ptr to end of syms |
_C_LABEL(esym): .long 0 # ptr to end of syms |
_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(proc0paddr): .long 0 |
Line 245 _C_LABEL(biosextmem): .long REALEXTMEM |
|
Line 239 _C_LABEL(biosextmem): .long REALEXTMEM |
|
tmpstk: |
tmpstk: |
|
|
|
|
#define _RELOC(x) ((x) - KERNBASE) |
#define _RELOC(x) ((x) - KERNBASE_LOCORE) |
#define RELOC(x) _RELOC(_C_LABEL(x)) |
#define RELOC(x) _RELOC(_C_LABEL(x)) |
|
|
.text |
.text |
Line 299 start: movw $0x1234,0x472 # warm boot |
|
Line 293 start: movw $0x1234,0x472 # warm boot |
|
movl 16(%esp),%eax |
movl 16(%esp),%eax |
testl %eax,%eax |
testl %eax,%eax |
jz 1f |
jz 1f |
addl $KERNBASE,%eax |
addl $KERNBASE_LOCORE,%eax |
1: movl %eax,RELOC(esym) |
1: movl %eax,RELOC(esym) |
|
|
movl RELOC(biosextmem),%eax |
movl RELOC(biosextmem),%eax |
Line 519 try586: /* Use the `cpuid' instruction. |
|
Line 513 try586: /* Use the `cpuid' instruction. |
|
movl RELOC(esym),%eax |
movl RELOC(esym),%eax |
testl %eax,%eax |
testl %eax,%eax |
jz 1f |
jz 1f |
subl $KERNBASE,%eax |
subl $KERNBASE_LOCORE,%eax |
movl %eax,%edi |
movl %eax,%edi |
1: |
1: |
#endif |
#endif |
Line 635 try586: /* Use the `cpuid' instruction. |
|
Line 629 try586: /* Use the `cpuid' instruction. |
|
ret |
ret |
|
|
begin: |
begin: |
/* Now running relocated at KERNBASE. Remove double mapping. */ |
/* Now running relocated at KERNBASE_LOCORE. Remove double mapping. */ |
movl _C_LABEL(nkpde),%ecx # for this many pde s, |
movl _C_LABEL(nkpde),%ecx # for this many pde s, |
leal (PROC0PDIR+0*4)(%esi),%ebx # which is where temp maps! |
leal (PROC0PDIR+0*4)(%esi),%ebx # which is where temp maps! |
addl $(KERNBASE), %ebx # now use relocated address |
addl $(KERNBASE_LOCORE), %ebx # now use relocated address |
1: movl $0,(%ebx) |
1: movl $0,(%ebx) |
addl $4,%ebx # next pde |
addl $4,%ebx # next pde |
loop 1b |
loop 1b |
|
|
/* Relocate atdevbase. */ |
/* Relocate atdevbase. */ |
movl _C_LABEL(nkpde),%edx |
movl _C_LABEL(nkpde),%edx |
shll $PGSHIFT,%edx |
shll $PGSHIFT,%edx |
addl $(TABLESIZE+KERNBASE),%edx |
addl $(TABLESIZE+KERNBASE_LOCORE),%edx |
addl %esi,%edx |
addl %esi,%edx |
movl %edx,_C_LABEL(atdevbase) |
movl %edx,_C_LABEL(atdevbase) |
|
|
/* Set up bootstrap stack. */ |
/* Set up bootstrap stack. */ |
leal (PROC0STACK+KERNBASE)(%esi),%eax |
leal (PROC0STACK+KERNBASE_LOCORE)(%esi),%eax |
movl %eax,_C_LABEL(proc0paddr) |
movl %eax,_C_LABEL(proc0paddr) |
leal (USPACE-FRAMESIZE)(%eax),%esp |
leal (USPACE-FRAMESIZE)(%eax),%esp |
movl %esi,PCB_CR3(%eax) # pcb->pcb_cr3 |
movl %esi,PCB_CR3(%eax) # pcb->pcb_cr3 |
Line 712 NENTRY(proc_trampoline) |
|
Line 706 NENTRY(proc_trampoline) |
|
/* NOTREACHED */ |
/* NOTREACHED */ |
|
|
/*****************************************************************************/ |
/*****************************************************************************/ |
|
#ifdef COMPAT_16 |
/* |
/* |
* Signal trampoline; copied to top of user stack. |
* Signal trampoline; copied to top of user stack. |
*/ |
*/ |
|
|
leal 12(%esp),%eax # get pointer to sigcontext |
leal 12(%esp),%eax # get pointer to sigcontext |
movl %eax,4(%esp) # put it in the argument slot |
movl %eax,4(%esp) # put it in the argument slot |
# fake return address already there |
# fake return address already there |
movl $SYS___sigreturn14,%eax |
movl $SYS_compat_16___sigreturn14,%eax |
int $0x80 # enter kernel with args on stack |
int $0x80 # enter kernel with args on stack |
movl $SYS_exit,%eax |
movl $SYS_exit,%eax |
int $0x80 # exit if sigreturn fails |
int $0x80 # exit if sigreturn fails |
.globl _C_LABEL(esigcode) |
.globl _C_LABEL(esigcode) |
_C_LABEL(esigcode): |
_C_LABEL(esigcode): |
|
#endif |
|
|
/*****************************************************************************/ |
/*****************************************************************************/ |
|
|
|
|
jz idle_loop |
jz idle_loop |
idle_exit: |
idle_exit: |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh |
|
sti |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
call _C_LABEL(sched_lock_idle) |
call _C_LABEL(sched_lock_idle) |
#endif |
#endif |
|
|
SET_CURLWP(%edi,%ecx) |
SET_CURLWP(%edi,%ecx) |
|
|
/* Skip context switch if same lwp. */ |
/* Skip context switch if same lwp. */ |
movl $1, %eax |
xorl %ebx,%ebx |
cmpl %edi,%esi |
cmpl %edi,%esi |
je switch_return |
je switch_return |
|
|
Line 1961 switch_restored: |
|
Line 1957 switch_restored: |
|
je 1f |
je 1f |
movl %eax,TF_EIP(%ebx) |
movl %eax,TF_EIP(%ebx) |
1: |
1: |
xor %eax,%eax |
movl $1,%ebx |
|
|
switch_return: |
switch_return: |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) |
|
|
call _C_LABEL(Xspllower) # process pending interrupts |
call _C_LABEL(Xspllower) # process pending interrupts |
addl $4,%esp |
addl $4,%esp |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh() |
movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh() |
|
|
|
movl %ebx,%eax |
|
|
popl %edi |
popl %edi |
popl %esi |
popl %esi |
|
|
movl CPUVAR(CURLWP),%edx |
movl CPUVAR(CURLWP),%edx |
movl %esp,L_MD_REGS(%edx) # save pointer to frame |
movl %esp,L_MD_REGS(%edx) # save pointer to frame |
movl L_PROC(%edx),%edx |
movl L_PROC(%edx),%edx |
|
pushl %esp |
call *P_MD_SYSCALL(%edx) # get pointer to syscall() function |
call *P_MD_SYSCALL(%edx) # get pointer to syscall() function |
|
addl $4,%esp |
2: /* Check for ASTs on exit to user mode. */ |
2: /* Check for ASTs on exit to user mode. */ |
cli |
cli |
CHECK_ASTPENDING(%eax) |
CHECK_ASTPENDING(%eax) |
|
|
CLEAR_ASTPENDING(%eax) |
CLEAR_ASTPENDING(%eax) |
sti |
sti |
/* Pushed T_ASTFLT into tf_trapno on entry. */ |
/* Pushed T_ASTFLT into tf_trapno on entry. */ |
|
pushl %esp |
call _C_LABEL(trap) |
call _C_LABEL(trap) |
|
addl $4,%esp |
jmp 2b |
jmp 2b |
#ifndef DIAGNOSTIC |
#ifndef DIAGNOSTIC |
1: INTRFASTEXIT |
1: INTRFASTEXIT |