Deleted Added
full compact
locore.s (592) locore.s (608)
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)locore.s 7.3 (Berkeley) 5/13/91
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)locore.s 7.3 (Berkeley) 5/13/91
37 * $Id: locore.s,v 1.6 1993/10/10 06:07:57 rgrimes Exp $
37 * $Id: locore.s,v 1.7 1993/10/13 07:11:11 rgrimes Exp $
38 */
39
40
41/*
42 * locore.s: 4BSD machine support for the Intel 386
43 * Preliminary version
44 * Written by William F. Jolitz, 386BSD Project
45 */

--- 70 unchanged lines hidden (view full) ---

116
117/*
118 * PTmap is recursive pagemap at top of virtual address space.
119 * Within PTmap, the page directory can be found (third indirection).
120 */
121 .globl _PTmap,_PTD,_PTDpde,_Sysmap
122 .set _PTmap,PTDPTDI << PDRSHIFT
123 .set _PTD,_PTmap + (PTDPTDI * NBPG)
38 */
39
40
41/*
42 * locore.s: 4BSD machine support for the Intel 386
43 * Preliminary version
44 * Written by William F. Jolitz, 386BSD Project
45 */

--- 70 unchanged lines hidden (view full) ---

116
117/*
118 * PTmap is recursive pagemap at top of virtual address space.
119 * Within PTmap, the page directory can be found (third indirection).
120 */
121 .globl _PTmap,_PTD,_PTDpde,_Sysmap
122 .set _PTmap,PTDPTDI << PDRSHIFT
123 .set _PTD,_PTmap + (PTDPTDI * NBPG)
124 .set _PTDpde,_PTD + (PTDPTDI * 4) /* XXX 4=sizeof pte */
124 .set _PTDpde,_PTD + (PTDPTDI * 4) /* XXX 4=sizeof pde */
125
125
126 .set _Sysmap,0xFDFF8000
126 .set _Sysmap,_PTmap + (KPTDI * NBPG)
127
128/*
129 * APTmap, APTD is the alternate recursive pagemap.
130 * It's used when modifying another process's page tables.
131 */
132 .globl _APTmap,_APTD,_APTDpde
133 .set _APTmap,APTDPTDI << PDRSHIFT
134 .set _APTD,_APTmap + (APTDPTDI * NBPG)
127
128/*
129 * APTmap, APTD is the alternate recursive pagemap.
130 * It's used when modifying another process's page tables.
131 */
132 .globl _APTmap,_APTD,_APTDpde
133 .set _APTmap,APTDPTDI << PDRSHIFT
134 .set _APTD,_APTmap + (APTDPTDI * NBPG)
135 .set _APTDpde,_PTD + (APTDPTDI * 4) /* XXX 4=sizeof pte */
135 .set _APTDpde,_PTD + (APTDPTDI * 4) /* XXX 4=sizeof pde */
136
137/*
138 * Access to each processes kernel stack is via a region of
139 * per-process address space (at the beginning), immediatly above
140 * the user process stack.
141 */
142 .set _kstack,USRSTACK
143 .globl _kstack

--- 91 unchanged lines hidden (view full) ---

235 * program should check:
236 * text+data <= &stack_variable - more_space_for_stack
237 * text+data+bss+pad+space_for_page_tables <= end_of_memory
238 * Oops, the gdt is in the carcass of the boot program so clearing
239 * the rest of memory is still not possible.
240 */
241 movl $tmpstk-KERNBASE,%esp /* bootstrap stack end location */
242
136
137/*
138 * Access to each processes kernel stack is via a region of
139 * per-process address space (at the beginning), immediatly above
140 * the user process stack.
141 */
142 .set _kstack,USRSTACK
143 .globl _kstack

--- 91 unchanged lines hidden (view full) ---

