Hey OS-Dev.
I need to do a final course project and I just started doing an OS, but I need a little help about Hard-Drive management.. Is there a way to manage the hard drive c based ? I need inline assembly? How does my system recognize the hard-drive ? (that's the main question)
Can someone please help me??
I'm not english, so sorry if there's some grammar mistake :s
Hard-Drive Management
- BrightLight
- Member

- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: Hard-Drive Management
What exactly does "manage/recognize the hard drive" mean?
If you mean how does the system detect hard drives, read about BIOS INT 0x13. For reading/writing sectors in protected/long mode, read ATA and AHCI.
If you mean how does the system detect hard drives, read about BIOS INT 0x13. For reading/writing sectors in protected/long mode, read ATA and AHCI.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: Hard-Drive Management
I want to create a file and "insert" it into the Xth sector...
I need to do that with assembly ? What if my kernel is written in c ?? Do I need to use inline assembly or something ?
I need to do that with assembly ? What if my kernel is written in c ?? Do I need to use inline assembly or something ?
-
glauxosdever
- Member

- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: Hard-Drive Management
Hi,
Regards,
glauxosdever
If you are writing your own bootloader, then you will definitely need to use INT 0x13 to load the kernel, before switching to Protected Mode. Your options are:DarkGV wrote:I need to do that with assembly ? What if my kernel is written in c ?? Do I need to use inline assembly or something ?
- Use pure assembly
- Use a really outdated and ancient compiler that can emit 16-bit code (with inline assembly)
This question is undefined: Do you want to create a file from inside your own OS, or do you want to create one from the host OS so it is read by your OS? Those details are really important when asking for help.DarkGV wrote:I want to create a file and "insert" it into the Xth sector...
INT 0x13 shouldn't be used by the OS to detect drives. It's better to do it in Protected Mode while the kernel is being executed, because then you can have total control over drives.omarrx024 wrote:If you mean how does the system detect hard drives, read about BIOS INT 0x13.
Regards,
glauxosdever
Re: Hard-Drive Management
I want to create from inside my OS.
Like notepad from windows..
the user writes (for example):
CreateFile and it executes CreateFile function.
My CreateFile needs to know where and how to write.. I have a problem to do that in C.
Like notepad from windows..
the user writes (for example):
CreateFile and it executes CreateFile function.
My CreateFile needs to know where and how to write.. I have a problem to do that in C.
-
glauxosdever
- Member

- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: Hard-Drive Management
Hi,
Regards,
glauxosdever
You will need to use the IDE ports to detect the drives and read from and write to them (see IDE, ATA and AHCI articles in the wiki). Yes, you can do it in C once you have implemented port I/O functions. When you get more advanced, don't forget to implement a filesystem too, so your files are structured and organized.DarkGV wrote:I want to create from inside my OS.
Like notepad from windows..
the user writes (for example):
CreateFile and it executes CreateFile function.
My CreateFile needs to know where and how to write.. I have a problem to do that in C.
Regards,
glauxosdever
Re: Hard-Drive Management
The I/O functions are those which are used in VGA and keyboard right?
Re: Hard-Drive Management
Hi DarkGV,DarkGV wrote:I need to do a final course project and I just started doing an OS, but I need a little help about Hard-Drive management.. Is there a way to manage the hard drive c based ? I need inline assembly? How does my system recognize the hard-drive ? (that's the main question)
You are saying this is a final course project? School, university?
You are lacking several important concepts such as filesystems, PCI, ATA, hardware interfaces, drivers, what support drivers need from the core kernel.
Please don't make this your final course project. You're not ready. This is too hard for you. A simple harddisk driver requires a lot of other stuff from the kernel that you aren't ready for. The CreateFile function is a high level Windows API for user-space. It implies the existence of a filesystem driver in addition to a harddisk.
I suggest you pick another project.
Re: Hard-Drive Management
Alternatively,glauxosdever wrote:If you are writing your own bootloader, then you will definitely need to use INT 0x13 to load the kernel, before switching to Protected Mode. Your options are:DarkGV wrote:I need to do that with assembly ? What if my kernel is written in c ?? Do I need to use inline assembly or something ?
- Use pure assembly
- Use a really outdated and ancient compiler that can emit 16-bit code (with inline assembly)
- Use C with EFI disk services
- Use C and switch between protected/long mode and real mode
The original poster is not providing nearly enough information to make any recommendation on a course of action. If he has the actual project description that he can provide us, we might be able to. Until then, we are just guessing. I do not see an operating system project as any kind of school project -- it is simply not going to happen.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
