Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/i386/i386/locore.S,v rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/i386/i386/locore.S,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.5 retrieving revision 1.20 diff -u -p -r1.5 -r1.20 --- src/sys/arch/i386/i386/locore.S 2003/01/17 23:10:30 1.5 +++ src/sys/arch/i386/i386/locore.S 2003/11/04 10:33:15 1.20 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.5 2003/01/17 23:10:30 thorpej Exp $ */ +/* $NetBSD: locore.S,v 1.20 2003/11/04 10:33:15 dsl Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -51,11 +51,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * 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 + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -74,22 +70,24 @@ * @(#)locore.s 7.3 (Berkeley) 5/13/91 */ +#include "opt_compat_netbsd.h" +#include "opt_compat_oldboot.h" #include "opt_cputype.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_compat_oldboot.h" -#include "opt_multiprocessor.h" +#include "opt_ipkdb.h" #include "opt_lockdebug.h" +#include "opt_multiprocessor.h" #include "opt_realmem.h" +#include "opt_user_ldt.h" +#include "opt_vm86.h" #include "npx.h" #include "assym.h" #include "apm.h" #include "lapic.h" #include "ioapic.h" +#include "ksyms.h" #include #include @@ -163,7 +161,7 @@ * XXX 4 == sizeof pde */ .set _C_LABEL(PTmap),(PDSLOT_PTE << PDSHIFT) - .set _C_LABEL(PTD),(_C_LABEL(PTmap) + PDSLOT_PTE * NBPG) + .set _C_LABEL(PTD),(_C_LABEL(PTmap) + PDSLOT_PTE * PAGE_SIZE) .set _C_LABEL(PTDpde),(_C_LABEL(PTD) + PDSLOT_PTE * 4) /* @@ -173,7 +171,7 @@ * XXX 4 == sizeof pde */ .set _C_LABEL(APTmap),(PDSLOT_APTE << PDSHIFT) - .set _C_LABEL(APTD),(_C_LABEL(APTmap) + PDSLOT_APTE * NBPG) + .set _C_LABEL(APTD),(_C_LABEL(APTmap) + PDSLOT_APTE * PAGE_SIZE) .set _C_LABEL(APTDpde),(_C_LABEL(PTD) + PDSLOT_APTE * 4) @@ -183,7 +181,6 @@ .data .globl _C_LABEL(cpu) - .globl _C_LABEL(cpu_feature) .globl _C_LABEL(esym),_C_LABEL(boothowto) .globl _C_LABEL(bootinfo),_C_LABEL(atdevbase) #ifdef COMPAT_OLDBOOT @@ -199,7 +196,7 @@ #if NLAPIC > 0 #ifdef __ELF__ - .align NBPG + .align PAGE_SIZE #else .align 12 #endif @@ -214,7 +211,7 @@ _C_LABEL(lapic_tpr): _C_LABEL(lapic_ppr): .space LAPIC_ISR-LAPIC_PPRI _C_LABEL(lapic_isr): - .space NBPG-LAPIC_ISR + .space PAGE_SIZE-LAPIC_ISR #else _C_LABEL(lapic_tpr): .long 0 @@ -223,8 +220,6 @@ _C_LABEL(lapic_tpr): _C_LABEL(cpu): .long 0 # are we 386, 386sx, or 486, # 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(atdevbase): .long 0 # location of start of iomem in virtual _C_LABEL(proc0paddr): .long 0 @@ -244,7 +239,7 @@ _C_LABEL(biosextmem): .long REALEXTMEM tmpstk: -#define _RELOC(x) ((x) - KERNBASE) +#define _RELOC(x) ((x) - KERNBASE_LOCORE) #define RELOC(x) _RELOC(_C_LABEL(x)) .text @@ -298,7 +293,7 @@ start: movw $0x1234,0x472 # warm boot movl 16(%esp),%eax testl %eax,%eax jz 1f - addl $KERNBASE,%eax + addl $KERNBASE_LOCORE,%eax 1: movl %eax,RELOC(esym) movl RELOC(biosextmem),%eax @@ -506,19 +501,19 @@ try586: /* Use the `cpuid' instruction. * text | data | bss | [syms] | page dir | proc0 kstack * 0 1 2 3 */ -#define PROC0PDIR ((0) * NBPG) -#define PROC0STACK ((1) * NBPG) -#define SYSMAP ((1+UPAGES) * NBPG) -#define TABLESIZE ((1+UPAGES) * NBPG) /* + nkpde * NBPG */ +#define PROC0PDIR ((0) * PAGE_SIZE) +#define PROC0STACK ((1) * PAGE_SIZE) +#define SYSMAP ((1+UPAGES) * PAGE_SIZE) +#define TABLESIZE ((1+UPAGES) * PAGE_SIZE) /* + nkpde * PAGE_SIZE */ /* Find end of kernel image. */ movl $RELOC(end),%edi -#if defined(DDB) && !defined(SYMTAB_SPACE) +#if (NKSYMS || defined(DDB) || defined(LKM)) && !defined(SYMTAB_SPACE) /* Save the symbols (if loaded). */ movl RELOC(esym),%eax testl %eax,%eax jz 1f - subl $KERNBASE,%eax + subl $KERNBASE_LOCORE,%eax movl %eax,%edi 1: #endif @@ -561,7 +556,7 @@ try586: /* Use the `cpuid' instruction. */ #define fillkpt \ 1: movl %eax,(%ebx) ; \ - addl $NBPG,%eax ; /* increment physical address */ \ + addl $PAGE_SIZE,%eax ; /* increment physical address */ \ addl $4,%ebx ; /* next pte */ \ loop 1b ; @@ -634,10 +629,10 @@ try586: /* Use the `cpuid' instruction. ret 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, 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) addl $4,%ebx # next pde loop 1b @@ -645,12 +640,12 @@ begin: /* Relocate atdevbase. */ movl _C_LABEL(nkpde),%edx shll $PGSHIFT,%edx - addl $(TABLESIZE+KERNBASE),%edx + addl $(TABLESIZE+KERNBASE_LOCORE),%edx addl %esi,%edx movl %edx,_C_LABEL(atdevbase) /* Set up bootstrap stack. */ - leal (PROC0STACK+KERNBASE)(%esi),%eax + leal (PROC0STACK+KERNBASE_LOCORE)(%esi),%eax movl %eax,_C_LABEL(proc0paddr) leal (USPACE-FRAMESIZE)(%eax),%esp movl %esi,PCB_CR3(%eax) # pcb->pcb_cr3 @@ -711,7 +706,7 @@ NENTRY(proc_trampoline) /* NOTREACHED */ /*****************************************************************************/ - +#ifdef COMPAT_16 /* * Signal trampoline; copied to top of user stack. */ @@ -724,12 +719,19 @@ NENTRY(sigcode) leal 12(%esp),%eax # get pointer to sigcontext movl %eax,4(%esp) # put it in the argument slot # fake return address already there +#if defined(SYS_compat_16___sigreturn14) + movl $SYS_compat_16___sigreturn14,%eax +#elif defined(SYS___sigreturn14) movl $SYS___sigreturn14,%eax +#else + #error "no sigreturn14 syscall" +#endif int $0x80 # enter kernel with args on stack movl $SYS_exit,%eax int $0x80 # exit if sigreturn fails .globl _C_LABEL(esigcode) _C_LABEL(esigcode): +#endif /*****************************************************************************/ @@ -1095,8 +1097,8 @@ ENTRY(copyoutstr) /* Compute number of bytes in first page. */ movl %edi,%eax andl $PGOFSET,%eax - movl $NBPG,%ecx - subl %eax,%ecx # ecx = NBPG - (src % NBPG) + movl $PAGE_SIZE,%ecx + subl %eax,%ecx # ecx = PAGE_SIZE - (src % PAGE_SIZE) GET_CURPCB(%eax) movl $6f,PCB_ONFAULT(%eax) @@ -1143,7 +1145,7 @@ ENTRY(copyoutstr) jmp copystr_return 4: /* Go to next page, if any. */ - movl $NBPG,%ecx + movl $PAGE_SIZE,%ecx testl %edx,%edx jnz 1b @@ -1802,6 +1804,7 @@ idle_start: jz idle_loop idle_exit: movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh + sti #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) call _C_LABEL(sched_lock_idle) #endif @@ -1852,7 +1855,7 @@ switch_resume: SET_CURLWP(%edi,%ecx) /* Skip context switch if same lwp. */ - movl $1, %eax + xorl %ebx,%ebx cmpl %edi,%esi je switch_return @@ -1948,19 +1951,10 @@ switch_restored: */ movl CPUVAR(CURLWP),%edi movl L_PROC(%edi),%esi - cmpl $0,P_NRAS(%esi) - je 1f - movl L_MD_REGS(%edi),%ebx - movl TF_EIP(%ebx),%eax - pushl %eax - pushl %esi - call _C_LABEL(ras_lookup) - addl $8,%esp - cmpl $-1,%eax - je 1f - movl %eax,TF_EIP(%ebx) + cmpl $0,P_RASLIST(%esi) + jne 2f 1: - xor %eax,%eax + movl $1,%ebx switch_return: #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) @@ -1970,12 +1964,26 @@ switch_return: call _C_LABEL(Xspllower) # process pending interrupts addl $4,%esp movl $IPL_HIGH,CPUVAR(ILEVEL) # splhigh() + + movl %ebx,%eax popl %edi popl %esi popl %ebx ret +2: # check RAS list + movl L_MD_REGS(%edi),%ebx + movl TF_EIP(%ebx),%eax + pushl %eax + pushl %esi + call _C_LABEL(ras_lookup) + addl $8,%esp + cmpl $-1,%eax + je 1b + movl %eax,TF_EIP(%ebx) + jmp 1b + /* * void cpu_switchto(struct lwp *current, struct lwp *next) * Switch to the specified next LWP. @@ -2030,7 +2038,7 @@ ENTRY(cpu_switchto) #endif .globl _C_LABEL(uvmspace_free),_C_LABEL(kernel_map) .globl _C_LABEL(uvm_km_free),_C_LABEL(tss_free) -/* LINTSTUB: Func: void switch_exit(struct lwp *l) */ +/* LINTSTUB: Func: void switch_exit(struct lwp *l, void (*exit)(struct lwp *)) */ ENTRY(switch_exit) movl 4(%esp),%edi # old process movl 8(%esp),%eax # exit func @@ -2146,7 +2154,9 @@ syscall1: movl CPUVAR(CURLWP),%edx movl %esp,L_MD_REGS(%edx) # save pointer to frame movl L_PROC(%edx),%edx + pushl %esp call *P_MD_SYSCALL(%edx) # get pointer to syscall() function + addl $4,%esp 2: /* Check for ASTs on exit to user mode. */ cli CHECK_ASTPENDING(%eax) @@ -2155,7 +2165,9 @@ syscall1: CLEAR_ASTPENDING(%eax) sti /* Pushed T_ASTFLT into tf_trapno on entry. */ + pushl %esp call _C_LABEL(trap) + addl $4,%esp jmp 2b #ifndef DIAGNOSTIC 1: INTRFASTEXIT