235 * program should check:
236 * text+data <= &stack_variable - more_space_for_stack
237 * text+data+bss+pad+space_for_page_tables <= end_of_memory
238 * Oops, the gdt is in the carcass of the boot program so clearing
239 * the rest of memory is still not possible.
240 */
241 movl $tmpstk-KERNBASE,%esp /* bootstrap stack end location */
242
243#ifdef garbage
244 /* count up memory */
245
246 xorl %eax,%eax /* start with base memory at 0x0 */
247 #movl $0xA0000/NBPG,%ecx /* look every 4K up to 640K */
248 movl $0xA0,%ecx /* look every 4K up to 640K */
2491: movl (%eax),%ebx /* save location to check */
250 movl $0xa55a5aa5,(%eax) /* write test pattern */
251 /* flush stupid cache here! (with bcopy(0,0,512*1024) ) */
252 cmpl $0xa55a5aa5,(%eax) /* does not check yet for rollover */
253 jne 2f
254 movl %ebx,(%eax) /* restore memory */
255 addl $NBPG,%eax
256 loop 1b
2572: shrl $12,%eax
258 movl %eax,_Maxmem-KERNBASE
259
260 movl $0x100000,%eax /* next, talley remaining memory */
261 #movl $((0xFFF000-0x100000)/NBPG),%ecx
262 movl $(0xFFF-0x100),%ecx
2631: movl (%eax),%ebx /* save location to check */
264 movl $0xa55a5aa5,(%eax) /* write test pattern */
265 cmpl $0xa55a5aa5,(%eax) /* does not check yet for rollover */
266 jne 2f
267 movl %ebx,(%eax) /* restore memory */
268 addl $NBPG,%eax
269 loop 1b
2702: shrl $12,%eax
271 movl %eax,_Maxmem-KERNBASE
272#endif
273
274/*
275 * Virtual address space of kernel:
276 *
277 * text | data | bss | [syms] | page dir | proc0 kernel stack | usr stk map | Sysmap
278 * 0 1 2 3 4
279 */
280
281/* find end of kernel image */

--- 7 unchanged lines hidden (view full) ---

289 subl %edi,%ecx
290 addl $(UPAGES+5)*NBPG,%ecx /* size of tables */
291
292 xorl %eax,%eax /* pattern */
293 cld
294 rep
295 stosb
296
243/*
244 * Virtual address space of kernel:
245 *
246 * text | data | bss | [syms] | page dir | proc0 kernel stack | usr stk map | Sysmap
247 * 0 1 2 3 4
248 */
249
250/* find end of kernel image */

--- 7 unchanged lines hidden (view full) ---

