1998-10-05 10:08:37 +00:00
|
|
|
#
|
1999-09-03 01:38:29 +00:00
|
|
|
# Copyright (c) 1998 Robert Nordier
|
1998-10-05 10:08:37 +00:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
1999-08-28 01:08:13 +00:00
|
|
|
# $FreeBSD$
|
1998-10-05 10:08:37 +00:00
|
|
|
|
2000-10-02 17:30:22 +00:00
|
|
|
# A 512-byte boot manager.
|
1998-10-05 10:08:37 +00:00
|
|
|
|
1998-12-05 11:58:33 +00:00
|
|
|
.set NHRDRV,0x475 # Number of hard drives
|
1998-11-29 14:09:00 +00:00
|
|
|
.set ORIGIN,0x600 # Execution address
|
2000-10-02 17:30:22 +00:00
|
|
|
.set FAKE,0x800 # Partition entry
|
1998-12-05 11:58:33 +00:00
|
|
|
.set LOAD,0x7c00 # Load address
|
|
|
|
|
|
|
|
.set PRT_OFF,0x1be # Partition table
|
|
|
|
|
2000-10-02 17:30:22 +00:00
|
|
|
.set TBL0SZ,0x3 # Table 0 size
|
|
|
|
.set TBL1SZ,0xc # Table 1 size
|
1998-11-29 14:09:00 +00:00
|
|
|
|
1998-12-05 11:58:33 +00:00
|
|
|
.set MAGIC,0xaa55 # Magic: bootable
|
2000-12-12 17:27:35 +00:00
|
|
|
.set B0MAGIC,0xbb66 # Identification
|
1998-12-05 11:58:33 +00:00
|
|
|
|
|
|
|
.set KEY_ENTER,0x1c # Enter key scan code
|
|
|
|
.set KEY_F1,0x3b # F1 key scan code
|
2003-06-01 20:41:04 +00:00
|
|
|
.set KEY_1,0x02 # #1 key scan code
|
1998-12-05 11:58:33 +00:00
|
|
|
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2000-07-12 18:11:54 +00:00
|
|
|
# Addresses in the sector of embedded data values.
|
2000-10-02 17:30:22 +00:00
|
|
|
# Accessed with negative offsets from the end of the relocated sector (%ebp).
|
|
|
|
#
|
|
|
|
.set _NXTDRV,-0x48 # Next drive
|
|
|
|
.set _OPT,-0x47 # Default option
|
|
|
|
.set _SETDRV,-0x46 # Drive to force
|
|
|
|
.set _FLAGS,-0x45 # Flags
|
|
|
|
.set _TICKS,-0x44 # Timeout ticks
|
1999-06-18 21:49:18 +00:00
|
|
|
.set _FAKE,0x0 # Fake partition entry
|
|
|
|
.set _MNUOPT,0xc # Menu options
|
1998-10-05 10:08:37 +00:00
|
|
|
|
|
|
|
.globl start # Entry point
|
2000-05-05 13:22:10 +00:00
|
|
|
.code16 # This runs in real mode
|
1998-10-05 10:08:37 +00:00
|
|
|
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Initialise segments and registers to known values.
|
|
|
|
# segments start at 0.
|
2000-08-08 07:20:25 +00:00
|
|
|
# The stack is immediately below the address we were loaded to.
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
1998-11-29 14:09:00 +00:00
|
|
|
start: cld # String ops inc
|
2000-05-05 13:22:10 +00:00
|
|
|
xorw %ax,%ax # Zero
|
|
|
|
movw %ax,%es # Address
|
|
|
|
movw %ax,%ds # data
|
|
|
|
movw %ax,%ss # Set up
|
|
|
|
movw $LOAD,%sp # stack
|
2000-10-02 17:30:22 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Copy this code to the address it was linked for
|
|
|
|
#
|
|
|
|
movw %sp,%si # Source
|
|
|
|
movw $start,%di # Destination
|
|
|
|
movw $0x100,%cx # Word count
|
|
|
|
rep # Relocate
|
|
|
|
movsw # code
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Set address for variable space beyond code, and clear it.
|
2000-08-08 07:20:25 +00:00
|
|
|
# Notice that this is also used to point to the values embedded in the block,
|
1999-09-03 01:35:06 +00:00
|
|
|
# by using negative offsets.
|
|
|
|
#
|
2000-10-02 17:30:22 +00:00
|
|
|
movw %di,%bp # Address variables
|
|
|
|
movb $0x8,%cl # Words to clear
|
1998-10-05 10:08:37 +00:00
|
|
|
rep # Zero
|
2000-05-05 13:22:10 +00:00
|
|
|
stosw # them
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Relocate to the new copy of the code.
|
|
|
|
#
|
2000-10-02 17:30:22 +00:00
|
|
|
incb -0xe(%di) # Sector number
|
|
|
|
jmp main-LOAD+ORIGIN # To relocated code
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2000-10-02 17:30:22 +00:00
|
|
|
# Check what flags were loaded with us, specifically, Use a predefined Drive.
|
1999-09-03 01:35:06 +00:00
|
|
|
# If what the bios gives us is bad, use the '0' in the block instead, as well.
|
|
|
|
#
|
2000-12-19 00:17:36 +00:00
|
|
|
main: testb $0x20,_FLAGS(%bp) # Set number drive?
|
1999-06-18 21:49:18 +00:00
|
|
|
jnz main.1 # Yes
|
|
|
|
testb %dl,%dl # Drive number valid?
|
1999-09-03 01:35:06 +00:00
|
|
|
js main.2 # Possibly (0x80 set)
|
2000-05-23 12:18:49 +00:00
|
|
|
main.1: movb _SETDRV(%bp),%dl # Drive number to use
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Whatever we decided to use, now store it into the fake
|
|
|
|
# partition entry that lives in the data space above us.
|
|
|
|
#
|
2000-05-23 12:18:49 +00:00
|
|
|
main.2: movb %dl,_FAKE(%bp) # Save drive number
|
|
|
|
callw putn # To new line
|
2000-05-05 13:22:10 +00:00
|
|
|
pushw %dx # Save drive number
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Start out with a pointer to the 4th byte of the first table entry
|
|
|
|
# so that after 4 iterations it's beyond the end of the sector.
|
2000-08-08 07:20:25 +00:00
|
|
|
# and beyond a 256 byte boundary and has overflowed 8 bits (see next comment).
|
1999-09-03 01:35:06 +00:00
|
|
|
# (remember that the table starts 2 bytes earlier than you would expect
|
|
|
|
# as the bootable flag is after it in the block)
|
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
movw $(partbl+0x4),%bx # Partition table (+4)
|
|
|
|
xorw %dx,%dx # Item number
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Loop around on the partition table, printing values until we
|
|
|
|
# pass a 256 byte boundary. The end of loop test is at main.5.
|
|
|
|
#
|
2000-05-23 12:18:49 +00:00
|
|
|
main.3: movb %ch,-0x4(%bx) # Zero active flag (ch == 0)
|
|
|
|
btw %dx,_FLAGS(%bp) # Entry enabled?
|
1999-06-19 21:40:55 +00:00
|
|
|
jnc main.5 # No
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2000-05-23 12:18:49 +00:00
|
|
|
movb (%bx),%al # Load type
|
2000-05-05 13:22:10 +00:00
|
|
|
movw $tables,%di # Lookup tables
|
1999-06-18 21:49:18 +00:00
|
|
|
movb $TBL0SZ,%cl # Number of entries
|
1998-10-05 10:08:37 +00:00
|
|
|
repne # Exclude
|
|
|
|
scasb # partition?
|
1999-06-18 21:49:18 +00:00
|
|
|
je main.5 # Yes
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Now scan the table of known types
|
|
|
|
#
|
1999-06-18 21:49:18 +00:00
|
|
|
movb $TBL1SZ,%cl # Number of entries
|
1998-10-05 10:08:37 +00:00
|
|
|
repne # Known
|
|
|
|
scasb # type?
|
1999-06-18 21:49:18 +00:00
|
|
|
jne main.4 # No
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# If it matches get the matching element in the
|
2000-10-02 17:30:22 +00:00
|
|
|
# next array. if it doesn't, we are already
|
1999-09-03 01:35:06 +00:00
|
|
|
# pointing at its first element which points to a "?".
|
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
addw $TBL1SZ,%di # Adjust
|
2000-05-23 12:18:49 +00:00
|
|
|
main.4: movb (%di),%cl # Partition
|
2000-05-05 13:22:10 +00:00
|
|
|
addw %cx,%di # description
|
2000-05-23 12:18:49 +00:00
|
|
|
callw putx # Display it
|
2000-05-05 13:22:10 +00:00
|
|
|
main.5: incw %dx # Next item
|
1999-06-18 21:49:18 +00:00
|
|
|
addb $0x10,%bl # Next entry
|
|
|
|
jnc main.3 # Till done
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Passed a 256 byte boundary..
|
|
|
|
# table is finished.
|
|
|
|
# Add one to the drive number and check it is valid,
|
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
popw %ax # Drive number
|
1998-11-29 14:09:00 +00:00
|
|
|
subb $0x80-0x1,%al # Does next
|
2000-05-05 13:22:10 +00:00
|
|
|
cmpb NHRDRV,%al # drive exist? (from BIOS?)
|
1999-06-18 21:49:18 +00:00
|
|
|
jb main.6 # Yes
|
1999-09-03 01:35:06 +00:00
|
|
|
# If not then if there is only one drive,
|
|
|
|
# Don't display drive as an option.
|
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
decw %ax # Already drive 0?
|
1999-06-18 21:49:18 +00:00
|
|
|
jz main.7 # Yes
|
1999-09-03 01:35:06 +00:00
|
|
|
# If it was illegal or we cycled through them,
|
|
|
|
# then go back to drive 0.
|
|
|
|
#
|
1998-11-29 14:09:00 +00:00
|
|
|
xorb %al,%al # Drive 0
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Whatever drive we selected, make it an ascii digit and save it back
|
|
|
|
# to the "next drive" location in the loaded block in case we
|
|
|
|
# want to save it for next time.
|
|
|
|
# This also is part of the printed drive string so add 0x80 to indicate
|
|
|
|
# end of string.
|
|
|
|
#
|
1999-06-18 21:49:18 +00:00
|
|
|
main.6: addb $'0'|0x80,%al # Save next
|
2000-05-23 12:18:49 +00:00
|
|
|
movb %al,_NXTDRV(%bp) # drive number
|
2000-05-05 13:22:10 +00:00
|
|
|
movw $drive,%di # Display
|
2000-05-23 12:18:49 +00:00
|
|
|
callw putx # item
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Now that we've printed the drive (if we needed to), display a prompt.
|
2000-10-02 17:30:22 +00:00
|
|
|
# Get ready for the input byt noting the time.
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
main.7: movw $prompt,%si # Display
|
2000-05-23 12:18:49 +00:00
|
|
|
callw putstr # prompt
|
|
|
|
movb _OPT(%bp),%dl # Display
|
2000-05-05 13:22:10 +00:00
|
|
|
decw %si # default
|
2000-05-23 12:18:49 +00:00
|
|
|
callw putkey # key
|
1998-10-05 10:08:37 +00:00
|
|
|
xorb %ah,%ah # BIOS: Get
|
|
|
|
int $0x1a # system time
|
2000-05-05 13:22:10 +00:00
|
|
|
movw %dx,%di # Ticks when
|
2000-05-23 12:18:49 +00:00
|
|
|
addw _TICKS(%bp),%di # timeout
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Busy loop, looking for keystrokes but
|
|
|
|
# keeping one eye on the time.
|
|
|
|
#
|
1999-06-18 21:49:18 +00:00
|
|
|
main.8: movb $0x1,%ah # BIOS: Check
|
1998-10-05 10:08:37 +00:00
|
|
|
int $0x16 # for keypress
|
1999-06-18 21:49:18 +00:00
|
|
|
jnz main.11 # Have one
|
1998-10-05 10:08:37 +00:00
|
|
|
xorb %ah,%ah # BIOS: Get
|
|
|
|
int $0x1a # system time
|
2000-05-05 13:22:10 +00:00
|
|
|
cmpw %di,%dx # Timeout?
|
1999-06-18 21:49:18 +00:00
|
|
|
jb main.8 # No
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# If timed out or defaulting, come here.
|
|
|
|
#
|
2000-05-23 12:18:49 +00:00
|
|
|
main.9: movb _OPT(%bp),%al # Load default
|
1999-06-18 21:49:18 +00:00
|
|
|
jmp main.12 # Join common code
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# User's last try was bad, beep in displeasure.
|
|
|
|
# Since nothing was printed, just continue on as if the user
|
|
|
|
# hadn't done anything. This gives the effect of the user getting a beep
|
|
|
|
# for all bad keystrokes but no action until either the timeout
|
|
|
|
# occurs or the user hits a good key.
|
|
|
|
#
|
1999-06-18 21:49:18 +00:00
|
|
|
main.10: movb $0x7,%al # Signal
|
2000-05-23 12:18:49 +00:00
|
|
|
callw putchr # error
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Get the keystroke.
|
|
|
|
#
|
1999-06-18 21:49:18 +00:00
|
|
|
main.11: xorb %ah,%ah # BIOS: Get
|
1998-10-05 10:08:37 +00:00
|
|
|
int $0x16 # keypress
|
|
|
|
movb %ah,%al # Scan code
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# If it's CR act as if timed out.
|
|
|
|
#
|
1998-12-05 11:58:33 +00:00
|
|
|
cmpb $KEY_ENTER,%al # Enter pressed?
|
1999-06-18 21:49:18 +00:00
|
|
|
je main.9 # Yes
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Otherwise check if legal
|
|
|
|
# If not ask again.
|
|
|
|
#
|
1998-12-05 11:58:33 +00:00
|
|
|
subb $KEY_F1,%al # Less F1 scan code
|
1998-11-29 14:09:00 +00:00
|
|
|
cmpb $0x4,%al # F1..F5?
|
2003-06-01 20:41:04 +00:00
|
|
|
jna main.12 # Yes
|
|
|
|
subb $(KEY_1 - KEY_F1),%al # Less #1 scan code
|
|
|
|
cmpb $0x4,%al # #1..#5?
|
1999-06-18 21:49:18 +00:00
|
|
|
ja main.10 # No
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# We have a selection.
|
|
|
|
# but if it's a bad selection go back to complain.
|
|
|
|
# The bits in MNUOPT were set when the options were printed.
|
|
|
|
# Anything not printed is not an option.
|
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
main.12: cbtw # Option
|
2000-05-23 12:18:49 +00:00
|
|
|
btw %ax,_MNUOPT(%bp) # enabled?
|
1999-06-18 21:49:18 +00:00
|
|
|
jnc main.10 # No
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Save the info in the original tables
|
|
|
|
# for rewriting to the disk.
|
|
|
|
#
|
2000-05-23 12:18:49 +00:00
|
|
|
movb %al,_OPT(%bp) # Save option
|
2000-10-02 17:30:22 +00:00
|
|
|
movw $FAKE,%si # Partition for write
|
2000-05-23 12:18:49 +00:00
|
|
|
movb (%si),%dl # Drive number
|
2000-05-05 13:22:10 +00:00
|
|
|
movw %si,%bx # Partition for read
|
1999-03-01 02:42:47 +00:00
|
|
|
cmpb $0x4,%al # F5 pressed?
|
2000-05-05 13:22:10 +00:00
|
|
|
pushf # Save
|
1999-06-18 21:49:18 +00:00
|
|
|
je main.13 # Yes
|
|
|
|
shlb $0x4,%al # Point to
|
2000-05-05 13:22:10 +00:00
|
|
|
addw $partbl,%ax # selected
|
|
|
|
xchgw %bx,%ax # partition
|
2000-05-23 12:18:49 +00:00
|
|
|
movb $0x80,(%bx) # Flag active
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# If not asked to do a write-back (flags 0x40) don't do one.
|
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
main.13: pushw %bx # Save
|
2000-10-02 17:30:22 +00:00
|
|
|
testb $0x40,_FLAGS(%bp) # No updates?
|
1999-06-18 21:49:18 +00:00
|
|
|
jnz main.14 # Yes
|
2000-05-05 13:22:10 +00:00
|
|
|
movw $start,%bx # Data to write
|
2000-10-02 17:30:22 +00:00
|
|
|
movb $0x3,%ah # Write sector
|
2000-05-23 12:18:49 +00:00
|
|
|
callw intx13 # to disk
|
2000-05-05 13:22:10 +00:00
|
|
|
main.14: popw %si # Restore
|
|
|
|
popf # Restore
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# If going to next drive, replace drive with selected one.
|
|
|
|
# Remember to un-ascii it. Hey 0x80 is already set, cool!
|
|
|
|
#
|
1999-06-18 21:49:18 +00:00
|
|
|
jne main.15 # If not F5
|
2000-05-23 12:18:49 +00:00
|
|
|
movb _NXTDRV(%bp),%dl # Next drive
|
1999-03-01 02:42:47 +00:00
|
|
|
subb $'0',%dl # number
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# load selected bootsector to the LOAD location in RAM.
|
|
|
|
# If it fails to read or isn't marked bootable, treat it
|
|
|
|
# as a bad selection.
|
2000-10-02 17:30:22 +00:00
|
|
|
# XXX what does %si carry?
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2000-05-05 13:22:10 +00:00
|
|
|
main.15: movw $LOAD,%bx # Address for read
|
2000-10-02 17:30:22 +00:00
|
|
|
movb $0x2,%ah # Read sector
|
2000-05-23 12:18:49 +00:00
|
|
|
callw intx13 # from disk
|
1999-06-18 21:49:18 +00:00
|
|
|
jc main.10 # If error
|
2000-05-23 12:18:49 +00:00
|
|
|
cmpw $MAGIC,0x1fe(%bx) # Bootable?
|
1999-06-18 21:49:18 +00:00
|
|
|
jne main.10 # No
|
2000-10-02 17:30:22 +00:00
|
|
|
pushw %si # Save
|
|
|
|
movw $crlf,%si # Leave some
|
|
|
|
callw puts # space
|
|
|
|
popw %si # Restore
|
2000-05-23 12:18:49 +00:00
|
|
|
jmp *%bx # Invoke bootstrap
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
1998-10-05 10:08:37 +00:00
|
|
|
# Display routines
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
1998-10-05 10:08:37 +00:00
|
|
|
|
1998-11-29 14:09:00 +00:00
|
|
|
putkey: movb $'F',%al # Display
|
2000-05-23 12:18:49 +00:00
|
|
|
callw putchr # 'F'
|
1998-10-05 10:08:37 +00:00
|
|
|
movb $'1',%al # Prepare
|
|
|
|
addb %dl,%al # digit
|
|
|
|
jmp putstr.1 # Display the rest
|
|
|
|
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# Display the option and note that it is a valid option.
|
|
|
|
# That last point is a bit tricky..
|
|
|
|
#
|
2000-05-23 12:18:49 +00:00
|
|
|
putx: btsw %dx,_MNUOPT(%bp) # Enable menu option
|
2000-05-05 13:22:10 +00:00
|
|
|
movw $item,%si # Display
|
2000-05-23 12:18:49 +00:00
|
|
|
callw putkey # key
|
2000-05-05 13:22:10 +00:00
|
|
|
movw %di,%si # Display the rest
|
1998-11-29 14:09:00 +00:00
|
|
|
|
2000-05-23 12:18:49 +00:00
|
|
|
puts: callw putstr # Display string
|
1998-10-05 10:08:37 +00:00
|
|
|
|
2000-05-05 13:22:10 +00:00
|
|
|
putn: movw $crlf,%si # To next line
|
1998-10-05 10:08:37 +00:00
|
|
|
|
1998-11-29 14:09:00 +00:00
|
|
|
putstr: lodsb # Get byte
|
|
|
|
testb $0x80,%al # End of string?
|
1998-10-05 10:08:37 +00:00
|
|
|
jnz putstr.2 # Yes
|
2000-05-23 12:18:49 +00:00
|
|
|
putstr.1: callw putchr # Display char
|
1998-10-05 10:08:37 +00:00
|
|
|
jmp putstr # Continue
|
1998-11-29 14:09:00 +00:00
|
|
|
putstr.2: andb $~0x80,%al # Clear MSB
|
1998-10-05 10:08:37 +00:00
|
|
|
|
2000-05-05 13:22:10 +00:00
|
|
|
putchr: pushw %bx # Save
|
|
|
|
movw $0x7,%bx # Page:attribute
|
1998-10-05 10:08:37 +00:00
|
|
|
movb $0xe,%ah # BIOS: Display
|
|
|
|
int $0x10 # character
|
2000-05-05 13:22:10 +00:00
|
|
|
popw %bx # Restore
|
2000-05-23 12:18:49 +00:00
|
|
|
retw # To caller
|
1998-10-05 10:08:37 +00:00
|
|
|
|
1999-06-18 21:49:18 +00:00
|
|
|
# One-sector disk I/O routine
|
1998-10-05 10:08:37 +00:00
|
|
|
|
2000-05-23 12:18:49 +00:00
|
|
|
intx13: movb 0x1(%si),%dh # Load head
|
|
|
|
movw 0x2(%si),%cx # Load cylinder:sector
|
2000-10-02 17:30:22 +00:00
|
|
|
movb $0x1,%al # Sector count
|
2000-05-05 13:22:10 +00:00
|
|
|
pushw %si # Save
|
|
|
|
movw %sp,%di # Save
|
2000-10-02 17:30:22 +00:00
|
|
|
testb $0x80,_FLAGS(%bp) # Use packet interface?
|
|
|
|
jz intx13.1 # No
|
2000-05-05 13:22:10 +00:00
|
|
|
pushl $0x0 # Set the
|
2000-05-23 12:18:49 +00:00
|
|
|
pushl 0x8(%si) # LBA address
|
2000-05-05 13:22:10 +00:00
|
|
|
pushw %es # Set the transfer
|
|
|
|
pushw %bx # buffer address
|
2000-10-02 17:30:22 +00:00
|
|
|
push $0x1 # Block count
|
|
|
|
push $0x10 # Packet size
|
2000-05-05 13:22:10 +00:00
|
|
|
movw %sp,%si # Packet pointer
|
2000-10-02 17:30:22 +00:00
|
|
|
decw %ax # Verify off
|
|
|
|
orb $0x40,%ah # Use disk packet
|
|
|
|
intx13.1: int $0x13 # BIOS: Disk I/O
|
2000-05-05 13:22:10 +00:00
|
|
|
movw %di,%sp # Restore
|
|
|
|
popw %si # Restore
|
2000-05-23 12:18:49 +00:00
|
|
|
retw # To caller
|
1998-10-05 10:08:37 +00:00
|
|
|
|
|
|
|
# Menu strings
|
|
|
|
|
1998-11-29 14:09:00 +00:00
|
|
|
item: .ascii " "; .byte ' '|0x80
|
1998-10-05 10:08:37 +00:00
|
|
|
prompt: .ascii "\nDefault:"; .byte ' '|0x80
|
1998-11-29 14:09:00 +00:00
|
|
|
crlf: .ascii "\r"; .byte '\n'|0x80
|
1998-10-05 10:08:37 +00:00
|
|
|
|
|
|
|
# Partition type tables
|
|
|
|
|
1998-11-29 14:09:00 +00:00
|
|
|
tables:
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# These entries identify invalid or NON BOOT types and partitions.
|
|
|
|
#
|
2000-10-02 17:30:22 +00:00
|
|
|
.byte 0x0, 0x5, 0xf
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2000-08-08 07:20:25 +00:00
|
|
|
# These values indicate bootable types we know the names of
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2003-06-01 20:41:04 +00:00
|
|
|
.byte 0x1, 0x4, 0x6, 0xb, 0xc, 0xe, 0x83
|
2000-09-09 18:05:22 +00:00
|
|
|
.byte 0x9f, 0xa5, 0xa6, 0xa9
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# These are offsets that match the known names above and point to the strings
|
|
|
|
# that will be printed.
|
|
|
|
#
|
1998-11-29 14:09:00 +00:00
|
|
|
.byte os_misc-. # Unknown
|
|
|
|
.byte os_dos-. # DOS
|
|
|
|
.byte os_dos-. # DOS
|
|
|
|
.byte os_dos-. # DOS
|
2000-10-02 17:30:22 +00:00
|
|
|
.byte os_dos-. # Windows
|
|
|
|
.byte os_dos-. # Windows
|
|
|
|
.byte os_dos-. # Windows
|
1998-11-29 14:09:00 +00:00
|
|
|
.byte os_linux-. # Linux
|
2000-10-02 17:30:22 +00:00
|
|
|
.byte os_bsd-. # BSD/OS
|
1998-11-29 14:09:00 +00:00
|
|
|
.byte os_freebsd-. # FreeBSD
|
2000-10-02 17:30:22 +00:00
|
|
|
.byte os_bsd-. # OpenBSD
|
|
|
|
.byte os_bsd-. # NetBSD
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
|
|
|
# And here are the strings themselves. 0x80 or'd into a byte indicates
|
|
|
|
# the end of the string. (not so great for Russians but...)
|
|
|
|
#
|
2000-10-02 17:30:22 +00:00
|
|
|
os_misc: .ascii "?"; .byte '?'|0x80
|
|
|
|
os_dos: .ascii "DO"; .byte 'S'|0x80
|
|
|
|
os_linux: .ascii "Linu"; .byte 'x'|0x80
|
|
|
|
os_freebsd: .ascii "Free"
|
|
|
|
os_bsd: .ascii "BS"; .byte 'D'|0x80
|
1998-10-05 10:08:37 +00:00
|
|
|
|
2000-12-12 17:27:35 +00:00
|
|
|
.org PRT_OFF-0xe,0x90
|
|
|
|
|
|
|
|
.word B0MAGIC # Magic number
|
|
|
|
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2000-10-02 17:30:22 +00:00
|
|
|
# These values are sometimes changed before writing back to the drive
|
|
|
|
# Be especially careful that nxtdrv: must come after drive:, as it
|
|
|
|
# is part of the same string.
|
1999-09-03 01:35:06 +00:00
|
|
|
#
|
2000-10-02 17:30:22 +00:00
|
|
|
drive: .ascii "Drive "
|
|
|
|
nxtdrv: .byte 0x0 # Next drive number
|
|
|
|
opt: .byte 0x0 # Option
|
|
|
|
setdrv: .byte 0x80 # Drive to force
|
|
|
|
flags: .byte FLAGS # Flags
|
|
|
|
ticks: .word TICKS # Delay
|
|
|
|
|
|
|
|
#
|
|
|
|
# here is the 64 byte partition table that fdisk would fiddle with.
|
|
|
|
#
|
|
|
|
partbl: .fill 0x40,0x1,0x0 # Partition table
|
|
|
|
.word MAGIC # Magic number
|