mbr.s (62176) | mbr.s (134431) |
---|---|
1# 2# Copyright (c) 1999 Robert Nordier 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms are freely 6# permitted provided that the above copyright notice and this 7# paragraph and the following disclaimer are duplicated in all 8# such forms. 9# 10# This software is provided "AS IS" and without any express or 11# implied warranties, including, without limitation, the implied 12# warranties of merchantability and fitness for a particular 13# purpose. 14# 15 | 1# 2# Copyright (c) 1999 Robert Nordier 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms are freely 6# permitted provided that the above copyright notice and this 7# paragraph and the following disclaimer are duplicated in all 8# such forms. 9# 10# This software is provided "AS IS" and without any express or 11# implied warranties, including, without limitation, the implied 12# warranties of merchantability and fitness for a particular 13# purpose. 14# 15 |
16# $FreeBSD: head/sys/boot/i386/mbr/mbr.s 62176 2000-06-27 20:04:10Z jhb $ | 16# $FreeBSD: head/sys/boot/i386/mbr/mbr.s 134431 2004-08-28 08:39:35Z yar $ |
17 18# A 512 byte MBR boot manager that simply boots the active partition. 19 20 .set LOAD,0x7c00 # Load address 21 .set EXEC,0x600 # Execution address 22 .set PT_OFF,0x1be # Partition table 23 .set MAGIC,0xaa55 # Magic: bootable | 17 18# A 512 byte MBR boot manager that simply boots the active partition. 19 20 .set LOAD,0x7c00 # Load address 21 .set EXEC,0x600 # Execution address 22 .set PT_OFF,0x1be # Partition table 23 .set MAGIC,0xaa55 # Magic: bootable |
24 .set FL_PACKET,0x80 # Flag: try EDD |
|
24 25 .set NHRDRV,0x475 # Number of hard drives 26 27 .globl start # Entry point 28 .code16 29 30# 31# Setup the segment registers for flat addressing and setup the stack. --- 51 unchanged lines hidden (view full) --- 83# 84# Ok, now that we have a valid drive and partition entry, load the CHS from 85# the partition entry and read the sector from the disk. 86# 87main.5: movw %sp,%di # Save stack pointer 88 movb 0x1(%si),%dh # Load head 89 movw 0x2(%si),%cx # Load cylinder:sector 90 movw $LOAD,%bx # Transfer buffer | 25 26 .set NHRDRV,0x475 # Number of hard drives 27 28 .globl start # Entry point 29 .code16 30 31# 32# Setup the segment registers for flat addressing and setup the stack. --- 51 unchanged lines hidden (view full) --- 84# 85# Ok, now that we have a valid drive and partition entry, load the CHS from 86# the partition entry and read the sector from the disk. 87# 88main.5: movw %sp,%di # Save stack pointer 89 movb 0x1(%si),%dh # Load head 90 movw 0x2(%si),%cx # Load cylinder:sector 91 movw $LOAD,%bx # Transfer buffer |
91 cmpb $0xff,%dh # Might we need to use LBA? 92 jnz main.7 # No. 93 cmpw $0xffff,%cx # Do we need to use LBA? 94 jnz main.7 # No. | 92 testb $FL_PACKET,flags # Try EDD? 93 jz main.7 # No. |
95 pushw %cx # Save %cx 96 pushw %bx # Save %bx 97 movw $0x55aa,%bx # Magic 98 movb $0x41,%ah # BIOS: EDD extensions 99 int $0x13 # present? 100 jc main.6 # No. 101 cmpw $0xaa55,%bx # Magic ok? 102 jne main.6 # No. --- 43 unchanged lines hidden (view full) --- 146 testb %al,%al # End of string? 147 jnz putstr.0 # No 148putstr.1: jmp putstr.1 # Await reset 149 150msg_pt: .asciz "Invalid partition table" 151msg_rd: .asciz "Error loading operating system" 152msg_os: .asciz "Missing operating system" 153 | 94 pushw %cx # Save %cx 95 pushw %bx # Save %bx 96 movw $0x55aa,%bx # Magic 97 movb $0x41,%ah # BIOS: EDD extensions 98 int $0x13 # present? 99 jc main.6 # No. 100 cmpw $0xaa55,%bx # Magic ok? 101 jne main.6 # No. --- 43 unchanged lines hidden (view full) --- 145 testb %al,%al # End of string? 146 jnz putstr.0 # No 147putstr.1: jmp putstr.1 # Await reset 148 149msg_pt: .asciz "Invalid partition table" 150msg_rd: .asciz "Error loading operating system" 151msg_os: .asciz "Missing operating system" 152 |
154 .org PT_OFF | 153 .org PT_OFF-1,0x90 154flags: .byte FLAGS # Flags |
155 156partbl: .fill 0x10,0x4,0x0 # Partition table 157 .word MAGIC # Magic number | 155 156partbl: .fill 0x10,0x4,0x0 # Partition table 157 .word MAGIC # Magic number |