258 subl %edi,%ecx
259 addl $(UPAGES+5)*NBPG,%ecx /* size of tables */
260
261 xorl %eax,%eax /* pattern */
262 cld
263 rep
264 stosb
265
266/*
267 * If we are loaded at 0x0 check to see if we have space for the
268 * page tables pages after the kernel and before the 640K ISA memory
269 * hole. If we do not have space relocate the page table pages and
270 * the kernel stack to start at 1MB. The value that ends up in esi
271 * is used by the rest of locore to build the tables. Locore adjusts
272 * esi each time it allocates a structure and then passes the final
273 * value to init386(first) as the value first. esi should ALWAYS
274 * be page aligned!!
275 */
276 movl %esi,%ecx /* Get current first availiable address */
277 cmpl $0x100000,%ecx /* Lets see if we are already above 1MB */
278 jge 1f /* yep, don't need to check for room */
279 addl $(NKPDE + 4) * NBPG,%ecx /* XXX the 4 is for kstack */
280 /* space for kstack, PTD and PTE's */
281 cmpl $(640*1024),%ecx
282 /* see if it fits in low memory */
283 jle 1f /* yep, don't need to relocate it */
284 movl $0x100000,%esi /* won't fit, so start it at 1MB */
2851:
286
297/* physical address of Idle Address space */
298 movl %esi,_IdlePTD-KERNBASE
299
300/*
301 * fillkpt
302 * eax = (page frame address | control | status) == pte
303 * ebx = address of page table
304 * ecx = how many pages to map

--- 146 unchanged lines hidden (view full) ---

451
452 /* set up bootstrap stack */
453 movl $_kstack+UPAGES*NBPG-4*12,%esp /* bootstrap stack end location */
454 xorl %eax,%eax /* mark end of frames */
455 movl %eax,%ebp
456 movl _proc0paddr,%eax
457 movl %esi,PCB_CR3(%eax)
458
287/* physical address of Idle Address space */
288 movl %esi,_IdlePTD-KERNBASE
289
290/*
291 * fillkpt
292 * eax = (page frame address | control | status) == pte
293 * ebx = address of page table
294 * ecx = how many pages to map

--- 146 unchanged lines hidden (view full) ---

441
442 /* set up bootstrap stack */
443 movl $_kstack+UPAGES*NBPG-4*12,%esp /* bootstrap stack end location */
444 xorl %eax,%eax /* mark end of frames */
445 movl %eax,%ebp
446 movl _proc0paddr,%eax
447 movl %esi,PCB_CR3(%eax)
448
459 lea 7*NBPG(%esi),%esi /* skip past stack. */
460 pushl %esi
461
462 /* relocate debugger gdt entries */
463
464 movl $_gdt+8*9,%eax /* adjust slots 9-17 */
465 movl $9,%ecx
466reloc_gdt:
467 movb $0xfe,7(%eax) /* top byte of base addresses, was 0, */
468 addl $8,%eax /* now KERNBASE>>24 */
469 loop reloc_gdt
470
471 cmpl $0,_bdb_exists
472 je 1f
473 int $3
4741:
475
449 /* relocate debugger gdt entries */
450
451 movl $_gdt+8*9,%eax /* adjust slots 9-17 */
452 movl $9,%ecx
453reloc_gdt:
454 movb $0xfe,7(%eax) /* top byte of base addresses, was 0, */
455 addl $8,%eax /* now KERNBASE>>24 */
456 loop reloc_gdt
457
458 cmpl $0,_bdb_exists
459 je 1f
460 int $3
4611:
462
463 /*
464 * Skip over the page tables and the kernel stack
465 * XXX 4 is kstack size
466 */
467 lea (NKPDE + 4) * NBPG(%esi),%esi
468
469 pushl %esi /* value of first for init386(first) */
476 call _init386 /* wire 386 chip for unix operation */
477
478 movl $0,_PTD
479 call _main /* autoconfiguration, mountroot etc */
480 popl %esi
481
482 /*
483 * now we've run main() and determined what cpu-type we are, we can

--- 1174 unchanged lines hidden (view full) ---

1658 movl (%esp),%eax /* Hardware registers */
1659 movl %eax,PCB_EIP(%ecx)
1660 movl %ebx,PCB_EBX(%ecx)
1661 movl %esp,PCB_ESP(%ecx)
1662 movl %ebp,PCB_EBP(%ecx)
1663 movl %esi,PCB_ESI(%ecx)
1664 movl %edi,PCB_EDI(%ecx)
1665
470 call _init386 /* wire 386 chip for unix operation */
471
472 movl $0,_PTD
473 call _main /* autoconfiguration, mountroot etc */
474 popl %esi
475
476 /*
477 * now we've run main() and determined what cpu-type we are, we can

--- 1174 unchanged lines hidden (view full) ---

1652 movl (%esp),%eax /* Hardware registers */
1653 movl %eax,PCB_EIP(%ecx)
1654 movl %ebx,PCB_EBX(%ecx)
1655 movl %esp,PCB_ESP(%ecx)
1656 movl %ebp,PCB_EBP(%ecx)
1657 movl %esi,PCB_ESI(%ecx)
1658 movl %edi,PCB_EDI(%ecx)
1659
1666#ifdef NPX
1660#if NNPX > 0
1667 /* have we used fp, and need a save? */
1668 mov _curproc,%eax
1669 cmp %eax,_npxproc
1670 jne 1f
1671 pushl %ecx /* h/w bugs make saving complicated */
1672 leal PCB_SAVEFPU(%ecx),%eax
1673 pushl %eax
1674 call _npxsave /* do it in a big C function */
1675 popl %eax
1676 popl %ecx
16771:
1661 /* have we used fp, and need a save? */
1662 mov _curproc,%eax
1663 cmp %eax,_npxproc
1664 jne 1f
1665 pushl %ecx /* h/w bugs make saving complicated */
1666 leal PCB_SAVEFPU(%ecx),%eax
1667 pushl %eax
1668 call _npxsave /* do it in a big C function */
1669 popl %eax
1670 popl %ecx
16711:
1678#endif
1672#endif /* NNPX > 0 */
1679
1680 movl _CMAP2,%eax /* save temporary map PTE */
1681 movl %eax,PCB_CMAP2(%ecx) /* in our context */
1682 movl $0,_curproc /* out of process */
1683
1684# movw _cpl,%ax
1685# movw %ax,PCB_IML(%ecx) /* save ipl */
1686

