a few OS questions

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
elias

a few OS questions

Post by elias »

hi guys, ive been planning on writing an OS for a while, and have done a lot of research, and think im about ready to start, but first i have af ew questions i would really appreciate if you answer.

1.) how does BIOS laod off a floppy? what sector and head does the boot loader code go on?

2.) how do i store programs? once someone wants to write one, do I jsut find it on the disk, and load it into memory?

3.) in pmode, how do i use the interrupts? ive read in other threads that you have to write your own drivers, but what exactly does that mean? wont these drivers have to call the interrupts themselves?

thanks guys
davin

Re:a few OS questions

Post by davin »

hmmm. i dotn know but maybe others can help
Schol-R-LEA

Re:a few OS questions

Post by Schol-R-LEA »

elias wrote: hi guys, ive been planning on writing an OS for a while, and have done a lot of research, and think im about ready to start, but first i have af ew questions i would really appreciate if you answer.

1.) how does BIOS laod off a floppy? what sector and head does the boot loader code go on?
I assume you mean, "how does the BIOS load a boot sector off of a floppy?" (the BIOS doesn't load off of anything; it is hardwired into the system as a flash ROM). That's very simple; the BIOS has some very minimal routines in it for reading from and writing to sectors on floppy disks, printing messages to the screen, etc. (hence the name Basic Input/Output System). One startup, the CPU always begins running at the first location of the BIOS ROM; this location happens to hold a program which tests the system (the Power On Self Test, or POST). If everything tests out correctly, it then proceeds to initialize the PCI bus and retrieve the PnP information for the peripherals. Then it checks to see if there is a floppy disk in the drive, and if there is, it loads sector 1, head 0 to memory location 0000:7C00. It then checks to see if the the boot sector is valid (by checking the last two bytes to see if they contain the boot signature, 55AAh. If it is, it jumps to the beginning of the boot sector code at 0000:7C00 to run the boot loader.
2.) how do i store programs? once someone wants to write one, do I jsut find it on the disk, and load it into memory?
While you could read and write the sectors directly, I suppose, realistically you need to implement a file system of some kind.
This is a whole major subject in and of itself.
3.) in pmode, how do i use the interrupts? ive read in other threads that you have to write your own drivers, but what exactly does that mean? wont these drivers have to call the interrupts themselves?
Explaining how to set up an IDT could fill up several whole threads by itself (and has), but I will explain about the drivers. The issue at hand is not in calling interrupts, or in writing interrupt handlers, but in using the handler in the BIOS. What you have to understand is that most soft interrupts (INT 13h calls and the like) are actually using the interrupt system to vector calls to the BIOS routines, which, aside from the fact that they are stored in ROM, are just ordinary software. It is entirely posible to write drivers to replace the BIOS drivers.

Furthermore, since the BIOS routines are all real-mode programs, they won't run in protected mode; it is necessary to write your own interrupt handlers and drivers to replace them. When you set up the Interrupt Descriptor Table in p-mode, you are actually telling it where to find your own interupt handlers.
Post Reply