Page 1 of 1
MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 7:07 am
by IOne
My MBR doesn't work with the motherboard with UEFI (Intel DH77EB), it nothing prints, but with the old motherboard with BIOS it works.
For example, it's
demo MBR does not print's anything with Intel DH77EB.
UEFI Boot is disabled.
What difference between "real" BIOS and BIOS emulation in UEFI?
P.S. I am booting from USB flash, I am write my MBR to flash by Linux dd command.
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 7:36 am
by Octocontrabass
That demo code is broken. I'm surprised it works on any motherboards.
Find a real MBR that properly sets all segment registers before relying on their values. You'll see that the UEFI BIOS emulation works just as well as a real BIOS.
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 8:03 am
by Muazzam
Have a look at MBR from my OS:
- mbr.asm
- (3.59 KiB) Downloaded 64 times
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 8:08 am
by Octocontrabass
muazzam wrote:Have a look at MBR from my OS:
Your MBR sets up the stack somewhere insane and expects things to work.
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 8:10 am
by IOne
Octocontrabass wrote:That demo code is broken. I'm surprised it works on any motherboards.
Find a real MBR that properly sets all segment registers before relying on their values. You'll see that the UEFI BIOS emulation works just as well as a real BIOS.
It's the beginning of the my MBR (BOOTSTACK=0xFFF0, BOOTSEG=0x1000).
It sets segment registers.
Code: Select all
.set SIGNATURE,0xaa55
.set LOAD,0x7c00 # Load address
.code16
.text
.globl start # Entry point
start:
jmp main
.= start +3
oem :.ascii "oc2k 210"
secsiz :.word 0
clsiz :.byte 0
ressecs :.word 0
fatcnt :.byte 0
rootsiz :.word 0
totsec :.word 0
media :.byte 0
fatsiz :.word 0
trksecs :.word 0
headcnt :.byte 0 #?????????????????
hidnsec :.word 0
# нестандартные расширения
.= start +52
fsec: .word 0 # первый сектор 52
.word 0 #
spc : .word 0 # spt*headcnt 56
.word 0 #
spt : .word 0 # 60
.word 0 #
fsec0: .word 0 # первый сектор 64
.word 0 #
drive: .byte 0 # номер диска например 0x80 68
head: .byte 0 # 69
cyl : .word 0 # 70
nsec: .word 0 # 72
.word 0 # 74
startmsg:.ascii "Start \0" # 80
okmsg:.ascii "Ok \r\n\0" #
main:
movw $BOOTSEG, %ax # ax=0x1000
movw %ax, %es # es=ax=0x1000 set up %es, (where we will load boot2 to)
movw %ax, %ss # ss=0x1000
movw $BOOTSTACK-64, %sp # sp=0xfff0-64
movw $(LOAD/16),%ax
movw %ax,%ds # data ds=0x7c0
movw $startmsg, %si
call message
It's work with motherboards with BIOS, but don't print anything with UEFI. What's wrong?
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 8:26 am
by Candy
You're assuming CS to be 0. You're not guaranteed that - only that CS:IP is 0x7C00 in total.
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 8:31 am
by Brendan
Hi,
IOne wrote:Code: Select all
main:
movw $BOOTSEG, %ax # ax=0x1000
movw %ax, %es # es=ax=0x1000 set up %es, (where we will load boot2 to)
movw %ax, %ss # ss=0x1000
movw $BOOTSTACK-64, %sp # sp=0xfff0-64
movw $(LOAD/16),%ax
movw %ax,%ds # data ds=0x7c0
movw $startmsg, %si
call message
It's work with motherboards with BIOS, but don't print anything with UEFI. What's wrong?
What's wrong is that it calls a routine that doesn't exist, and then (if the missing routine returns) nothing stops the CPU from executing garbage that was left in RAM.
Cheers,
Brendan
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 8:44 am
by IOne
Brendan wrote:
What's wrong is that it calls a routine that doesn't exist, and then (if the missing routine returns) nothing stops the CPU from executing garbage that was left in RAM.
Cheers,
Brendan
Sorry, I am forgot to show "message" source code:
Code: Select all
/*
* message: write the error message in %ds:%esi to console
*/
message:
/*
* Use BIOS "int 10H Function 0Eh" to write character in teletype mode
* %ah = 0xe %al = character
* %bh = page %bl = foreground color (graphics modes)
*/
push %ax
push %bx
mov $0x0001, %bx
cld
nextb:
lodsb # load a byte into %al
cmpb $0x0, %al
je done
movb $0xe, %ah
int $0x10 # display a byte
jmp nextb
done:
pop %bx
pop %ax
ret
Re: MBR doesn't work on motherboard with UEFI
Posted: Thu Mar 19, 2015 9:49 am
by Candy
What happens after "ret" ?