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