summaryrefslogtreecommitdiff
path: root/sys/boot/i386
diff options
context:
space:
mode:
Diffstat (limited to 'sys/boot/i386')
-rw-r--r--sys/boot/i386/boot0/Makefile10
-rw-r--r--sys/boot/i386/boot0/boot0.m417
-rw-r--r--sys/boot/i386/boot0/boot0.s224
-rw-r--r--sys/boot/i386/boot2/Makefile11
-rw-r--r--sys/boot/i386/boot2/boot1.m44
-rw-r--r--sys/boot/i386/boot2/boot1.s176
-rw-r--r--sys/boot/i386/boot2/boot2.c74
-rw-r--r--sys/boot/i386/boot2/sio.s8
-rw-r--r--sys/boot/i386/btx/btx/btx.s32
-rw-r--r--sys/boot/i386/btx/btxldr/Makefile5
-rw-r--r--sys/boot/i386/btx/btxldr/btxldr.s68
-rw-r--r--sys/boot/i386/btx/lib/btxv86.s7
-rw-r--r--sys/boot/i386/libi386/Makefile27
-rw-r--r--sys/boot/i386/libi386/biosdisk.c130
-rw-r--r--sys/boot/i386/libi386/biospci.c294
-rw-r--r--sys/boot/i386/libi386/biospnp.c289
-rw-r--r--sys/boot/i386/libi386/bootinfo.c6
-rw-r--r--sys/boot/i386/libi386/comconsole.c89
-rw-r--r--sys/boot/i386/libi386/vidconsole.c403
-rw-r--r--sys/boot/i386/loader/Makefile72
-rw-r--r--sys/boot/i386/loader/conf.c10
-rw-r--r--sys/boot/i386/loader/help.i38634
-rw-r--r--sys/boot/i386/loader/main.c46
-rwxr-xr-xsys/boot/i386/loader/newvers.sh1
-rw-r--r--sys/boot/i386/loader/setdef0.c49
-rw-r--r--sys/boot/i386/loader/setdef1.c41
26 files changed, 487 insertions, 1640 deletions
diff --git a/sys/boot/i386/boot0/Makefile b/sys/boot/i386/boot0/Makefile
index 4e890da32565c..d6c407a0cc478 100644
--- a/sys/boot/i386/boot0/Makefile
+++ b/sys/boot/i386/boot0/Makefile
@@ -1,16 +1,12 @@
-# $Id: Makefile,v 1.5 1998/10/17 14:20:25 rnordier Exp $
+# $Id: Makefile,v 1.3 1998/10/09 17:19:51 rnordier Exp $
PROG= boot0
NOMAN=
STRIP=
BINDIR?= /boot
-BINMODE= 444
M4?= m4
-B0FLAGS=0x0
-B0TICKS=0xb6
-
ORG= 0x600
boot0: boot0.o
@@ -23,8 +19,8 @@ boot0: boot0.o
.endif
boot0.o: boot0.m4 boot0.s
- (cd ${.CURDIR}; ${M4} -DFLAGS=${B0FLAGS} -DTICKS=${B0TICKS} \
- boot0.m4 boot0.s) | ${AS} ${AFLAGS} -o ${.TARGET}
+ (cd ${.CURDIR}; ${M4} boot0.m4 boot0.s) | \
+ ${AS} ${AFLAGS} -o ${.TARGET}
CLEANFILES+= boot0.out boot0.o
diff --git a/sys/boot/i386/boot0/boot0.m4 b/sys/boot/i386/boot0/boot0.m4
index f0912a8882439..c0a38b76911e7 100644
--- a/sys/boot/i386/boot0/boot0.m4
+++ b/sys/boot/i386/boot0/boot0.m4
@@ -13,7 +13,7 @@
# purpose.
#
-# $Id: boot0.m4,v 1.2 1998/10/19 19:13:53 rnordier Exp $
+# $Id:$
define(_al,0x0)dnl
define(_cl,0x1)dnl
@@ -52,22 +52,25 @@ define(_bx_,0x7)dnl
define(o16,`.byte 0x66')dnl
define(addwia,`.byte 0x5; .word $1')dnl
-define(btwr1,`.word 0xa30f; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(btswr1,`.word 0xab0f; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(cmpbmr,`.byte 0x3a; .byte 0x6 | ($2 << 0x3); .word $1')dnl
-define(cmpw1r,`.byte 0x3b; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
+define(btwrm,`.byte 0xf; .byte 0xa3; .byte 0x6 | ($1 << 0x3); .word $2')dnl
+define(btswrm,`.byte 0xf; .byte 0xab; .byte 0x6 | ($1 << 0x3); .word $2')dnl
+define(cmpwmr,`.byte 0x3b; .byte ($2 << 0x3) | 0x6; .word $1')dnl
define(cmpwi2,`.byte 0x81; .byte 0xb8 | $3; .word $2; .word $1')dnl
-define(addwir,`.byte 0x83; .byte 0xc0 | $2; .byte $1')dnl
+define(cmpwir,`.byte 0x81; .byte 0xf8 | $2; .word $1')dnl
define(movbr0,`.byte 0x88; .byte ($1 << 0x3) | $2')dnl
+define(movbrm,`.byte 0x88; .byte 0x6 | ($1 << 0x3); .word $2')dnl
define(movbr1,`.byte 0x88; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
define(movwr1,`.byte 0x89; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
define(movb0r,`.byte 0x8a; .byte ($2 << 0x3) | $1')dnl
+define(movbmr,`.byte 0x8a; .byte 0x6 | ($2 << 0x3); .word $1')dnl
define(movb1r,`.byte 0x8a; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
define(movw1r,`.byte 0x8b; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
define(movws1,`.byte 0x8c; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
+define(leaw1r,`.byte 0x8d; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
+define(movbma,`.byte 0xa0; .word $1')dnl
+define(movbam,`.byte 0xa2; .word $1')dnl
define(movwir,`.byte 0xb8 | $2; .word $1')dnl
define(movbi0,`.byte 0xc6; .byte $2; .byte $1')dnl
define(callwi,`.byte 0xe8; .word $1 - . - 0x2')dnl
define(jmpnwi,`.byte 0xe9; .word $1 - . - 0x2')dnl
-define(tstbi1,`.byte 0xf6; .byte 0x40 | $3; .byte $2; .byte $1')dnl
define(incb1,`.byte 0xfe; .byte 0x40 | $2; .byte $1')dnl
diff --git a/sys/boot/i386/boot0/boot0.s b/sys/boot/i386/boot0/boot0.s
index 08a8d6be21b2f..ae7fa5db8893a 100644
--- a/sys/boot/i386/boot0/boot0.s
+++ b/sys/boot/i386/boot0/boot0.s
@@ -13,36 +13,19 @@
# purpose.
#
-# $Id: boot0.s,v 1.5 1998/11/29 14:09:00 rnordier Exp $
+# $Id: boot0.s,v 1.2 1998/10/09 17:19:51 rnordier Exp $
# A 512-byte boot manager.
- .set NHRDRV,0x475 # Number of hard drives
- .set ORIGIN,0x600 # Execution address
- .set DSKPKT,0x800 # Disk packet
- .set FAKE,0x810 # Partition entry
.set LOAD,0x7c00 # Load address
-
+ .set ORIGIN,0x600 # Relocation address
.set PRT_OFF,0x1be # Partition table
-
- .set TBL0SZ,0x3 # Table 0 size
- .set TBL1SZ,0xa # Table 1 size
-
- .set MAGIC,0xaa55 # Magic: bootable
-
- .set KEY_ENTER,0x1c # Enter key scan code
- .set KEY_F1,0x3b # F1 key scan code
-
- .set _NXTDRV,-0x47 # Drive number
- .set _OPT,-0x46 # Default option
- .set _FLAGS,-0x45 # Flags
- .set _TICKS,-0x44 # Timeout ticks
- .set _FAKE,0x10 # Fake partition entry
- .set _MNUOPT,0x1c # Menu options
+ .set FAKE,0x810 # Partition entry
+ .set MNUOPT,0x81c # Menu options
.globl start # Entry point
-start: cld # String ops inc
+start: cld # String ops inc
xorl %eax,%eax # Zero
movl %eax,%es # Address
movl %eax,%ds # data
@@ -53,185 +36,183 @@ start: cld # String ops inc
movwir(0x100,_cx) # Word count
rep # Relocate
movsl # code
- movl %edi,%ebp # Address variables
movb $0x10,%cl # Words to clear
rep # Zero
stosl # them
incb1(-0xe,_di_) # Sector number
jmpnwi(main-LOAD+ORIGIN) # To relocated code
-main: movbr1(_dl,_FAKE,_bp_) # Save drive number
+main: movbrm(_dl,FAKE) # Save drive number
callwi(putn) # To new line
movwir(partbl,_bx) # Partition table
xorl %edx,%edx # Item
-main.1: movbr0(_dh,_bx_) # Mark inactive
+main.1: movbr0(_dh,_bx_) # Mark inactive
movb1r(0x4,_bx_,_al) # Load type
- movwir(tables,_di) # Lookup tables
- movb $TBL0SZ,%cl # Entries
+ movwir(table0,_di) # Exclusion table
+ movb $0x3,%cl # Entries
repne # Exclude
scasb # partition?
je main.3 # Yes
- movb $TBL1SZ,%cl # Entries
+ movb $0xa,%cl # Entries
repne # Known
scasb # type?
jne main.2 # No
- addwir(TBL1SZ,_di) # Adjust
-main.2: movb0r(_di_,_cl) # Partition
- addl %ecx,%edi # description
- callwi(putx) # Display it
-main.3: addwir(0x10,_bx) # Next entry
+ leaw1r(0xa,_di_,_di) # Name table
+main.2: movwir(item,_si) # Display start
+ callwi(putkey) # of menu item
+ movl %edi,%esi # Set pointer
+ lodsb # to
+ cwde # partition
+ add %eax,%esi # description
+ callwi(puts) # Display it
+ btswrm(_dx,MNUOPT) # Flag option enabled
+main.3: addb $0x10,%bl # Next entry
incl %edx # Next item
cmpb $0x4,%dl # Done?
jb main.1 # No
- movb1r(_FAKE,_bp_,_al) # Drive number
- subb $0x80-0x1,%al # Does next
- cmpbmr(NHRDRV,_al) # drive exist?
- jb main.4 # Yes
- decb %al # Already drive 0?
- jz main.5 # Yes
- xorb %al,%al # Drive 0
-main.4: addb $'0'|0x80,%al # Save
- movbr1(_al,_NXTDRV,_bp_) # it
- movwir(drive,_di) # Display
- callwi(putx) # item
-main.5: movwir(prompt,_si) # Display
+ movwir(prompt,_si) # Display
callwi(putstr) # prompt
- movb1r(_OPT,_bp_,_dl) # Display
+ movbmr(opt,_dl) # Display
decl %esi # default
callwi(putkey) # key
xorb %ah,%ah # BIOS: Get
int $0x1a # system time
- movl %edx,%edi # Save ticks
-main.6: movb $0x1,%ah # BIOS: Check
+ movl %edx,%edi # Save
+main.4: movb $0x1,%ah # BIOS: Check
int $0x16 # for keypress
- jnz main.9 # Have one
+ jnz main.6 # Have one
xorb %ah,%ah # BIOS: Get
int $0x1a # system time
subl %edi,%edx # Elapsed time
- cmpw1r(_TICKS,_bp_,_dx) # Timeout?
- jb main.6 # No
-main.7: movb1r(_OPT,_bp_,_al) # Load default
- jmp main.10 # Join common code
-main.8: movb $0x7,%al # Signal
+ cmpwmr(ticks,_dx) # Timeout?
+ jb main.4 # No
+ jmp main.7 # Join common code
+main.5: movb $0x7,%al # Signal
callwi(putchr) # error
-main.9: xorb %ah,%ah # BIOS: Get
+main.6: xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
movb %ah,%al # Scan code
- cmpb $KEY_ENTER,%al # Enter pressed?
- je main.7 # No
- subb $KEY_F1,%al # Less F1 scan code
- cmpb $0x4,%al # F1..F5?
- ja main.8 # No
-main.10: cwtl # Option
- btwr1(_ax,_MNUOPT,_bp_) # enabled?
- jnc main.8 # No
+ cmpb $0x1c,%al # Enter pressed?
+ jne main.8 # No
+main.7: movbma(opt) # Load
+ jmp main.9 # default
+main.8: subb $0x3b,%al # Less F1 scan code
+ jb main.5 # Not a function key
+main.9: cmpb $0x4,%al # F1..F5?
+ ja main.5 # No
movwir(FAKE,_si) # Partition entry
- movb1r(_NXTDRV,_bp_,_dl) # Next drive
- subb $'0',%dl # number
- cmpb $0x4,%al # F5 pressed?
- je main.11 # Yes
- movb0r(_si_,_dl) # Drive number
- movbr1(_al,_OPT,_bp_) # Save option
+ movb0r(_si_,_dl) # Load drive number
+ jne main.10 # If not F5
+ xorb $0x1,%dl # Toggle drive
+ jmp main.11 # number
+main.10: cwtl # Option
+ btwrm(_ax,MNUOPT) # enabled?
+ jnc main.5 # No
+ movbam(opt) # Save option
shlb $0x4,%al # Point to
addwia(partbl) # partition
- xchgl %esi,%eax # entry
- tstbi1(0x40,_FLAGS,_bp_) # No updates?
- jnz main.11 # Yes
+ xchgl %esi,%eax # entry
movbi0(0x80,_si_) # Flag active
pushl %esi # Save
- xchgl %esi,%eax # Fake partition entry
+ movl %eax,%esi # Fake partition entry
movwir(start,_bx) # Data to write
movwir(0x301,_ax) # Write sector
callwi(intx13) # to disk
popl %esi # Restore
+ jc main.5 # If error
main.11: movwir(LOAD,_bx) # Address for read
movwir(0x201,_ax) # Read sector
callwi(intx13) # from disk
- jc main.8 # If error
- cmpwi2(MAGIC,0x1fe,_bx_) # Bootable?
- jne main.8 # No
+ jc main.5 # If error
+ cmpwi2(0xaa55,0x1fe,_bx_) # Bootable?
+ jne main.5 # No
movwir(crlf,_si) # Leave some
callwi(puts) # space
jmp *%ebx # Invoke bootstrap
# Display routines
-putkey: movb $'F',%al # Display
+putkey: movb $'F',%al # Display
callwi(putchr) # 'F'
movb $'1',%al # Prepare
addb %dl,%al # digit
jmp putstr.1 # Display the rest
-putx: btswr1(_dx,_MNUOPT,_bp_) # Enable menu option
- movwir(item,_si) # Display
- callwi(putkey) # key
- movl %edi,%esi # Display the rest
-
puts: callwi(putstr) # Display string
putn: movwir(crlf,_si) # To next line
-putstr: lodsb # Get byte
- testb $0x80,%al # End of string?
+putstr: lodsb # Get byte
+ testb $0x80,%al # End of string?
jnz putstr.2 # Yes
putstr.1: callwi(putchr) # Display char
jmp putstr # Continue
-putstr.2: andb $~0x80,%al # Clear MSB
+putstr.2: andb $~0x80,%al # Clear MSB
-putchr: pushl %ebx # Save
- movwir(0x7,_bx) # Page:attribute
+putchr: pushl %ebx # Save
+ movwir(0x7,_bx) # Page:attribute
movb $0xe,%ah # BIOS: Display
int $0x10 # character
popl %ebx # Restore
ret # To caller
-# Disk I/O routine
+# Disk I/O
-intx13: cli # Disable interrupts
- movb1r(0x1,_si_,_dh) # Load head
+intx13: movb1r(0x1,_si_,_dh) # Load head
movw1r(0x2,_si_,_cx) # Load cylinder:sector
o16 # Load
movw1r(0x8,_si_,_di) # offset
- movwir(DSKPKT,_si) # Packet pointer
+ pushl %ecx # Save
+ pushl %ebx # caller's
+ movwir(0x55aa,_bx) # Magic
+ pushl %eax # Save
+ movb $0x41,%ah # BIOS: EDD extensions
+ int $0x13 # present?
+ popl %eax # Restore
+ jc intx13.1 # No
+ cmpwir(0xaa55,_bx) # Magic?
+ jne intx13.1 # No
+ testb $0x1,%cl # Use packet?
+ jz intx13.1 # No
+ orb $0x40,%ah # Use EDD
+intx13.1: popl %ebx # Restore
+ popl %ecx # caller's
+ testb $0x40,%ah # Use EDD?
+ jz intx13.2 # No
+ movwir(break,_si) # Packet pointer
movbi0(0x10,_si_) # Packet size
movbr1(_al,0x2,_si_) # Block count
movwr1(_bx,0x4,_si_) # Transfer
movws1(_es,0x6,_si_) # buffer
o16 # LBA
movwr1(_di,0x8,_si_) # address
- sti # Enable interrupts
- tstbi1(0x80,_FLAGS,_bp_) # Use packet interface?
- jz intx13.1 # No
- orb $0x40,%ah # Use disk packet
- decl %eax # Verify off
-intx13.1: int $0x13 # BIOS: Disk I/O
+ xorb %al,%al # Verify off
+intx13.2: int $0x13 # BIOS: Disk I/O
ret # To caller
# Menu strings
-item: .ascii " "; .byte ' '|0x80
+crlf: .ascii "\r"; .byte '\n'|0x80
+item: .ascii " "; .byte ' '|0x80
prompt: .ascii "\nDefault:"; .byte ' '|0x80
-crlf: .ascii "\r"; .byte '\n'|0x80
# Partition type tables
-tables:
- .byte 0x0, 0x5, 0xf
-
- .byte 0x1, 0x4, 0x6, 0xb, 0xc, 0xe, 0x63, 0x83
+table0: .byte 0x0, 0x5, 0xf
+table1: .byte 0x1, 0x4, 0x6, 0xb, 0xc, 0xe, 0x63, 0x83
.byte 0xa5, 0xa6
- .byte os_misc-. # Unknown
- .byte os_dos-. # DOS
- .byte os_dos-. # DOS
- .byte os_dos-. # DOS
- .byte os_dos-. # Windows
- .byte os_dos-. # Windows
- .byte os_dos-. # Windows
- .byte os_unix-. # UNIX
- .byte os_linux-. # Linux
- .byte os_freebsd-. # FreeBSD
- .byte os_bsd-. # OpenBSD
+ .byte os_misc-.-1 # Unknown
+ .byte os_dos-.-1 # DOS
+ .byte os_dos-.-1 # DOS
+ .byte os_dos-.-1 # DOS
+ .byte os_dos-.-1 # Windows
+ .byte os_dos-.-1 # Windows
+ .byte os_dos-.-1 # Windows
+ .byte os_unix-.-1 # UNIX
+ .byte os_linux-.-1 # Linux
+ .byte os_freebsd-.-1 # FreeBSD
+ .byte os_bsd-.-1 # OpenBSD
os_misc: .ascii "?"; .byte '?'|0x80
os_dos: .ascii "DO"; .byte 'S'|0x80
@@ -240,13 +221,12 @@ os_linux: .ascii "Linu"; .byte 'x'|0x80
os_freebsd: .ascii "Free"
os_bsd: .ascii "BS"; .byte 'D'|0x80
- .org PRT_OFF-0xb,0x90
+ .org PRT_OFF-0x3,0x90
+
+opt: .byte 0x1 # Option
+ticks: .word 0xb6 # Delay
-drive: .ascii "Drive "
-nxtdrv: .byte 0x0 # Next drive number
-opt: .byte 0x0 # Option
-flags: .byte FLAGS # Flags
-ticks: .word TICKS # Delay
+partbl: .fill 0x40,0x1,0x0 # Partition table
+ .word 0xaa55 # Magic number
-partbl: .fill 0x40,0x1,0x0 # Partition table
- .word MAGIC # Magic number
+break: # Uninitialized data
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index 2b581ec521cd5..e36df60f2a9bb 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.10 1998/11/08 15:36:34 rnordier Exp $
+# $Id: Makefile,v 1.6 1998/10/15 20:04:21 rnordier Exp $
PROG= boot2
NOMAN=
@@ -11,10 +11,6 @@ CLEANFILES+= boot1 boot1.out boot1.o \
M4?= m4
-BOOT_COMCONSOLE_PORT?= 0x3f8
-BOOT_COMCONSOLE_SPEED?= 9600
-B2SIOFMT?= 0x3
-
.if exists(${.OBJDIR}/../btx)
BTX= ${.OBJDIR}/../btx
.else
@@ -62,10 +58,7 @@ boot2.out: boot2.o sio.o
${BTX}/lib/crt0.o boot2.o sio.o
sio.o: sio.s
- (cd ${.CURDIR}; ${M4} -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
- -DSIOFMT=${B2SIOFMT} \
- -DSIOSPD=${BOOT_COMCONSOLE_SPEED} sio.s) | \
- ${AS} ${AFLAGS} -o ${.TARGET}
+ ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
install:
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
diff --git a/sys/boot/i386/boot2/boot1.m4 b/sys/boot/i386/boot2/boot1.m4
index 06bdc9789331d..fc221a1854c1d 100644
--- a/sys/boot/i386/boot2/boot1.m4
+++ b/sys/boot/i386/boot2/boot1.m4
@@ -13,7 +13,7 @@
# purpose.
#
-# $Id: boot1.m4,v 1.2 1998/11/05 20:52:25 rnordier Exp $
+# $Id:$
define(_al,0x0)dnl
define(_cl,0x1)dnl
@@ -60,5 +60,3 @@ define(movbi1,`.byte 0xc6; .byte 0x40 | $3; .byte $2; .byte $1')dnl
define(callwi,`.byte 0xe8; .word $1 - . - 0x2')dnl
define(jmpnwi,`.byte 0xe9; .word $1 - . - 0x2')dnl
define(tstbi0,`.byte 0xf6; .byte $2; .byte $1')dnl
-define(tstbim,`.byte 0xf6; .byte 0x6; .word $2; .byte $1')dnl
-define(incw1,`.byte 0xff; .byte 0x40 | $2; .byte $1')dnl
diff --git a/sys/boot/i386/boot2/boot1.s b/sys/boot/i386/boot2/boot1.s
index 3161b748b8e92..8b408cebeff47 100644
--- a/sys/boot/i386/boot2/boot1.s
+++ b/sys/boot/i386/boot2/boot1.s
@@ -13,10 +13,11 @@
# purpose.
#
-# $Id: boot1.s,v 1.7 1999/01/10 13:29:51 peter Exp $
+# $Id: boot1.s,v 1.1.1.1 1998/10/12 21:16:26 rnordier Exp $
- .set MEM_REL,0x700 # Relocation address
- .set MEM_ARG,0x900 # Arguments
+ .set MEM_REL,0x600 # Relocation address
+ .set MEM_ARG,0x800 # Arguments
+ .set MEM_PKT,0x810 # Disk packet
.set MEM_ORG,0x7c00 # Origin
.set MEM_BUF,0x8c00 # Load area
.set MEM_BTX,0x9000 # BTX start
@@ -37,58 +38,59 @@ start: jmp main # Start recognizably
.org 0x4,0x90
-# External read from disk
-
-xread: pushl %ecx # Set
- pushl %eax # LBA
- pushl %es # Set transfer
- pushl %ebx # buffer
- pushl %edx # Set count:drive
+xread: pushl %cs # Address
+ popl %ds # data
+xread.1: movwir(MEM_PKT,_si) # Packet
+ movbr1(_al,0x2,_si_) # Blocks to read
+ o16 # Transfer
+ movwr1(_bx,0x4,_si_) # buffer
+ o16 # LBA
+ movwr1(_cx,0x8,_si_) # address
callwi(read) # Read from disk
- popl %edx # Pop all
- popl %ebx # registers
- popl %es # pushed, but
- popl %ecx # preserve
- popl %ecx # AX
- lret # To far caller
-
-# Bootstrap
+ lret # To caller
main: cld # String ops inc
- xorl %ecx,%ecx # Zero
- movl %cx,%es # Address
- movl %cx,%ds # data
- movl %cx,%ss # Set up
+ xorl %eax,%eax # Zero
+ movl %ax,%es # Address
+ movl %ax,%ds # data
+ movl %ax,%ss # Set up
movwir(start,_sp) # stack
movl %esp,%esi # Source
movwir(MEM_REL,_di) # Destination
- incb %ch # Word count
+ movwir(0x100,_cx) # Word count
rep # Copy
movsl # code
- movwir(part4,_si) # Partition
+ movb $0x10,%cl # Words to clear
+ rep # Zero
+ stosl # them
+ movbi1(0x10,-0x10,_di_) # Set packet size
cmpb $0x80,%dl # Hard drive?
jb main.4 # No
- movb $0x1,%dh # Block count
- callwi(nread) # Read MBR
- movwir(0x1,_cx) # Two passes
+ movwir(part4,_si) # Read master
+ movb $0x1,%al # boot
+ callwi(nread) # record
+ xorl %eax,%eax # Pass number
main.1: movwir(MEM_BUF+PRT_OFF,_si) # Partition table
movb $0x1,%dh # Partition
main.2: cmpbi1(PRT_BSD,0x4,_si_) # Our partition type?
jne main.3 # No
- jecxz main.5 # If second pass
tstbi0(0x80,_si_) # Active?
jnz main.5 # Yes
+ testb %al,%al # Second pass?
+ jnz main.5 # Yes
main.3: addl $0x10,%esi # Next entry
incb %dh # Partition
- cmpb $0x1+PRT_NUM,%dh # In table?
- jb main.2 # Yes
- decl %ecx # Do two
- jecxz main.1 # passes
+ cmpb $0x1+PRT_NUM,%dh # Done?
+ jb main.2 # No
+ incl %eax # Pass
+ cmpb $0x2,%al # Done?
+ jb main.1 # No
movwir(msg_part,_si) # Message
jmp error # Error
main.4: xorl %edx,%edx # Partition:drive
+ movwir(part4,_si) # Partition pointer
main.5: movwrm(_dx,MEM_ARG) # Save args
- movb $0x10,%dh # Sector count
+ movb $0x10,%al # Sector count
callwi(nread) # Read disk
movwir(MEM_BTX,_bx) # BTX
movw1r(0xa,_bx_,_si) # Point past
@@ -107,34 +109,33 @@ main.5: movwrm(_dx,MEM_ARG) # Save args
# Enable A20
-seta20: cli # Disable interrupts
-seta20.1: inb $0x64,%al # Get status
+seta20: inb $0x64,%al # Get status
testb $0x2,%al # Busy?
- jnz seta20.1 # Yes
+ jnz seta20 # Yes
movb $0xd1,%al # Command: Write
outb %al,$0x64 # output port
-seta20.2: inb $0x64,%al # Get status
+seta20.1: inb $0x64,%al # Get status
testb $0x2,%al # Busy?
- jnz seta20.2 # Yes
+ jnz seta20.1 # Yes
movb $0xdf,%al # Enable
outb %al,$0x60 # A20
- sti # Enable interrupts
ret # To caller
-# Local read from disk
+# Read from disk
-nread: movwir(MEM_BUF,_bx) # Transfer buffer
- movw1r(0x8,_si_,_ax) # Get
- movw1r(0xa,_si_,_cx) # LBA
+nread: xorw %bx,%bx # Transfer
+ movb $MEM_BUF>>0x8,%bh # buffer
+ o16 # LBA
+ movw1r(0x8,_si_,_cx) # address
pushl %cs # Read from
- callwi(xread) # disk
+ callwi(xread.1) # disk
jnc return # If success
movwir(msg_read,_si) # Message
# Error exit
error: callwi(putstr) # Display message
- movwir(prompt,_si) # Display
+ movwir(msg_boot,_si) # Display
callwi(putstr) # prompt
xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
@@ -149,24 +150,40 @@ putstr: lodsb # Get char
testb %al,%al # End of string?
jne putstr.0 # No
-ereturn: movb $0x1,%ah # Invalid
- stc # argument
-return: ret # To caller
+return: ret # Generic return
# Read from disk
-read: movl %esp,%ebp # Address stack frame
+read: testb %dh,%dh # Try for extensions?
+ jz read.3 # No
+ movwir(0x55aa,_bx) # Magic
pushl %edx # Save
+ movb $0x41,%ah # BIOS: Check
+ int $0x13 # extensions present
+ popl %edx # Restore
+ jc read.3 # If error
+ cmpwir(0xaa55,_bx) # Magic?
+ jne read.3 # No
+ testb $0x1,%cl # Packet interface?
+ jz read.3 # No
+ movb $0x42,%ah # BIOS: Extended
+ int $0x13 # read
+ ret # To caller
+
+read.1: movb $0x1,%ah # Invalid
+ stc # parameter
+read.2: ret # To caller
+
+read.3: pushl %edx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
popl %edx # Restore
- jc return # If error
+ jc read.2 # If error
andb $0x3f,%cl # Sectors per track
- jz ereturn # If zero
- cli # Disable interrupts
+ jz read.1 # If zero
o16 # Get
- movw1r(0x8,_bp_,_ax) # LBA
+ movw1r(0x8,_si_,_ax) # LBA
pushl %edx # Save
movzbw %cl,%bx # Divide by
xorw %dx,%dx # sectors
@@ -174,14 +191,13 @@ read: movl %esp,%ebp # Address stack frame
movb %ch,%bl # Max head number
movb %dl,%ch # Sector number
incl %ebx # Divide by
- xorb %dl,%dl # number
- divw %bx,%ax # of heads
+ xorb %dl,%dl # number of
+ divw %bx,%ax # heads
movb %dl,%bh # Head number
popl %edx # Restore
o16 # Cylinder number
cmpl $0x3ff,%eax # supportable?
- sti # Enable interrupts
- ja ereturn # No
+ ja read.1 # No
xchgb %al,%ah # Set up cylinder
rorb $0x2,%al # number
orb %ch,%al # Merge
@@ -189,39 +205,37 @@ read: movl %esp,%ebp # Address stack frame
xchgl %eax,%ecx # number
movb %bh,%dh # Head number
subb %ah,%al # Sectors this track
- movb1r(0x3,_bp_,_ah) # Blocks to read
+ movb1r(0x2,_si_,_ah) # Blocks to read
cmpb %ah,%al # To read
- jb read.1 # this
+ jb read.4 # this
movb %ah,%al # track
-read.1: movwir(0x5,_di) # Try count
-read.2: lesw1r(0x4,_bp_,_bx) # Transfer buffer
+read.4: movwir(0x5,_bp) # Try count
+read.5: lesw1r(0x4,_si_,_bx) # Transfer buffer
pushl %eax # Save
- movb $0x2,%ah # BIOS: Read
- int $0x13 # from disk
+ movb $0x2,%ah # BIOS: Conventional
+ int $0x13 # read
popl %ebx # Restore
- jnc read.3 # If success
- decl %edi # Retry?
- jz read.5 # No
+ jnc read.6 # If success
+ decl %ebp # Retry?
+ jz read.7 # No
xorb %ah,%ah # BIOS: Reset
int $0x13 # disk system
- xchgl %ebx,%eax # Block count
- jmp read.2 # Continue
-read.3: movzbl %bl,%eax # Sectors read
- addwr1(_ax,0x8,_bp_) # Adjust
- jnc read.4 # LBA,
- incw1(0xa,_bp_) # transfer
-read.4: shlb %bl # buffer
- addbr1(_bl,0x5,_bp_) # pointer,
- subbr1(_al,0x3,_bp_) # block count
- ja read # If not done
-read.5: ret # To caller
+ movl %ebx,%eax # Block count
+ jmp read.5 # Continue
+read.6: movzbw %bl,%ax # Sectors read
+ o16 # Adjust
+ addwr1(_ax,0x8,_si_) # LBA,
+ shlb %bl # buffer
+ addbr1(_bl,0x5,_si_) # pointer,
+ subbr1(_al,0x2,_si_) # block count
+ ja read.3 # If not done
+read.7: ret # To caller
# Messages
-msg_read: .asciz "Read"
-msg_part: .asciz "Boot"
-
-prompt: .asciz " error\r\n"
+msg_read: .asciz "Read error"
+msg_part: .asciz "No bootable partition"
+msg_boot: .asciz "\r\nHit return to reboot: "
.org PRT_OFF,0x90
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
index fa6058bcccb76..bf9ed8c61f54b 100644
--- a/sys/boot/i386/boot2/boot2.c
+++ b/sys/boot/i386/boot2/boot2.c
@@ -14,7 +14,7 @@
*/
/*
- * $Id: boot2.c,v 1.17 1999/01/10 13:29:52 peter Exp $
+ * $Id: boot2.c,v 1.6 1998/10/13 23:43:38 rnordier Exp $
*/
#include <sys/param.h>
@@ -53,9 +53,11 @@
#define PATH_CONFIG "/boot.config"
#define PATH_BOOT3 "/boot/loader"
#define PATH_KERNEL "/kernel"
+#define PATH_HELP "boot.help"
-#define ARGS 0x900
+#define ARGS 0x800
#define NOPT 11
+#define XOPT 2
#define BSIZEMAX 8192
#define NDEV 5
#define MEM_BASE 0x12
@@ -102,6 +104,7 @@ static struct dsk {
} dsk;
static char cmd[512];
static char kname[1024];
+static char help[2048];
static uint32_t opts;
static struct bootinfo bootinfo;
static int ls;
@@ -136,7 +139,7 @@ static int getc(int);
int
main(void)
{
- int autoboot, i;
+ int autoboot, helpon, i;
v86.ctl = V86_FLAGS;
dsk.drive = *(uint8_t *)PTOV(ARGS);
@@ -151,14 +154,11 @@ main(void)
for (i = 0; i < N_BIOS_GEOM; i++)
bootinfo.bi_bios_geom[i] = drvinfo(i);
autoboot = 2;
+ helpon = 1;
readfile(PATH_CONFIG, cmd, sizeof(cmd));
- if (*cmd) {
- printf("%s: %s", PATH_CONFIG, cmd);
- if (parse(cmd))
- autoboot = 0;
- *cmd = 0;
- }
- if (autoboot && !*kname) {
+ if (parse(cmd))
+ autoboot = 0;
+ else if (!*kname) {
if (autoboot == 2) {
memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
if (!keyhit(0x37)) {
@@ -169,21 +169,21 @@ main(void)
if (autoboot == 1)
memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
}
+ readfile(PATH_HELP, help, sizeof(help));
for (;;) {
printf(" \n>> FreeBSD/i386 BOOT\n"
"Default: %u:%s(%u,%c)%s\n"
+ "%s"
"boot: ",
dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
- 'a' + dsk.part, kname);
+ 'a' + dsk.part, kname, helpon ? help : "");
if (ioctrl & 0x2)
sio_flush();
if (!autoboot || keyhit(0x5a))
getstr(cmd, sizeof(cmd));
- else
- putchar('\n');
- autoboot = 0;
+ autoboot = helpon = 0;
if (parse(cmd))
- putchar('\a');
+ helpon = 1;
else
load(kname);
}
@@ -226,16 +226,22 @@ load(const char *fname)
if (fmt == 0) {
addr = hdr.ex.a_entry & 0xffffff;
p = PTOV(addr);
+ printf("%s=0x%x ", "text", (unsigned)hdr.ex.a_text);
fs_off = PAGE_SIZE;
if (xfsread(ino, p, hdr.ex.a_text))
return;
p += roundup2(hdr.ex.a_text, PAGE_SIZE);
+ printf("%s=0x%x ", "data", (unsigned)hdr.ex.a_data);
if (xfsread(ino, p, hdr.ex.a_data))
return;
- p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
+ p += hdr.ex.a_data;
+ printf("%s=0x%x ", "bss", (unsigned)hdr.ex.a_bss);
+ p += roundup2(hdr.ex.a_bss, PAGE_SIZE);
bootinfo.bi_symtab = VTOP(p);
memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
p += sizeof(hdr.ex.a_syms);
+ printf("symbols=[");
+ printf("+0x%x", (unsigned)hdr.ex.a_syms);
if (hdr.ex.a_syms) {
if (xfsread(ino, p, hdr.ex.a_syms))
return;
@@ -245,6 +251,7 @@ load(const char *fname)
x = *(uint32_t *)p;
p += sizeof(int);
x -= sizeof(int);
+ printf("+0x%x", x);
if (xfsread(ino, p, x))
return;
p += x;
@@ -259,12 +266,15 @@ load(const char *fname)
}
for (i = 0; i < 2; i++) {
p = PTOV(ep[i].p_paddr & 0xffffff);
+ printf("%s=0x%x ", !i ? "text" : "data", ep[i].p_filesz);
fs_off = ep[i].p_offset;
if (xfsread(ino, p, ep[i].p_filesz))
return;
}
+ printf("%s=0x%x ", "bss", ep[1].p_memsz - ep[1].p_filesz);
p += roundup2(ep[1].p_memsz, PAGE_SIZE);
bootinfo.bi_symtab = VTOP(p);
+ printf("symbols=[");
if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) {
fs_off = hdr.eh.e_shoff + sizeof(es[0]) *
(hdr.eh.e_shstrndx + 1);
@@ -273,6 +283,7 @@ load(const char *fname)
for (i = 0; i < 2; i++) {
memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
p += sizeof(es[i].sh_size);
+ printf("+0x%x", es[i].sh_size);
fs_off = es[i].sh_offset;
if (xfsread(ino, p, es[i].sh_size))
return;
@@ -282,6 +293,7 @@ load(const char *fname)
addr = hdr.eh.e_entry & 0xffffff;
}
bootinfo.bi_esymtab = VTOP(p);
+ printf("]\nentry=0x%x\n", addr);
bootinfo.bi_kernelname = VTOP(fname);
__exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
MAKEBOOTDEV(dsk.type, 0, dsk.slice, dsk.unit, dsk.part),
@@ -305,14 +317,16 @@ parse(char *arg)
for (i = 0; c != optstr[i]; i++)
if (i == NOPT - 1)
return -1;
- opts ^= 1 << flags[i];
+ if (i < XOPT)
+ opts ^= 1 << flags[i];
+ else
+ opts |= 1 << flags[i];
}
if (opts & 1 << RBX_PROBEKBD) {
i = *(uint8_t *)PTOV(0x496) & 0x10;
printf("Keyboard: %s\n", i ? "yes" : "no");
if (!i)
opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
- opts &= ~(1 << RBX_PROBEKBD);
}
ioctrl = opts & 1 << RBX_DUAL ? 0x3 :
opts & 1 << RBX_SERIAL ? 0x2 : 0x1;
@@ -469,7 +483,7 @@ fsread(ino_t inode, void *buf, size_t nbyte)
return -1;
}
fsblks = fs.fs_bsize >> DEV_BSHIFT;
- dsk.meta++;
+ dsk.meta = 1;
}
if (!inode)
return 0;
@@ -630,15 +644,9 @@ getstr(char *str, int size)
s = str;
do {
switch (c = getchar()) {
- case 0:
- break;
case '\b':
- if (s > str) {
+ if (s > str)
s--;
- putchar(c);
- putchar(' ');
- } else
- c = 0;
break;
case '\n':
*s = 0;
@@ -647,8 +655,7 @@ getstr(char *str, int size)
if (s - str < size - 1)
*s++ = c;
}
- if (c)
- putchar(c);
+ putchar(c);
} while (c != '\n');
}
@@ -731,12 +738,11 @@ drvread(void *buf, unsigned lba, unsigned nblk)
printf("%c\b", c = c << 8 | c >> 24);
v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
- v86.addr = 0x704; /* call to xread in boot1 */
- v86.es = VTOPSEG(buf);
- v86.eax = lba;
- v86.ebx = VTOPOFF(buf);
- v86.ecx = lba >> 16;
- v86.edx = nblk << 8 | dsk.drive;
+ v86.addr = 0x604;
+ v86.eax = nblk;
+ v86.ebx = VTOPSEG(buf) << 16 | VTOPOFF(buf);
+ v86.ecx = lba;
+ v86.edx = 0x100 | dsk.drive;
v86int();
v86.ctl = V86_FLAGS;
if (V86_CY(v86.efl)) {
diff --git a/sys/boot/i386/boot2/sio.s b/sys/boot/i386/boot2/sio.s
index 92237b852b729..985ac04ef469e 100644
--- a/sys/boot/i386/boot2/sio.s
+++ b/sys/boot/i386/boot2/sio.s
@@ -13,11 +13,11 @@
# purpose.
#
-# $Id: sio.s,v 1.2 1998/10/20 20:20:48 rnordier Exp $
+# $Id:$
- .set SIO_PRT,SIOPRT # Base port
- .set SIO_FMT,SIOFMT # 8N1
- .set SIO_DIV,(115200/SIOSPD) # 115200 / SPD
+ .set SIO_PRT,0x3f8 # Base port
+ .set SIO_FMT,0x3 # 8N1
+ .set SIO_DIV,0xc # 115200 / 9600
.globl sio_init
.globl sio_flush
diff --git a/sys/boot/i386/btx/btx/btx.s b/sys/boot/i386/btx/btx/btx.s
index 92842626d00ff..d94fa2c11a27a 100644
--- a/sys/boot/i386/btx/btx/btx.s
+++ b/sys/boot/i386/btx/btx/btx.s
@@ -13,7 +13,7 @@
# purpose.
#
-# $Id: btx.s,v 1.7 1998/11/01 13:52:52 rnordier Exp $
+# $Id: btx.s,v 1.5 1998/10/03 18:05:12 rnordier Exp $
#
# Memory layout.
@@ -340,7 +340,7 @@ intx00: pushb $0x0 # Int 0x0: #DE
intx10: pushb $0x10 # Int 0x10: #MF
jmp ex_noc # Floating-point error
#
-# Handle #GP exception.
+#
#
ex_v86: testb $0x2,0x12(%esp,1) # V86 mode?
jz except # No
@@ -459,7 +459,7 @@ v86mon.1: lodsb # Get opcode
v86mon.2: cmpb $0xf4,%al # HLT?
jne v86mon.3 # No
cmpl $inthlt+0x1,%esi # Is inthlt?
- jne v86mon.6 # No (ignore)
+ jne v86mon.4 # No
jmp intrtn # Return to user mode
v86mon.3: cmpb $0xfa,%al # CLI?
je v86cli # Yes
@@ -479,13 +479,13 @@ v86mon.3: cmpb $0xfa,%al # CLI?
cmpb $0xcf,%al # IRET/IRETD?
je v86iret # Yes
popl %ebx # Restore
- popa # Restore
+v86mon.4: popa # Restore
jmp except # Handle exception
-v86mon.4: movl %edx,0x30(%ebp) # Save V86 flags
-v86mon.5: popl %edx # V86 SS adjustment
+v86mon.5: movl %edx,0x30(%ebp) # Save V86 flags
+v86mon.6: popl %edx # V86 SS adjustment
subl %edx,%ebx # Save V86
movl %ebx,0x34(%ebp) # SP
-v86mon.6: subl %edi,%esi # From linear
+v86mon.7: subl %edi,%esi # From linear
movl %esi,0x28(%ebp) # Save V86 IP
popa # Restore
leal 0x8(%esp,1),%esp # Discard int no, error
@@ -494,12 +494,12 @@ v86mon.6: subl %edi,%esi # From linear
# Emulate CLI.
#
v86cli: andb $~0x2,0x31(%ebp) # Clear IF
- jmp v86mon.6 # Finish up
+ jmp v86mon.7 # Finish up
#
# Emulate STI.
#
v86sti: orb $0x2,0x31(%ebp) # Set IF
- jmp v86mon.6 # Finish up
+ jmp v86mon.7 # Finish up
#
# Emulate PUSHF/PUSHFD.
#
@@ -508,7 +508,7 @@ v86pushf: subl %ecx,%ebx # Adjust SP
je v86pushf.1 # Yes
o16 # 16-bit
v86pushf.1: movl %edx,(%ebx) # Save flags
- jmp v86mon.5 # Finish up
+ jmp v86mon.6 # Finish up
#
# Emulate IRET/IRETD.
#
@@ -529,7 +529,7 @@ v86popf.1: movl (%ebx),%eax # Load flags
andl $V86_FLG,%eax # Merge
andl $~V86_FLG,%edx # the
orl %eax,%edx # flags
- jmp v86mon.4 # Finish up
+ jmp v86mon.5 # Finish up
#
# Emulate INT imm8.
#
@@ -546,7 +546,7 @@ v86intn: lodsb # Get int no
movl %edi,0x2c(%ebp) # Save CS
xorl %edi,%edi # No ESI adjustment
andb $~0x3,%dh # Clear IF and TF
- jmp v86mon.4 # Finish up
+ jmp v86mon.5 # Finish up
#
# Hardware interrupt jump table.
#
@@ -693,12 +693,12 @@ intusr.4: shrl $0x4,%eax # Gives segment
xchgl %eax,%ebp # Get int no/address
testb $0x1,%dl # Address?
jnz intusr.5 # Yes
- shll $0x2,%eax # Scale
+ shll $0x2,%eax # XXX Scale
movl (%eax),%eax # Load int vector
-intusr.5: movl %eax,%ecx # Save
+intusr.5: movl %eax,%ecx # XXX Save
shrl $0x10,%eax # Gives segment
stosl # Set CS
- movw %cx,%ax # Restore
+ movw %cx,%ax # XXX Restore
stosl # Set EIP
leal 0x10(%esp,1),%esp # Discard seg regs
popa # Restore
@@ -755,7 +755,7 @@ dump.1: testb $DMP_X32,%ch # Dump long?
dump.2: testb $DMP_MEM,%ch # Dump memory?
jz dump.8 # No
pushl %ds # Save
- testb $0x2,0x52(%ebx) # V86 mode?
+ testb $0x2,0x52(%ebx) # XXX V86 mode?
jnz dump.3 # Yes
verrl 0x4(%esi) # Readable selector?
jnz dump.3 # No
diff --git a/sys/boot/i386/btx/btxldr/Makefile b/sys/boot/i386/btx/btxldr/Makefile
index 32cb4adb0b8e1..9df9681867ec7 100644
--- a/sys/boot/i386/btx/btxldr/Makefile
+++ b/sys/boot/i386/btx/btxldr/Makefile
@@ -1,7 +1,6 @@
-# $Id: Makefile,v 1.5 1998/10/13 18:29:18 rnordier Exp $
+# $Id: Makefile,v 1.4 1998/09/25 17:14:15 peter Exp $
ORG=0x100000
-AFLAGS+= --assembler-with-cpp
all: btxldr
@@ -15,7 +14,7 @@ btxldr: btxldr.o
.endif
btxldr.o: btxldr.s
- ${CC} ${AFLAGS} -c -o ${.TARGET} ${.CURDIR}/btxldr.s
+ ${AS} ${AFLAGS} -o ${.TARGET} ${.CURDIR}/btxldr.s
CLEANFILES+= btxldr btxldr.out btxldr.o
diff --git a/sys/boot/i386/btx/btxldr/btxldr.s b/sys/boot/i386/btx/btxldr/btxldr.s
index a3172e3e3cb5d..7a6bd50b1a152 100644
--- a/sys/boot/i386/btx/btxldr/btxldr.s
+++ b/sys/boot/i386/btx/btxldr/btxldr.s
@@ -13,7 +13,7 @@
# purpose.
#
-# $Id: btxldr.s,v 1.3 1998/10/06 07:15:35 rnordier Exp $
+# $Id: btxldr.s,v 1.2 1998/10/06 06:13:36 msmith Exp $
#
# Prototype BTX loader program, written in a couple of hours. The
@@ -70,24 +70,24 @@ start: cld # String ops inc
shll $0xa,%eax # in bytes
movl %eax,%ebp # Base of user stack
movl $m_mem,%esi # Display
- call dhexout # amount of
- call dputstr # base memory
+ call hexout # amount of
+ call putstr # base memory
lgdt gdtdesc # Load new GDT
#
# Relocate caller's arguments.
#
movl $m_esp,%esi # Display
movl %esp,%eax # caller's
- call dhexout # stack
- call dputstr # pointer
+ call hexout # stack
+ call putstr # pointer
movl $m_args,%esi # Format string
leal 0x4(%esp,1),%ebx # First argument
movl $0x6,%ecx # Count
start.1: movl (%ebx),%eax # Get argument and
addl $0x4,%ebx # bump pointer
- call dhexout # Display it
+ call hexout # Display it
loop start.1 # Till done
- call dputstr # End message
+ call putstr # End message
movl $0x48,%ecx # Allocate space
subl %ecx,%ebp # for bootinfo
movl 0x18(%esp,1),%esi # Source
@@ -97,8 +97,8 @@ start.1: movl (%ebx),%eax # Get argument and
movl %ebp,0x18(%esp,1) # Update pointer
movl $m_rel_bi,%esi # Display
movl %ebp,%eax # bootinfo
- call dhexout # relocation
- call dputstr # message
+ call hexout # relocation
+ call putstr # message
movl $0x18,%ecx # Allocate space
subl %ecx,%ebp # for arguments
leal 0x4(%esp,1),%esi # Source
@@ -107,8 +107,8 @@ start.1: movl (%ebx),%eax # Get argument and
movsb # them
movl $m_rel_args,%esi # Display
movl %ebp,%eax # argument
- call dhexout # relocation
- call dputstr # message
+ call hexout # relocation
+ call putstr # message
#
# Set up BTX kernel.
#
@@ -145,16 +145,16 @@ start.1: movl (%ebx),%eax # Get argument and
movl %esi,%ebx # Keep place
movl $m_rel_btx,%esi # Restore
popl %eax # parameters
- call dhexout # and
+ call hexout # and
popl %ebp # display
movl %ebp,%eax # the
- call dhexout # relocation
- call dputstr # message
+ call hexout # relocation
+ call putstr # message
addl $PAG_SIZ,%ebp # Display
movl $m_base,%esi # the
movl %ebp,%eax # user
- call dhexout # base
- call dputstr # address
+ call hexout # base
+ call putstr # address
#
# Set up ELF-format client program.
#
@@ -164,7 +164,7 @@ start.1: movl (%ebx),%eax # Get argument and
call putstr # message
start.2: jmp start.2 # Hang
start.3: movl $m_elf,%esi # Display ELF
- call dputstr # message
+ call putstr # message
movl $m_segs,%esi # Format string
movl $0x2,%edi # Segment count
movl 0x1c(%ebx),%edx # Get e_phoff
@@ -173,14 +173,14 @@ start.3: movl $m_elf,%esi # Display ELF
start.4: cmpl $0x1,(%edx) # Is p_type PT_LOAD?
jne start.6 # No
movl 0x4(%edx),%eax # Display
- call dhexout # p_offset
+ call hexout # p_offset
movl 0x8(%edx),%eax # Display
- call dhexout # p_vaddr
+ call hexout # p_vaddr
movl 0x10(%edx),%eax # Display
- call dhexout # p_filesz
+ call hexout # p_filesz
movl 0x14(%edx),%eax # Display
- call dhexout # p_memsz
- call dputstr # End message
+ call hexout # p_memsz
+ call putstr # End message
pushl %esi # Save
pushl %edi # working
pushl %ecx # registers
@@ -205,7 +205,7 @@ start.5: popl %ecx # Restore
start.6: addl $0x20,%edx # To next entry
loop start.4 # Till done
start.7: movl $m_done,%esi # Display done
- call dputstr # message
+ call putstr # message
movl $start.8,%esi # Real mode stub
movl $MEM_STUB,%edi # Destination
movl $SIZ_STUB,%ecx # Size
@@ -229,10 +229,6 @@ start.9:
#
# Output message [ESI] followed by EAX in hex.
#
-dhexout:
-#ifndef BTXLDR_VERBOSE
- ret
-#endif
hexout: pushl %eax # Save
call putstr # Display message
popl %eax # Restore
@@ -258,12 +254,6 @@ hexout.2: decl %esi # Adjust for inc
#
# Output zero-terminated string [ESI] to the console.
#
-dputstr:
-#ifndef BTXLDR_VERBOSE
- ret
-#else
- jmp putstr
-#endif
putstr.0: call putchr # Output char
putstr: lodsb # Load char
testb %al,%al # End of string?
@@ -272,10 +262,6 @@ putstr: lodsb # Load char
#
# Output character AL to the console.
#
-dputchr:
-#ifndef BTXLDR_VERBOSE
- ret
-#endif
putchr: pusha # Save
xorl %ecx,%ecx # Zero for loops
movb $SCR_MAT,%ah # Mode/attribute
@@ -351,10 +337,7 @@ gdtdesc: .word gdt.1-gdt-1 # Limit
#
# Messages.
#
-m_logo: .asciz "\nBTX loader 0.01 "
-m_vers: .asciz "BTX version is \0\n"
-e_fmt: .asciz "Error: Client format not supported\n"
-#ifdef BTXLDR_VERBOSE
+m_logo: .asciz "\nBTX loader 0.01\n"
m_mem: .asciz "Starting in protected mode (base mem=\0)\n"
m_esp: .asciz "Arguments passed (esp=\0):\n"
m_args: .asciz"<howto="
@@ -365,8 +348,10 @@ m_args: .asciz"<howto="
.asciz" bootinfo=\0>\n"
m_rel_bi: .asciz "Relocated bootinfo (size=48) to \0\n"
m_rel_args: .asciz "Relocated arguments (size=18) to \0\n"
+m_vers: .asciz "BTX version is \0\n"
m_rel_btx: .asciz "Relocated kernel (size=\0) to \0\n"
m_base: .asciz "Client base address is \0\n"
+e_fmt: .asciz "Error: Client format not supported\n"
m_elf: .asciz "Client format is ELF\n"
m_segs: .asciz "text segment: offset="
.asciz " vaddr="
@@ -377,7 +362,6 @@ m_segs: .asciz "text segment: offset="
.asciz " filesz="
.asciz " memsz=\0\n"
m_done: .asciz "Loading complete\n"
-#endif
#
# Uninitialized data area.
#
diff --git a/sys/boot/i386/btx/lib/btxv86.s b/sys/boot/i386/btx/lib/btxv86.s
index 46709a39540c8..b67e873510e58 100644
--- a/sys/boot/i386/btx/lib/btxv86.s
+++ b/sys/boot/i386/btx/lib/btxv86.s
@@ -13,7 +13,7 @@
# purpose.
#
-# $Id: btxv86.s,v 1.1 1998/09/14 10:37:00 rnordier Exp $
+# $Id:$
#
# BTX V86 interface.
@@ -48,13 +48,11 @@
#
# V86 interface function.
#
-__v86int: popl __v86ret # Save return address
- pushl $__v86 # Push pointer
+__v86int: pushl $__v86 # Push pointer
call __v86_swap # Load V86 registers
int $INT_V86 # To BTX
call __v86_swap # Load user registers
addl $0x4,%esp # Discard pointer
- pushl __v86ret # Restore return address
ret # To user
#
# Swap V86 and user registers.
@@ -82,4 +80,3 @@ __v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP
# V86 interface structure.
#
.comm __v86,SIZ_V86
- .comm __v86ret,4
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
index 2cfd2e345956a..ec22662921de5 100644
--- a/sys/boot/i386/libi386/Makefile
+++ b/sys/boot/i386/libi386/Makefile
@@ -1,39 +1,26 @@
-# $Id: Makefile,v 1.12 1998/12/22 11:51:25 abial Exp $
+# $Id: Makefile,v 1.7 1998/09/30 22:36:45 peter Exp $
#
-LIB= i386
+LIB= i386
NOPIC=
NOPROFILE=
-INTERNALLIB= true
+INTERNALLIB= true
INTERNALSTATICLIB= true
-SRCS= aout_freebsd.c biosdisk.c biosmem.c biospnp.c biospci.c \
- bootinfo.c comconsole.c devicename.c elf_freebsd.c gatea20.c \
- i386_copy.c i386_module.c time.c vidconsole.c
+SRCS= aout_freebsd.c biosdisk.c biosmem.c bootinfo.c comconsole.c \
+ devicename.c elf_freebsd.c gatea20.c i386_copy.c i386_module.c time.c vidconsole.c
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib \
-I${.CURDIR}/../../.. -I.
-BOOT_COMCONSOLE_PORT?= 0x3f8
-CFLAGS+= -DCOMPORT=${BOOT_COMCONSOLE_PORT}
-
-BOOT_COMCONSOLE_SPEED?= 9600
-CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED}
-
# Make the disk code more talkative
#CFLAGS+= -DDISK_DEBUG
-# Include simple terminal emulation (cons25-compatible)
-CFLAGS+= -DTERM_EMU
-
-# If it's not there, don't consider it a target
-.if exists(${.CURDIR}/../../../i386/include)
-beforedepend ${OBJS}: machine
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
-.endif
-
CLEANFILES+= machine
.include <bsd.lib.mk>
+
+beforedepend ${OBJS}: machine
diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c
index 8b102aefbd5d6..1337a92ac0d95 100644
--- a/sys/boot/i386/libi386/biosdisk.c
+++ b/sys/boot/i386/libi386/biosdisk.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: biosdisk.c,v 1.19 1999/01/09 02:36:19 msmith Exp $
+ * $Id: biosdisk.c,v 1.13 1998/10/11 10:01:55 peter Exp $
*/
/*
@@ -101,14 +101,10 @@ static int bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest);
static int bd_int13probe(struct bdinfo *bd);
-static void bd_printslice(struct open_disk *od, int offset, char *prefix);
-
static int bd_init(void);
static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize);
-static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize);
static int bd_open(struct open_file *f, ...);
static int bd_close(struct open_file *f);
-static void bd_print(int verbose);
struct devsw biosdisk = {
"disk",
@@ -117,8 +113,7 @@ struct devsw biosdisk = {
bd_strategy,
bd_open,
bd_close,
- noioctl,
- bd_print
+ noioctl
};
static int bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev);
@@ -174,6 +169,7 @@ bd_init(void)
/* XXX we need "disk aliases" to make this simpler */
printf("BIOS drive %c: is disk%d\n",
(unit < 0x80) ? ('A' + unit) : ('C' + unit - 0x80), nbdinfo);
+ bdinfo[nbdinfo].bd_unit = unit;
nbdinfo++;
}
}
@@ -204,91 +200,6 @@ bd_int13probe(struct bdinfo *bd)
}
/*
- * Print information about disks
- */
-static void
-bd_print(int verbose)
-{
- int i, j;
- char line[80];
- struct i386_devdesc dev;
- struct open_disk *od;
- struct dos_partition *dptr;
-
- for (i = 0; i < nbdinfo; i++) {
- sprintf(line, " disk%d: BIOS drive %c:\n", i,
- (bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit) : ('C' + bdinfo[i].bd_unit - 0x80));
- pager_output(line);
-
- /* try to open the whole disk */
- dev.d_kind.biosdisk.unit = i;
- dev.d_kind.biosdisk.slice = -1;
- dev.d_kind.biosdisk.partition = -1;
-
- if (!bd_opendisk(&od, &dev)) {
-
- /* Do we have a partition table? */
- if (od->od_flags & BD_PARTTABOK) {
- dptr = &od->od_parttab[0];
-
- /* Check for a "truly dedicated" disk */
- if ((dptr[3].dp_typ == DOSPTYP_386BSD) &&
- (dptr[3].dp_start == 0) &&
- (dptr[3].dp_size == 50000)) {
- sprintf(line, " disk%d", i);
- bd_printslice(od, 0, line);
- } else {
- for (j = 0; j < NDOSPART; j++) {
- switch(dptr[j].dp_typ) {
- case DOSPTYP_386BSD:
- sprintf(line, " disk%ds%d", i, j + 1);
- bd_printslice(od, dptr[j].dp_start, line);
- break;
- default:
- }
- }
-
- }
- }
- bd_closedisk(od);
- }
- }
-}
-
-static void
-bd_printslice(struct open_disk *od, int offset, char *prefix)
-{
- char line[80];
- u_char buf[BIOSDISK_SECSIZE];
- struct disklabel *lp;
- int i;
-
- /* read disklabel */
- if (bd_read(od, offset + LABELSECTOR, 1, buf))
- return;
- lp =(struct disklabel *)(&buf[0]);
- if (lp->d_magic != DISKMAGIC) {
- sprintf(line, "%s: bad disklabel\n");
- pager_output(line);
- return;
- }
-
- /* Print partitions */
- for (i = 0; i < lp->d_npartitions; i++) {
- if ((lp->d_partitions[i].p_fstype == FS_BSDFFS) || (lp->d_partitions[i].p_fstype == FS_SWAP) ||
- ((lp->d_partitions[i].p_fstype == FS_UNUSED) &&
- (od->od_flags & BD_FLOPPY) && (i == 0))) { /* Floppies often have bogus fstype, print 'a' */
- sprintf(line, " %s%c: %s %.6dMB (%d - %d)\n", prefix, 'a' + i,
- (lp->d_partitions[i].p_fstype == FS_SWAP) ? "swap" : "FFS",
- lp->d_partitions[i].p_size / 2048, /* 512-byte sector assumption */
- lp->d_partitions[i].p_offset, lp->d_partitions[i].p_offset + lp->d_partitions[i].p_size);
- pager_output(line);
- }
- }
-}
-
-
-/*
* Attempt to open the disk described by (dev) for use by (f).
*
* Note that the philosophy here is "give them exactly what
@@ -391,14 +302,8 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
dptr = &od->od_parttab[0];
od->od_flags |= BD_PARTTABOK;
- /* Is this a request for the whole disk? */
- if (dev->d_kind.biosdisk.slice == -1) {
- sector == 0;
- goto unsliced;
- }
-
/* Try to auto-detect the best slice; this should always give a slice number */
- if (dev->d_kind.biosdisk.slice == 0)
+ if (dev->d_kind.biosdisk.slice < 1)
dev->d_kind.biosdisk.slice = bd_bestslice(dptr);
switch (dev->d_kind.biosdisk.slice) {
@@ -406,7 +311,6 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
error = ENOENT;
goto out;
case 0:
- sector = 0;
goto unsliced;
default:
break;
@@ -570,16 +474,6 @@ bd_closedisk(struct open_disk *od)
static int
bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize)
{
- struct bcache_devdata bcd;
-
- bcd.dv_strategy = bd_realstrategy;
- bcd.dv_devdata = devdata;
- return(bcache_strategy(&bcd, rw, dblk, size, buf, rsize));
-}
-
-static int
-bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize)
-{
struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)devdata)->d_kind.biosdisk.data);
int blks;
#ifdef BD_SUPPORT_FRAGS
@@ -747,10 +641,7 @@ bd_getgeom(struct open_disk *od)
}
/*
- * Return a suitable dev_t value for (dev).
- *
- * In the case where it looks like (dev) is a SCSI disk, we allow the number of
- * IDE disks to be specified in $num_ide_disks. There should be a Better Way.
+ * Return a suitable dev_t value for (dev)
*/
int
bd_getdev(struct i386_devdesc *dev)
@@ -759,8 +650,6 @@ bd_getdev(struct i386_devdesc *dev)
int biosdev;
int major;
int rootdev;
- char *nip, *cp;
- int unitofs = 0;
biosdev = bd_unit2bios(dev->d_kind.biosdisk.unit);
DEBUG("unit %d BIOS device %d", dev->d_kind.biosdisk.unit, biosdev);
@@ -783,13 +672,6 @@ bd_getdev(struct i386_devdesc *dev)
if ((od->od_flags & BD_LABELOK) && (od->od_disklabel.d_type == DTYPE_SCSI)) {
/* label OK, disk labelled as SCSI */
major = DAMAJOR;
- /* check for unit number correction hint */
- if ((nip = getenv("num_ide_disks")) != NULL) {
- unitofs = strtol(nip, &cp, 0);
- /* check for parse error */
- if ((cp == nip) || (*cp != 0))
- unitofs = 0;
- }
} else {
/* assume an IDE disk */
major = WDMAJOR;
@@ -798,7 +680,7 @@ bd_getdev(struct i386_devdesc *dev)
rootdev = MAKEBOOTDEV(major,
(dev->d_kind.biosdisk.slice + 1) >> 4, /* XXX slices may be wrong here */
(dev->d_kind.biosdisk.slice + 1) & 0xf,
- (biosdev & 0x7f) - unitofs, /* allow for #wd compenstation in da case */
+ biosdev & 0x7f, /* XXX allow/compute shift for da when wd present */
dev->d_kind.biosdisk.partition);
DEBUG("dev is 0x%x\n", rootdev);
return(rootdev);
diff --git a/sys/boot/i386/libi386/biospci.c b/sys/boot/i386/libi386/biospci.c
deleted file mode 100644
index 92f4fd28c2972..0000000000000
--- a/sys/boot/i386/libi386/biospci.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- */
-
-/*
- * PnP enumerator using the PCI BIOS.
- */
-
-#include <stand.h>
-#include <string.h>
-#include <machine/stdarg.h>
-#include <bootstrap.h>
-#include <isapnp.h>
-#include <btxv86.h>
-
-/*
- * Stupid PCI BIOS interface doesn't let you simply enumerate everything
- * that's there, instead you have to ask it if it has something.
- *
- * So we have to scan by class code, subclass code and sometimes programming
- * interface.
- */
-
-struct pci_progif
-{
- int pi_code;
- char *pi_name;
-};
-
-static struct pci_progif progif_null[] = {
- {0x0, NULL},
- {-1, NULL}
-};
-
-static struct pci_progif progif_display[] = {
- {0x0, "VGA"},
- {0x1, "8514"},
- {-1, NULL}
-};
-
-static struct pci_progif progif_ide[] = {
- {0x00, NULL},
- {0x01, NULL},
- {0x02, NULL},
- {0x03, NULL},
- {0x04, NULL},
- {0x05, NULL},
- {0x06, NULL},
- {0x07, NULL},
- {0x08, NULL},
- {0x09, NULL},
- {0x0a, NULL},
- {0x0b, NULL},
- {0x0c, NULL},
- {0x0d, NULL},
- {0x0e, NULL},
- {0x0f, NULL},
- {0x80, NULL},
- {0x81, NULL},
- {0x82, NULL},
- {0x83, NULL},
- {0x84, NULL},
- {0x85, NULL},
- {0x86, NULL},
- {0x87, NULL},
- {0x88, NULL},
- {0x89, NULL},
- {0x8a, NULL},
- {0x8b, NULL},
- {0x8c, NULL},
- {0x8d, NULL},
- {0x8e, NULL},
- {0x8f, NULL},
- {-1, NULL}
-};
-
-static struct pci_progif progif_serial[] = {
- {0x0, "8250"},
- {0x1, "16450"},
- {0x2, "16550"},
- {-1, NULL}
-};
-
-static struct pci_progif progif_parallel[] = {
- {0x0, "Standard"},
- {0x1, "Bidirectional"},
- {0x2, "ECP"},
- {-1, NULL}
-};
-
-
-struct pci_subclass
-{
- int ps_subclass;
- char *ps_name;
- struct pci_progif *ps_progif; /* if set, use for programming interface value(s) */
-};
-
-static struct pci_subclass subclass_old[] = {
- {0x0, "Old non-VGA", progif_null},
- {0x1, "Old VGA", progif_null},
- {-1, NULL, NULL}
-};
-
-static struct pci_subclass subclass_mass[] = {
- {0x0, "SCSI", progif_null},
- {0x1, "IDE", progif_ide},
- {0x2, "Floppy disk", progif_null},
- {0x3, "IPI", progif_null},
- {0x4, "RAID", progif_null},
- {0x80, "mass storage", progif_null},
- {-1, NULL, NULL}
-};
-
-static struct pci_subclass subclass_net[] = {
- {0x0, "Ethernet", progif_null},
- {0x1, "Token ring", progif_null},
- {0x2, "FDDI", progif_null},
- {0x3, "ATM", progif_null},
- {0x80, "network", progif_null},
- {-1, NULL, NULL}
-};
-
-static struct pci_subclass subclass_display[] = {
- {0x0, NULL, progif_display},
- {0x1, "XGA", progif_null},
- {0x80, "other", progif_null},
- {-1, NULL, NULL}
-};
-
-static struct pci_subclass subclass_comms[] = {
- {0x0, "serial", progif_serial},
- {0x1, "parallel", progif_parallel},
- {0x80, "communications", progif_null},
- {-1, NULL, NULL}
-};
-
-static struct pci_subclass subclass_serial[] = {
- {0x0, "Firewire", progif_null},
- {0x1, "ACCESS.bus", progif_null},
- {0x2, "SSA", progif_null},
- {0x3, "USB", progif_null},
- {0x4, "Fibrechannel", progif_null},
- {-1, NULL, NULL}
-};
-
-static struct pci_class
-{
- int pc_class;
- char *pc_name;
- struct pci_subclass *pc_subclass;
-} pci_classes[] = {
- {0x0, "device", subclass_old},
- {0x1, "controller", subclass_mass},
- {0x2, "controller", subclass_net},
- {0x3, "display", subclass_display},
- {0x7, "controller", subclass_comms},
- {0xc, "controller", subclass_serial},
- {-1, NULL, NULL}
-};
-
-
-static void biospci_enumerate(void);
-static void biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc, struct pci_progif *ppi);
-
-static int biospci_version;
-static int biospci_hwcap;
-
-struct pnphandler biospcihandler =
-{
- "PCI BIOS",
- biospci_enumerate
-};
-
-static void
-biospci_enumerate(void)
-{
- int index, locator, devid;
- struct pci_class *pc;
- struct pci_subclass *psc;
- struct pci_progif *ppi;
-
- /* Find the PCI BIOS */
- v86.ctl = V86_FLAGS;
- v86.addr = 0x1a;
- v86.eax = 0xb101;
- v86.edi = 0x0;
- v86int();
-
- /* Check for OK response */
- if ((v86.efl & 1) || ((v86.eax & 0xff00) != 0) || (v86.edx != 0x20494350))
- return;
-
- biospci_version = v86.ebx & 0xffff;
- biospci_hwcap = v86.eax & 0xff;
-#if 0
- printf("PCI BIOS %d.%d%s%s\n",
- bcd2bin((biospci_version >> 8) & 0xf), bcd2bin(biospci_version & 0xf),
- (biospci_hwcap & 1) ? " config1" : "", (biospci_hwcap & 2) ? " config2" : "");
-#endif
- /* Iterate over known classes */
- for (pc = pci_classes; pc->pc_class >= 0; pc++) {
- /* Iterate over subclasses */
- for (psc = pc->pc_subclass; psc->ps_subclass >= 0; psc++) {
- /* Iterate over programming interfaces */
- for (ppi = psc->ps_progif; ppi->pi_code >= 0; ppi++) {
-
- /* Scan for matches */
- for (index = 0; ; index++) {
-
- /* Look for a match */
- v86.ctl = V86_FLAGS;
- v86.addr = 0x1a;
- v86.eax = 0xb103;
- v86.ecx = (pc->pc_class << 16) + (psc->ps_subclass << 8) + ppi->pi_code;
- v86.esi = index;
- v86int();
- /* error/end of matches */
- if ((v86.efl & 1) || (v86.eax & 0xff00))
- break;
-
- /* Got something */
- locator = v86.ebx;
-
- /* Read the device identifier from the nominated device */
- v86.ctl = V86_FLAGS;
- v86.addr = 0x1a;
- v86.eax = 0xb10a;
- v86.ebx = locator;
- v86.edi = 0x0;
- v86int();
- /* error */
- if ((v86.efl & 1) || (v86.eax & 0xff00))
- break;
-
- /* We have the device ID, create a PnP object and save everything */
- devid = v86.ecx;
- biospci_addinfo(devid, pc, psc, ppi);
- }
- }
- }
- }
-}
-
-static void
-biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc, struct pci_progif *ppi)
-{
- struct pnpinfo *pi;
- char desc[80];
-
-
- /* build the description */
- desc[0] = 0;
- if (ppi->pi_name != NULL) {
- strcat(desc, ppi->pi_name);
- strcat(desc, " ");
- }
- if (psc->ps_name != NULL) {
- strcat(desc, psc->ps_name);
- strcat(desc, " ");
- }
- if (pc->pc_name != NULL)
- strcat(desc, pc->pc_name);
-
- pi = pnp_allocinfo();
- pi->pi_desc = strdup(desc);
- sprintf(desc,"0x%08x", devid);
- pnp_addident(pi, desc);
- pnp_addinfo(pi);
-}
diff --git a/sys/boot/i386/libi386/biospnp.c b/sys/boot/i386/libi386/biospnp.c
deleted file mode 100644
index a6064ba27462c..0000000000000
--- a/sys/boot/i386/libi386/biospnp.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: biospnp.c,v 1.2 1998/10/23 22:29:08 msmith Exp $
- */
-
-/*
- * PnP BIOS enumerator.
- */
-
-#include <stand.h>
-#include <string.h>
-#include <machine/stdarg.h>
-#include <bootstrap.h>
-#include <isapnp.h>
-#include <btxv86.h>
-
-
-static int biospnp_init(void);
-static void biospnp_enumerate(void);
-
-struct pnphandler biospnphandler =
-{
- "PnP BIOS",
- biospnp_enumerate
-};
-
-struct pnp_ICstructure
-{
- u_int8_t pnp_signature[4] __attribute__ ((packed));
- u_int8_t pnp_version __attribute__ ((packed));
- u_int8_t pnp_length __attribute__ ((packed));
- u_int16_t pnp_BIOScontrol __attribute__ ((packed));
- u_int8_t pnp_checksum __attribute__ ((packed));
- u_int32_t pnp_eventflag __attribute__ ((packed));
- u_int16_t pnp_rmip __attribute__ ((packed));
- u_int16_t pnp_rmcs __attribute__ ((packed));
- u_int16_t pnp_pmip __attribute__ ((packed));
- u_int32_t pnp_pmcs __attribute__ ((packed));
- u_int8_t pnp_OEMdev[4] __attribute__ ((packed));
- u_int16_t pnp_rmds __attribute__ ((packed));
- u_int32_t pnp_pmds __attribute__ ((packed));
-};
-
-struct pnp_devNode
-{
- u_int16_t dn_size __attribute__ ((packed));
- u_int8_t dn_handle __attribute__ ((packed));
- u_int8_t dn_id[4] __attribute__ ((packed));
- u_int8_t dn_type[3] __attribute__ ((packed));
- u_int16_t dn_attrib __attribute__ ((packed));
- u_int8_t dn_data[0] __attribute__ ((packed));
-};
-
-struct pnp_isaConfiguration
-{
- u_int8_t ic_revision __attribute__ ((packed));
- u_int8_t ic_nCSN __attribute__ ((packed));
- u_int16_t ic_rdport __attribute__ ((packed));
- u_int16_t ic_reserved __attribute__ ((packed));
-};
-
-static struct pnp_ICstructure *pnp_Icheck = NULL;
-static u_int16_t pnp_NumNodes;
-static u_int16_t pnp_NodeSize;
-
-static void biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn);
-static int biospnp_call(int func, char *fmt, ...);
-
-#define vsegofs(vptr) (((u_int32_t)VTOPSEG(vptr) << 16) + VTOPOFF(vptr))
-void (* v86bios)(u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3) = (void *)v86int;
-
-#define biospnp_f00(NumNodes, NodeSize) biospnp_call(0x00, "ll", NumNodes, NodeSize)
-#define biospnp_f01(Node, devNodeBuffer, Control) biospnp_call(0x01, "llw", Node, devNodeBuffer, Control)
-#define biospnp_f40(Configuration) biospnp_call(0x40, "l", Configuration)
-
-/* PnP BIOS return codes */
-#define PNP_SUCCESS 0x00
-#define PNP_FUNCTION_NOT_SUPPORTED 0x80
-
-/*
- * Initialisation: locate the PnP BIOS, test that we can call it.
- * Returns nonzero if the PnP BIOS is not usable on this system.
- */
-static int
-biospnp_init(void)
-{
- struct pnp_isaConfiguration icfg;
- char *sigptr;
- int result;
-
- /* Search for the $PnP signature */
- pnp_Icheck = NULL;
- for (sigptr = PTOV(0xf0000); sigptr < PTOV(0xfffff); sigptr += 16)
- if (!bcmp(sigptr, "$PnP", 4)) {
- pnp_Icheck = (struct pnp_ICstructure *)sigptr;
- break;
- }
-
- /* No signature, no BIOS */
- if (pnp_Icheck == NULL)
- return(1);
-
- /*
- * Fetch the system table parameters as a test of the BIOS
- */
- result = biospnp_f00(vsegofs(&pnp_NumNodes), vsegofs(&pnp_NodeSize));
- if (result != PNP_SUCCESS) {
- return(1);
- }
-
- /*
- * Look for the PnP ISA configuration table
- */
- result = biospnp_f40(vsegofs(&icfg));
- switch (result) {
- case PNP_SUCCESS:
- /* If the BIOS found some PnP devices, take its hint for the read port */
- if ((icfg.ic_revision == 1) && (icfg.ic_nCSN > 0))
- isapnp_readport = icfg.ic_rdport;
- break;
- case PNP_FUNCTION_NOT_SUPPORTED:
- /* The BIOS says there is no ISA bus (should we trust that this works?) */
- printf("PnP BIOS claims no ISA bus\n");
- isapnp_readport = -1;
- break;
- }
- return(0);
-}
-
-static void
-biospnp_enumerate(void)
-{
- u_int8_t Node;
- struct pnp_devNode *devNodeBuffer;
- int result;
- struct pnpinfo *pi;
- int count;
-
- /* Init/check state */
- if (biospnp_init())
- return;
-
- devNodeBuffer = (struct pnp_devNode *)malloc(pnp_NodeSize);
- Node = 0;
- count = 1000;
- while((Node != 0xff) && (count-- > 0)) {
- result = biospnp_f01(vsegofs(&Node), vsegofs(devNodeBuffer), 0x1);
- if (result != PNP_SUCCESS) {
- printf("PnP BIOS node %d: error 0x%x\n", Node, result);
- } else {
- pi = pnp_allocinfo();
- pnp_addident(pi, pnp_eisaformat(devNodeBuffer->dn_id));
- biospnp_scanresdata(pi, devNodeBuffer);
- pnp_addinfo(pi);
- }
- }
-}
-
-/*
- * Scan the resource data in the node's data area for compatible device IDs
- * and descriptions.
- */
-static void
-biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn)
-{
- int tag, i, rlen, dlen;
- u_int8_t *p;
- char *str;
-
- p = dn->dn_data; /* point to resource data */
- dlen = dn->dn_size - (p - (u_int8_t *)dn); /* length of resource data */
-
- for (i = 0; i < dlen; i+= rlen) {
- tag = p[i];
- i++;
- if (PNP_RES_TYPE(tag) == 0) {
- rlen = PNP_SRES_LEN(tag);
- /* small resource */
- switch (PNP_SRES_NUM(tag)) {
-
- case COMP_DEVICE_ID:
- /* got a compatible device ID */
- pnp_addident(pi, pnp_eisaformat(p + i));
- break;
-
- case END_TAG:
- return;
- }
- } else {
- /* large resource */
- rlen = *(u_int16_t *)(p + i);
- i += sizeof(u_int16_t);
-
- switch(PNP_LRES_NUM(tag)) {
-
- case ID_STRING_ANSI:
- str = malloc(rlen + 1);
- bcopy(p + i, str, rlen);
- str[rlen] = 0;
- if (pi->pi_desc == NULL) {
- pi->pi_desc = str;
- } else {
- free(str);
- }
- break;
- }
- }
- }
-}
-
-
-/*
- * Make a 16-bit realmode PnP BIOS call.
- *
- * The first argument passed is the function number, the last is the
- * BIOS data segment selector. Intermediate arguments may be 16 or
- * 32 bytes in length, and are described by the format string.
- *
- * Arguments to the BIOS functions must be packed on the stack, hence
- * this evil.
- */
-static int
-biospnp_call(int func, char *fmt, ...)
-{
- va_list ap;
- char *p;
- u_int8_t *argp;
- u_int32_t args[4];
- u_int32_t i;
-
- /* function number first */
- argp = (u_int8_t *)args;
- *(u_int16_t *)argp = func;
- argp += sizeof(u_int16_t);
-
- /* take args according to format */
- va_start(ap, fmt);
- for (p = fmt; *p != 0; p++) {
- switch(*p) {
-
- case 'w':
- i = va_arg(ap, u_int16_t);
- *(u_int16_t *)argp = i;
- argp += sizeof(u_int16_t);
- break;
-
- case 'l':
- i = va_arg(ap, u_int32_t);
- *(u_int32_t *)argp = i;
- argp += sizeof(u_int32_t);
- break;
- }
- }
-
- /* BIOS segment last */
- *(u_int16_t *)argp = pnp_Icheck->pnp_rmds;
- argp += sizeof(u_int16_t);
-
- /* prepare for call */
- v86.ctl = V86_ADDR | V86_CALLF;
- v86.addr = ((u_int32_t)pnp_Icheck->pnp_rmcs << 16) + pnp_Icheck->pnp_rmip;
-
- /* call with packed stack and return */
- v86bios(args[0], args[1], args[2], args[3]);
- return(v86.eax & 0xffff);
-}
diff --git a/sys/boot/i386/libi386/bootinfo.c b/sys/boot/i386/libi386/bootinfo.c
index 77ba8b75a83a6..5b479cd3446e5 100644
--- a/sys/boot/i386/libi386/bootinfo.c
+++ b/sys/boot/i386/libi386/bootinfo.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bootinfo.c,v 1.14 1998/10/15 17:06:36 peter Exp $
+ * $Id: bootinfo.c,v 1.13 1998/10/14 05:07:23 peter Exp $
*/
#include <stand.h>
@@ -249,7 +249,9 @@ bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
printf("can't determine root device\n");
return(EINVAL);
}
-
+
+ /* Boot from whatever the current device is */
+ i386_getdev((void **)(&rootdev), NULL, NULL);
switch(rootdev->d_type) {
case DEVT_DISK:
/* pass in the BIOS device number of the current disk */
diff --git a/sys/boot/i386/libi386/comconsole.c b/sys/boot/i386/libi386/comconsole.c
index 7b35d1dce8c97..261e909d225b8 100644
--- a/sys/boot/i386/libi386/comconsole.c
+++ b/sys/boot/i386/libi386/comconsole.c
@@ -22,45 +22,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: comconsole.c,v 1.5 1998/11/22 07:59:16 rnordier Exp $
+ * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp
+ *
+ * $Id: comconsole.c,v 1.3 1998/10/02 16:32:45 msmith Exp $
*/
#include <stand.h>
#include <bootstrap.h>
-#include <machine/cpufunc.h>
+#include <btxv86.h>
#include "libi386.h"
-/* selected defines from ns16550.h */
-#define com_data 0 /* data register (R/W) */
-#define com_dlbl 0 /* divisor latch low (W) */
-#define com_dlbh 1 /* divisor latch high (W) */
-#define com_ier 1 /* interrupt enable (W) */
-#define com_iir 2 /* interrupt identification (R) */
-#define com_fifo 2 /* FIFO control (W) */
-#define com_lctl 3 /* line control register (R/W) */
-#define com_cfcr 3 /* line control register (R/W) */
-#define com_mcr 4 /* modem control register (R/W) */
-#define com_lsr 5 /* line status register (R/W) */
-#define com_msr 6 /* modem status register (R/W) */
-
-/* selected defines from sioreg.h */
-#define CFCR_DLAB 0x80
-#define MCR_RTS 0x02
-#define MCR_DTR 0x01
-#define LSR_TXRDY 0x20
-#define LSR_RXRDY 0x01
-
-#define COMC_FMT 0x3 /* 8N1 */
-#define COMC_TXWAIT 0x40000 /* transmit timeout */
-#define COMC_BPS(x) (115200 / (x)) /* speed to DLAB divisor */
-
-#ifndef COMPORT
-#define COMPORT 0x3f8
-#endif
-#ifndef COMSPEED
-#define COMSPEED 9600
-#endif
-
static void comc_probe(struct console *cp);
static int comc_init(int arg);
static void comc_putchar(int c);
@@ -71,7 +42,7 @@ static int comc_started;
struct console comconsole = {
"comconsole",
- "serial port",
+ "BIOS serial port",
0,
comc_probe,
comc_init,
@@ -80,6 +51,8 @@ struct console comconsole = {
comc_ischar
};
+#define BIOS_COMPORT 0
+
static void
comc_probe(struct console *cp)
{
@@ -90,19 +63,19 @@ comc_probe(struct console *cp)
static int
comc_init(int arg)
{
+ int i;
+
if (comc_started && arg == 0)
return 0;
comc_started = 1;
+ v86.ctl = 0;
+ v86.addr = 0x14;
+ v86.eax = 0xe3; /* 9600N81 */
+ v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
+ v86int();
- outb(COMPORT + com_cfcr, CFCR_DLAB | COMC_FMT);
- outb(COMPORT + com_dlbl, COMC_BPS(COMSPEED) & 0xff);
- outb(COMPORT + com_dlbh, COMC_BPS(COMSPEED) >> 8);
- outb(COMPORT + com_cfcr, COMC_FMT);
- outb(COMPORT + com_mcr, MCR_RTS | MCR_DTR);
-
- do
- inb(COMPORT + com_data);
- while (inb(COMPORT + com_lsr) & LSR_RXRDY);
+ for(i = 0; i < 10 && comc_ischar(); i++)
+ (void)comc_getchar();
return(0);
}
@@ -110,23 +83,35 @@ comc_init(int arg)
static void
comc_putchar(int c)
{
- int wait;
-
- for (wait = COMC_TXWAIT; wait > 0; wait--)
- if (inb(COMPORT + com_lsr) & LSR_TXRDY) {
- outb(COMPORT + com_data, c);
- break;
- }
+ v86.ctl = 0;
+ v86.addr = 0x14;
+ v86.eax = 0x100 | c; /* Function 1 = write */
+ v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
+ v86int();
}
static int
comc_getchar(void)
{
- return(comc_ischar() ? inb(COMPORT + com_data) : -1);
+ if (comc_ischar()) {
+ v86.ctl = 0;
+ v86.addr = 0x14;
+ v86.eax = 0x200; /* Function 2 = read */
+ v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
+ v86int();
+ return(v86.eax & 0xff);
+ } else {
+ return(-1);
+ }
}
static int
comc_ischar(void)
{
- return(inb(COMPORT + com_lsr) & LSR_RXRDY);
+ v86.ctl = 0;
+ v86.addr = 0x14;
+ v86.eax = 0x300; /* Function 3 = status */
+ v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */
+ v86int();
+ return(v86.eax & 0x100); /* AH bit 1 is "receive data ready" */
}
diff --git a/sys/boot/i386/libi386/vidconsole.c b/sys/boot/i386/libi386/vidconsole.c
index 05e77110c2efa..c67cd72061b52 100644
--- a/sys/boot/i386/libi386/vidconsole.c
+++ b/sys/boot/i386/libi386/vidconsole.c
@@ -26,7 +26,7 @@
*
* From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp
*
- * $Id: vidconsole.c,v 1.10 1998/12/31 13:44:04 abial Exp $
+ * $Id: vidconsole.c,v 1.5 1998/10/07 07:34:31 msmith Exp $
*/
#include <stand.h>
@@ -48,28 +48,6 @@ static int vidc_ischar(void);
static int vidc_started;
-#ifdef TERM_EMU
-void end_term();
-void bail_out(int c);
-void vidc_term_emu(int c);
-void get_pos(void);
-void curs_move(int x, int y);
-void write_char(int c, int fg, int bg);
-void scroll_up(int rows, int fg, int bg);
-void AB(void);
-void AF(void);
-void CD(void);
-void CM(void);
-void HO(void);
-void ME(void);
-
-static int args[2],argc,br;
-static int fg,bg,dig;
-static int fg_c,bg_c,curx,cury;
-static int esc;
-#endif
-
-
struct console vidconsole = {
"vidconsole",
"internal video/keyboard",
@@ -106,390 +84,21 @@ vidc_init(int arg)
if (vidc_started && arg == 0)
return;
vidc_started = 1;
-#ifdef TERM_EMU
- /* Init terminal emulator */
- end_term();
- get_pos();
- curs_move(curx,cury);
- fg_c=7;
- bg_c=0;
-#endif
for(i = 0; i < 10 && vidc_ischar(); i++)
(void)vidc_getchar();
return(0); /* XXX reinit? */
}
static void
-vidc_biosputchar(int c)
+vidc_putchar(int c)
{
v86.ctl = 0;
v86.addr = 0x10;
- v86.eax = 0xe00 | (c & 0xff);
+ v86.eax = 0xe00 | c;
v86.ebx = 0x7;
v86int();
}
-static void
-vidc_rawputchar(int c)
-{
- int i;
-
- if(c == '\t')
- /* lame tab expansion */
- for (i = 0; i < 8; i++)
- vidc_rawputchar(' ');
- else {
-#ifndef TERM_EMU
- vidc_biosputchar(c);
-#else
- /* Emulate AH=0eh (teletype output) */
- switch(c) {
- case '\a':
- vidc_biosputchar(c);
- return;
- case '\r':
- curx=0;
- curs_move(curx,cury);
- return;
- case '\n':
- cury++;
- if(cury>24) {
- scroll_up(1,fg_c,bg_c);
- cury--;
- } else {
- curs_move(curx,cury);
- }
- return;
- case '\b':
- if(curx>0) {
- curx--;
- curs_move(curx,cury);
- /* write_char(' ',fg_c,bg_c); XXX destructive(!) */
- return;
- }
- return;
- default:
- write_char(c,fg_c,bg_c);
- curx++;
- if(curx>79) {
- curx=0;
- cury++;
- }
- if(cury>24) {
- curx=0;
- scroll_up(1,fg_c,bg_c);
- cury--;
- }
- }
- curs_move(curx,cury);
-#endif
- }
-}
-
-#ifdef TERM_EMU
-
-/* Get cursor position on the screen. Result is in edx. Sets
- * curx and cury appropriately.
- */
-void
-get_pos(void)
-{
- v86.ctl = 0;
- v86.addr = 0x10;
- v86.eax = 0x0300;
- v86.ebx = 0x0;
- v86int();
- curx=v86.edx & 0x00ff;
- cury=(v86.edx & 0xff00)>>8;
-}
-
-/* Move cursor to x rows and y cols (0-based). */
-void
-curs_move(int x, int y)
-{
- v86.ctl = 0;
- v86.addr = 0x10;
- v86.eax = 0x0200;
- v86.ebx = 0x0;
- v86.edx = ((0x00ff & y)<<8)+(0x00ff & x);
- v86int();
- curx=x;
- cury=y;
- /* If there is ctrl char at this position, cursor would be invisible.
- * Make it a space instead.
- */
- v86.ctl=0;
- v86.addr = 0x10;
- v86.eax = 0x0800;
- v86.ebx= 0x0;
- v86int();
-#define isvisible(c) (((c)>32) && ((c)<255))
- if(!isvisible(v86.eax & 0x00ff)) {
- write_char(' ',fg_c,bg_c);
- }
-}
-
-/* Scroll up the whole window by a number of rows. If rows==0,
- * clear the window. fg and bg are attributes for the new lines
- * inserted in the window.
- */
-void
-scroll_up(int rows, int fg, int bg)
-{
- if(rows==0) rows=25;
- v86.ctl = 0;
- v86.addr = 0x10;
- v86.eax = 0x0600+(0x00ff & rows);
- v86.ebx = (bg<<12)+(fg<<8);
- v86.ecx = 0x0;
- v86.edx = 0x184f;
- v86int();
-}
-
-/* Write character and attribute at cursor position. */
-void
-write_char(int c, int fg, int bg)
-{
- v86.ctl=0;
- v86.addr = 0x10;
- v86.eax = 0x0900+(0x00ff & c);
- v86.ebx = (bg<<4)+fg;
- v86.ecx = 0x1;
- v86int();
-}
-
-/* Calculate power of 10 */
-int
-pow10(int i)
-{
- int res=1;
-
- while(i-->0) {
- res*=10;
- }
- return res;
-}
-
-/**************************************************************/
-/*
- * Screen manipulation functions. They use accumulated data in
- * args[] and argc variables.
- *
- */
-
-/* Set background color */
-void
-AB(void){
- bg_c=args[0];
- end_term();
-}
-
-/* Set foreground color */
-void
-AF(void)
-{
- fg_c=args[0];
- end_term();
-}
-
-/* Clear display from current position to end of screen */
-void
-CD(void)
-{
- get_pos();
- v86.ctl = 0;
- v86.addr = 0x10;
- v86.eax = 0x0600;
- v86.ebx = (bg_c<<4)+fg_c;
- v86.ecx = v86.edx;
- v86.edx = 0x184f;
- v86int();
- curx=0;
- curs_move(curx,cury);
- end_term();
-}
-
-/* Absolute cursor move to args[0] rows and args[1] columns
- * (the coordinates are 1-based).
- */
-void
-CM(void)
-{
- if(args[0]>0) args[0]--;
- if(args[1]>0) args[1]--;
- curs_move(args[1],args[0]);
- end_term();
-}
-
-/* Home cursor (left top corner) */
-void
-HO(void)
-{
- argc=1;
- args[0]=args[1]=1;
- CM();
-}
-
-/* Exit attribute mode (reset fore/back-ground colors to defaults) */
-void
-ME(void)
-{
- fg_c=7;
- bg_c=0;
- end_term();
-}
-
-/* Clear internal state of the terminal emulation code */
-void
-end_term(void)
-{
- esc=0;
- argc=-1;
- fg=bg=br=0;
- args[0]=args[1]=0;
- dig=0;
-}
-
-/* Gracefully exit ESC-sequence processing in case of misunderstanding */
-void
-bail_out(int c)
-{
- char buf[6],*ch;
-
- if(esc) vidc_rawputchar('\033');
- if(br) vidc_rawputchar('[');
- if(argc>-1) {
- sprintf(buf,"%d",args[0]);
- ch=buf;
- while(*ch) vidc_rawputchar(*ch++);
-
- if(argc>0) {
- vidc_rawputchar(';');
- sprintf(buf,"%d",args[1]);
- ch=buf;
- while(*ch) vidc_rawputchar(*ch++);
- }
- }
- vidc_rawputchar(c);
- end_term();
-}
-
-/* Emulate basic capabilities of cons25 terminal */
-void
-vidc_term_emu(int c)
-{
-
- if(!esc) {
- if(c=='\033') {
- esc=1;
- } else {
- vidc_rawputchar(c);
- }
- return;
- }
-
- /* Do ESC sequences processing */
- switch(c) {
- case '\033':
- /* ESC in ESC sequence - error */
- bail_out(c);
- break;
- case '[':
- /* Check if it's first char after ESC */
- if(argc<0) {
- br=1;
- } else {
- bail_out(c);
- }
- break;
- case 'H':
- /* Emulate \E[H (cursor home) and
- * \E%d;%dH (cursor absolute move) */
- if(br) {
- switch(argc) {
- case -1:
- HO();
- break;
- case 1:
- if(fg) args[0]+=pow10(dig)*3;
- if(bg) args[0]+=pow10(dig)*4;
- CM();
- break;
- default:
- bail_out(c);
- }
- } else bail_out(c);
- break;
- case 'J':
- /* Emulate \EJ (clear to end of screen) */
- if(br && argc<0) {
- CD();
- } else bail_out(c);
- break;
- case ';':
- /* perhaps args separator */
- if(br && (argc>-1)) {
- argc++;
- } else bail_out(c);
- break;
- case 'm':
- /* Change char attributes */
- if(br) {
- switch(argc) {
- case -1:
- ME();
- break;
- case 0:
- if(fg) AF();
- else AB();
- break;
- default:
- bail_out(c);
- }
- } else bail_out(c);
- break;
- default:
- if(isdigit(c)) {
- /* Carefully collect numeric arguments */
- /* XXX this is ugly. */
- if(br) {
- if(argc==-1) {
- argc=0;
- args[argc]=0;
- dig=0;
- /* in case we're in error... */
- if(c=='3') {
- fg=1;
- return;
- }
- if(c=='4') {
- bg=1;
- return;
- }
- args[argc]=(int)(c-'0');
- dig=1;
- args[argc+1]=0;
- } else {
- args[argc]=args[argc]*10+(int)(c-'0');
- if(argc==0) dig++;
- }
- } else bail_out(c);
- } else bail_out(c);
- break;
- }
-}
-#endif
-
-static void
-vidc_putchar(int c)
-{
-#ifdef TERM_EMU
- vidc_term_emu(c);
-#else
- vidc_rawputchar(c);
-#endif
-}
-
static int
vidc_getchar(void)
{
@@ -511,7 +120,9 @@ vidc_ischar(void)
v86.addr = 0x16;
v86.eax = 0x100;
v86int();
- return(!(v86.efl & PSL_Z));
+ if (!(v86.efl & PSL_Z))
+ return(v86.eax & 0xff);
+ return(0);
}
#if KEYBOARD_PROBE
@@ -537,7 +148,7 @@ static void
delay7(void)
{
/*
- * I know this is broken, but no timer is available yet at this stage...
+ * I know this is broken, but no timer is avaiable yet at this stage...
* See also comments in `delay1ms()'.
*/
inb(IO_DUMMY); inb(IO_DUMMY);
diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile
index 053fbd3488620..02fd2d005a1a8 100644
--- a/sys/boot/i386/loader/Makefile
+++ b/sys/boot/i386/loader/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.27 1999/01/11 05:52:28 msmith Exp $
+# $Id: Makefile,v 1.11 1998/10/12 01:03:00 rnordier Exp $
BASE= loader
PROG= ${BASE}
@@ -11,17 +11,8 @@ BINDIR?= /boot
SRCS= main.c conf.c
# Enable PnP and ISA-PnP code.
-HAVE_PNP= yes
-HAVE_ISABUS= yes
-
-# Enable BootForth
-BOOT_FORTH= yes
-CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl
-.if exists(${.OBJDIR}/../../ficl/libficl.a)
-LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
-.else
-LIBFICL= ${.CURDIR}/../../ficl/libficl.a
-.endif
+#HAVE_PNP= yes
+#HAVE_ISABUS= yes
# Always add MI sources
.PATH: ${.CURDIR}/../../common
@@ -29,7 +20,8 @@ LIBFICL= ${.CURDIR}/../../ficl/libficl.a
CFLAGS+= -I${.CURDIR}/../../common
CFLAGS+= -I${.CURDIR}/../../.. -I.
-CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
+CLEANFILES+= vers.c vers.o ${BASE}.list setdef0.o setdef1.o setdefs.h \
+ gensetdefs.o gensetdefs ${BASE}.bin
CFLAGS+= -Wall
LDFLAGS= -nostdlib -static -Ttext 0x1000
@@ -57,9 +49,6 @@ CFLAGS+= -I${.CURDIR}/../btx/lib
# BTX is expecting ELF components
CFLAGS+= -elf
-# New linker set code
-CFLAGS+= -DNEW_LINKER_SET
-
# Debug me!
#CFLAGS+= -g
#LDFLAGS+= -g
@@ -68,47 +57,34 @@ vers.o:
sh ${.CURDIR}/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
${CC} -c vers.c
-${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT} ${BASE}.help
+${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN}
btxld -v -f aout -e 0x100000 -o ${.TARGET} -l ${BTXLDR} -b ${BTXKERN} \
${BASE}.bin
-# /usr/bin/kzip ${.TARGET}
-# mv ${.TARGET}.kz ${.TARGET}
-
-${BASE}.bin: ${BASE}.sym
- cp ${.ALLSRC} ${.TARGET}
- strip ${.TARGET}
-
-${BASE}.help: help.common help.i386
- cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
-
-beforeinstall:
-.if exists(${DESTDIR}/boot/loader)
- mv ${DESTDIR}/boot/loader ${DESTDIR}/boot/loader.old
-.endif
-.if exists(${.OBJDIR}/loader.help)
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
-.else
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${.CURDIR}/${BASE}.help ${DESTDIR}/boot
-.endif
-# Cannot use ${OBJS} above this line
-.include <bsd.prog.mk>
+${BASE}.bin: ${OBJS} ${LIBI386} vers.o setdef0.o setdef1.o
+ ${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} setdef0.o ${OBJS} vers.o setdef1.o \
+ ${LIBSTAND} ${LIBI386} ${LIBSTAND}
-${BASE}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o
- ${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \
- ${LIBFICL} ${LIBSTAND} ${LIBI386} ${LIBSTAND}
+setdef0.o: setdefs.h
-# If it's not there, don't consider it a target
-.if exists(${.CURDIR}/../../../i386/include)
-beforedepend ${OBJS}: machine
+setdef1.o: setdefs.h
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
-.endif
-
CLEANFILES+= machine
+.include <bsd.prog.mk>
+# Linker set gymnastics
+setdefs.h: gensetdefs ${OBJS}
+ @echo Generating linker sets
+ @./gensetdefs ${OBJS} >setdefs.h
+
+gensetdefs: gensetdefs.o
+ ${CC} -static gensetdefs.o -o $@
+
+gensetdefs.o: gensetdefs.c
+ ${CC} -c $<
+
+beforedepend ${OBJS}: machine
diff --git a/sys/boot/i386/loader/conf.c b/sys/boot/i386/loader/conf.c
index 9b4d554bc1a03..d39d67f33873d 100644
--- a/sys/boot/i386/loader/conf.c
+++ b/sys/boot/i386/loader/conf.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: conf.c,v 1.9 1998/10/22 20:23:58 msmith Exp $
+ * $Id: conf.c,v 1.6 1998/09/30 19:48:42 peter Exp $
*/
#include <stand.h>
@@ -85,12 +85,10 @@ struct console *consoles[] = {
};
extern struct pnphandler isapnphandler;
-extern struct pnphandler biospnphandler;
-extern struct pnphandler biospcihandler;
+/* extern struct pnphandler pcipnphandler;*/
struct pnphandler *pnphandlers[] = {
- &biospnphandler, /* should go first, as it may set isapnp_readport */
- &isapnphandler,
- &biospcihandler,
+/* &isapnphandler, */
+/* &pcipnphandler, */
NULL
};
diff --git a/sys/boot/i386/loader/help.i386 b/sys/boot/i386/loader/help.i386
deleted file mode 100644
index 81288250ade0e..0000000000000
--- a/sys/boot/i386/loader/help.i386
+++ /dev/null
@@ -1,34 +0,0 @@
-################################################################################
-# Treboot DReboot the system
-
- reboot
-
- Causes the system to immediately reboot.
-
-################################################################################
-# Theap DDisplay memory management statistics
-
- heap
-
- Requests debugging output from the heap manager. For debugging use
- only.
-
-################################################################################
-# Tset Snum_ide_disks DSet the number of IDE disks
-
- set num_ide_disks=<value>
-
- When booting from a SCSI disk on a system with one or more IDE disks,
- and where the IDE disks are the default boot device, it is necessary
- to tell the kernel how many IDE disks there are in order to have it
- correctly locate the SCSI disk you are booting from.
-
-################################################################################
-# Tset Sboot_userconfig DStart Userconfig
-
- set boot_userconfig
-
- Requests that the kernel's interactive device configuration program
- be run when the kernel is booted.
-
-################################################################################
diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c
index dfd1bfffbb98c..b9e93f49b357e 100644
--- a/sys/boot/i386/loader/main.c
+++ b/sys/boot/i386/loader/main.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: main.c,v 1.13 1998/10/22 20:23:58 msmith Exp $
+ * $Id: main.c,v 1.10 1998/10/03 18:27:50 rnordier Exp $
*/
/*
@@ -58,8 +58,6 @@ static struct bootinfo *initial_bootinfo;
struct arch_switch archsw; /* MI/MD interface boundary */
static void extract_currdev(void);
-static int isa_inb(int port);
-static void isa_outb(int port, int value);
/* from vers.c */
extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
@@ -98,11 +96,6 @@ main(void)
cons_probe();
/*
- * Initialise the block cache
- */
- bcache_init(32, 512); /* 16k cache XXX tune this */
-
- /*
* March through the device switch probing for things.
*/
for (i = 0; devsw[i] != NULL; i++)
@@ -112,6 +105,10 @@ main(void)
printf("\n");
printf("%s, Revision %s %d/%dkB\n", bootprog_name, bootprog_rev, getbasemem(), getextmem());
printf("(%s, %s)\n", bootprog_maker, bootprog_date);
+#if 0
+ printf("recovered args howto = 0x%x bootdev = 0x%x bootinfo = %p\n",
+ initial_howto, initial_bootdev, initial_bootinfo);
+#endif
extract_currdev(); /* set $currdev and $loaddev */
setenv("LINES", "24", 1); /* optional */
@@ -121,8 +118,6 @@ main(void)
archsw.arch_copyin = i386_copyin;
archsw.arch_copyout = i386_copyout;
archsw.arch_readin = i386_readin;
- archsw.arch_isainb = isa_inb;
- archsw.arch_isaoutb = isa_outb;
interact(); /* doesn't return */
}
@@ -200,34 +195,3 @@ command_heap(int argc, char *argv[])
printf("heap base at %p, top at %p\n", end, sbrk(0));
return(CMD_OK);
}
-
-/* ISA bus access functions for PnP, derived from <machine/cpufunc.h> */
-static int
-isa_inb(int port)
-{
- u_char data;
-
- if (__builtin_constant_p(port) &&
- (((port) & 0xffff) < 0x100) &&
- ((port) < 0x10000)) {
- __asm __volatile("inb %1,%0" : "=a" (data) : "id" ((u_short)(port)));
- } else {
- __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
- }
- return(data);
-}
-
-static void
-isa_outb(int port, int value)
-{
- u_char al = value;
-
- if (__builtin_constant_p(port) &&
- (((port) & 0xffff) < 0x100) &&
- ((port) < 0x10000)) {
- __asm __volatile("outb %0,%1" : : "a" (al), "id" ((u_short)(port)));
- } else {
- __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
- }
-}
-
diff --git a/sys/boot/i386/loader/newvers.sh b/sys/boot/i386/loader/newvers.sh
index 476913be37a0d..34b0e7e674d9e 100755
--- a/sys/boot/i386/loader/newvers.sh
+++ b/sys/boot/i386/loader/newvers.sh
@@ -35,7 +35,6 @@
#
# @(#)newvers.sh 8.1 (Berkeley) 4/20/94
-LC_TIME=C; export LC_TIME
u=${USER-root} h=`hostname` t=`date`
#r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '`
r=`awk -F: ' /^[0-9]\.[0-9]+:/ { print $1; exit }' $1`
diff --git a/sys/boot/i386/loader/setdef0.c b/sys/boot/i386/loader/setdef0.c
new file mode 100644
index 0000000000000..e2af74e843938
--- /dev/null
+++ b/sys/boot/i386/loader/setdef0.c
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1997 John D. Polstra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: setdef0.c,v 1.2 1997/05/21 23:21:30 jdp Exp $
+ */
+
+#ifdef __ELF__
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+
+/*
+ * DEFINE_SET creates the section and label for a set, and emits the
+ * count word at the front of it.
+ */
+#define DEFINE_SET(set, count) \
+ __asm__(".section .set." #set ",\"aw\""); \
+ __asm__(".globl " #set); \
+ __asm__(".type " #set ",@object"); \
+ __asm__(".p2align 2"); \
+ __asm__(#set ":"); \
+ __asm__(".long " #count); \
+ __asm__(".previous")
+
+#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */
+
+#endif /* __ELF__ */
diff --git a/sys/boot/i386/loader/setdef1.c b/sys/boot/i386/loader/setdef1.c
new file mode 100644
index 0000000000000..3f2011920526a
--- /dev/null
+++ b/sys/boot/i386/loader/setdef1.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1997 John D. Polstra
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: setdef1.c,v 1.2 1997/05/21 23:21:30 jdp Exp $
+ */
+
+#ifdef __ELF__
+
+/*
+ * DEFINE_SET emits the NULL terminator for a set.
+ */
+#define DEFINE_SET(set, count) \
+ __asm__(".section .set." #set ",\"aw\""); \
+ __asm__(".long 0"); \
+ __asm__(".previous")
+
+#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */
+
+#endif /* __ELF__ */