freebsd-nq/sys/i386/boot/biosboot/boot2.S

173 lines
3.8 KiB
ArmAsm
Raw Normal View History

/*
* Mach Operating System
* Copyright (c) 1992, 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:26 rpd
Load the kernel symbol table in the boot loader and not at compile time. (Boot with the -D flag if you want symbols.) Make it easier to extend `struct bootinfo' without losing either forwards or backwards compatibility. ddb_aout.c: Get the symbol table from wherever the loader put it. Nuke db_symtab[SYMTAB_SPACE]. boot.c: Enable loading of symbols. Align them on a page boundary. Add printfs about the symbol table sizes. Pass the memory sizes to the kernel. Fix initialization of `unit' (it got moved out of the loop). Fix adding the bss size (it got moved inside an ifdef). Initialize serial port when RB_SERIAL is toggled on. Fix comments. Clean up formatting of recently added code. io.c: Clean up formatting of recently added code. netboot/main.c, machdep.c, wd.c: Change names of bootinfo fields. LINT: Nuke SYMTAB_SPACE. Fix comment about DODUMP. Makefile.i386: Nuke use of dbsym. Exclude gcc symbols from kernel unless compiling with -g. Remove unused macro. Fix comments and formatting. genassym.c: Generate defines for some new bootinfo fields. Change names of old ones. locore.s: Copy only the valid part of the `struct bootinfo' passed by the loader. Reserve space for symbol table, if any. machdep.c: Check the memory sizes passed by the loader, if any. Don't use them yet. bootinfo.h: Add a size field so that we can resolve some mismatches between the loader bootinfo and the kernel boot info. The version number is not so good for this because of historical botches and because it's harder to maintain. Add memory size and symbol table fields. Change the names of everything. Hacks to save a few bytes: asm.S, boot.c, boot2.S: Replace `ouraddr' by `(BOOTSEG << 4)'. boot.c: Don't statically initialize `loadflags' to 0. Disable the "REDUNDANT" code that skips the BIOS variables. Eliminate `total'. Combine some more printfs. boot.h, disk.c, io.c, table.c: Move all statically initialzed data to table.c. io.c: Don't put the A20 gate bits in a variable.
1995-01-25 21:40:47 +00:00
* $Id: boot2.S,v 1.5 1994/08/30 01:38:03 bde Exp $
*/
#include "asm.h"
/* Conventional GDT indexes. */
#define BOOT_CS_INDEX 3
#define BOOT_CS16_INDEX 5
#define BOOT_DS_INDEX 4
#ifdef BDE_DEBUGGER
#define DB_CS_INDEX 14
#define DB_CS16_INDEX 15
#define DB_DS_INDEX 16
#define GDT_INDEX 17
#endif
/* Vector numbers. */
#define BREAKPOINT_VECTOR 3
#define DEBUG_VECTOR 1
/*
* boot2() -- second stage boot
*/
ENTRY(boot2)
data32
subl %eax, %eax
mov %cs, %ax
mov %ax, %ds
mov %ax, %es
data32
shll $4, %eax
/* fix up GDT entries for bootstrap */
#define FIXUP(gdt_index) \
addr32; \
movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \
addr32; \
movb %bl, EXT(Gdt)+(8*gdt_index)+4
data32
shld $16, %eax, %ebx
FIXUP(BOOT_CS_INDEX)
FIXUP(BOOT_CS16_INDEX)
FIXUP(BOOT_DS_INDEX)
/* fix up GDT pointer */
data32
movl %eax, %ecx
data32
addl $ EXT(Gdt), %eax
addr32
data32
movl %eax, EXT(Gdtr)+2
#ifdef BDE_DEBUGGER
/* fix up GDT entry for GDT */
data32
shld $16, %eax, %ebx
FIXUP(GDT_INDEX)
/* fix up IDT pointer */
data32
addl $ EXT(Idt), %ecx
addr32
data32
movl %ecx, EXT(Idtr_prot)+2
/* %es = vector table segment for a while */
push %es
data32
subl %eax, %eax
mov %ax, %es
/* fix up GDT entries for bdb */
data32
movl $4*DEBUG_VECTOR, %esi
addr32
movl %es: 2(%esi), %eax /* actually movw to %ax */
data32
shll $4, %eax
data32
shld $16, %eax, %ebx
FIXUP(DB_CS_INDEX)
FIXUP(DB_CS16_INDEX)
FIXUP(DB_DS_INDEX)
/* Fetch entry points of bdb's protected mode trap handlers. These
* are stored at 2 before the corresponding entry points for real mode.
*/
data32
subl %ebx, %ebx
addr32
movl %es: (%esi), %ebx /* actually movw to %bx */
data32
subl %ecx, %ecx
addr32
movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx
/* actually movw to %cx */
/* %es = bdb segment for a while */
data32
shrl $4, %eax
mov %ax, %es
/* fix up IDT entries for bdb */
Commit a whole cluster of last minute critical (and one cosmetic) fixes from David Greenman, Bruce Evans and Julian Elischer. They are: [vnode pager - David/Bruce]: The following patch fixes a problem where some data could be lost in a delayed-write buffer if the cached buffer was larger than a page. This fix was provided by Bruce Evans and modified slightly by me. [st.c - Julian]: My fix for "bad request, must be between 0 and 0" RTFS if you're interested). [gnu/fpemul - David/Bruce]: These changes fix single stepping of emulated FPU instructions. Previously, the instruction after an emulated instruction was executed without causing a SIGTRAP ... The also fix the initial control word being different for the GPL emulator (it is still wrong for the old emulator) and remove an unnecessary panic when emulation is not configured (I hope at least init, sh and reboot will run without floating point. I remember only df and mkfs being broken by the lack of FP in 0.0). [Various fixes described below - Bruce/David]: sys/i386/boot/boot2.S: Yet another attempt to propagate the correct fix for 16 vs 32-bit mode bugs. [verified] sys/i386/i386/db_interface.c: Protect against reentering Debugger(). sys/kern/kern_time.c: Don't allow 'time.tv_usec == 0' except at clock interrupts. sys/pcfs/pcfs_fat.c: Make it compile without -O. sys/scsi/sd.c: Fix as posted to some freebsd mailing list. (changes the order of the assignment of "sectors" because it earlier value is needed first -DG) sys/vm/vm_glue.c: Fix stale comments and verbose code. sys/vm/vm_mmap.c Fix off by 1 errors and verbose code. [From Nate - cosmetic but non-intrusive and useful enough to go in] sys/i386/isa/isa.c: Appended you'll find a patch to the NMI error log routine in isa/isa.c. The below patch just adds some additional information when an NMI occurs which can help debug the hardware problem.
1994-06-22 05:52:25 +00:00
data32
subl $2, %ebx /* calculate EA to check it */
jb 1f /* give up if it would trap */
addr32
movl %es: (%ebx), %eax /* actually movw to %ax */
addr32
movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */
Commit a whole cluster of last minute critical (and one cosmetic) fixes from David Greenman, Bruce Evans and Julian Elischer. They are: [vnode pager - David/Bruce]: The following patch fixes a problem where some data could be lost in a delayed-write buffer if the cached buffer was larger than a page. This fix was provided by Bruce Evans and modified slightly by me. [st.c - Julian]: My fix for "bad request, must be between 0 and 0" RTFS if you're interested). [gnu/fpemul - David/Bruce]: These changes fix single stepping of emulated FPU instructions. Previously, the instruction after an emulated instruction was executed without causing a SIGTRAP ... The also fix the initial control word being different for the GPL emulator (it is still wrong for the old emulator) and remove an unnecessary panic when emulation is not configured (I hope at least init, sh and reboot will run without floating point. I remember only df and mkfs being broken by the lack of FP in 0.0). [Various fixes described below - Bruce/David]: sys/i386/boot/boot2.S: Yet another attempt to propagate the correct fix for 16 vs 32-bit mode bugs. [verified] sys/i386/i386/db_interface.c: Protect against reentering Debugger(). sys/kern/kern_time.c: Don't allow 'time.tv_usec == 0' except at clock interrupts. sys/pcfs/pcfs_fat.c: Make it compile without -O. sys/scsi/sd.c: Fix as posted to some freebsd mailing list. (changes the order of the assignment of "sectors" because it earlier value is needed first -DG) sys/vm/vm_glue.c: Fix stale comments and verbose code. sys/vm/vm_mmap.c Fix off by 1 errors and verbose code. [From Nate - cosmetic but non-intrusive and useful enough to go in] sys/i386/isa/isa.c: Appended you'll find a patch to the NMI error log routine in isa/isa.c. The below patch just adds some additional information when an NMI occurs which can help debug the hardware problem.
1994-06-22 05:52:25 +00:00
1:
data32
subl $2, %ecx
Commit a whole cluster of last minute critical (and one cosmetic) fixes from David Greenman, Bruce Evans and Julian Elischer. They are: [vnode pager - David/Bruce]: The following patch fixes a problem where some data could be lost in a delayed-write buffer if the cached buffer was larger than a page. This fix was provided by Bruce Evans and modified slightly by me. [st.c - Julian]: My fix for "bad request, must be between 0 and 0" RTFS if you're interested). [gnu/fpemul - David/Bruce]: These changes fix single stepping of emulated FPU instructions. Previously, the instruction after an emulated instruction was executed without causing a SIGTRAP ... The also fix the initial control word being different for the GPL emulator (it is still wrong for the old emulator) and remove an unnecessary panic when emulation is not configured (I hope at least init, sh and reboot will run without floating point. I remember only df and mkfs being broken by the lack of FP in 0.0). [Various fixes described below - Bruce/David]: sys/i386/boot/boot2.S: Yet another attempt to propagate the correct fix for 16 vs 32-bit mode bugs. [verified] sys/i386/i386/db_interface.c: Protect against reentering Debugger(). sys/kern/kern_time.c: Don't allow 'time.tv_usec == 0' except at clock interrupts. sys/pcfs/pcfs_fat.c: Make it compile without -O. sys/scsi/sd.c: Fix as posted to some freebsd mailing list. (changes the order of the assignment of "sectors" because it earlier value is needed first -DG) sys/vm/vm_glue.c: Fix stale comments and verbose code. sys/vm/vm_mmap.c Fix off by 1 errors and verbose code. [From Nate - cosmetic but non-intrusive and useful enough to go in] sys/i386/isa/isa.c: Appended you'll find a patch to the NMI error log routine in isa/isa.c. The below patch just adds some additional information when an NMI occurs which can help debug the hardware problem.
1994-06-22 05:52:25 +00:00
jb 1f
addr32
movl %es: (%ecx), %eax /* actually movw to %ax */
addr32
movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */
Commit a whole cluster of last minute critical (and one cosmetic) fixes from David Greenman, Bruce Evans and Julian Elischer. They are: [vnode pager - David/Bruce]: The following patch fixes a problem where some data could be lost in a delayed-write buffer if the cached buffer was larger than a page. This fix was provided by Bruce Evans and modified slightly by me. [st.c - Julian]: My fix for "bad request, must be between 0 and 0" RTFS if you're interested). [gnu/fpemul - David/Bruce]: These changes fix single stepping of emulated FPU instructions. Previously, the instruction after an emulated instruction was executed without causing a SIGTRAP ... The also fix the initial control word being different for the GPL emulator (it is still wrong for the old emulator) and remove an unnecessary panic when emulation is not configured (I hope at least init, sh and reboot will run without floating point. I remember only df and mkfs being broken by the lack of FP in 0.0). [Various fixes described below - Bruce/David]: sys/i386/boot/boot2.S: Yet another attempt to propagate the correct fix for 16 vs 32-bit mode bugs. [verified] sys/i386/i386/db_interface.c: Protect against reentering Debugger(). sys/kern/kern_time.c: Don't allow 'time.tv_usec == 0' except at clock interrupts. sys/pcfs/pcfs_fat.c: Make it compile without -O. sys/scsi/sd.c: Fix as posted to some freebsd mailing list. (changes the order of the assignment of "sectors" because it earlier value is needed first -DG) sys/vm/vm_glue.c: Fix stale comments and verbose code. sys/vm/vm_mmap.c Fix off by 1 errors and verbose code. [From Nate - cosmetic but non-intrusive and useful enough to go in] sys/i386/isa/isa.c: Appended you'll find a patch to the NMI error log routine in isa/isa.c. The below patch just adds some additional information when an NMI occurs which can help debug the hardware problem.
1994-06-22 05:52:25 +00:00
1:
/* finished with groping in real mode segments */
pop %es
#endif /* BDE_DEBUGGER */
/* change to protected mode */
data32
call EXT(real_to_prot)
/* clear the bss */
movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */
movl $ EXT(end), %ecx /* or EXT(_end) */
subl %edi, %ecx
subb %al, %al
rep
stosb
movzbl %dl, %edx /* discard head (%dh) and random high bits */
pushl %edx
call EXT(boot)
oops:
hlt
jmp oops