
But seriously, if you're just starting about how you could write an operating system, stop dreaming you're OS will ever replace any of the big fishes out there...
Some nice alternatives: using GRUB's or your own bootloader's ability to load additional files (modules) into memory when booting; using a network stack to download the programs.I know that in order to load additional programs, I first need to create a file system.
You can neatly divide reading files into subsystems: a harddrive subsystem, a disk partition subsystem which allows you access a particular partition and a filesystem of your choice subsystem.I'm having difficulty in understanding how to start this. I basically think of a hard drive and think (theoretically) how I can manage the bits on the drive.
The firmware helps a lot but it doesn't guarantee that it will succeed in rescuing a sector and then it cannot swap the sector with a sector from the swap-with-bad-sectors pool. However, FAT generally gives you a list of clusters a file occupies, if a file occupies a bad cluster then obviously you can't read the file so it's not complicated to react to bad cluster marks while reading.1: I know that Fat used some redundance in its index to mark bad sectors (in case the mark was on a bad sector itself). Do I even need to worry about this anymore? Does the drive's firmware handel this for me now?
There is more than one executable file format. If you use DOS's COM files in real mode then it's just a matter of setting the data segment, stack segment and a proper choice of code segment, I suppose. EXE files seem to need some relocation, that's a simple routine. If you use protected mode, then ELF or binary I think should be easy to execute.2: Once I have the ability to read and write from my file system, I'm at a loss of how to execute other binary apps. Do I simply load the binary app to memory, and then use jmp command to begin execution of another binary? I know this part seems trivial, but I've only ever assembled single execution programs. Or are all other binaries after this point somewhat interperated (I hope not, that seems inefficient)?
The driver writing to the file system should handle that, so for reading you don't have to worry about it. I can't say for sure, but I haven't heard of a drive's firmware handling something implemented at a file system level.austinlcherry wrote:1: I know that Fat used some redundance in its index to mark bad sectors (in case the mark was on a bad sector itself). Do I even need to worry about this anymore? Does the drive's firmware handel this for me now?
Kind of. Unless you're having flat binary files, your program is usually stored inside of a file using an executable format (PE and ELF being the most common formats). These formats basically what part of the file to copy in to what part of the memory (e.g. copy 0xFA to 0x10FA in the file to 0x101000 to 0x1020FA in memory). After this is done, you jump to the program's entry point (this is usually OS dependent, not program dependent).austinlcherry wrote:2: Once I have the ability to read and write from my file system, I'm at a loss of how to execute other binary apps. Do I simply load the binary app to memory, and then use jmp command to begin execution of another binary? I know this part seems trivial, but I've only ever assembled single execution programs. Or are all other binaries after this point somewhat interperated (I hope not, that seems inefficient)?
The x86 processor natively supports little endian integer loads and stores, along with IEEE754 single and double precision floating point loads/stores/processing. What sort of "binary format" were you thinking of? If (and only if) you were thinking of ELF/PE, remember that the processor is no more than a glorified adder, and has no concept of "file formats". That's for software to abstract away and define.austinlcherry wrote:Thank You Adek336, and MessiahAndrw. These clear a few things up.
Now a few more questions
1: So, there is no particular binary format that the processor natively supports?
I was hoping for an interrupt that I could set a memory address pointer to point to the HD to go to this section and begin execution. (kind of like the MBR on the HDD)
Yes, they are. You can write loading code assembly, C, pascal, whatever you can write a kernel in.2: I assume that PE and ELF are specifications so that you can write assembly to find data portions and execution start points? (I guess I'm going to have to do more reading on this one).
Yes, but you say "using assembler". Are you talking about BIOS interrupts, or protected mode port I/O? You get status reports in either, however.3: With Respect to the Disk. I assume when I'm reading/writing to the disk using assembler, I can get error codes when it attempts to read/write to determine that there is a problem with the sector? Then I can update my file system's index to mark the sector as bad?
I thought the processor also had logic gates. The ability to compare one thing to another. With this in mind, I thought maybe there was a native binary structure (maybe structure is a better word than format) that could be "fed" into the processor for execution. I thought maybe the mechanism for feeding was an interrupt that said begin reading at this address. Additionally, I thought maybe I could create a pointer in that address to a sector on the HDD for reading (using bios interrupts).JamesM wrote: The x86 processor natively supports little endian integer loads and stores, along with IEEE754 single and double precision floating point loads/stores/processing. What sort of "binary format" were you thinking of? If (and only if) you were thinking of ELF/PE, remember that the processor is no more than a glorified adder, and has no concept of "file formats". That's for software to abstract away and define.