summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/boot/i386/boot0/Makefile6
-rw-r--r--sys/boot/i386/boot0/boot0.m477
-rw-r--r--sys/boot/i386/boot0/boot0.s157
-rw-r--r--sys/boot/i386/boot2/Makefile15
-rw-r--r--sys/boot/i386/boot2/boot1.S184
-rw-r--r--sys/boot/i386/boot2/boot1.m466
-rw-r--r--sys/boot/i386/boot2/boot1.s184
-rw-r--r--sys/boot/i386/btx/btx/Makefile4
-rw-r--r--sys/boot/i386/btx/btx/btx.S265
-rw-r--r--sys/boot/i386/btx/btx/btx.m459
-rw-r--r--sys/boot/i386/btx/btx/btx.s265
-rw-r--r--sys/boot/i386/cdboot/cdboot.s34
-rw-r--r--sys/boot/i386/cdldr/cdldr.s34
-rw-r--r--sys/boot/i386/gptboot/Makefile15
-rw-r--r--sys/boot/i386/pxeldr/pxeldr.S34
-rw-r--r--sys/boot/i386/pxeldr/pxeldr.s34
16 files changed, 564 insertions, 869 deletions
diff --git a/sys/boot/i386/boot0/Makefile b/sys/boot/i386/boot0/Makefile
index 5ccddf2..015a5e8 100644
--- a/sys/boot/i386/boot0/Makefile
+++ b/sys/boot/i386/boot0/Makefile
@@ -22,9 +22,9 @@ boot0: boot0.o
objcopy -S -O binary boot0.out ${.TARGET}
.endif
-boot0.o: boot0.m4 boot0.s
- (cd ${.CURDIR}; ${M4} -DFLAGS=${B0FLAGS} -DTICKS=${B0TICKS} \
- boot0.m4 boot0.s) | ${AS} ${AFLAGS} -o ${.TARGET}
+boot0.o: boot0.s
+ ${AS} ${AFLAGS} --defsym FLAGS=${B0FLAGS} --defsym TICKS=${B0TICKS} \
+ ${.IMPSRC} -o ${.TARGET}
CLEANFILES+= boot0.out boot0.o
diff --git a/sys/boot/i386/boot0/boot0.m4 b/sys/boot/i386/boot0/boot0.m4
deleted file mode 100644
index 7515d58..0000000
--- a/sys/boot/i386/boot0/boot0.m4
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_es,0x0)dnl
-define(_cs,0x1)dnl
-define(_ss,0x2)dnl
-define(_ds,0x3)dnl
-define(_fs,0x4)dnl
-define(_gs,0x5)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(o16,`.byte 0x66')dnl
-
-define(addw1r,`.byte 0x3; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')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(cmpwi2,`.byte 0x81; .byte 0xb8 | $3; .word $2; .word $1')dnl
-define(addwir,`.byte 0x83; .byte 0xc0 | $2; .byte $1')dnl
-define(movbr0,`.byte 0x88; .byte ($1 << 0x3) | $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(addb0r,`.byte 0x2; .byte ($2 << 0x3) | $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(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
-define(pushw1,`.byte 0xff; .byte 0x70 | $2; .byte $1')dnl
-define(retn,`.byte 0xc3')dnl
diff --git a/sys/boot/i386/boot0/boot0.s b/sys/boot/i386/boot0/boot0.s
index f7a3ec2..4d186ac 100644
--- a/sys/boot/i386/boot0/boot0.s
+++ b/sys/boot/i386/boot0/boot0.s
@@ -79,32 +79,23 @@ start: cld # String ops inc
#
# Relocate to the new copy of the code.
#
- incb1(-0xe,_di_) # Sector number
- /* incb $-0xe(%di) */
- jmpnwi(main-LOAD+ORIGIN) # To relocated code
- /* jmp main-LOAD+ORIGIN */
+ incb -0xe(%di) # Sector number
+ jmp main-LOAD+ORIGIN # To relocated code
#
# Check what flags were loaded with us, specifically, Use a predefined Drive.
# If what the bios gives us is bad, use the '0' in the block instead, as well.
#
-main: tstbi1(0x20,_FLAGS,_bp_) # Set number drive?
- /* testb $(0x20+_FLAGS)(%bp) */
- .code32
+main: testb $0x20,_FLAGS(%bp) # Set number drive?
jnz main.1 # Yes
- .code16
testb %dl,%dl # Drive number valid?
- .code32
js main.2 # Possibly (0x80 set)
- .code16
-main.1: movb1r(_SETDRV,_bp_,_dl) # Drive number to use
- /* movb $_SETDRV(%bp),%dl */
+main.1: movb _SETDRV(%bp),%dl # Drive number to use
#
# Whatever we decided to use, now store it into the fake
# partition entry that lives in the data space above us.
#
-main.2: movbr1(_dl,_FAKE,_bp_) # Save drive number
- /* movb %dl,$_FAKE(%bp) */
- callwi(putn) # To new line
+main.2: movb %dl,_FAKE(%bp) # Save drive number
+ callw putn # To new line
pushw %dx # Save drive number
#
# Start out with a pointer to the 4th byte of the first table entry
@@ -119,51 +110,39 @@ main.2: movbr1(_dl,_FAKE,_bp_) # Save drive number
# Loop around on the partition table, printing values until we
# pass a 256 byte boundary. The end of loop test is at main.5.
#
-main.3: movbr1(_ch,-0x4,_bx_) # Zero active flag (ch == 0)
- /* movb %ch,$-0x4(%bx) */
- btwr1(_dx,_FLAGS,_bp_) # Entry enabled?
- /* bt %dx,$_FLAGS(%bp) */
- .code32
+main.3: movb %ch,-0x4(%bx) # Zero active flag (ch == 0)
+ btw %dx,_FLAGS(%bp) # Entry enabled?
jnc main.5 # No
- .code16
#
# If any of the entries in the table are
# the same as the 'type' in the slice table entry,
# then this is an empty or non bootable partition. Skip it.
#
- movb0r(_bx_,_al) # Load type
- /* movb (%bx),%al */
+ movb (%bx),%al # Load type
movw $tables,%di # Lookup tables
movb $TBL0SZ,%cl # Number of entries
repne # Exclude
scasb # partition?
- .code32
je main.5 # Yes
- .code16
#
# Now scan the table of known types
#
movb $TBL1SZ,%cl # Number of entries
repne # Known
scasb # type?
- .code32
jne main.4 # No
- .code16
#
# If it matches get the matching element in the
# next array. if it doesn't, we are already
# pointing at its first element which points to a "?".
#
addw $TBL1SZ,%di # Adjust
-main.4: movb0r(_di_,_cl) # Partition
- /* movb (%di),%cl */
+main.4: movb (%di),%cl # Partition
addw %cx,%di # description
- callwi(putx) # Display it
+ callw putx # Display it
main.5: incw %dx # Next item
addb $0x10,%bl # Next entry
- .code32
jnc main.3 # Till done
- .code16
#
# Passed a 256 byte boundary..
# table is finished.
@@ -172,16 +151,12 @@ main.5: incw %dx # Next item
popw %ax # Drive number
subb $0x80-0x1,%al # Does next
cmpb NHRDRV,%al # drive exist? (from BIOS?)
- .code32
jb main.6 # Yes
- .code16
# If not then if there is only one drive,
# Don't display drive as an option.
#
decw %ax # Already drive 0?
- .code32
jz main.7 # Yes
- .code16
# If it was illegal or we cycled through them,
# then go back to drive 0.
#
@@ -194,48 +169,38 @@ main.5: incw %dx # Next item
# end of string.
#
main.6: addb $'0'|0x80,%al # Save next
- movbr1(_al,_NXTDRV,_bp_) # drive number
- /* movb %al,$NXTDRV(%bp) */
+ movb %al,_NXTDRV(%bp) # drive number
movw $drive,%di # Display
- callwi(putx) # item
+ callw putx # item
#
# Now that we've printed the drive (if we needed to), display a prompt.
# Get ready for the input byt noting the time.
#
main.7: movw $prompt,%si # Display
- callwi(putstr) # prompt
- movb1r(_OPT,_bp_,_dl) # Display
- /* movb $_OPT(%bp),%dl */
+ callw putstr # prompt
+ movb _OPT(%bp),%dl # Display
decw %si # default
- callwi(putkey) # key
+ callw putkey # key
xorb %ah,%ah # BIOS: Get
int $0x1a # system time
movw %dx,%di # Ticks when
- addw1r(_TICKS,_bp_,_di) # timeout
- /* addw $_TICKS(%bp),%di */
+ addw _TICKS(%bp),%di # timeout
#
# Busy loop, looking for keystrokes but
# keeping one eye on the time.
#
main.8: movb $0x1,%ah # BIOS: Check
int $0x16 # for keypress
- .code32
jnz main.11 # Have one
- .code16
xorb %ah,%ah # BIOS: Get
int $0x1a # system time
cmpw %di,%dx # Timeout?
- .code32
jb main.8 # No
- .code16
#
# If timed out or defaulting, come here.
#
-main.9: movb1r(_OPT,_bp_,_al) # Load default
- /* movb $_OPT(%bp),%al */
- .code32
+main.9: movb _OPT(%bp),%al # Load default
jmp main.12 # Join common code
- .code16
#
# User's last try was bad, beep in displeasure.
# Since nothing was printed, just continue on as if the user
@@ -244,7 +209,7 @@ main.9: movb1r(_OPT,_bp_,_al) # Load default
# occurs or the user hits a good key.
#
main.10: movb $0x7,%al # Signal
- callwi(putchr) # error
+ callw putchr # error
#
# Get the keystroke.
#
@@ -255,18 +220,14 @@ main.11: xorb %ah,%ah # BIOS: Get
# If it's CR act as if timed out.
#
cmpb $KEY_ENTER,%al # Enter pressed?
- .code32
je main.9 # Yes
- .code16
#
# Otherwise check if legal
# If not ask again.
#
subb $KEY_F1,%al # Less F1 scan code
cmpb $0x4,%al # F1..F5?
- .code32
ja main.10 # No
- .code16
#
# We have a selection.
# but if it's a bad selection go back to complain.
@@ -274,54 +235,40 @@ main.11: xorb %ah,%ah # BIOS: Get
# Anything not printed is not an option.
#
main.12: cbtw # Option
- btwr1(_ax,_MNUOPT,_bp_) # enabled?
- /* btw %ax,$_MNUOPT(%bp) */
- .code32
+ btw %ax,_MNUOPT(%bp) # enabled?
jnc main.10 # No
- .code16
#
# Save the info in the original tables
# for rewriting to the disk.
#
- movbr1(_al,_OPT,_bp_) # Save option
- /* movb %al,$OPT(%bp) */
+ movb %al,_OPT(%bp) # Save option
movw $FAKE,%si # Partition for write
- movb0r(_si_,_dl) # Drive number
- /* movb (%si),%dl */
+ movb (%si),%dl # Drive number
movw %si,%bx # Partition for read
cmpb $0x4,%al # F5 pressed?
pushf # Save
- .code32
je main.13 # Yes
- .code16
shlb $0x4,%al # Point to
addw $partbl,%ax # selected
xchgw %bx,%ax # partition
- movbi0(0x80,_bx_) # Flag active
- /* movb $0x80,(%bx) */
+ movb $0x80,(%bx) # Flag active
#
# If not asked to do a write-back (flags 0x40) don't do one.
#
main.13: pushw %bx # Save
- tstbi1(0x40,_FLAGS,_bp_) # No updates?
- /* testb $0x40,$_FLAGS(%bp) */
- .code32
+ testb $0x40,_FLAGS(%bp) # No updates?
jnz main.14 # Yes
- .code16
movw $start,%bx # Data to write
movb $0x3,%ah # Write sector
- callwi(intx13) # to disk
+ callw intx13 # to disk
main.14: popw %si # Restore
popf # Restore
#
# If going to next drive, replace drive with selected one.
# Remember to un-ascii it. Hey 0x80 is already set, cool!
#
- .code32
jne main.15 # If not F5
- .code16
- movb1r(_NXTDRV,_bp_,_dl) # Next drive
- /* movb $_NXTDRV(%bp),%dl */
+ movb _NXTDRV(%bp),%dl # Next drive
subb $'0',%dl # number
#
# load selected bootsector to the LOAD location in RAM.
@@ -331,58 +278,43 @@ main.14: popw %si # Restore
#
main.15: movw $LOAD,%bx # Address for read
movb $0x2,%ah # Read sector
- callwi(intx13) # from disk
- .code32
+ callw intx13 # from disk
jc main.10 # If error
- .code16
- cmpwi2(MAGIC,0x1fe,_bx_) # Bootable?
- /* cmpw $MAGIC,$0x1fe(%bx) */
- .code32
+ cmpw $MAGIC,0x1fe(%bx) # Bootable?
jne main.10 # No
- .code16
pushw %si # Save
movw $crlf,%si # Leave some
- callwi(puts) # space
+ callw puts # space
popw %si # Restore
- .code32
- jmp *%ebx # Invoke bootstrap
- /* jmp *%bx */
- .code16
+ jmp *%bx # Invoke bootstrap
#
# Display routines
#
putkey: movb $'F',%al # Display
- callwi(putchr) # 'F'
+ callw putchr # 'F'
movb $'1',%al # Prepare
addb %dl,%al # digit
- .code32
jmp putstr.1 # Display the rest
- .code16
#
# Display the option and note that it is a valid option.
# That last point is a bit tricky..
#
-putx: btswr1(_dx,_MNUOPT,_bp_) # Enable menu option
- /* btsw %dx,$_MNUOPT(%bp) */
+putx: btsw %dx,_MNUOPT(%bp) # Enable menu option
movw $item,%si # Display
- callwi(putkey) # key
+ callw putkey # key
movw %di,%si # Display the rest
-puts: callwi(putstr) # Display string
+puts: callw putstr # Display string
putn: movw $crlf,%si # To next line
putstr: lodsb # Get byte
testb $0x80,%al # End of string?
- .code32
jnz putstr.2 # Yes
- .code16
-putstr.1: callwi(putchr) # Display char
- .code32
+putstr.1: callw putchr # Display char
jmp putstr # Continue
- .code16
putstr.2: andb $~0x80,%al # Clear MSB
putchr: pushw %bx # Save
@@ -390,26 +322,19 @@ putchr: pushw %bx # Save
movb $0xe,%ah # BIOS: Display
int $0x10 # character
popw %bx # Restore
- retn # To caller
+ retw # To caller
# One-sector disk I/O routine
-intx13: movb1r(0x1,_si_,_dh) # Load head
- /* movb $0x1(%si),%dh */
- movw1r(0x2,_si_,_cx) # Load cylinder:sector
- /* movw $0x2(%si),%cx */
+intx13: movb 0x1(%si),%dh # Load head
+ movw 0x2(%si),%cx # Load cylinder:sector
movb $0x1,%al # Sector count
pushw %si # Save
movw %sp,%di # Save
- tstbi1(0x80,_FLAGS,_bp_) # Use packet interface?
- /* testb $0x80,$_FLAGS(%bp) */
- .code32
+ testb $0x80,_FLAGS(%bp) # Use packet interface?
jz intx13.1 # No
- .code16
pushl $0x0 # Set the
- o16 # LBA
- pushw1(0x8,_si_) # address
- /* pushl $0x8(%si) */
+ pushl 0x8(%si) # LBA address
pushw %es # Set the transfer
pushw %bx # buffer address
push $0x1 # Block count
@@ -420,7 +345,7 @@ intx13: movb1r(0x1,_si_,_dh) # Load head
intx13.1: int $0x13 # BIOS: Disk I/O
movw %di,%sp # Restore
popw %si # Restore
- retn # To caller
+ retw # To caller
# Menu strings
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index 5f523bb..0ccf65d 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -9,8 +9,6 @@ CLEANFILES+= boot1 boot1.out boot1.o \
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
sio.o
-M4?= m4
-
# A value of 0x80 enables LBA support.
B1FLAGS= 0
@@ -45,9 +43,8 @@ boot1: boot1.out
boot1.out: boot1.o
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
-boot1.o: boot1.m4 boot1.s
- (cd ${.CURDIR}; ${M4} -DFLAGS=${B1FLAGS} boot1.m4 boot1.s) | \
- ${AS} ${AFLAGS} -o ${.TARGET}
+boot1.o: boot1.s
+ ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET}
boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
@@ -67,10 +64,10 @@ 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} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
+ --defsym SIOFMT=${B2SIOFMT} \
+ --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \
+ ${.IMPSRC} -o ${.TARGET}
install:
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
diff --git a/sys/boot/i386/boot2/boot1.S b/sys/boot/i386/boot2/boot1.S
index d78aaf2..2c557ec 100644
--- a/sys/boot/i386/boot2/boot1.S
+++ b/sys/boot/i386/boot2/boot1.S
@@ -32,6 +32,7 @@
.globl start
.globl xread
+ .code16
start: jmp main # Start recognizably
@@ -39,75 +40,75 @@ start: jmp main # Start recognizably
# External read from disk
-xread: pushl %ss # Address
- popl %ds # data
-xread.1: o16 # Starting
- pushb $0x0 # absolute
- pushl %ecx # block
- pushl %eax # number
- pushl %es # Address of
- pushl %ebx # transfer buffer
- xorl %eax,%eax # Number of
+xread: push %ss # Address
+ pop %ds # data
+xread.1: # Starting
+ pushl $0x0 # absolute
+ push %cx # block
+ push %ax # number
+ push %es # Address of
+ push %bx # transfer buffer
+ xor %ax,%ax # Number of
movb %dh,%al # blocks to
- pushl %eax # transfer
- pushb $0x10 # Size of packet
- movl %esp,%ebp # Packet pointer
- callwi(read) # Read from disk
- leaw1r(0x10,_bp_,_sp) # Clear stack
+ push %ax # transfer
+ push $0x10 # Size of packet
+ mov %sp,%bp # Packet pointer
+ callw read # Read from disk
+ lea 0x10(%bp),%sp # Clear stack
lret # To far caller
# Bootstrap
main: cld # String ops inc
- xorl %ecx,%ecx # Zero
- movl %cx,%es # Address
- movl %cx,%ds # data
- movl %cx,%ss # Set up
- movwir(start,_sp) # stack
- movl %esp,%esi # Source
- movwir(MEM_REL,_di) # Destination
+ xor %cx,%cx # Zero
+ mov %cx,%es # Address
+ mov %cx,%ds # data
+ mov %cx,%ss # Set up
+ mov $start,%sp # stack
+ mov %sp,%si # Source
+ mov $MEM_REL,%di # Destination
incb %ch # Word count
rep # Copy
- movsl # code
- movwir(part4,_si) # Partition
+ movsw # code
+ mov $part4,%si # Partition
cmpb $0x80,%dl # Hard drive?
jb main.4 # No
movb $0x1,%dh # Block count
- callwi(nread) # Read MBR
- movwir(0x1,_cx) # Two passes
-main.1: movwir(MEM_BUF+PRT_OFF,_si) # Partition table
+ callw nread # Read MBR
+ mov $0x1,%cx # Two passes
+main.1: mov $MEM_BUF+PRT_OFF,%si # Partition table
movb $0x1,%dh # Partition
-main.2: cmpbi1(PRT_BSD,0x4,_si_) # Our partition type?
+main.2: cmpb $PRT_BSD,0x4(%si) # Our partition type?
jne main.3 # No
- jecxz main.5 # If second pass
- tstbi0(0x80,_si_) # Active?
+ jcxz main.5 # If second pass
+ testb $0x80,(%si) # Active?
jnz main.5 # Yes
-main.3: addl $0x10,%esi # Next entry
+main.3: add $0x10,%si # Next entry
incb %dh # Partition
cmpb $0x1+PRT_NUM,%dh # In table?
jb main.2 # Yes
- decl %ecx # Do two
- jecxz main.1 # passes
- movwir(msg_part,_si) # Message
+ dec %cx # Do two
+ jcxz main.1 # passes
+ mov $msg_part,%si # Message
jmp error # Error
-main.4: xorl %edx,%edx # Partition:drive
-main.5: movwrm(_dx,MEM_ARG) # Save args
+main.4: xor %dx,%dx # Partition:drive
+main.5: mov %dx,MEM_ARG # Save args
movb $0x10,%dh # Sector count
- callwi(nread) # Read disk
- movwir(MEM_BTX,_bx) # BTX
- movw1r(0xa,_bx_,_si) # Point past
- addl %ebx,%esi # it
- movwir(MEM_USR+SIZ_PAG,_di) # Client page 1
- movwir(MEM_BTX+0xe*SIZ_SEC,_cx) # Byte
- subl %esi,%ecx # count
+ callw nread # Read disk
+ mov $MEM_BTX,%bx # BTX
+ mov 0xa(%bx),%si # Point past
+ add %bx,%si # it
+ mov $MEM_USR+SIZ_PAG,%di # Client page 1
+ mov $MEM_BTX+0xe*SIZ_SEC,%cx # Byte
+ sub %si,%cx # count
rep # Relocate
movsb # client
- subl %edi,%ecx # Byte count
+ sub %di,%cx # Byte count
xorb %al,%al # Zero
rep # assumed
stosb # bss
- callwi(seta20) # Enable A20
- jmpnwi(start+MEM_JMP-MEM_ORG) # Start BTX
+ callw seta20 # Enable A20
+ jmp start+MEM_JMP-MEM_ORG # Start BTX
# Enable A20
@@ -123,30 +124,30 @@ seta20.2: inb $0x64,%al # Get status
movb $0xdf,%al # Enable
outb %al,$0x60 # A20
sti # Enable interrupts
- ret # To caller
+ retw # To caller
# Local read from disk
-nread: movwir(MEM_BUF,_bx) # Transfer buffer
- movw1r(0x8,_si_,_ax) # Get
- movw1r(0xa,_si_,_cx) # LBA
- pushl %cs # Read from
- callwi(xread.1) # disk
+nread: mov $MEM_BUF,%bx # Transfer buffer
+ mov 0x8(%si),%ax # Get
+ mov 0xa(%si),%cx # LBA
+ push %cs # Read from
+ callw xread.1 # disk
jnc return # If success
- movwir(msg_read,_si) # Message
+ mov $msg_read,%si # Message
# Error exit
-error: callwi(putstr) # Display message
- movwir(prompt,_si) # Display
- callwi(putstr) # prompt
+error: callw putstr # Display message
+ mov $prompt,%si # Display
+ callw putstr # prompt
xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
int $0x19 # BIOS: Reboot
# Display string
-putstr.0: movwir(0x7,_bx) # Page:attribute
+putstr.0: mov $0x7,%bx # Page:attribute
movb $0xe,%ah # BIOS: Display
int $0x10 # character
putstr: lodsb # Get char
@@ -155,87 +156,84 @@ putstr: lodsb # Get char
ereturn: movb $0x1,%ah # Invalid
stc # argument
-return: ret # To caller
+return: retw # To caller
# Read from disk
-read: cs_ # LBA support
- tstbim(0x80,MEM_REL+flags-start)# enabled?
+read: testb $0x80,%cs:MEM_REL+flags-start # LBA support enabled?
jz read.1 # No
- movwir(0x55aa,_bx) # Magic
- pushl %edx # Save
+ mov $0x55aa,%bx # Magic
+ push %dx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
- popl %edx # Restore
+ pop %dx # Restore
jc read.1 # If error
- cmpwir(0xaa55,_bx) # Magic?
+ cmp $0xaa55,%bx # Magic?
jne read.1 # No
testb $0x1,%cl # Packet interface?
jz read.1 # No
- movl %ebp,%esi # Disk packet
+ mov %bp,%si # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
- ret # To caller
+ retw # To caller
-read.1: pushl %edx # Save
+read.1: push %dx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
- popl %edx # Restore
+ pop %dx # Restore
jc return # If error
andb $0x3f,%cl # Sectors per track
jz ereturn # If zero
cli # Disable interrupts
- o16 # Get
- movw1r(0x8,_bp_,_ax) # LBA
- pushl %edx # Save
- movzbw %cl,%bx # Divide by
- xorw %dx,%dx # sectors
- divw %bx,%ax # per track
+ mov 0x8(%bp),%eax # Get LBA
+ push %dx # Save
+ movzbl %cl,%ebx # Divide by
+ xor %edx,%edx # sectors
+ div %ebx # per track
movb %ch,%bl # Max head number
movb %dl,%ch # Sector number
- incl %ebx # Divide by
+ inc %bx # Divide by
xorb %dl,%dl # number
- divw %bx,%ax # of heads
+ div %ebx # of heads
movb %dl,%bh # Head number
- popl %edx # Restore
- o16 # Cylinder number
- cmpl $0x3ff,%eax # supportable?
+ pop %dx # Restore
+ cmpl $0x3ff,%eax # Cylinder number supportable?
sti # Enable interrupts
ja ereturn # No
xchgb %al,%ah # Set up cylinder
rorb $0x2,%al # number
orb %ch,%al # Merge
- incl %eax # sector
- xchgl %eax,%ecx # number
+ inc %ax # sector
+ xchg %ax,%cx # number
movb %bh,%dh # Head number
subb %ah,%al # Sectors this track
- movb1r(0x2,_bp_,_ah) # Blocks to read
+ mov 0x2(%bp),%ah # Blocks to read
cmpb %ah,%al # To read
jb read.2 # this
movb %ah,%al # track
-read.2: movwir(0x5,_di) # Try count
-read.3: lesw1r(0x4,_bp_,_bx) # Transfer buffer
- pushl %eax # Save
+read.2: mov $0x5,%di # Try count
+read.3: les 0x4(%bp),%bx # Transfer buffer
+ push %ax # Save
movb $0x2,%ah # BIOS: Read
int $0x13 # from disk
- popl %ebx # Restore
+ pop %bx # Restore
jnc read.4 # If success
- decl %edi # Retry?
+ dec %di # Retry?
jz read.6 # No
xorb %ah,%ah # BIOS: Reset
int $0x13 # disk system
- xchgl %ebx,%eax # Block count
+ xchg %bx,%ax # Block count
jmp read.3 # Continue
-read.4: movzbl %bl,%eax # Sectors read
- addwr1(_ax,0x8,_bp_) # Adjust
+read.4: movzbw %bl,%ax # Sectors read
+ add %ax,0x8(%bp) # Adjust
jnc read.5 # LBA,
- incw1(0xa,_bp_) # transfer
+ incw 0xa(%bp) # transfer
read.5: shlb %bl # buffer
- addbr1(_bl,0x5,_bp_) # pointer,
- subbr1(_al,0x2,_bp_) # block count
+ add %bl,0x5(%bp) # pointer,
+ sub %al,0x2(%bp) # block count
ja read.1 # If not done
-read.6: ret # To caller
+read.6: retw # To caller
# Messages
diff --git a/sys/boot/i386/boot2/boot1.m4 b/sys/boot/i386/boot2/boot1.m4
deleted file mode 100644
index 94dd13b..0000000
--- a/sys/boot/i386/boot2/boot1.m4
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(cs_,`.byte 0x2e')dnl
-define(o16,`.byte 0x66')dnl
-
-define(addbr1,`.byte 0x0; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(addwr1,`.byte 0x1; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(subbr1,`.byte 0x28; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(cmpbi1,`.byte 0x80; .byte 0x78 | $3; .byte $2; .byte $1')dnl
-define(cmpwir,`.byte 0x81; .byte 0xf8 | $2; .word $1')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(movwrm,`.byte 0x89; .byte 0x6 | ($1 << 0x3); .word $2')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(leaw1r,`.byte 0x8d; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movwir,`.byte 0xb8 | $2; .word $1')dnl
-define(lesw1r,`.byte 0xc4; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-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 d78aaf2..2c557ec 100644
--- a/sys/boot/i386/boot2/boot1.s
+++ b/sys/boot/i386/boot2/boot1.s
@@ -32,6 +32,7 @@
.globl start
.globl xread
+ .code16
start: jmp main # Start recognizably
@@ -39,75 +40,75 @@ start: jmp main # Start recognizably
# External read from disk
-xread: pushl %ss # Address
- popl %ds # data
-xread.1: o16 # Starting
- pushb $0x0 # absolute
- pushl %ecx # block
- pushl %eax # number
- pushl %es # Address of
- pushl %ebx # transfer buffer
- xorl %eax,%eax # Number of
+xread: push %ss # Address
+ pop %ds # data
+xread.1: # Starting
+ pushl $0x0 # absolute
+ push %cx # block
+ push %ax # number
+ push %es # Address of
+ push %bx # transfer buffer
+ xor %ax,%ax # Number of
movb %dh,%al # blocks to
- pushl %eax # transfer
- pushb $0x10 # Size of packet
- movl %esp,%ebp # Packet pointer
- callwi(read) # Read from disk
- leaw1r(0x10,_bp_,_sp) # Clear stack
+ push %ax # transfer
+ push $0x10 # Size of packet
+ mov %sp,%bp # Packet pointer
+ callw read # Read from disk
+ lea 0x10(%bp),%sp # Clear stack
lret # To far caller
# Bootstrap
main: cld # String ops inc
- xorl %ecx,%ecx # Zero
- movl %cx,%es # Address
- movl %cx,%ds # data
- movl %cx,%ss # Set up
- movwir(start,_sp) # stack
- movl %esp,%esi # Source
- movwir(MEM_REL,_di) # Destination
+ xor %cx,%cx # Zero
+ mov %cx,%es # Address
+ mov %cx,%ds # data
+ mov %cx,%ss # Set up
+ mov $start,%sp # stack
+ mov %sp,%si # Source
+ mov $MEM_REL,%di # Destination
incb %ch # Word count
rep # Copy
- movsl # code
- movwir(part4,_si) # Partition
+ movsw # code
+ mov $part4,%si # Partition
cmpb $0x80,%dl # Hard drive?
jb main.4 # No
movb $0x1,%dh # Block count
- callwi(nread) # Read MBR
- movwir(0x1,_cx) # Two passes
-main.1: movwir(MEM_BUF+PRT_OFF,_si) # Partition table
+ callw nread # Read MBR
+ mov $0x1,%cx # Two passes
+main.1: mov $MEM_BUF+PRT_OFF,%si # Partition table
movb $0x1,%dh # Partition
-main.2: cmpbi1(PRT_BSD,0x4,_si_) # Our partition type?
+main.2: cmpb $PRT_BSD,0x4(%si) # Our partition type?
jne main.3 # No
- jecxz main.5 # If second pass
- tstbi0(0x80,_si_) # Active?
+ jcxz main.5 # If second pass
+ testb $0x80,(%si) # Active?
jnz main.5 # Yes
-main.3: addl $0x10,%esi # Next entry
+main.3: add $0x10,%si # Next entry
incb %dh # Partition
cmpb $0x1+PRT_NUM,%dh # In table?
jb main.2 # Yes
- decl %ecx # Do two
- jecxz main.1 # passes
- movwir(msg_part,_si) # Message
+ dec %cx # Do two
+ jcxz main.1 # passes
+ mov $msg_part,%si # Message
jmp error # Error
-main.4: xorl %edx,%edx # Partition:drive
-main.5: movwrm(_dx,MEM_ARG) # Save args
+main.4: xor %dx,%dx # Partition:drive
+main.5: mov %dx,MEM_ARG # Save args
movb $0x10,%dh # Sector count
- callwi(nread) # Read disk
- movwir(MEM_BTX,_bx) # BTX
- movw1r(0xa,_bx_,_si) # Point past
- addl %ebx,%esi # it
- movwir(MEM_USR+SIZ_PAG,_di) # Client page 1
- movwir(MEM_BTX+0xe*SIZ_SEC,_cx) # Byte
- subl %esi,%ecx # count
+ callw nread # Read disk
+ mov $MEM_BTX,%bx # BTX
+ mov 0xa(%bx),%si # Point past
+ add %bx,%si # it
+ mov $MEM_USR+SIZ_PAG,%di # Client page 1
+ mov $MEM_BTX+0xe*SIZ_SEC,%cx # Byte
+ sub %si,%cx # count
rep # Relocate
movsb # client
- subl %edi,%ecx # Byte count
+ sub %di,%cx # Byte count
xorb %al,%al # Zero
rep # assumed
stosb # bss
- callwi(seta20) # Enable A20
- jmpnwi(start+MEM_JMP-MEM_ORG) # Start BTX
+ callw seta20 # Enable A20
+ jmp start+MEM_JMP-MEM_ORG # Start BTX
# Enable A20
@@ -123,30 +124,30 @@ seta20.2: inb $0x64,%al # Get status
movb $0xdf,%al # Enable
outb %al,$0x60 # A20
sti # Enable interrupts
- ret # To caller
+ retw # To caller
# Local read from disk
-nread: movwir(MEM_BUF,_bx) # Transfer buffer
- movw1r(0x8,_si_,_ax) # Get
- movw1r(0xa,_si_,_cx) # LBA
- pushl %cs # Read from
- callwi(xread.1) # disk
+nread: mov $MEM_BUF,%bx # Transfer buffer
+ mov 0x8(%si),%ax # Get
+ mov 0xa(%si),%cx # LBA
+ push %cs # Read from
+ callw xread.1 # disk
jnc return # If success
- movwir(msg_read,_si) # Message
+ mov $msg_read,%si # Message
# Error exit
-error: callwi(putstr) # Display message
- movwir(prompt,_si) # Display
- callwi(putstr) # prompt
+error: callw putstr # Display message
+ mov $prompt,%si # Display
+ callw putstr # prompt
xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
int $0x19 # BIOS: Reboot
# Display string
-putstr.0: movwir(0x7,_bx) # Page:attribute
+putstr.0: mov $0x7,%bx # Page:attribute
movb $0xe,%ah # BIOS: Display
int $0x10 # character
putstr: lodsb # Get char
@@ -155,87 +156,84 @@ putstr: lodsb # Get char
ereturn: movb $0x1,%ah # Invalid
stc # argument
-return: ret # To caller
+return: retw # To caller
# Read from disk
-read: cs_ # LBA support
- tstbim(0x80,MEM_REL+flags-start)# enabled?
+read: testb $0x80,%cs:MEM_REL+flags-start # LBA support enabled?
jz read.1 # No
- movwir(0x55aa,_bx) # Magic
- pushl %edx # Save
+ mov $0x55aa,%bx # Magic
+ push %dx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
- popl %edx # Restore
+ pop %dx # Restore
jc read.1 # If error
- cmpwir(0xaa55,_bx) # Magic?
+ cmp $0xaa55,%bx # Magic?
jne read.1 # No
testb $0x1,%cl # Packet interface?
jz read.1 # No
- movl %ebp,%esi # Disk packet
+ mov %bp,%si # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
- ret # To caller
+ retw # To caller
-read.1: pushl %edx # Save
+read.1: push %dx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
- popl %edx # Restore
+ pop %dx # Restore
jc return # If error
andb $0x3f,%cl # Sectors per track
jz ereturn # If zero
cli # Disable interrupts
- o16 # Get
- movw1r(0x8,_bp_,_ax) # LBA
- pushl %edx # Save
- movzbw %cl,%bx # Divide by
- xorw %dx,%dx # sectors
- divw %bx,%ax # per track
+ mov 0x8(%bp),%eax # Get LBA
+ push %dx # Save
+ movzbl %cl,%ebx # Divide by
+ xor %edx,%edx # sectors
+ div %ebx # per track
movb %ch,%bl # Max head number
movb %dl,%ch # Sector number
- incl %ebx # Divide by
+ inc %bx # Divide by
xorb %dl,%dl # number
- divw %bx,%ax # of heads
+ div %ebx # of heads
movb %dl,%bh # Head number
- popl %edx # Restore
- o16 # Cylinder number
- cmpl $0x3ff,%eax # supportable?
+ pop %dx # Restore
+ cmpl $0x3ff,%eax # Cylinder number supportable?
sti # Enable interrupts
ja ereturn # No
xchgb %al,%ah # Set up cylinder
rorb $0x2,%al # number
orb %ch,%al # Merge
- incl %eax # sector
- xchgl %eax,%ecx # number
+ inc %ax # sector
+ xchg %ax,%cx # number
movb %bh,%dh # Head number
subb %ah,%al # Sectors this track
- movb1r(0x2,_bp_,_ah) # Blocks to read
+ mov 0x2(%bp),%ah # Blocks to read
cmpb %ah,%al # To read
jb read.2 # this
movb %ah,%al # track
-read.2: movwir(0x5,_di) # Try count
-read.3: lesw1r(0x4,_bp_,_bx) # Transfer buffer
- pushl %eax # Save
+read.2: mov $0x5,%di # Try count
+read.3: les 0x4(%bp),%bx # Transfer buffer
+ push %ax # Save
movb $0x2,%ah # BIOS: Read
int $0x13 # from disk
- popl %ebx # Restore
+ pop %bx # Restore
jnc read.4 # If success
- decl %edi # Retry?
+ dec %di # Retry?
jz read.6 # No
xorb %ah,%ah # BIOS: Reset
int $0x13 # disk system
- xchgl %ebx,%eax # Block count
+ xchg %bx,%ax # Block count
jmp read.3 # Continue
-read.4: movzbl %bl,%eax # Sectors read
- addwr1(_ax,0x8,_bp_) # Adjust
+read.4: movzbw %bl,%ax # Sectors read
+ add %ax,0x8(%bp) # Adjust
jnc read.5 # LBA,
- incw1(0xa,_bp_) # transfer
+ incw 0xa(%bp) # transfer
read.5: shlb %bl # buffer
- addbr1(_bl,0x5,_bp_) # pointer,
- subbr1(_al,0x2,_bp_) # block count
+ add %bl,0x5(%bp) # pointer,
+ sub %al,0x2(%bp) # block count
ja read.1 # If not done
-read.6: ret # To caller
+read.6: retw # To caller
# Messages
diff --git a/sys/boot/i386/btx/btx/Makefile b/sys/boot/i386/btx/btx/Makefile
index ac42dfb..22b935d 100644
--- a/sys/boot/i386/btx/btx/Makefile
+++ b/sys/boot/i386/btx/btx/Makefile
@@ -19,8 +19,8 @@ btx: btx.o
objcopy -S -O binary btx.out ${.TARGET}
.endif
-btx.o: btx.m4 btx.s
- (cd ${.CURDIR}; ${M4} ${M4FLAGS} btx.m4 btx.s) | \
+btx.o: btx.s
+ (cd ${.CURDIR}; ${M4} ${M4FLAGS} btx.s) | \
${AS} ${AFLAGS} -o ${.TARGET}
CLEANFILES+= btx btx.out btx.o
diff --git a/sys/boot/i386/btx/btx/btx.S b/sys/boot/i386/btx/btx/btx.S
index ceda55f..00f153c 100644
--- a/sys/boot/i386/btx/btx/btx.S
+++ b/sys/boot/i386/btx/btx/btx.S
@@ -94,6 +94,7 @@
# Code segment.
#
.globl start
+ .code16
start: # Start of code
#
# BTX header.
@@ -111,116 +112,115 @@ btx_hdr: .byte 0xeb # Machine ID
# Initialization routine.
#
init: cli # Disable interrupts
- xorl %eax,%eax # Zero/segment
- movl %ax,%ss # Set up
- movwir(MEM_ESP0,_sp) # stack
- movl %ax,%es # Address
- movl %ax,%ds # data
- pushw $0x2 # Clear
- popfw # flags
+ xor %ax,%ax # Zero/segment
+ mov %ax,%ss # Set up
+ mov $MEM_ESP0,%sp # stack
+ mov %ax,%es # Address
+ mov %ax,%ds # data
+ pushl $0x2 # Clear
+ popfl # flags
#
# Initialize memory.
#
- movwir(MEM_IDT,_di) # Memory to initialize
- movwir((MEM_ORG-MEM_IDT)/2,_cx) # Words to zero
- pushl %edi # Save
+ mov $MEM_IDT,%di # Memory to initialize
+ mov $(MEM_ORG-MEM_IDT)/2,%cx # Words to zero
+ push %di # Save
rep # Zero-fill
- stosl # memory
- popl %edi # Restore
+ stosw # memory
+ pop %di # Restore
#
# Create IDT.
#
- movwir(idtctl,_si) # Control string
+ mov $idtctl,%si # Control string
init.1: lodsb # Get entry
- cwde # count
- xchgl %eax,%ecx # as word
- jecxz init.4 # If done
+ cbw # count
+ xchg %ax,%cx # as word
+ jcxz init.4 # If done
lodsb # Get segment
- xchgl %eax,%edx # P:DPL:type
- lodsl # Get control
- xchgl %eax,%ebx # set
- lodsl # Get handler offset
- movb $SEL_SCODE,%dh # Segment selector
-init.2: shrl %ebx # Handle this int?
+ xchg %ax,%dx # P:DPL:type
+ lodsw # Get control
+ xchg %ax,%bx # set
+ lodsw # Get handler offset
+ mov $SEL_SCODE,%dh # Segment selector
+init.2: shr %bx # Handle this int?
jnc init.3 # No
- movwr0(_ax,_di_) # Set handler offset
- movbr1(_dh,0x2,_di_) # and selector
- movbr1(_dl,0x5,_di_) # Set P:DPL:type
- addwia(0x4) # Next handler
-init.3: leaw1r(0x8,_di_,_di) # Next entry
+ mov %ax,(%di) # Set handler offset
+ mov %dh,0x2(%di) # and selector
+ mov %dl,0x5(%di) # Set P:DPL:type
+ add $0x4,%ax # Next handler
+init.3: lea 0x8(%di),%di # Next entry
loop init.2 # Till set done
jmp init.1 # Continue
#
# Initialize TSS.
#
-init.4: movbi1(_ESP0H,TSS_ESP0+1,_di_) # Set ESP0
- movbi1(SEL_SDATA,TSS_SS0,_di_) # Set SS0
- movbi1(_ESP1H,TSS_ESP1+1,_di_) # Set ESP1
- movbi1(_TSSIO,TSS_MAP,_di_) # Set I/O bit map base
+init.4: movb $_ESP0H,TSS_ESP0+1(%di) # Set ESP0
+ movb $SEL_SDATA,TSS_SS0(%di) # Set SS0
+ movb $_ESP1H,TSS_ESP1+1(%di) # Set ESP1
+ movb $_TSSIO,TSS_MAP(%di) # Set I/O bit map base
ifdef(`PAGING',`
#
# Create page directory.
#
- xorw %dx,%dx # Page
- movb $PAG_SIZ>>0x8,%dh # size
- xorw %ax,%ax # Zero
- movwir(MEM_DIR,_di) # Page directory
- movb $PAG_CNT>>0xa,%cl # Entries
- movwir(MEM_TBL|0x7,_ax) # First entry
-init.5: stosw # Write entry
- addl %edx,%eax # To next
+ xor %edx,%edx # Page
+ mov $PAG_SIZ>>0x8,%dh # size
+ xor %eax,%eax # Zero
+ mov $MEM_DIR,%di # Page directory
+ mov $PAG_CNT>>0xa,%cl # Entries
+ mov $MEM_TBL|0x7,%ax # First entry
+init.5: stosl # Write entry
+ add %dx,%ax # To next
loop init.5 # Till done
#
# Create page tables.
#
- movwir(MEM_TBL,_di) # Page table
- movb $PAG_CNT>>0x8,%ch # Entries
- xorl %eax,%eax # Start address
-init.6: movb $0x7,%al # Set U:W:P flags
- cmpwmr(btx_hdr+0x8,_cx) # Standard user page?
+ mov $MEM_TBL,%di # Page table
+ mov $PAG_CNT>>0x8,%ch # Entries
+ xor %ax,%ax # Start address
+init.6: mov $0x7,%al # Set U:W:P flags
+ cmp btx_hdr+0x8,%cx # Standard user page?
jb init.7 # Yes
- cmpwir(PAG_CNT-MEM_BTX>>0xc,_cx)# BTX memory?
+ cmp $PAG_CNT-MEM_BTX>>0xc,%cx # BTX memory?
jae init.7 # No or first page
- andb $~0x2,%al # Clear W flag
- cmpwir(PAG_CNT-MEM_USR>>0xc,_cx)# User page zero?
+ and $~0x2,%al # Clear W flag
+ cmp $PAG_CNT-MEM_USR>>0xc,%cx # User page zero?
jne init.7 # No
- tstbim(0x80,btx_hdr+0x7) # Unmap it?
+ testb $0x80,btx_hdr+0x7 # Unmap it?
jz init.7 # No
- andb $~0x1,%al # Clear P flag
-init.7: stosw # Set entry
- addw %dx,%ax # Next address
+ and $~0x1,%al # Clear P flag
+init.7: stosl # Set entry
+ add %edx,%eax # Next address
loop init.6 # Till done
')
#
# Bring up the system.
#
- movwir(0x2820,_bx) # Set protected mode
- callwi(setpic) # IRQ offsets
- lidtwm(idtdesc) # Set IDT
+ mov $0x2820,%bx # Set protected mode
+ callw setpic # IRQ offsets
+ lidt idtdesc # Set IDT
ifdef(`PAGING',`
- xorw %ax,%ax # Set base
- movb $MEM_DIR>>0x8,%ah # of page
- movl %eax,%cr3 # directory
+ xor %eax,%eax # Set base
+ mov $MEM_DIR>>0x8,%ah # of page
+ mov %eax,%cr3 # directory
')
- lgdtwm(gdtdesc) # Set GDT
- movl %cr0,%eax # Switch to
+ lgdt gdtdesc # Set GDT
+ mov %cr0,%eax # Switch to protected
ifdef(`PAGING',`
- o16 # protected mode
- orl $0x80000001,%eax # and enable paging
+ or $0x80000001,%eax # mode and enable paging
',`
- o16 # protected mode
- orl $0x01,%eax #
+ or $0x01,%eax # mode
')
- movl %eax,%cr0 #
- jmpfwi(SEL_SCODE,init.8) # To 32-bit code
+ mov %eax,%cr0 #
+ ljmp $SEL_SCODE,$init.8 # To 32-bit code
+ .code32
init.8: xorl %ecx,%ecx # Zero
movb $SEL_SDATA,%cl # To 32-bit
- movl %cx,%ss # stack
+ movw %cx,%ss # stack
#
# Launch user task.
#
movb $SEL_TSS,%cl # Set task
- ltrl %ecx # register
+ ltr %cx # register
movl $MEM_USR,%edx # User base address
movzwl %ss:BDA_MEM,%eax # Get free memory
shll $0xa,%eax # To bytes
@@ -229,8 +229,8 @@ init.8: xorl %ecx,%ecx # Zero
movb $SEL_UDATA,%cl # User data selector
pushl %ecx # Set SS
pushl %eax # Set ESP
- pushl $0x202 # Set flags (IF set)
- pushl $SEL_UCODE # Set CS
+ push $0x202 # Set flags (IF set)
+ push $SEL_UCODE # Set CS
pushl btx_hdr+0xc # Set EIP
pushl %ecx # Set GS
pushl %ecx # Set FS
@@ -238,7 +238,7 @@ init.8: xorl %ecx,%ecx # Zero
pushl %ecx # Set ES
pushl %edx # Set EAX
movb $0x7,%cl # Set remaining
-init.9: pushb $0x0 # general
+init.9: push $0x0 # general
loop init.9 # registers
popa # and initialize
popl %es # Initialize
@@ -266,43 +266,41 @@ ifdef(`PAGING',`
#
# To 16 bits.
#
- o16 # Reload
- jmpfwi(SEL_RCODE,exit.1) # CS
-exit.1: movb $SEL_RDATA,%cl # 16-bit selector
- movl %cx,%ss # Reload SS
- movl %cx,%ds # Load
- movl %cx,%es # remaining
- movl %cx,%fs # segment
- movl %cx,%gs # registers
+ ljmpw $SEL_RCODE,$exit.1 # Reload CS
+ .code16
+exit.1: mov $SEL_RDATA,%cl # 16-bit selector
+ mov %cx,%ss # Reload SS
+ mov %cx,%ds # Load
+ mov %cx,%es # remaining
+ mov %cx,%fs # segment
+ mov %cx,%gs # registers
#
# To real-address mode.
#
- decl %eax # Switch to
- movl %eax,%cr0 # real mode
- jmpfwi(0x0,exit.2) # Reload CS
-exit.2: xorl %eax,%eax # Real mode segment
- movl %ax,%ss # Reload SS
- movl %ax,%ds # Address data
- movwir(0x7008,_bx) # Set real mode
- callwi(setpic) # IRQ offsets
- lidtwm(ivtdesc) # Set IVT
+ dec %ax # Switch to
+ mov %eax,%cr0 # real mode
+ ljmp $0x0,$exit.2 # Reload CS
+exit.2: xor %ax,%ax # Real mode segment
+ mov %ax,%ss # Reload SS
+ mov %ax,%ds # Address data
+ mov $0x7008,%bx # Set real mode
+ callw setpic # IRQ offsets
+ lidt ivtdesc # Set IVT
#
# Reboot or await reset.
#
sti # Enable interrupts
- tstbim(0x1,btx_hdr+0x7) # Reboot?
+ testb $0x1,btx_hdr+0x7 # Reboot?
exit.3: jz exit.3 # No
- .code16
movw $0x1234, BDA_BOOT # Do a warm boot
- jmpfwi(0xffff,0x0) # reboot the machine
- .code32
+ ljmp $0xffff,$0x0 # reboot the machine
#
# Set IRQ offsets by reprogramming 8259A PICs.
#
-setpic: inb $0x21,%al # Save master
- pushl %eax # IMR
- inb $0xa1,%al # Save slave
- pushl %eax # IMR
+setpic: in $0x21,%al # Save master
+ push %ax # IMR
+ in $0xa1,%al # Save slave
+ push %ax # IMR
movb $0x11,%al # ICW1 to
outb %al,$0x20 # master,
outb %al,$0xa0 # slave
@@ -317,11 +315,12 @@ setpic: inb $0x21,%al # Save master
movb $0x1,%al # ICW4 to
outb %al,$0x21 # master,
outb %al,$0xa1 # slave
- popl %eax # Restore slave
+ pop %ax # Restore slave
outb %al,$0xa1 # IMR
- popl %eax # Restore master
+ pop %ax # Restore master
outb %al,$0x21 # IMR
- ret # To caller
+ retw # To caller
+ .code32
#
# Initiate return from V86 mode to user mode.
#
@@ -329,33 +328,33 @@ inthlt: hlt # To supervisor mode
#
# Exception jump table.
#
-intx00: pushb $0x0 # Int 0x0: #DE
+intx00: push $0x0 # Int 0x0: #DE
jmp ex_noc # Divide error
- pushb $0x1 # Int 0x1: #DB
+ push $0x1 # Int 0x1: #DB
jmp ex_noc # Debug
- pushb $0x3 # Int 0x3: #BP
+ push $0x3 # Int 0x3: #BP
jmp ex_noc # Breakpoint
- pushb $0x4 # Int 0x4: #OF
+ push $0x4 # Int 0x4: #OF
jmp ex_noc # Overflow
- pushb $0x5 # Int 0x5: #BR
+ push $0x5 # Int 0x5: #BR
jmp ex_noc # BOUND range exceeded
- pushb $0x6 # Int 0x6: #UD
+ push $0x6 # Int 0x6: #UD
jmp ex_noc # Invalid opcode
- pushb $0x7 # Int 0x7: #NM
+ push $0x7 # Int 0x7: #NM
jmp ex_noc # Device not available
- pushb $0x8 # Int 0x8: #DF
+ push $0x8 # Int 0x8: #DF
jmp except # Double fault
- pushb $0xa # Int 0xa: #TS
+ push $0xa # Int 0xa: #TS
jmp except # Invalid TSS
- pushb $0xb # Int 0xb: #NP
+ push $0xb # Int 0xb: #NP
jmp except # Segment not present
- pushb $0xc # Int 0xc: #SS
+ push $0xc # Int 0xc: #SS
jmp except # Stack segment fault
- pushb $0xd # Int 0xd: #GP
+ push $0xd # Int 0xd: #GP
jmp ex_v86 # General protection
- pushb $0xe # Int 0xe: #PF
+ push $0xe # Int 0xe: #PF
jmp except # Page fault
-intx10: pushb $0x10 # Int 0x10: #MF
+intx10: push $0x10 # Int 0x10: #MF
jmp ex_noc # Floating-point error
#
# Handle #GP exception.
@@ -392,7 +391,7 @@ except: cld # String ops inc
except.1: pushl 0x50(%esp,1) # Set GS, FS, DS, ES
decb %al # (if V86 mode), and
jne except.1 # SS, ESP
-except.2: pushl $SEL_SDATA # Set up
+except.2: push $SEL_SDATA # Set up
popl %ds # to
pushl %ds # address
popl %es # data
@@ -538,7 +537,7 @@ v86sti: orb $0x2,0x31(%ebp) # Set IF
v86pushf: subl %ecx,%ebx # Adjust SP
cmpb $0x4,%cl # 32-bit
je v86pushf.1 # Yes
- o16 # 16-bit
+ data16 # 16-bit
v86pushf.1: movl %edx,(%ebx) # Save flags
jmp v86mon.6 # Finish up
#
@@ -555,7 +554,7 @@ v86iret: movzwl (%ebx),%esi # Load V86 IP
v86popf: cmpb $0x4,%cl # 32-bit?
je v86popf.1 # Yes
movl %edx,%eax # Initialize
- o16 # 16-bit
+ data16 # 16-bit
v86popf.1: movl (%ebx),%eax # Load flags
addl %ecx,%ebx # Adjust SP
andl $V86_FLG,%eax # Merge
@@ -654,37 +653,37 @@ v86intn.3: subl %edi,%esi # From
#
# Hardware interrupt jump table.
#
-intx20: pushb $0x8 # Int 0x20: IRQ0
+intx20: push $0x8 # Int 0x20: IRQ0
jmp int_hw # V86 int 0x8
- pushb $0x9 # Int 0x21: IRQ1
+ push $0x9 # Int 0x21: IRQ1
jmp int_hw # V86 int 0x9
- pushb $0xa # Int 0x22: IRQ2
+ push $0xa # Int 0x22: IRQ2
jmp int_hw # V86 int 0xa
- pushb $0xb # Int 0x23: IRQ3
+ push $0xb # Int 0x23: IRQ3
jmp int_hw # V86 int 0xb
- pushb $0xc # Int 0x24: IRQ4
+ push $0xc # Int 0x24: IRQ4
jmp int_hw # V86 int 0xc
- pushb $0xd # Int 0x25: IRQ5
+ push $0xd # Int 0x25: IRQ5
jmp int_hw # V86 int 0xd
- pushb $0xe # Int 0x26: IRQ6
+ push $0xe # Int 0x26: IRQ6
jmp int_hw # V86 int 0xe
- pushb $0xf # Int 0x27: IRQ7
+ push $0xf # Int 0x27: IRQ7
jmp int_hw # V86 int 0xf
- pushb $0x70 # Int 0x28: IRQ8
+ push $0x70 # Int 0x28: IRQ8
jmp int_hw # V86 int 0x70
- pushb $0x71 # Int 0x29: IRQ9
+ push $0x71 # Int 0x29: IRQ9
jmp int_hw # V86 int 0x71
- pushb $0x72 # Int 0x2a: IRQ10
+ push $0x72 # Int 0x2a: IRQ10
jmp int_hw # V86 int 0x72
- pushb $0x73 # Int 0x2b: IRQ11
+ push $0x73 # Int 0x2b: IRQ11
jmp int_hw # V86 int 0x73
- pushb $0x74 # Int 0x2c: IRQ12
+ push $0x74 # Int 0x2c: IRQ12
jmp int_hw # V86 int 0x74
- pushb $0x75 # Int 0x2d: IRQ13
+ push $0x75 # Int 0x2d: IRQ13
jmp int_hw # V86 int 0x75
- pushb $0x76 # Int 0x2e: IRQ14
+ push $0x76 # Int 0x2e: IRQ14
jmp int_hw # V86 int 0x76
- pushb $0x77 # Int 0x2f: IRQ15
+ push $0x77 # Int 0x2f: IRQ15
jmp int_hw # V86 int 0x77
#
# Reflect hardware interrupts.
@@ -733,7 +732,7 @@ intusr: std # String ops dec
pushl %fs # and
pushl %ds # point
pushl %es # to them
- pushb $SEL_SDATA # Set up
+ push $SEL_SDATA # Set up
popl %ds # to
pushl %ds # address
popl %es # data
@@ -863,7 +862,7 @@ dump.2: testb $DMP_MEM,%ch # Dump memory?
pushl %ds # Save
testb $0x2,0x52(%ebx) # V86 mode?
jnz dump.3 # Yes
- verrl 0x4(%esi) # Readable selector?
+ verr 0x4(%esi) # Readable selector?
jnz dump.3 # No
ldsl (%esi),%esi # Load pointer
jmp dump.4 # Join common code
diff --git a/sys/boot/i386/btx/btx/btx.m4 b/sys/boot/i386/btx/btx/btx.m4
deleted file mode 100644
index 70649bb..0000000
--- a/sys/boot/i386/btx/btx/btx.m4
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-define(_al,0x0)dnl
-define(_cl,0x1)dnl
-define(_dl,0x2)dnl
-define(_bl,0x3)dnl
-define(_ah,0x4)dnl
-define(_ch,0x5)dnl
-define(_dh,0x6)dnl
-define(_bh,0x7)dnl
-
-define(_ax,0x0)dnl
-define(_cx,0x1)dnl
-define(_dx,0x2)dnl
-define(_bx,0x3)dnl
-define(_sp,0x4)dnl
-define(_bp,0x5)dnl
-define(_si,0x6)dnl
-define(_di,0x7)dnl
-
-define(_bx_si,0x0)dnl
-define(_bx_di,0x1)dnl
-define(_bp_si,0x2)dnl
-define(_bp_di,0x3)dnl
-define(_si_,0x4)dnl
-define(_di_,0x5)dnl
-define(_bp_,0x6)dnl
-define(_bx_,0x7)dnl
-
-define(o16,`.byte 0x66')dnl
-
-define(addwia,`.byte 0x5; .word $1')dnl
-define(lgdtwm,`.byte 0xf; .byte 0x1; .byte 0x16; .word $1')dnl
-define(lidtwm,`.byte 0xf; .byte 0x1; .byte 0x1e; .word $1')dnl
-define(cmpwmr,`.byte 0x3b; .byte ($2 << 0x3) | 0x6; .word $1')dnl
-define(cmpwir,`.byte 0x81; .byte 0xf8 | $2; .word $1')dnl
-define(movbr1,`.byte 0x88; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
-define(movwr0,`.byte 0x89; .byte ($1 << 0x3) | $2')dnl
-define(leaw1r,`.byte 0x8d; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
-define(movwir,`.byte 0xb8 | $2; .word $1')dnl
-define(movbi1,`.byte 0xc6; .byte 0x40 | $3; .byte $2; .byte $1')dnl
-define(callwi,`.byte 0xe8; .word $1 - . - 0x2')dnl
-define(jmpfwi,`.byte 0xea; .word $2; .word $1')dnl
-define(tstbim,`.byte 0xf6; .byte 0x6; .word $2; .byte $1')dnl
diff --git a/sys/boot/i386/btx/btx/btx.s b/sys/boot/i386/btx/btx/btx.s
index ceda55f..00f153c 100644
--- a/sys/boot/i386/btx/btx/btx.s
+++ b/sys/boot/i386/btx/btx/btx.s
@@ -94,6 +94,7 @@
# Code segment.
#
.globl start
+ .code16
start: # Start of code
#
# BTX header.
@@ -111,116 +112,115 @@ btx_hdr: .byte 0xeb # Machine ID
# Initialization routine.
#
init: cli # Disable interrupts
- xorl %eax,%eax # Zero/segment
- movl %ax,%ss # Set up
- movwir(MEM_ESP0,_sp) # stack
- movl %ax,%es # Address
- movl %ax,%ds # data
- pushw $0x2 # Clear
- popfw # flags
+ xor %ax,%ax # Zero/segment
+ mov %ax,%ss # Set up
+ mov $MEM_ESP0,%sp # stack
+ mov %ax,%es # Address
+ mov %ax,%ds # data
+ pushl $0x2 # Clear
+ popfl # flags
#
# Initialize memory.
#
- movwir(MEM_IDT,_di) # Memory to initialize
- movwir((MEM_ORG-MEM_IDT)/2,_cx) # Words to zero
- pushl %edi # Save
+ mov $MEM_IDT,%di # Memory to initialize
+ mov $(MEM_ORG-MEM_IDT)/2,%cx # Words to zero
+ push %di # Save
rep # Zero-fill
- stosl # memory
- popl %edi # Restore
+ stosw # memory
+ pop %di # Restore
#
# Create IDT.
#
- movwir(idtctl,_si) # Control string
+ mov $idtctl,%si # Control string
init.1: lodsb # Get entry
- cwde # count
- xchgl %eax,%ecx # as word
- jecxz init.4 # If done
+ cbw # count
+ xchg %ax,%cx # as word
+ jcxz init.4 # If done
lodsb # Get segment
- xchgl %eax,%edx # P:DPL:type
- lodsl # Get control
- xchgl %eax,%ebx # set
- lodsl # Get handler offset
- movb $SEL_SCODE,%dh # Segment selector
-init.2: shrl %ebx # Handle this int?
+ xchg %ax,%dx # P:DPL:type
+ lodsw # Get control
+ xchg %ax,%bx # set
+ lodsw # Get handler offset
+ mov $SEL_SCODE,%dh # Segment selector
+init.2: shr %bx # Handle this int?
jnc init.3 # No
- movwr0(_ax,_di_) # Set handler offset
- movbr1(_dh,0x2,_di_) # and selector
- movbr1(_dl,0x5,_di_) # Set P:DPL:type
- addwia(0x4) # Next handler
-init.3: leaw1r(0x8,_di_,_di) # Next entry
+ mov %ax,(%di) # Set handler offset
+ mov %dh,0x2(%di) # and selector
+ mov %dl,0x5(%di) # Set P:DPL:type
+ add $0x4,%ax # Next handler
+init.3: lea 0x8(%di),%di # Next entry
loop init.2 # Till set done
jmp init.1 # Continue
#
# Initialize TSS.
#
-init.4: movbi1(_ESP0H,TSS_ESP0+1,_di_) # Set ESP0
- movbi1(SEL_SDATA,TSS_SS0,_di_) # Set SS0
- movbi1(_ESP1H,TSS_ESP1+1,_di_) # Set ESP1
- movbi1(_TSSIO,TSS_MAP,_di_) # Set I/O bit map base
+init.4: movb $_ESP0H,TSS_ESP0+1(%di) # Set ESP0
+ movb $SEL_SDATA,TSS_SS0(%di) # Set SS0
+ movb $_ESP1H,TSS_ESP1+1(%di) # Set ESP1
+ movb $_TSSIO,TSS_MAP(%di) # Set I/O bit map base
ifdef(`PAGING',`
#
# Create page directory.
#
- xorw %dx,%dx # Page
- movb $PAG_SIZ>>0x8,%dh # size
- xorw %ax,%ax # Zero
- movwir(MEM_DIR,_di) # Page directory
- movb $PAG_CNT>>0xa,%cl # Entries
- movwir(MEM_TBL|0x7,_ax) # First entry
-init.5: stosw # Write entry
- addl %edx,%eax # To next
+ xor %edx,%edx # Page
+ mov $PAG_SIZ>>0x8,%dh # size
+ xor %eax,%eax # Zero
+ mov $MEM_DIR,%di # Page directory
+ mov $PAG_CNT>>0xa,%cl # Entries
+ mov $MEM_TBL|0x7,%ax # First entry
+init.5: stosl # Write entry
+ add %dx,%ax # To next
loop init.5 # Till done
#
# Create page tables.
#
- movwir(MEM_TBL,_di) # Page table
- movb $PAG_CNT>>0x8,%ch # Entries
- xorl %eax,%eax # Start address
-init.6: movb $0x7,%al # Set U:W:P flags
- cmpwmr(btx_hdr+0x8,_cx) # Standard user page?
+ mov $MEM_TBL,%di # Page table
+ mov $PAG_CNT>>0x8,%ch # Entries
+ xor %ax,%ax # Start address
+init.6: mov $0x7,%al # Set U:W:P flags
+ cmp btx_hdr+0x8,%cx # Standard user page?
jb init.7 # Yes
- cmpwir(PAG_CNT-MEM_BTX>>0xc,_cx)# BTX memory?
+ cmp $PAG_CNT-MEM_BTX>>0xc,%cx # BTX memory?
jae init.7 # No or first page
- andb $~0x2,%al # Clear W flag
- cmpwir(PAG_CNT-MEM_USR>>0xc,_cx)# User page zero?
+ and $~0x2,%al # Clear W flag
+ cmp $PAG_CNT-MEM_USR>>0xc,%cx # User page zero?
jne init.7 # No
- tstbim(0x80,btx_hdr+0x7) # Unmap it?
+ testb $0x80,btx_hdr+0x7 # Unmap it?
jz init.7 # No
- andb $~0x1,%al # Clear P flag
-init.7: stosw # Set entry
- addw %dx,%ax # Next address
+ and $~0x1,%al # Clear P flag
+init.7: stosl # Set entry
+ add %edx,%eax # Next address
loop init.6 # Till done
')
#
# Bring up the system.
#
- movwir(0x2820,_bx) # Set protected mode
- callwi(setpic) # IRQ offsets
- lidtwm(idtdesc) # Set IDT
+ mov $0x2820,%bx # Set protected mode
+ callw setpic # IRQ offsets
+ lidt idtdesc # Set IDT
ifdef(`PAGING',`
- xorw %ax,%ax # Set base
- movb $MEM_DIR>>0x8,%ah # of page
- movl %eax,%cr3 # directory
+ xor %eax,%eax # Set base
+ mov $MEM_DIR>>0x8,%ah # of page
+ mov %eax,%cr3 # directory
')
- lgdtwm(gdtdesc) # Set GDT
- movl %cr0,%eax # Switch to
+ lgdt gdtdesc # Set GDT
+ mov %cr0,%eax # Switch to protected
ifdef(`PAGING',`
- o16 # protected mode
- orl $0x80000001,%eax # and enable paging
+ or $0x80000001,%eax # mode and enable paging
',`
- o16 # protected mode
- orl $0x01,%eax #
+ or $0x01,%eax # mode
')
- movl %eax,%cr0 #
- jmpfwi(SEL_SCODE,init.8) # To 32-bit code
+ mov %eax,%cr0 #
+ ljmp $SEL_SCODE,$init.8 # To 32-bit code
+ .code32
init.8: xorl %ecx,%ecx # Zero
movb $SEL_SDATA,%cl # To 32-bit
- movl %cx,%ss # stack
+ movw %cx,%ss # stack
#
# Launch user task.
#
movb $SEL_TSS,%cl # Set task
- ltrl %ecx # register
+ ltr %cx # register
movl $MEM_USR,%edx # User base address
movzwl %ss:BDA_MEM,%eax # Get free memory
shll $0xa,%eax # To bytes
@@ -229,8 +229,8 @@ init.8: xorl %ecx,%ecx # Zero
movb $SEL_UDATA,%cl # User data selector
pushl %ecx # Set SS
pushl %eax # Set ESP
- pushl $0x202 # Set flags (IF set)
- pushl $SEL_UCODE # Set CS
+ push $0x202 # Set flags (IF set)
+ push $SEL_UCODE # Set CS
pushl btx_hdr+0xc # Set EIP
pushl %ecx # Set GS
pushl %ecx # Set FS
@@ -238,7 +238,7 @@ init.8: xorl %ecx,%ecx # Zero
pushl %ecx # Set ES
pushl %edx # Set EAX
movb $0x7,%cl # Set remaining
-init.9: pushb $0x0 # general
+init.9: push $0x0 # general
loop init.9 # registers
popa # and initialize
popl %es # Initialize
@@ -266,43 +266,41 @@ ifdef(`PAGING',`
#
# To 16 bits.
#
- o16 # Reload
- jmpfwi(SEL_RCODE,exit.1) # CS
-exit.1: movb $SEL_RDATA,%cl # 16-bit selector
- movl %cx,%ss # Reload SS
- movl %cx,%ds # Load
- movl %cx,%es # remaining
- movl %cx,%fs # segment
- movl %cx,%gs # registers
+ ljmpw $SEL_RCODE,$exit.1 # Reload CS
+ .code16
+exit.1: mov $SEL_RDATA,%cl # 16-bit selector
+ mov %cx,%ss # Reload SS
+ mov %cx,%ds # Load
+ mov %cx,%es # remaining
+ mov %cx,%fs # segment
+ mov %cx,%gs # registers
#
# To real-address mode.
#
- decl %eax # Switch to
- movl %eax,%cr0 # real mode
- jmpfwi(0x0,exit.2) # Reload CS
-exit.2: xorl %eax,%eax # Real mode segment
- movl %ax,%ss # Reload SS
- movl %ax,%ds # Address data
- movwir(0x7008,_bx) # Set real mode
- callwi(setpic) # IRQ offsets
- lidtwm(ivtdesc) # Set IVT
+ dec %ax # Switch to
+ mov %eax,%cr0 # real mode
+ ljmp $0x0,$exit.2 # Reload CS
+exit.2: xor %ax,%ax # Real mode segment
+ mov %ax,%ss # Reload SS
+ mov %ax,%ds # Address data
+ mov $0x7008,%bx # Set real mode
+ callw setpic # IRQ offsets
+ lidt ivtdesc # Set IVT
#
# Reboot or await reset.
#
sti # Enable interrupts
- tstbim(0x1,btx_hdr+0x7) # Reboot?
+ testb $0x1,btx_hdr+0x7 # Reboot?
exit.3: jz exit.3 # No
- .code16
movw $0x1234, BDA_BOOT # Do a warm boot
- jmpfwi(0xffff,0x0) # reboot the machine
- .code32
+ ljmp $0xffff,$0x0 # reboot the machine
#
# Set IRQ offsets by reprogramming 8259A PICs.
#
-setpic: inb $0x21,%al # Save master
- pushl %eax # IMR
- inb $0xa1,%al # Save slave
- pushl %eax # IMR
+setpic: in $0x21,%al # Save master
+ push %ax # IMR
+ in $0xa1,%al # Save slave
+ push %ax # IMR
movb $0x11,%al # ICW1 to
outb %al,$0x20 # master,
outb %al,$0xa0 # slave
@@ -317,11 +315,12 @@ setpic: inb $0x21,%al # Save master
movb $0x1,%al # ICW4 to
outb %al,$0x21 # master,
outb %al,$0xa1 # slave
- popl %eax # Restore slave
+ pop %ax # Restore slave
outb %al,$0xa1 # IMR
- popl %eax # Restore master
+ pop %ax # Restore master
outb %al,$0x21 # IMR
- ret # To caller
+ retw # To caller
+ .code32
#
# Initiate return from V86 mode to user mode.
#
@@ -329,33 +328,33 @@ inthlt: hlt # To supervisor mode
#
# Exception jump table.
#
-intx00: pushb $0x0 # Int 0x0: #DE
+intx00: push $0x0 # Int 0x0: #DE
jmp ex_noc # Divide error
- pushb $0x1 # Int 0x1: #DB
+ push $0x1 # Int 0x1: #DB
jmp ex_noc # Debug
- pushb $0x3 # Int 0x3: #BP
+ push $0x3 # Int 0x3: #BP
jmp ex_noc # Breakpoint
- pushb $0x4 # Int 0x4: #OF
+ push $0x4 # Int 0x4: #OF
jmp ex_noc # Overflow
- pushb $0x5 # Int 0x5: #BR
+ push $0x5 # Int 0x5: #BR
jmp ex_noc # BOUND range exceeded
- pushb $0x6 # Int 0x6: #UD
+ push $0x6 # Int 0x6: #UD
jmp ex_noc # Invalid opcode
- pushb $0x7 # Int 0x7: #NM
+ push $0x7 # Int 0x7: #NM
jmp ex_noc # Device not available
- pushb $0x8 # Int 0x8: #DF
+ push $0x8 # Int 0x8: #DF
jmp except # Double fault
- pushb $0xa # Int 0xa: #TS
+ push $0xa # Int 0xa: #TS
jmp except # Invalid TSS
- pushb $0xb # Int 0xb: #NP
+ push $0xb # Int 0xb: #NP
jmp except # Segment not present
- pushb $0xc # Int 0xc: #SS
+ push $0xc # Int 0xc: #SS
jmp except # Stack segment fault
- pushb $0xd # Int 0xd: #GP
+ push $0xd # Int 0xd: #GP
jmp ex_v86 # General protection
- pushb $0xe # Int 0xe: #PF
+ push $0xe # Int 0xe: #PF
jmp except # Page fault
-intx10: pushb $0x10 # Int 0x10: #MF
+intx10: push $0x10 # Int 0x10: #MF
jmp ex_noc # Floating-point error
#
# Handle #GP exception.
@@ -392,7 +391,7 @@ except: cld # String ops inc
except.1: pushl 0x50(%esp,1) # Set GS, FS, DS, ES
decb %al # (if V86 mode), and
jne except.1 # SS, ESP
-except.2: pushl $SEL_SDATA # Set up
+except.2: push $SEL_SDATA # Set up
popl %ds # to
pushl %ds # address
popl %es # data
@@ -538,7 +537,7 @@ v86sti: orb $0x2,0x31(%ebp) # Set IF
v86pushf: subl %ecx,%ebx # Adjust SP
cmpb $0x4,%cl # 32-bit
je v86pushf.1 # Yes
- o16 # 16-bit
+ data16 # 16-bit
v86pushf.1: movl %edx,(%ebx) # Save flags
jmp v86mon.6 # Finish up
#
@@ -555,7 +554,7 @@ v86iret: movzwl (%ebx),%esi # Load V86 IP
v86popf: cmpb $0x4,%cl # 32-bit?
je v86popf.1 # Yes
movl %edx,%eax # Initialize
- o16 # 16-bit
+ data16 # 16-bit
v86popf.1: movl (%ebx),%eax # Load flags
addl %ecx,%ebx # Adjust SP
andl $V86_FLG,%eax # Merge
@@ -654,37 +653,37 @@ v86intn.3: subl %edi,%esi # From
#
# Hardware interrupt jump table.
#
-intx20: pushb $0x8 # Int 0x20: IRQ0
+intx20: push $0x8 # Int 0x20: IRQ0
jmp int_hw # V86 int 0x8
- pushb $0x9 # Int 0x21: IRQ1
+ push $0x9 # Int 0x21: IRQ1
jmp int_hw # V86 int 0x9
- pushb $0xa # Int 0x22: IRQ2
+ push $0xa # Int 0x22: IRQ2
jmp int_hw # V86 int 0xa
- pushb $0xb # Int 0x23: IRQ3
+ push $0xb # Int 0x23: IRQ3
jmp int_hw # V86 int 0xb
- pushb $0xc # Int 0x24: IRQ4
+ push $0xc # Int 0x24: IRQ4
jmp int_hw # V86 int 0xc
- pushb $0xd # Int 0x25: IRQ5
+ push $0xd # Int 0x25: IRQ5
jmp int_hw # V86 int 0xd
- pushb $0xe # Int 0x26: IRQ6
+ push $0xe # Int 0x26: IRQ6
jmp int_hw # V86 int 0xe
- pushb $0xf # Int 0x27: IRQ7
+ push $0xf # Int 0x27: IRQ7
jmp int_hw # V86 int 0xf
- pushb $0x70 # Int 0x28: IRQ8
+ push $0x70 # Int 0x28: IRQ8
jmp int_hw # V86 int 0x70
- pushb $0x71 # Int 0x29: IRQ9
+ push $0x71 # Int 0x29: IRQ9
jmp int_hw # V86 int 0x71
- pushb $0x72 # Int 0x2a: IRQ10
+ push $0x72 # Int 0x2a: IRQ10
jmp int_hw # V86 int 0x72
- pushb $0x73 # Int 0x2b: IRQ11
+ push $0x73 # Int 0x2b: IRQ11
jmp int_hw # V86 int 0x73
- pushb $0x74 # Int 0x2c: IRQ12
+ push $0x74 # Int 0x2c: IRQ12
jmp int_hw # V86 int 0x74
- pushb $0x75 # Int 0x2d: IRQ13
+ push $0x75 # Int 0x2d: IRQ13
jmp int_hw # V86 int 0x75
- pushb $0x76 # Int 0x2e: IRQ14
+ push $0x76 # Int 0x2e: IRQ14
jmp int_hw # V86 int 0x76
- pushb $0x77 # Int 0x2f: IRQ15
+ push $0x77 # Int 0x2f: IRQ15
jmp int_hw # V86 int 0x77
#
# Reflect hardware interrupts.
@@ -733,7 +732,7 @@ intusr: std # String ops dec
pushl %fs # and
pushl %ds # point
pushl %es # to them
- pushb $SEL_SDATA # Set up
+ push $SEL_SDATA # Set up
popl %ds # to
pushl %ds # address
popl %es # data
@@ -863,7 +862,7 @@ dump.2: testb $DMP_MEM,%ch # Dump memory?
pushl %ds # Save
testb $0x2,0x52(%ebx) # V86 mode?
jnz dump.3 # Yes
- verrl 0x4(%esi) # Readable selector?
+ verr 0x4(%esi) # Readable selector?
jnz dump.3 # No
ldsl (%esi),%esi # Load pointer
jmp dump.4 # Join common code
diff --git a/sys/boot/i386/cdboot/cdboot.s b/sys/boot/i386/cdboot/cdboot.s
index 30ed2fa..625dce9 100644
--- a/sys/boot/i386/cdboot/cdboot.s
+++ b/sys/boot/i386/cdboot/cdboot.s
@@ -81,13 +81,13 @@ start: cld # string ops inc
movw %ax, %ds # setup the
movw %ax, %es # data segments
movw $welcome_msg, %si # %ds:(%si) -> welcome message
- call putstr # display the welcome message
+ callw putstr # display the welcome message
#
# Setup the arguments that the loader is expecting from boot[12]
#
movw $bootinfo_msg, %si # %ds:(%si) -> boot args message
- call putstr # display the message
- movl $MEM_ARG, %ebx # %ds:(%ebx) -> boot args
+ callw putstr # display the message
+ movl $MEM_ARG, %bx # %ds:(%bx) -> boot args
movw %bx, %di # %es:(%di) -> boot args
xorl %eax, %eax # zero %eax
movw $(MEM_ARG_SIZE/4), %cx # Size of arguments in 32-bit
@@ -95,18 +95,18 @@ start: cld # string ops inc
rep # Clear the arguments
stosl # to zero
popw %dx # restore BIOS boot device
- movb %dl, 0x4(%ebx) # set kargs->bootdev
- orb $KARGS_FLAGS_CD, 0x8(%ebx) # kargs->bootflags |=
+ movb %dl, 0x4(%bx) # set kargs->bootdev
+ orb $KARGS_FLAGS_CD, 0x8(%bx) # kargs->bootflags |=
# KARGS_FLAGS_CD
#
# Turn on the A20 address line
#
- call seta20 # Turn A20 on
+ callw seta20 # Turn A20 on
#
# Relocate the loader and BTX using a very lazy protected mode
#
movw $relocate_msg, %si # Display the
- call putstr # relocation message
+ callw putstr # relocation message
movl end+AOUT_ENTRY, %edi # %edi is the destination
movl $(end+AOUT_HEADER), %esi # %esi is
# the start of the text
@@ -118,9 +118,8 @@ start: cld # string ops inc
movl %cr0, %eax # Turn on
orb $0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # long jump to
- .word pm_start # clear the instruction
- .word SEL_SCODE # pre-fetch queue
+ ljmp $SEL_SCODE,$pm_start # long jump to clear the
+ # instruction pre-fetch queue
.code32
pm_start: movw $SEL_SDATA, %ax # Initialize
movw %ax, %ds # %ds and
@@ -152,9 +151,8 @@ pm_16: movw $SEL_RDATA, %ax # Initialize
movl %cr0, %eax # Turn off
andb $~0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # Long jump to
- .word pm_end # clear the instruction
- .word 0x0 # pre-fetch
+ ljmp $0,$pm_end # Long jump to clear the
+ # instruction pre-fetch queue
pm_end: sti # Turn interrupts back on now
#
# Copy the BTX client to MEM_BTX_CLIENT
@@ -185,10 +183,8 @@ pm_end: sti # Turn interrupts back on now
# Now we just start up BTX and let it do the rest
#
movw $jump_message, %si # Display the
- call putstr # jump message
- .byte 0xea # Jump to
- .word MEM_BTX_ENTRY # BTX entry
- .word 0x0 # point
+ callw putstr # jump message
+ ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
#
# Display a null-terminated string
@@ -196,7 +192,7 @@ pm_end: sti # Turn interrupts back on now
putstr: lodsb # load %al from %ds:(%si)
testb %al,%al # stop at null
jnz putc # if the char != null, output it
- ret # return when null is hit
+ retw # return when null is hit
putc: movw $0x7,%bx # attribute for output
movb $0xe,%ah # BIOS: put_char
int $0x10 # call BIOS, print char in %al
@@ -217,7 +213,7 @@ seta20.2: inb $0x64,%al # Get status
movb $0xdf,%al # Enable
outb %al,$0x60 # A20
sti # Enable interrupts
- ret # To caller
+ retw # To caller
#
# BTX client to start btxldr
diff --git a/sys/boot/i386/cdldr/cdldr.s b/sys/boot/i386/cdldr/cdldr.s
index 30ed2fa..625dce9 100644
--- a/sys/boot/i386/cdldr/cdldr.s
+++ b/sys/boot/i386/cdldr/cdldr.s
@@ -81,13 +81,13 @@ start: cld # string ops inc
movw %ax, %ds # setup the
movw %ax, %es # data segments
movw $welcome_msg, %si # %ds:(%si) -> welcome message
- call putstr # display the welcome message
+ callw putstr # display the welcome message
#
# Setup the arguments that the loader is expecting from boot[12]
#
movw $bootinfo_msg, %si # %ds:(%si) -> boot args message
- call putstr # display the message
- movl $MEM_ARG, %ebx # %ds:(%ebx) -> boot args
+ callw putstr # display the message
+ movl $MEM_ARG, %bx # %ds:(%bx) -> boot args
movw %bx, %di # %es:(%di) -> boot args
xorl %eax, %eax # zero %eax
movw $(MEM_ARG_SIZE/4), %cx # Size of arguments in 32-bit
@@ -95,18 +95,18 @@ start: cld # string ops inc
rep # Clear the arguments
stosl # to zero
popw %dx # restore BIOS boot device
- movb %dl, 0x4(%ebx) # set kargs->bootdev
- orb $KARGS_FLAGS_CD, 0x8(%ebx) # kargs->bootflags |=
+ movb %dl, 0x4(%bx) # set kargs->bootdev
+ orb $KARGS_FLAGS_CD, 0x8(%bx) # kargs->bootflags |=
# KARGS_FLAGS_CD
#
# Turn on the A20 address line
#
- call seta20 # Turn A20 on
+ callw seta20 # Turn A20 on
#
# Relocate the loader and BTX using a very lazy protected mode
#
movw $relocate_msg, %si # Display the
- call putstr # relocation message
+ callw putstr # relocation message
movl end+AOUT_ENTRY, %edi # %edi is the destination
movl $(end+AOUT_HEADER), %esi # %esi is
# the start of the text
@@ -118,9 +118,8 @@ start: cld # string ops inc
movl %cr0, %eax # Turn on
orb $0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # long jump to
- .word pm_start # clear the instruction
- .word SEL_SCODE # pre-fetch queue
+ ljmp $SEL_SCODE,$pm_start # long jump to clear the
+ # instruction pre-fetch queue
.code32
pm_start: movw $SEL_SDATA, %ax # Initialize
movw %ax, %ds # %ds and
@@ -152,9 +151,8 @@ pm_16: movw $SEL_RDATA, %ax # Initialize
movl %cr0, %eax # Turn off
andb $~0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # Long jump to
- .word pm_end # clear the instruction
- .word 0x0 # pre-fetch
+ ljmp $0,$pm_end # Long jump to clear the
+ # instruction pre-fetch queue
pm_end: sti # Turn interrupts back on now
#
# Copy the BTX client to MEM_BTX_CLIENT
@@ -185,10 +183,8 @@ pm_end: sti # Turn interrupts back on now
# Now we just start up BTX and let it do the rest
#
movw $jump_message, %si # Display the
- call putstr # jump message
- .byte 0xea # Jump to
- .word MEM_BTX_ENTRY # BTX entry
- .word 0x0 # point
+ callw putstr # jump message
+ ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
#
# Display a null-terminated string
@@ -196,7 +192,7 @@ pm_end: sti # Turn interrupts back on now
putstr: lodsb # load %al from %ds:(%si)
testb %al,%al # stop at null
jnz putc # if the char != null, output it
- ret # return when null is hit
+ retw # return when null is hit
putc: movw $0x7,%bx # attribute for output
movb $0xe,%ah # BIOS: put_char
int $0x10 # call BIOS, print char in %al
@@ -217,7 +213,7 @@ seta20.2: inb $0x64,%al # Get status
movb $0xdf,%al # Enable
outb %al,$0x60 # A20
sti # Enable interrupts
- ret # To caller
+ retw # To caller
#
# BTX client to start btxldr
diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
index 5f523bb..0ccf65d 100644
--- a/sys/boot/i386/gptboot/Makefile
+++ b/sys/boot/i386/gptboot/Makefile
@@ -9,8 +9,6 @@ CLEANFILES+= boot1 boot1.out boot1.o \
boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
sio.o
-M4?= m4
-
# A value of 0x80 enables LBA support.
B1FLAGS= 0
@@ -45,9 +43,8 @@ boot1: boot1.out
boot1.out: boot1.o
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
-boot1.o: boot1.m4 boot1.s
- (cd ${.CURDIR}; ${M4} -DFLAGS=${B1FLAGS} boot1.m4 boot1.s) | \
- ${AS} ${AFLAGS} -o ${.TARGET}
+boot1.o: boot1.s
+ ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET}
boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
@@ -67,10 +64,10 @@ 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} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \
+ --defsym SIOFMT=${B2SIOFMT} \
+ --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \
+ ${.IMPSRC} -o ${.TARGET}
install:
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
diff --git a/sys/boot/i386/pxeldr/pxeldr.S b/sys/boot/i386/pxeldr/pxeldr.S
index 6ad5206..c9854f9 100644
--- a/sys/boot/i386/pxeldr/pxeldr.S
+++ b/sys/boot/i386/pxeldr/pxeldr.S
@@ -85,31 +85,31 @@ start: cld # string ops inc
addl %ebx, %ecx # the PXENV+ struct and
pushl %ecx # save it on the stack
movw $welcome_msg, %si # %ds:(%si) -> welcome message
- call putstr # display the welcome message
+ callw putstr # display the welcome message
#
# Setup the arguments that the loader is expecting from boot[12]
#
movw $bootinfo_msg, %si # %ds:(%si) -> boot args message
- call putstr # display the message
- movl $MEM_ARG, %ebx # %ds:(%ebx) -> boot args
+ callw putstr # display the message
+ movl $MEM_ARG, %bx # %ds:(%bx) -> boot args
movw %bx, %di # %es:(%di) -> boot args
xorl %eax, %eax # zero %eax
movw $(MEM_ARG_SIZE/4), %cx # Size of arguments in 32-bit
# dwords
rep # Clear the arguments
stosl # to zero
- orb $KARGS_FLAGS_PXE, 0x8(%ebx) # kargs->bootflags |=
+ orb $KARGS_FLAGS_PXE, 0x8(%bx) # kargs->bootflags |=
# KARGS_FLAGS_PXE
- popl 0xc(%ebx) # kargs->pxeinfo = *PXENV+
+ popl 0xc(%bx) # kargs->pxeinfo = *PXENV+
#
# Turn on the A20 address line
#
- call seta20 # Turn A20 on
+ callw seta20 # Turn A20 on
#
# Relocate the loader and BTX using a very lazy protected mode
#
movw $relocate_msg, %si # Display the
- call putstr # relocation message
+ callw putstr # relocation message
movl end+AOUT_ENTRY, %edi # %edi is the destination
movl $(end+AOUT_HEADER), %esi # %esi is
# the start of the text
@@ -121,9 +121,8 @@ start: cld # string ops inc
movl %cr0, %eax # Turn on
orb $0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # long jump to
- .word pm_start # clear the instruction
- .word SEL_SCODE # pre-fetch queue
+ ljmp $SEL_SCODE,$pm_start # long jump to clear the
+ # instruction pre-fetch queue
.code32
pm_start: movw $SEL_SDATA, %ax # Initialize
movw %ax, %ds # %ds and
@@ -155,9 +154,8 @@ pm_16: movw $SEL_RDATA, %ax # Initialize
movl %cr0, %eax # Turn off
andb $~0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # Long jump to
- .word pm_end # clear the instruction
- .word 0x0 # pre-fetch
+ ljmp $0,$pm_end # Long jump to clear the
+ # instruction pre-fetch queue
pm_end: sti # Turn interrupts back on now
#
# Copy the BTX client to MEM_BTX_CLIENT
@@ -188,10 +186,8 @@ pm_end: sti # Turn interrupts back on now
# Now we just start up BTX and let it do the rest
#
movw $jump_message, %si # Display the
- call putstr # jump message
- .byte 0xea # Jump to
- .word MEM_BTX_ENTRY # BTX entry
- .word 0x0 # point
+ callw putstr # jump message
+ ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
#
# Display a null-terminated string
@@ -199,7 +195,7 @@ pm_end: sti # Turn interrupts back on now
putstr: lodsb # load %al from %ds:(%si)
testb %al,%al # stop at null
jnz putc # if the char != null, output it
- ret # return when null is hit
+ retw # return when null is hit
putc: movw $0x7,%bx # attribute for output
movb $0xe,%ah # BIOS: put_char
int $0x10 # call BIOS, print char in %al
@@ -220,7 +216,7 @@ seta20.2: inb $0x64,%al # Get status
movb $0xdf,%al # Enable
outb %al,$0x60 # A20
sti # Enable interrupts
- ret # To caller
+ retw # To caller
#
# BTX client to start btxldr
diff --git a/sys/boot/i386/pxeldr/pxeldr.s b/sys/boot/i386/pxeldr/pxeldr.s
index 6ad5206..c9854f9 100644
--- a/sys/boot/i386/pxeldr/pxeldr.s
+++ b/sys/boot/i386/pxeldr/pxeldr.s
@@ -85,31 +85,31 @@ start: cld # string ops inc
addl %ebx, %ecx # the PXENV+ struct and
pushl %ecx # save it on the stack
movw $welcome_msg, %si # %ds:(%si) -> welcome message
- call putstr # display the welcome message
+ callw putstr # display the welcome message
#
# Setup the arguments that the loader is expecting from boot[12]
#
movw $bootinfo_msg, %si # %ds:(%si) -> boot args message
- call putstr # display the message
- movl $MEM_ARG, %ebx # %ds:(%ebx) -> boot args
+ callw putstr # display the message
+ movl $MEM_ARG, %bx # %ds:(%bx) -> boot args
movw %bx, %di # %es:(%di) -> boot args
xorl %eax, %eax # zero %eax
movw $(MEM_ARG_SIZE/4), %cx # Size of arguments in 32-bit
# dwords
rep # Clear the arguments
stosl # to zero
- orb $KARGS_FLAGS_PXE, 0x8(%ebx) # kargs->bootflags |=
+ orb $KARGS_FLAGS_PXE, 0x8(%bx) # kargs->bootflags |=
# KARGS_FLAGS_PXE
- popl 0xc(%ebx) # kargs->pxeinfo = *PXENV+
+ popl 0xc(%bx) # kargs->pxeinfo = *PXENV+
#
# Turn on the A20 address line
#
- call seta20 # Turn A20 on
+ callw seta20 # Turn A20 on
#
# Relocate the loader and BTX using a very lazy protected mode
#
movw $relocate_msg, %si # Display the
- call putstr # relocation message
+ callw putstr # relocation message
movl end+AOUT_ENTRY, %edi # %edi is the destination
movl $(end+AOUT_HEADER), %esi # %esi is
# the start of the text
@@ -121,9 +121,8 @@ start: cld # string ops inc
movl %cr0, %eax # Turn on
orb $0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # long jump to
- .word pm_start # clear the instruction
- .word SEL_SCODE # pre-fetch queue
+ ljmp $SEL_SCODE,$pm_start # long jump to clear the
+ # instruction pre-fetch queue
.code32
pm_start: movw $SEL_SDATA, %ax # Initialize
movw %ax, %ds # %ds and
@@ -155,9 +154,8 @@ pm_16: movw $SEL_RDATA, %ax # Initialize
movl %cr0, %eax # Turn off
andb $~0x1, %al # protected
movl %eax, %cr0 # mode
- .byte 0xea # Long jump to
- .word pm_end # clear the instruction
- .word 0x0 # pre-fetch
+ ljmp $0,$pm_end # Long jump to clear the
+ # instruction pre-fetch queue
pm_end: sti # Turn interrupts back on now
#
# Copy the BTX client to MEM_BTX_CLIENT
@@ -188,10 +186,8 @@ pm_end: sti # Turn interrupts back on now
# Now we just start up BTX and let it do the rest
#
movw $jump_message, %si # Display the
- call putstr # jump message
- .byte 0xea # Jump to
- .word MEM_BTX_ENTRY # BTX entry
- .word 0x0 # point
+ callw putstr # jump message
+ ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
#
# Display a null-terminated string
@@ -199,7 +195,7 @@ pm_end: sti # Turn interrupts back on now
putstr: lodsb # load %al from %ds:(%si)
testb %al,%al # stop at null
jnz putc # if the char != null, output it
- ret # return when null is hit
+ retw # return when null is hit
putc: movw $0x7,%bx # attribute for output
movb $0xe,%ah # BIOS: put_char
int $0x10 # call BIOS, print char in %al
@@ -220,7 +216,7 @@ seta20.2: inb $0x64,%al # Get status
movb $0xdf,%al # Enable
outb %al,$0x60 # A20
sti # Enable interrupts
- ret # To caller
+ retw # To caller
#
# BTX client to start btxldr
OpenPOWER on IntegriCloud