Project

General

Profile

Submit #2864 ยป 0001-some-refactoring-for-boot0.patch

Anonymous, 12/12/2015 10:36 AM

View differences:

sys/boot/pc32/boot0/boot0.S
91 91
		.set _FAKE,0x0			# Fake partition entry
92 92
		.set _MNUOPT,0xc		# Menu options
93 93

  
94
		.set _SECTOR_FIELD_OFF,-0xe	# Offset to Sector field
95
						# in the fake partition
96
		.set _DATA_OFF,PRT_OFF+_SECTOR_FIELD_OFF # Offset to boot0 variables
97
							 # from partition table
98

  
94 99
		.globl start			# Entry point
95 100
		.code16				# This runs in real mode
96 101

  
......
107 112
		movw $MEM_BIOS_LADDR,%sp	#  stack
108 113
	
109 114
		/*
110
		 * Copy this code to the address it was linked for
115
		 * Copy this code to the address it was linked for.
116
		 * Base address after relocation is - 0x600.
111 117
		 */
112 118
		movw %sp,%si			# Source
113 119
		movw $start,%di			# Destination
......
126 132
		stosw				#  them
127 133

  
128 134
		/*
129
		 * Relocate to the new copy of the code.  Do not make
130
		 * assumptions with regard to a relative-PC near jump
131
		 * capability.
135
		 * Set C:H:S to 0:0:1 and relocate to the new copy of
136
		 * the code.  Do not make assumptions with regard to
137
		 * a relative-PC near jump capability.
132 138
		 */
133
		incb -0xe(%di)			# Sector number
139
		incb _SECTOR_FIELD_OFF(%di)	# Sector number
134 140
		pushw $main			# Jump to relocated code
135 141
		retw
136 142

  
......
171 177
		 * that the table starts 2 bytes earlier than you would
172 178
		 * expect as the bootable flag is after it in the block)
173 179
		 */
174
		movw $(partbl+0x4),%bx		# Partition table (+4)
175
		xorw %dx,%dx			# Item number
180
		movw $(partbl+0x4),%bx		# Partition table (+4 - type)
181
		xorw %dx,%dx			# Partition entry item number
176 182

  
177 183
		/*
178 184
		 * Loop around on the partition table, printing values until
179
		 * we pass a 256 byte boundary. The end of loop test is at
185
		 * we pass a 256 (4x 64 byte partitions) byte boundary. The
186
		 * end of loop test is at
180 187
		 * main.5.
181 188
		 */
182 189
main.3: 	movb %ch,-0x4(%bx)		# Zero active flag (ch == 0)
......
375 382
		movw $start,%bx			# Data to write
376 383
		movb $0x3,%ah			# Write sector
377 384
		callw intx13			#  to disk
378
main.14:	popw %si			# Restore
379
		popf				# Restore
385
main.14:	popw %si			# Restore partition
386
		popf				# Restore eflags
380 387

  
381 388
		/*
382 389
		 * If going to next drive, replace drive with selected one.
......
448 455
putchr: 	
449 456
		movb $0x01,%ah			# BIOS: Send
450 457
bioscom:
451
		pusha				# Save
458
		pusha				# Save (preserve driver number)
452 459
		xorw %dx,%dx			# Use COM1
453 460
		int $0x14			#  Character
454
		popa				# Restore
461
		popa				# Restore (restore driver number)
455 462
		retw				# To caller
456 463
#endif
457 464
		
......
540 547
os_dfbsd:	.ascii "DF/F"
541 548
os_bsd: 	.ascii "BS";   .byte 'D'|0x80
542 549

  
543
		.org PRT_OFF-0xe,0x90
550
		.org _DATA_OFF,0x90
544 551

  
545 552
		.word B0MAGIC			# Magic number
546 553

  
sys/boot/pc32/bootasm.h
55 55
#define BDA_SCR		0x449		/* Video mode		*/
56 56
#define BDA_POS		0x450		/* Cursor position	*/
57 57
#define BDA_BOOT	0x472		/* Boot howto flag	*/
58
#define BDA_NHRDRV	0x475
58
#define BDA_NHRDRV	0x475		/* Number of drivers found by BIOS */
59 59
#define BDA_KEYBOARD	0x496		/* BDA byte with keyboard bit */
60 60

  
61 61
/*
    (1-1/1)