Page 1 of 1

how do I read from disk?

Posted: Thu Mar 12, 2020 3:22 pm
by haybame
how do I read from the disk in my OS and how do I do it in c?

Re: how do I read from disk?

Posted: Thu Mar 12, 2020 3:33 pm
by iansjack
First, you read the Wiki.

Re: how do I read from disk?

Posted: Thu Mar 12, 2020 4:15 pm
by haybame
is there a link?

Re: how do I read from disk?

Posted: Thu Mar 12, 2020 6:28 pm
by Gigasoft
No, unfortunately there isn't.

Re: how do I read from disk?

Posted: Thu Mar 12, 2020 6:46 pm
by haybame
so, how do I read from a disk?

Re: how do I read from disk?

Posted: Thu Mar 12, 2020 7:18 pm
by Schol-R-LEA
TL;DR - see the part I added with the bold-faced 'EDIT' at the start of the paragraph. Sorry for missing your earlier posts.

There's no royal road to OS Dev. Have you read the "Links and advice for New Members" thread yet, and read the pages it links to?

Also, we can't read minds; we don't know what sort of disk you are trying to read, nor what sort of computer you are reading it with.

Is it an x86 PC? A Raspberry Pi? A Rock Pro 64? A Commodore 64 you found in your grandparents' attic? If it is a PC, how old is it, and what model of processor does it have? Is it a Legacy BIOS system, or a modern UEFI one?

What sort of disk? A SATA hard disk? a SATA SSD? A USB flash drive? An image file for an emulated floppy (and if so, what emulator are you using, and how is it configured)? A real floppy disk (and if so, what size and data density)?

Assuming it is on a PC, is this going to be running in 16-bit real mode, 16-bit protected mode, 32-bit protected mode, or 64-bit long mode?

What are you trying to read, and when? Assuming you are booting the system, are you trying to roll your own boot loader, or have you used an existing boot loader such as GRUB or Das U-Boot to load your kernel? This circles back to the "Legacy vs. UEFI" question, too, since an newer UEFI motherboard may not have the Compatibility Services Module, in which case the real-mode BIOS routines one would usually have used on a Legacy BIOS won't work.

EDIT: OK, I've taken a look at your earlier thread, and from your posts there, I am assuming you are talking about a PC, and that you are using GRUB for the first-stage boot loader, in which case you will most likely be in 32-bit protected mode. This still doesn't tell us the type of disk, though I rather doubt that you'd be trying to boot GRUB with a floppy (IIRC, it is possible with certain disk types, though it wouldn't leave much room for anything else), meaning that the pages on ATA might be the right section for what you need... though not until you have things like the Global Descriptor Table (for physical to virtual memory translation) and Interrupt Descriptor Table (for interrupt handling) set up, since you'll need those in order to do most of that.