xref: /freebsd/stand/i386/boot0/boot0.S (revision 3bd637af)
1/*
2 * Copyright (c) 2008 Luigi Rizzo (mostly documentation)
3 * Copyright (c) 2002 Bruce M. Simpson
4 * Copyright (c) 1998 Robert Nordier
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms are freely
8 * permitted provided that the above copyright notice and this
9 * paragraph and the following disclaimer are duplicated in all
10 * such forms.
11 *
12 * This software is provided "AS IS" and without any express or
13 * implied warranties, including, without limitation, the implied
14 * warranties of merchantability and fitness for a particular
15 * purpose.
16 */
17
18/* build options: */
19
20#ifdef PXE		/* enable PXE/INT18 booting with F6 */
21#define SAVE_MORE_MEMORY
22#endif
23
24
25#ifdef VOLUME_SERIAL	/* support Volume serial number */
26#define B0_BASE	0x1ae	/* move the internal data area */
27#define SAVE_MEMORY
28#else
29#define B0_BASE	0x1b2
30#endif
31
32#ifdef TEST		/* enable some test code */
33#define SAVE_MEMORY
34#define SAVE_MORE_MEMORY
35#endif
36
37/*
38 * Note - this code uses many tricks to save space and fit in one sector.
39 * This includes using side effects of certain instructions, reusing
40 * register values from previous operations, etc.
41 * Be extremely careful when changing the code, even for simple things.
42 */
43
44/*
45 *		BOOT BLOCK STRUCTURE
46 *
47 * This code implements a Master Boot Record (MBR) for an Intel/PC disk.
48 * It is 512 bytes long and it is normally loaded by the BIOS (or another
49 * bootloader) at 0:0x7c00. This code depends on %cs:%ip being 0:0x7c00
50 *
51 * The initial chunk of instructions is used as a signature by external
52 * tools (e.g. boot0cfg) which can manipulate the block itself.
53 *
54 * The area at offset 0x1b2 contains a magic string ('Drive '), also
55 * used as a signature to detect the block, and some variables that can
56 * be updated by boot0cfg (and optionally written back to the disk).
57 * These variables control the operation of the bootloader itself,
58 * e.g. which partitions to enable, the timeout, the use of LBA
59 * (called 'packet') or CHS mode, whether to force a drive number,
60 * and whether to write back the user's selection back to disk.
61 *
62 * As in every Master Boot Record, the partition table is at 0x1be,
63 * made of four 16-byte entries each containing:
64 *
65 *   OFF SIZE	DESCRIPTION
66 *    0	  1	status (0x80: bootable, 0: non bootable)
67 *    1	  3	start sector CHS
68 *		   8:head, 6:sector, 2:cyl bit 9..8, 8:cyl bit 7..0
69 *    4   1	partition type
70 *    5   3	end sector CHS
71 *    8   4	LBA of first sector
72 *   12   4	partition size in sectors
73 *
74 * and followed by the two bytes 0x55, 0xAA (MBR signature).
75 */
76
77
78/*
79 *		BOOT BLOCK OPERATION
80 *
81 * On entry, the registers contain the following values:
82 *
83 *	%cs:%ip	0:0x7c00
84 *	%dl	drive number (0x80, 0x81, ... )
85 *	%si	pointer to the partition table from which we were loaded.
86 *		Some boot code (e.g. syslinux) use this info to relocate
87 *		themselves, so we want to pass a valid one to the next stage.
88 *		NOTE: the use of %si is not a standard.
89 *
90 * This boot block first relocates itself at a different address (0:0x600),
91 * to free the space at 0:0x7c00 for the next stage boot block.
92 *
93 * It then initializes some memory at 0:0x800 and above (pointed by %bp)
94 * to store the original drive number (%dl) passed to us, and to construct a
95 * fake partition entry. The latter is used by the disk I/O routine and,
96 * in some cases, passed in %si to the next stage boot code.
97 *
98 * The variables at 0x1b2 are accessed as negative offsets from %bp.
99 *
100 * After the relocation, the code scans the partition table printing
101 * out enabled partition or disks, and waits for user input.
102 *
103 * When a partition is selected, or a timeout expires, the currently
104 * selected partition is used to load the next stage boot code,
105 * %dl and %si are set appropriately as when we were called, and
106 * control is transferred to the newly loaded code at 0:0x7c00.
107 */
108
109/*
110 *	CONSTANTS
111 *
112 * NHRDRV is the address in segment 0 where the BIOS writes the
113 *	total number of hard disks in the system.
114 * LOAD is the original load address and cannot be changed.
115 * ORIGIN is the relocation address. If you change it, you also need
116 * 	to change the value passed to the linker in the Makefile
117 * PRT_OFF is the location of the partition table (from the MBR standard).
118 * B0_OFF is the location of the data area, known to boot0cfg so
119 *	it cannot be changed. Computed as a negative offset from 0x200
120 * MAGIC is the signature of a boot block.
121 */
122
123		.set NHRDRV,0x475		# Number of hard drives
124		.set ORIGIN,0x600		# Execution address
125		.set LOAD,0x7c00		# Load address
126
127		.set PRT_OFF,0x1be		# Partition table
128		.set B0_OFF,(B0_BASE-0x200)	# Offset of boot0 data
129
130		.set MAGIC,0xaa55		# Magic: bootable
131
132		.set KEY_ENTER,0x1c		# Enter key scan code
133		.set KEY_F1,0x3b		# F1 key scan code
134		.set KEY_1,0x02			# #1 key scan code
135
136		.set ASCII_BEL,'#'		# ASCII code for <BEL>
137		.set ASCII_CR,0x0D		# ASCII code for <CR>
138
139/*
140 * Offsets of variables in the block at B0_OFF, and in the volatile
141 * data area, computed as displacement from %bp.
142 * We need to define them as constant as the assembler cannot
143 * compute them in its single pass.
144 */
145		.set _NXTDRV,	B0_OFF+6	# Next drive
146		.set _OPT,	B0_OFF+7	# Default option
147		.set _SETDRV,	B0_OFF+8	# Drive to force
148		.set _FLAGS,	B0_OFF+9	# Flags
149		.set SETDRV,	0x20		# the 'setdrv' flag
150		.set NOUPDATE,	0x40		# the 'noupdate' flag
151		.set USEPACKET,	0x80		# the 'packet' flag
152
153	/* ticks is at a fixed position */
154		.set _TICKS,	(PRT_OFF - 0x200 - 2)	# Timeout ticks
155		.set _MNUOPT, 0x10		# Saved menu entries
156
157		.set TLEN, (desc_ofs - bootable_ids)	# size of bootable ids
158		.globl start			# Entry point
159		.code16				# This runs in real mode
160
161/*
162 * 	MAIN ENTRY POINT
163 * Initialise segments and registers to known values.
164 * segments start at 0.
165 * The stack is immediately below the address we were loaded to.
166 * NOTE: the initial section of the code (up to movw $LOAD,%sp)
167 * is used by boot0cfg, together with the 'Drive ' string and
168 * the 0x55, 0xaa at the end, as an identifier for version 1.0
169 * of the boot code. Do not change it.
170 * In version 1.0 the parameter table (_NEXTDRV etc) is at 0x1b9
171 */
172start:		cld				# String ops inc
173		xorw %ax,%ax			# Zero
174		movw %ax,%es			# Address
175		movw %ax,%ds			#  data
176		movw %ax,%ss			# Set up
177		movw $LOAD,%sp			#  stack
178
179	/*
180	 * Copy this code to the address it was linked for, 0x600 by default.
181	 */
182		movw %sp,%si			# Source
183		movw $start,%di			# Destination
184		movw $0x100,%cx			# Word count
185		rep				# Relocate
186		movsw				#  code
187	/*
188	 * After the code, (i.e. at %di+0, 0x800) create a partition entry,
189	 * initialized to LBA 0 / CHS 0:0:1.
190	 * Set %bp to point to the partition and also, with negative offsets,
191	 * to the variables embedded in the bootblock (nextdrv and so on).
192	 */
193		movw %di,%bp			# Address variables
194		movb $0x8,%cl			# Words to clear
195		rep				# Zero
196		stosw				#  them
197		incb -0xe(%di)			# Set the S field to 1
198
199		jmp main-LOAD+ORIGIN		# Jump to relocated code
200
201main:
202#if defined(SIO) && COMSPEED != 0
203	/*
204	 * Init the serial port. bioscom preserves the driver number in DX.
205	 */
206		movw $COMSPEED,%ax		# defined by Makefile
207		callw bioscom
208#endif
209
210	/*
211	 * If the 'setdrv' flag is set in the boot sector, use the drive
212	 * number from the boot sector at 'setdrv_num'.
213	 * Optionally, do the same if the BIOS gives us an invalid number
214	 * (note though that the override prevents booting from a floppy
215	 * or a ZIP/flash drive in floppy emulation).
216	 * The test costs 4 bytes of code so it is disabled by default.
217	 */
218		testb $SETDRV,_FLAGS(%bp)	# Set drive number?
219#ifndef CHECK_DRIVE	/* disable drive checks */
220		jz save_curdrive		# no, use the default
221#else
222		jnz disable_update		# Yes
223		testb %dl,%dl			# Drive number valid?
224		js save_curdrive		# Possibly (0x80 set)
225#endif
226	/*
227	 * Disable updates if the drive number is forced.
228	 */
229disable_update:	orb $NOUPDATE,_FLAGS(%bp)	# Disable updates
230		movb _SETDRV(%bp),%dl		# Use stored drive number
231
232	/*
233	 * Whatever drive we decided to use, store it at (%bp). The byte
234	 * is normally used for the state of the partition (0x80 or 0x00),
235	 * but we abuse it as it is very convenient to access at offset 0.
236	 * The value is read back after 'check_selection'
237	 */
238save_curdrive:	movb %dl, (%bp)			# Save drive number
239		pushw %dx			# Also in the stack
240#ifdef	TEST	/* test code, print internal bios drive */
241		rolb $1, %dl
242		movw $drive, %si
243		call putkey
244#endif
245		callw putn			# Print a newline
246	/*
247	 * Start out with a pointer to the 4th byte of the first table entry
248	 * so that after 4 iterations it's beyond the end of the sector
249	 * and beyond a 256 byte boundary. We use the latter trick to check for
250	 * end of the loop without using an extra register (see start.5).
251	 */
252		movw $(partbl+0x4),%bx		# Partition table (+4)
253		xorw %dx,%dx			# Item number
254
255	/*
256	 * Loop around on the partition table, printing values until we
257	 * pass a 256 byte boundary.
258	 */
259read_entry:	movb %ch,-0x4(%bx)		# Zero active flag (ch == 0)
260		btw %dx,_FLAGS(%bp)		# Entry enabled?
261		jnc next_entry			# No
262		movb (%bx),%al			# Load type
263		test %al, %al			# skip empty partition
264		jz next_entry
265	/*
266	 * Scan the table of bootable ids, which starts at %di and has
267	 * length TLEN. On a match, %di points to the element following the
268	 * match; the corresponding offset to the description is $(TLEN-1)
269	 * bytes ahead. We use a count of TLEN+1 so if we don't find a match
270	 * within the first TLEN entries, we hit the 'unknown' entry.
271	 */
272		movw $bootable_ids,%di		# Lookup tables
273		movb $(TLEN+1),%cl		# Number of entries
274		repne				# Locate
275		scasb				#  type
276	/*
277	 * Get the matching element in the next array.
278	 * The byte at $(TLEN-1)(%di) contains the offset of the description
279	 * string from %di, so we add the number and print the string.
280	 */
281		addw $(TLEN-1), %di		# Adjust
282		movb (%di),%cl			# Partition
283		addw %cx,%di			#  description
284		callw putx			# Display it
285
286next_entry:	incw %dx			# Next item
287		addb $0x10,%bl			# Next entry
288		jnc read_entry			# Till done
289	/*
290	 * We are past a 256 byte boundary: the partition table is finished.
291	 * Add one to the drive number and check it is valid.
292	 * Note that if we started from a floppy, %dl was 0 so we still
293	 * get an entry for the next drive, which is the first Hard Disk.
294	 */
295		popw %ax			# Drive number
296		subb $0x80-0x1,%al		# Does next
297		cmpb NHRDRV,%al			#  drive exist? (from BIOS?)
298		jb print_drive			# Yes
299	/*
300	 * If this is the only drive, don't display it as an option.
301	 */
302		decw %ax			# Already drive 0?
303		jz print_prompt			# Yes
304	/*
305	 * If it was illegal or we cycled through them, go back to drive 0.
306	 */
307		xorb %al,%al			# Drive 0
308	/*
309	 * Whatever drive we selected, make it an ascii digit and save it
310	 * back to the "nxtdrv" location in case we want to save it to disk.
311	 * This digit is also part of the printed drive string, so add 0x80
312	 * to indicate end of string.
313	 */
314print_drive:	addb $'0'|0x80,%al		# Save next
315		movb %al,_NXTDRV(%bp)		#  drive number
316		movw $drive,%di			# Display
317		callw putx			#  item
318	/*
319	 * Menu is complete, display a prompt followed by current selection.
320	 * 'decw %si' makes the register point to the space after 'Boot: '
321	 * so we do not see an extra CRLF on the screen.
322	 */
323print_prompt:	movw $prompt,%si		# Display
324		callw putstr			#  prompt
325		movb _OPT(%bp),%dl		# Display
326		decw %si			#  default
327		callw putkey			#  key
328		jmp start_input			# Skip beep
329
330/*
331 * Here we have the code waiting for user input or a timeout.
332 */
333beep:		movb $ASCII_BEL,%al		# Input error, print or beep
334		callw putchr
335
336start_input:
337	/*
338	 * Actual Start of input loop.  Take note of time
339	 */
340		xorb %ah,%ah			# BIOS: Get
341		int $0x1a			#  system time
342		movw %dx,%di			# Ticks when
343		addw _TICKS(%bp),%di		#  timeout
344read_key:
345	/*
346	 * Busy loop, looking for keystrokes but keeping one eye on the time.
347	 */
348#ifndef SIO
349		movb $0x1,%ah			# BIOS: Check
350		int $0x16			#  for keypress
351#else /* SIO */
352		movb $0x03,%ah			# BIOS: Read COM
353		call bioscom
354		testb $0x01,%ah			# Check line status
355						# (bit 1 indicates input)
356#endif /* SIO */
357		jnz got_key 			# Have input
358		xorb %ah,%ah			# BIOS: int 0x1a, 00
359		int $0x1a			#  get system time
360		cmpw %di,%dx			# Timeout?
361		jb read_key			# No
362
363	/*
364	 * Timed out or default selection
365	 */
366use_default:	movb _OPT(%bp),%al		# Load default
367		orb $NOUPDATE,_FLAGS(%bp) 	# Disable updates
368		jmp check_selection		# Join common code
369
370	/*
371	 * Get the keystroke.
372	 * ENTER or CR confirm the current selection (same as a timeout).
373	 * Otherwise convert F1..F6 (or '1'..'6') to 0..5 and check if the
374	 * selection is valid.
375	 * The SIO code uses ascii chars, the console code uses scancodes.
376	 */
377got_key:
378#ifndef SIO
379		xorb %ah,%ah			# BIOS: int 0x16, 00
380		int $0x16			#  get keypress
381		movb %ah,%al			# move scan code to %al
382		cmpb $KEY_ENTER,%al
383#else
384		movb $0x02,%ah			# BIOS: Receive
385		call bioscom
386		cmpb $ASCII_CR,%al
387#endif
388		je use_default			# enter -> default
389	/*
390	 * Check if the key is acceptable, and loop back if not.
391	 * The console (non-SIO) code looks at scancodes and accepts
392	 * both F1..F6 and 1..6 (the latter costs 6 bytes of code),
393	 * relying on the fact that F1..F6 have higher scancodes than 1..6
394	 * The SIO code only takes 1..6
395	 */
396#ifdef SIO /* SIO mode, use ascii values */
397		subb $'1',%al			# Subtract '1' ascii code
398#else /*  console mode -- use scancodes */
399		subb $KEY_F1,%al		/* Subtract F1 scan code */
400#if !defined(ONLY_F_KEYS)
401		cmpb $0x5,%al			# F1..F6
402		jna 3f				# Yes
403		subb $(KEY_1 - KEY_F1),%al	# Less #1 scan code
404	3:
405#endif /* ONLY_F_KEYS */
406#endif /* SIO */
407check_selection:
408		cmpb $0x5,%al			# F1..F6 or 1..6 ?
409#ifdef PXE /* enable PXE/INT18 using F6 */
410		jne 1f;
411		int $0x18			# found F6, try INT18
412	1:
413#endif /* PXE */
414		jae beep			# Not in F1..F5, beep
415
416	/*
417	 * We have a selection.  If it's a bad selection go back to complain.
418	 * The bits in MNUOPT were set when the options were printed.
419	 * Anything not printed is not an option.
420	 */
421		cbtw				# Extend (%ah=0 used later)
422		btw %ax,_MNUOPT(%bp)	 	# Option enabled?
423		jnc beep			# No
424	/*
425	 * Save the info in the original tables
426	 * for rewriting to the disk.
427	 */
428		movb %al,_OPT(%bp)		# Save option
429
430	/*
431	 * Make %si and %bx point to the fake partition at LBA 0 (CHS 0:0:1).
432	 * Because the correct address is already in %bp, just use it.
433	 * Set %dl with the drive number saved in byte 0.
434	 * If we have pressed F5 or 5, then this is a good, fake value
435	 * to present to the next stage boot code.
436	 */
437		movw %bp,%si			# Partition for write
438		movb (%si),%dl			# Drive number, saved above
439		movw %si,%bx			# Partition for read
440		cmpb $0x4,%al			# F5/#5 pressed?
441		pushf				# Save results for later
442		je 1f				# Yes, F5
443
444	/*
445	 * F1..F4 was pressed, so make %bx point to the currently
446	 * selected partition, and leave the drive number unchanged.
447	 */
448		shlb $0x4,%al			# Point to
449		addw $partbl,%ax		#  selected
450		xchgw %bx,%ax	 		#  partition
451		movb $0x80,(%bx)		# Flag active
452	/*
453	 * If not asked to do a write-back (flags 0x40) don't do one.
454	 * Around the call, save the partition pointer to %bx and
455	 * restore to %si which is where the next stage expects it.
456	 */
457	1:	pushw %bx			# Save
458		testb $NOUPDATE,_FLAGS(%bp)	# No updates?
459		jnz 2f				# skip update
460		movw $start,%bx			# Data to write
461		movb $0x3,%ah			# Write sector
462		callw intx13			#  to disk
463	2:	popw %si			# Restore
464
465	/*
466	 * If going to next drive, replace drive with selected one.
467	 * Remember to un-ascii it. Hey 0x80 is already set, cool!
468	 */
469		popf				# Restore %al test results
470		jne 3f				# If not F5/#5
471		movb _NXTDRV(%bp),%dl		# Next drive
472		subb $'0',%dl			#  number
473	/*
474	 * Load selected bootsector to the LOAD location in RAM. If read
475	 * fails or there is no 0x55aa marker, treat it as a bad selection.
476	 */
477	3:	movw $LOAD,%bx			# Address for read
478		movb $0x2,%ah			# Read sector
479		callw intx13			#  from disk
480		jc beep				# If error
481		cmpw $MAGIC,0x1fe(%bx)		# Bootable?
482		jne beep			# No
483		pushw %si			# Save ptr to selected part.
484		callw putn			# Leave some space
485		popw %si			# Restore, next stage uses it
486		jmp *%bx			# Invoke bootstrap
487
488/*
489 * Display routines
490 * putkey	prints the option selected in %dl (F1..F5 or 1..5) followed by
491 *		the string at %si
492 * putx:	print the option in %dl followed by the string at %di
493 *		also record the drive as valid.
494 * putn:	print a crlf
495 * putstr:	print the string at %si
496 * putchr:	print the char in al
497 */
498
499/*
500 * Display the option and record the drive as valid in the options.
501 * That last point is done using the btsw instruction which does
502 * a test and set. We don't care for the test part.
503 */
504putx:		btsw %dx,_MNUOPT(%bp)		# Enable menu option
505		movw $item,%si			# Display
506		callw putkey			#  key
507		movw %di,%si			# Display the rest
508		callw putstr			# Display string
509
510putn:		movw $crlf,%si			# To next line
511		jmp putstr
512
513putkey:
514#ifndef SIO
515		movb $'F',%al			# Display
516		callw putchr			#  'F'
517#endif
518		movb $'1',%al			# Prepare
519		addb %dl,%al			#  digit
520
521putstr.1:	callw putchr			# Display char
522putstr:		lodsb				# Get byte
523		testb $0x80,%al 		# End of string?
524		jz putstr.1			# No
525		andb $~0x80,%al 		# Clear MSB then print last
526
527putchr:
528#ifndef SIO
529		pushw %bx			# Save
530		movw $0x7,%bx	 		# Page:attribute
531		movb $0xe,%ah			# BIOS: Display
532		int $0x10			#  character
533		popw %bx			# Restore
534#else /* SIO */
535		movb $0x01,%ah			# BIOS: Send character
536bioscom:
537		pushw %dx			# Save
538		xorw %dx,%dx 			# Use COM1
539		int $0x14			# BIOS: Serial I/O
540		popw %dx			# Restore
541#endif /* SIO */
542		retw				# To caller
543
544/* One-sector disk I/O routine */
545
546/*
547 * %dl: drive, %si partition entry, %es:%bx transfer buffer.
548 * Load the CHS values and possibly the LBA address from the block
549 * at %si, and use the appropriate method to load the sector.
550 * Don't use packet mode for a floppy.
551 */
552intx13:						# Prepare CHS parameters
553		movb 0x1(%si),%dh		# Load head
554		movw 0x2(%si),%cx		# Load cylinder:sector
555		movb $0x1,%al			# Sector count
556		pushw %si			# Save
557		movw %sp,%di			# Save
558#ifndef CHECK_DRIVE				/* floppy support */
559		testb %dl, %dl			# is this a floppy ?
560		jz 1f				# Yes, use CHS mode
561#endif
562		testb $USEPACKET,_FLAGS(%bp)	# Use packet interface?
563		jz 1f				# No
564		pushl $0x0			# Set the
565		pushl 0x8(%si)			# LBA address
566		pushw %es			# Set the transfer
567		pushw %bx			#  buffer address
568		push  $0x1			# Block count
569		push  $0x10			# Packet size
570		movw %sp,%si			# Packet pointer
571		decw %ax			# Verify off
572		orb $0x40,%ah			# Use disk packet
573	1:	int $0x13			# BIOS: Disk I/O
574		movw %di,%sp			# Restore
575		popw %si			# Restore
576		retw				# To caller
577
578/*
579 * Various menu strings. 'item' goes after 'prompt' to save space.
580 * Also use shorter versions to make room for the PXE/INT18 code.
581 */
582prompt:
583#ifdef PXE
584		.ascii "\nF6 PXE\r"
585#endif
586		.ascii "\nBoot:"
587item:		.ascii " ";	     .byte ' '|0x80
588crlf:		.ascii "\r";	     .byte '\n'|0x80
589
590/* Partition type tables */
591
592bootable_ids:
593	/*
594	 * These values indicate bootable types we know about.
595	 * Corresponding descriptions are at desc_ofs:
596	 * Entries don't need to be sorted.
597	 */
598		.byte 0x83, 0xa5, 0xa6, 0xa9, 0x06, 0x07, 0x0b
599#ifndef SAVE_MORE_MEMORY
600		.byte 0x05	# extended partition
601#endif
602#ifndef SAVE_MEMORY	/* other DOS partitions */
603		.byte 0x01	# FAT12
604		.byte 0x04	# FAT16 < 32M
605#endif
606
607desc_ofs:
608	/*
609	 * Offsets that match the known types above, used to point to the
610	 * actual partition name. The last entry must point to os_misc,
611	 * which is used for non-matching names.
612	 */
613		.byte os_linux-.		# 131, Linux
614		.byte os_freebsd-.		# 165, FreeBSD
615		.byte os_bsd-.			# 166, OpenBSD
616		.byte os_bsd-.			# 169, NetBSD
617		.byte os_dos-.			#   6, FAT16 >= 32M
618		.byte os_win-.			#   7, NTFS
619		.byte os_win-.			#  11, FAT32
620
621#ifndef SAVE_MORE_MEMORY
622		.byte os_ext-.			#   5, DOS Ext
623#endif
624#ifndef SAVE_MEMORY
625		.byte os_dos-.			#   1, FAT12 DOS
626		.byte os_dos-.			#   4, FAT16 <32M
627#endif
628		.byte os_misc-. 		# Unknown
629
630	/*
631	 * And here are the strings themselves. The last byte of
632	 * the string has bit 7 set.
633	 */
634os_misc:	.byte '?'|0x80
635os_dos:
636#ifndef SAVE_MORE_MEMORY	/* 'DOS' remapped to 'WIN' if no room */
637		.ascii "DO";   .byte 'S'|0x80
638#endif
639os_win:		.ascii "Wi";   .byte 'n'|0x80
640os_linux:	.ascii "Linu"; .byte 'x'|0x80
641os_freebsd:	.ascii "Free"
642os_bsd:		.ascii "BS";   .byte 'D'|0x80
643#ifndef SAVE_MORE_MEMORY
644os_ext:		.ascii "EX";   .byte 'T'|0x80
645#endif
646
647		.org (0x200 + B0_OFF),0x90
648/*
649 * The boot0 version 1.0 parameter table.
650 * Do not move it nor change the "Drive " string, boot0cfg
651 * uses its offset and content to identify the boot sector.
652 * The other fields are sometimes changed before writing back to the drive
653 * Be especially careful that nxtdrv: must come after drive:, as it
654 * is part of the same string.
655 */
656drive:		.ascii "Drive "
657nxtdrv:		.byte 0x0			# Next drive number
658opt:		.byte 0x0			# Option
659setdrv_num:	.byte 0x80			# Drive to force
660flags:		.byte FLAGS			# Flags
661#ifdef VOLUME_SERIAL
662		.byte 0xa8,0xa8,0xa8,0xa8       # Volume Serial Number
663#endif
664ticks:		.word TICKS			# Delay
665
666		.org PRT_OFF
667/*
668 * Here is the 64 byte MBR partition table.
669 */
670partbl:		.fill 0x40,0x1,0x0		# Partition table
671		.word MAGIC			# Magic number
672		.org 0x200			# again, safety check
673endblock:
674