--- 118 unchanged lines hidden (view full) ---

1805 movl (%esp),%eax
1806 movl %eax,PCB_EIP(%ecx)
1807 movl %ebx,PCB_EBX(%ecx)
1808 movl %esp,PCB_ESP(%ecx)
1809 movl %ebp,PCB_EBP(%ecx)
1810 movl %esi,PCB_ESI(%ecx)
1811 movl %edi,PCB_EDI(%ecx)
1812
1673
1674 movl _CMAP2,%eax /* save temporary map PTE */
1675 movl %eax,PCB_CMAP2(%ecx) /* in our context */
1676 movl $0,_curproc /* out of process */
1677
1678# movw _cpl,%ax
1679# movw %ax,PCB_IML(%ecx) /* save ipl */
1680

--- 118 unchanged lines hidden (view full) ---

1799 movl (%esp),%eax
1800 movl %eax,PCB_EIP(%ecx)
1801 movl %ebx,PCB_EBX(%ecx)
1802 movl %esp,PCB_ESP(%ecx)
1803 movl %ebp,PCB_EBP(%ecx)
1804 movl %esi,PCB_ESI(%ecx)
1805 movl %edi,PCB_EDI(%ecx)
1806
1813#ifdef NPX
1807#if NNPX > 0
1814 /*
1815 * If npxproc == NULL, then the npx h/w state is irrelevant and the
1816 * state had better already be in the pcb. This is true for forks
1817 * but not for dumps (the old book-keeping with FP flags in the pcb
1818 * always lost for dumps because the dump pcb has 0 flags).
1819 *
1820 * If npxproc != NULL, then we have to save the npx h/w state to
1821 * npxproc's pcb and copy it to the requested pcb, or save to the

--- 19 unchanged lines hidden (view full) ---

1841 pushl $108+8*2 /* XXX h/w state size + padding */
1842 leal PCB_SAVEFPU(%ecx),%ecx
1843 pushl %ecx
1844 pushl %eax
1845 call _bcopy
1846 addl $12,%esp
1847 popl %ecx
18481:
1808 /*
1809 * If npxproc == NULL, then the npx h/w state is irrelevant and the
1810 * state had better already be in the pcb. This is true for forks
1811 * but not for dumps (the old book-keeping with FP flags in the pcb
1812 * always lost for dumps because the dump pcb has 0 flags).
1813 *
1814 * If npxproc != NULL, then we have to save the npx h/w state to
1815 * npxproc's pcb and copy it to the requested pcb, or save to the

--- 19 unchanged lines hidden (view full) ---

1835 pushl $108+8*2 /* XXX h/w state size + padding */
1836 leal PCB_SAVEFPU(%ecx),%ecx
1837 pushl %ecx
1838 pushl %eax
1839 call _bcopy
1840 addl $12,%esp
1841 popl %ecx
18421:
1849#endif
1843#endif /* NNPX > 0 */
1850
1851 movl _CMAP2,%edx /* save temporary map PTE */
1852 movl %edx,PCB_CMAP2(%ecx) /* in our context */
1853
1854 cmpl $0,8(%esp)
1855 je 1f
1856 movl %esp,%edx /* relocate current sp relative to pcb */
1857 subl $_kstack,%edx /* (sp is relative to kstack): */

