MBR doesn't work on motherboard with UEFI
MBR doesn't work on motherboard with UEFI
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.
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.
-
- Member
- Posts: 5588
- Joined: Mon Mar 25, 2013 7:01 pm
Re: MBR doesn't work on motherboard with UEFI
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.
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
Have a look at MBR from my OS:
-
- Member
- Posts: 5588
- Joined: Mon Mar 25, 2013 7:01 pm
Re: MBR doesn't work on motherboard with UEFI
Your MBR sets up the stack somewhere insane and expects things to work.muazzam wrote:Have a look at MBR from my OS:
Re: MBR doesn't work on motherboard with UEFI
It's the beginning of the my MBR (BOOTSTACK=0xFFF0, BOOTSEG=0x1000).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 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
Re: MBR doesn't work on motherboard with UEFI
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
Hi,
Cheers,
Brendan
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.IOne wrote:It's work with motherboards with BIOS, but don't print anything with UEFI. What's wrong?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
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: MBR doesn't work on motherboard with UEFI
Sorry, I am forgot to show "message" source code: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
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
What happens after "ret" ?