OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 1:30 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Accessing disk from bootloader
PostPosted: Mon Apr 10, 2017 6:14 am 
Offline

Joined: Mon Apr 10, 2017 6:01 am
Posts: 3
Hi all,

I wrote a bootloader that can access the disk and read hex from it.
I've set the registers as:
mov dl, 0x80
mov ah, 0x02
mov al, 5
mov ch, 0x00
mov dh, 0x00
mov cl, 0x02
and int 0x13

It worked fine but there was one thing that I didn't get
I used qemu to run the code
qemu-system-x86_64 -fda boot_sect.bin
Why do I have to use "-fda" when boot_sect.bin is in the hard drive? Also I thought setting dl to 0x80 instructs the bios to access C drive not floppy.

Am I misunderstanding anything?

Thank you.


Top
 Profile  
 
 Post subject: Re: Accessing disk from bootloader
PostPosted: Tue Apr 11, 2017 12:27 pm 
Offline
Member
Member

Joined: Wed Jun 17, 2015 9:40 am
Posts: 501
Location: Athens, Greece
Hi,


You shouldn't hardcode the value in DL - it's passed for you from the BIOS. All you have to do is to store it in a variable and then restore it when using the BIOS disk interrupts. This way you instruct the BIOS to read from whatever your bootloader has been booted from.

Hope this helps. :-)


Regards,
glauxosdever


Top
 Profile  
 
 Post subject: Re: Accessing disk from bootloader
PostPosted: Tue Apr 11, 2017 7:24 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
bios puts the dl the boot drive by default. 0x80 first hdd, 0x81 is second hdd. small numbers like 0x01 means floppy

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: Accessing disk from bootloader
PostPosted: Wed Apr 12, 2017 8:12 am 
Offline

Joined: Mon Apr 10, 2017 6:01 am
Posts: 3
Ok.
I stored the value in dl to a variable:
mov [drive_type], dl
restored the value before int0x13:
mov dl, [drive_type].
It all worked fine but I when checked the hex value of dl at the start, it was 0x80.
This means it will load the data from the first hard drive right?
But why do I have to use -fda flag when using qemu when It is not using a floppy drive?
qemu-system-x86_64 -fda boot_sect.bin
If I omit the flag or use -hda flag instead, it will set the carry flag and throw an error
This is confusing.


Top
 Profile  
 
 Post subject: Re: Accessing disk from bootloader
PostPosted: Wed Apr 12, 2017 8:31 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
for me, if i put it into hda, i get the floppy flag, if to the hdd, i get the hdd flag. for you, something is wrong with something.

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: Accessing disk from bootloader
PostPosted: Wed Apr 12, 2017 6:39 pm 
Offline

Joined: Mon Apr 10, 2017 6:01 am
Posts: 3
That's just great.


Top
 Profile  
 
 Post subject: Re: Accessing disk from bootloader
PostPosted: Thu Apr 13, 2017 12:13 am 
Offline
Member
Member

Joined: Wed Sep 19, 2012 3:43 am
Posts: 91
Location: The Netherlands
I agree that Geri's reply isn't very helpful. Have you tested what the value of DL looks like on a different emulator/simulator like Bochs or VirtualBox?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 166 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group