Page 1 of 1

loading your OS into the HDD ?

Posted: Sun Dec 17, 2006 12:01 am
by R2_
How would you make your OS save into the HDD and load from it the next time the computer turns on ?
any docs, tuts, example code all appreciated, Im pretty sure I need to add it to the IDT table.

docs on reading and writing to HD or reading files from it appreciated as I want to load text from a txt file, pretty sure all I have to do is access the memory address and load it to video memory to display it.

Thnx in advance :D

Posted: Sun Dec 17, 2006 4:46 am
by ntfs
There are two thing you want to do.
1)Make your OS boot from HD:Use GRUB for this matter, it is a bootloader you can find many tutorials on this site, or on osdever.net, in tutorials section. You can use GRUB to let your kernel boot from floppy,HD,net etc without changing it. Or you can use your own bootloader, but it is much more complicated.
2)Make your OS read/write from HD: You can not find any harddisk data in memory unless you load it there. If your OS is 16-bit the best solution is to use BIOS to do it for you. You can find BIOS services under various INTerrupts. Harddisk is 0x13 i thing. Just look it up in Ralph's brown interrupt list or somewhere else. Wen your OS is 32-bit it's more difficult to call BIOS whih is 16 bit, but you can still do it using switching to/from protected mode or by vm86 mode. Or you can use direct riting reading. I thing you can just search this forum, or look at the wiki it should be there.
And BTW for everybody who can read Czech I recommand Athelp .

Posted: Sun Dec 17, 2006 1:18 pm
by R2_
my OS is 32 bit, Im using grub but it doesnt save it to HD, what file do I need to mod ? (I'll read the tuts then re edit if I learn what to edit)

Posted: Sun Dec 17, 2006 3:44 pm
by Combuster
basic steps (you might have done a few of them already):

1) create some partition on the hd
2) format it
3) copy your kernel to it
4) point grub at it

I have a copy of my own kernel in my linux' /boot dir...

Posted: Sun Dec 17, 2006 3:52 pm
by R2_
Any way to copy it on GRUB command line ? its running on an emulator :P

Posted: Sun Dec 17, 2006 3:53 pm
by Combuster
GRUB cant partition or format disks. Get a linux floppy or write your own tools.

Posted: Sun Dec 17, 2006 10:17 pm
by R2_
well either way Im going to have to write grub and my kernel to the HD and modify the menu.lst to point to hard drive which is what I do not know how to do. btw does GRUB enable the a20 line and get you into protected mode ?

Posted: Sun Dec 17, 2006 10:33 pm
by m
Hi.
R2_ wrote:well either way Im going to have to write grub and my kernel to the HD and modify the menu.lst to point to hard drive which is what I do not know how to do. btw does GRUB enable the a20 line and get you into protected mode ?
The answer is from the wiki page on GRUB:
One major advantage of GRUB (or more precisely, a multiboot standard bootloader) is that the kernel will be entered in a known state, which includes the A20 Line having been enabled, and Protected Mode having been entered.

Posted: Tue Dec 19, 2006 8:58 pm
by R2_
Thnx, still I don't get how to programmatically get grub to install/be written into the HD Along with my kernel.

Posted: Tue Dec 19, 2006 11:22 pm
by Brynet-Inc
R2_ wrote:Thnx, still I don't get how to programmatically get grub to install/be written into the HD Along with my kernel.
What don't you understand? Grub is installed on the hardrives MBR and then it simply reads a kernel thats on one of the drives partitions.

To install grub on a drive usually you read the manual, Prepare the drive using linux for example.

Not rocket science buddy, Google It :wink:

Posted: Wed Dec 20, 2006 6:26 am
by xlq
It's probably best to read some data at a fixed location first, before parsing a filesystem, then when that is working well, start to write to the disk.

Posted: Wed Dec 20, 2006 7:10 am
by Solar
R2_ wrote:Thnx, still I don't get how to programmatically get grub to install/be written into the HD Along with my kernel.
Try the GRUB manual?

Posted: Wed Dec 20, 2006 7:20 pm
by R2_
Well my problem isn't with grub is with writing files to the HD overall. I know I can use linux and boot off the HD but thats not what I want the users of my OS to have to do every time they want to install my OS... I wouldn't like to have to download linux or unix every time im installing an OS, Ill read up on the GRUB manual maybe theres something there.

Posted: Wed Dec 20, 2006 10:28 pm
by TheQuux
Right... grub itself can't do this. For installation, you're probably going to be booting your OS off of a CD or something, which will then be able to copy your kernel and all necessary files to the hard disk.