Hard disk control

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
PavelChekov
Member
Member
Posts: 113
Joined: Mon Sep 21, 2020 9:51 am
Location: Aboard the Enterprise

Hard disk control

Post by PavelChekov »

How do I read and write to the hard disk with assembly or C, without using INT 13h? I am trying to keep up to date and Intel is dropping support for PC BIOS in favor for UEFI, I am new, but want to have a modern OS. Most of the stuff I see online these days only works on IBM PCs, and I want mine to run on a 2010 Dell Laptop running Linux.

Thx,
Checkov :mrgreen:
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Hard disk control

Post by Octacone »

You need to write a PATA (IDE)/SATA (AHCI) driver.
Check out: https://wiki.osdev.org/Storage
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: Hard disk control

Post by foliagecanine »

In general, storage is not UEFI/BIOS specific, but usually mapped to the PCI bus.
There might be a UEFI function to read the disk, but you're probably better off writing a IDE or AHCI driver.

I would assume that a 2010 laptop would be AHCI SATA, so take a look at the AHCI page.
AHCI is a bit harder than IDE to program but has a lot more features.
It is also possible that your laptop could have IDE emulation in the BIOS/UEFI settings.
However, have you verified that your laptop is UEFI? AFAIK 2010 is pretty early for UEFI.

And what do you mean by "2010 Dell Laptop running Linux"?
Is Linux the current operating system? You don't need any operating system to run an operating system unless you're emulating it.
My OS: TritiumOS
https://github.com/foliagecanine/tritium-os
void warranty(laptop_t laptop) { if (laptop.broken) return laptop; }
I don't get it: Why's the warranty void?
User avatar
PavelChekov
Member
Member
Posts: 113
Joined: Mon Sep 21, 2020 9:51 am
Location: Aboard the Enterprise

Re: Hard disk control

Post by PavelChekov »

I simply meant that whatever it is should compile or such on NASM and GCC
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: Hard disk control

Post by foliagecanine »

Ah okay. So you were saying the build machine runs Linux.
Good luck!
User avatar
PavelChekov
Member
Member
Posts: 113
Joined: Mon Sep 21, 2020 9:51 am
Location: Aboard the Enterprise

Re: Hard disk control

Post by PavelChekov »

The thing is, I have also created my own file system.
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!
foliagecanine
Member
Member
Posts: 148
Joined: Sun Aug 23, 2020 4:35 pm

Re: Hard disk control

Post by foliagecanine »

The filesystem driver goes on top of the hard disk driver.
Basically, you first want to be able to read and write sectors to the disk before you worry about files.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Hard disk control

Post by PeterX »

PavelCheckov wrote:How do I read and write to the hard disk with assembly or C, without using INT 13h? I am trying to keep up to date and Intel is dropping support for PC BIOS in favor for UEFI, I am new, but want to have a modern OS. Most of the stuff I see online these days only works on IBM PCs, and I want mine to run on a 2010 Dell Laptop running Linux.
First you must find out what protocol is used for your laptop's harddisk. ATA/IDE? Serial ATA (SATA)? SCSI?
Octacone gave you a useful link for disk programming.

Greetings
Peter
Post Reply