--- 112 unchanged lines hidden (view full) ---

1970 TRAP(T_STKFLT)
1971IDTVEC(prot)
1972 TRAP(T_PROTFLT)
1973IDTVEC(page)
1974 TRAP(T_PAGEFLT)
1975IDTVEC(rsvd)
1976 pushl $0; TRAP(T_RESERVED)
1977IDTVEC(fpu)
1844
1845 movl _CMAP2,%edx /* save temporary map PTE */
1846 movl %edx,PCB_CMAP2(%ecx) /* in our context */
1847
1848 cmpl $0,8(%esp)
1849 je 1f
1850 movl %esp,%edx /* relocate current sp relative to pcb */
1851 subl $_kstack,%edx /* (sp is relative to kstack): */

--- 112 unchanged lines hidden (view full) ---

1964 TRAP(T_STKFLT)
1965IDTVEC(prot)
1966 TRAP(T_PROTFLT)
1967IDTVEC(page)
1968 TRAP(T_PAGEFLT)
1969IDTVEC(rsvd)
1970 pushl $0; TRAP(T_RESERVED)
1971IDTVEC(fpu)
1978#ifdef NPX
1972#if NNPX > 0
1979 /*
1980 * Handle like an interrupt so that we can call npxintr to clear the
1981 * error. It would be better to handle npx interrupts as traps but
1982 * this is difficult for nested interrupts.
1983 */
1984 pushl $0 /* dummy error code */
1985 pushl $T_ASTFLT
1986 pushal

--- 5 unchanged lines hidden (view full) ---

1992 movl $KDSEL,%eax
1993 movl %ax,%ds
1994 movl %ax,%es
1995 pushl _cpl
1996 pushl $0 /* dummy unit to finish building intr frame */
1997 incl _cnt+V_TRAP
1998 call _npxintr
1999 jmp doreti
1973 /*
1974 * Handle like an interrupt so that we can call npxintr to clear the
1975 * error. It would be better to handle npx interrupts as traps but
1976 * this is difficult for nested interrupts.
1977 */
1978 pushl $0 /* dummy error code */
1979 pushl $T_ASTFLT
1980 pushal

--- 5 unchanged lines hidden (view full) ---

1986 movl $KDSEL,%eax
1987 movl %ax,%ds
1988 movl %ax,%es
1989 pushl _cpl
1990 pushl $0 /* dummy unit to finish building intr frame */
1991 incl _cnt+V_TRAP
1992 call _npxintr
1993 jmp doreti
2000#else
1994#else /* NNPX > 0 */
2001 pushl $0; TRAP(T_ARITHTRAP)
1995 pushl $0; TRAP(T_ARITHTRAP)
2002#endif
1996#endif /* NNPX > 0 */
2003 /* 17 - 31 reserved for future exp */
2004IDTVEC(rsvd0)
2005 pushl $0; TRAP(17)
2006IDTVEC(rsvd1)
2007 pushl $0; TRAP(18)
2008IDTVEC(rsvd2)
2009 pushl $0; TRAP(19)
2010IDTVEC(rsvd3)

--- 148 unchanged lines hidden ---
1997 /* 17 - 31 reserved for future exp */
1998IDTVEC(rsvd0)
1999 pushl $0; TRAP(17)
2000IDTVEC(rsvd1)
2001 pushl $0; TRAP(18)
2002IDTVEC(rsvd2)
2003 pushl $0; TRAP(19)
2004IDTVEC(rsvd3)

--- 148 unchanged lines hidden ---