C os programming

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.
beyondsociety

Re:C os programming

Post by beyondsociety »

The code you posted doesn't search for a file(for example kernel.bin), my bootloader doeas it.
I know. My bootsector just sets the BPB (Bios Parameter Block), and loads the raw sectors into memory. All I care about at the moment is allowing files to be stored on the floppy disk and nothing more. I will eventually add support for a fat12 filesystem driver in my kernel for backward compatibility with legacy devices.
Can i use my bootloader code for the bootloader AND a copy for the loader? (the loader copy will switch to pm, load gdt, enable a20, but first of all, will load a kernel.bin at FFFF:0010).
Yes as long as you change it to load at 1MB. The bootsector is limited to 512 bytes, whereas your second-stage loader is not, so you can put as much code as you want in the second-stage.
SpiglerG

Re:C os programming

Post by SpiglerG »

I'll try to use grub, as bootloader.
i'll post here if i'll have problems.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:C os programming

Post by Solar »

SpiglerG wrote: PS: FFFF:0010 is 1mb? isn't it 1000F
Remember to multiply the segment register with 16 (<< 4) before adding the offset:

0xFFFF << 4 = 0xFFFF0

0xFFFF0 + 0x0010 = 0x100000
Every good solution is obvious once you've found it.
SpiglerG

Re:C os programming

Post by SpiglerG »

yes.

PS: does grub set pmode, too?
i havn't read all the documentation yet.
AR

Re:C os programming

Post by AR »

GRUB starts protected mode, provides the memory size, the memory map if it's available, a list of additional "modules" loaded along with the kernel, APM and VBE2 configuration data, the name of the bootloader and the drives detected in the machine.
SpiglerG

Re:C os programming

Post by SpiglerG »

So, it's the best choice! :)

Ok. i think i'll use it.
i'll try it as soon as possible.

i found a good tutorial on osdever.net. it's simple and easy to implement.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:C os programming

Post by Pype.Clicker »

note that we have http://www.osdev.org/osfaq2/index.php/GRUB, http://www.osdev.org/osfaq2/index.php/BareBones (our small GRUB-based kernel for demonstration purposes) and plenty of related pages

sorry if we (administrator) seems to be spamming you with the FAQ, but what you've been asking all along this thread _are_ frequently asked questions and they _are_ for most of them answered in the FAQ.

e.g.
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 A20Line having been enabled, and ProtectedMode having been entered
creating your own GRUB bootdisk requires a unix-like environment. If you're working under MS Windows (or don't feel like setting up a GRUB disk with linux), check out our Disk Images Under Windows page to get a ready-to-use image.
etc. And even if you don't start with any of our BareBones, consider checking the BareBones pages wich contain troubleshooting info you'll probably need to quickly decode GRUB's error messages, etc.
Post Reply