Need a friendly slap in the right direction...
Posted: Sat Feb 13, 2010 9:03 pm
Well, I've gotten my hands pretty dirty and learned a lot. Maybe more than I expected initially... I learned to make PE executables multiboot compliant, how to use I/O ports, how to install a GDT and IDT, work with VGA, PIC, basic drivers, etc. So I've covered most of the bottom rung of the ladder (I guess, unless that excludes something really basic/fundamental). I've kept my code and design as neat as possible, even though I started with a very blurry picture of how things would turn out. But it was inevitable this design would begin to look sloppy when it was time to step up to the next level. I couldn't really plan ahead and outline the project before I knew what the project was going to include; in stark contrast to writing a userland application. I've got a much better picture of what needs to be done now, but certainly not the whole range of it. So, I'm trying to get organized, make some coherent plans and get into a real development cycle. I can't stay in this chaotic cowboy-coding approach, lol.
The first big concerns of mine are maintainability, modularity and structure. For example, it's totally unacceptable for me to just dump tons of code into a single project/folder and try to work with it. Way too chaotic and too difficult for other people to jump into further along the road. Likewise, that's going to cause a LOT of code repetition and thus increase the size of the kernel (or whatever component we're dealing with). That's one of the biggest downfalls of static libs, though they do have some big advantages. To put into perspective, my VGA code is currently a static lib which gets linked into the kernel. That's ok at this very moment, but other processes will need it soon. That means that it will be linked into ALL of them; each with their own little copy of it. So it seems to, obviously, follow that this should be a module (shared library) which can be digested by multiple processes as needed. If it hasn't hit your accumulator registers in your brain yet, I'm essentially going for a micro-kernel-like design, in which I'm going to attempt some modifications and deviations from the norm (hyrbid-kernel I suppose).
So it occurred to me that what I'm currently using as my primitive monolithic kernel could/should actually be a multiboot compliant system initialization program. From what I've read, Grub can load other things as "modules", which your own code has to handle (fair enough). So I figure why not have it load a more sophisticated micro-kernel as a module, load libraries/drivers/etc, and have my "initializer" perform all the setup work (maybe even installation in the future if needed). Then as control is given to the shiny new kernel, the initializer's code and resources can be disposed of and it won't need to exist from the duration of runtime (sounds good to me). I think this can be very advantageous in the future, since a certain interface between the initializer and kernel can be created which doesn't need changes, even though the internal implementations may be changed. This could make, for instance, upping the system to 64-bit less painful. I guess really I'm looking for an overview of how this is done. All I've really seen/read was a snippet from menu.lst files with "module <file name here>". I already get the multiboot information pointer after loading and know it has some data about modules. I've just never seen (and can't find) how to tie that together and handle it correctly. I'm pretty sure I can handle implementing something like GetProcAddress to find functions/resources and whatnot. The Grub side of it is a bit mysterious to me though, and how I can find out information about each and every module BEFORE I start trying to parse them. If anyone can fill in some of my mental blanks here, please do!
Another thing, which I can't find an answer to, is how to reliably determine the actual boot device on different hardware. All I've really seen is the suggestion that getting 0x0 is likely to be the 1st floppy drive, and 0x80 is likely to be the main HD. You could determine this much easier in Real Mode, but is this even relevant anymore when we're in PMode? Or is this information useless? I can't seem to find any standards on this about knowing the actual device with certainty; which I think could be very important. The spec doesn't seem to offer much insight here. Will I just need to come up with something original to determine this because BIOSes are too diverse in this area?
Wow, this is getting way too long, so let me try to wrap it up... I'm trying to learn more about how some working, modern operating systems work. It's been hard to find certain things, since I really don't know what to search for or it's simply non-existent. For example, there are plenty of very broad/general diagrams about how all the major operating system components relate, but practically nothing along the lines of deeper, more detailed diagrams about what goes on between them. Anyone know where some are? I've also been unable to find any info/diagrams about the things that go on AFTER booting and BEFORE the shell is initialized in modern operating systems. All that nitty-gritty initialization work is a bit mysterious to me, and so far I've just made stuff up (varying degrees of success). Most articles and those little pictures of all the stuff (like the kernel, HAL, drivers, etc) are nice, but demonstrate nothing along the lines of how all that gets setup in the first place.
I'm also starting to try to dissect MINIX in hopes that it can teach me alot about how a compact, Unix-like system works. That's great and all, but there are 497 files in my copy and the names of most files/folders reveal little to me. I'm unable to find any outline of directories and their contents or any diagrams of how everything fits together. I also can't extract the floppy image to see the final deployment structure. So this is starting to seem like a long, tedious, Sherlock Holmes mystery. So to end this, if anyone knows where I can find a "handbook" to the structure and implementation of MINIX, please point me to it (other than Tannenbaum's $120+ book, for now). I think it can be a great teacher, but I hate to have to spend eons (or hundreds $$$) just figuring out what's IN the thing.
Thanks, and my apologies for the wall-O-text! Just starting to get more and more curious as I learn! Any other insight you can offer me about organizing and planning this thing will be greatly appreciated as well!
The first big concerns of mine are maintainability, modularity and structure. For example, it's totally unacceptable for me to just dump tons of code into a single project/folder and try to work with it. Way too chaotic and too difficult for other people to jump into further along the road. Likewise, that's going to cause a LOT of code repetition and thus increase the size of the kernel (or whatever component we're dealing with). That's one of the biggest downfalls of static libs, though they do have some big advantages. To put into perspective, my VGA code is currently a static lib which gets linked into the kernel. That's ok at this very moment, but other processes will need it soon. That means that it will be linked into ALL of them; each with their own little copy of it. So it seems to, obviously, follow that this should be a module (shared library) which can be digested by multiple processes as needed. If it hasn't hit your accumulator registers in your brain yet, I'm essentially going for a micro-kernel-like design, in which I'm going to attempt some modifications and deviations from the norm (hyrbid-kernel I suppose).
So it occurred to me that what I'm currently using as my primitive monolithic kernel could/should actually be a multiboot compliant system initialization program. From what I've read, Grub can load other things as "modules", which your own code has to handle (fair enough). So I figure why not have it load a more sophisticated micro-kernel as a module, load libraries/drivers/etc, and have my "initializer" perform all the setup work (maybe even installation in the future if needed). Then as control is given to the shiny new kernel, the initializer's code and resources can be disposed of and it won't need to exist from the duration of runtime (sounds good to me). I think this can be very advantageous in the future, since a certain interface between the initializer and kernel can be created which doesn't need changes, even though the internal implementations may be changed. This could make, for instance, upping the system to 64-bit less painful. I guess really I'm looking for an overview of how this is done. All I've really seen/read was a snippet from menu.lst files with "module <file name here>". I already get the multiboot information pointer after loading and know it has some data about modules. I've just never seen (and can't find) how to tie that together and handle it correctly. I'm pretty sure I can handle implementing something like GetProcAddress to find functions/resources and whatnot. The Grub side of it is a bit mysterious to me though, and how I can find out information about each and every module BEFORE I start trying to parse them. If anyone can fill in some of my mental blanks here, please do!
Another thing, which I can't find an answer to, is how to reliably determine the actual boot device on different hardware. All I've really seen is the suggestion that getting 0x0 is likely to be the 1st floppy drive, and 0x80 is likely to be the main HD. You could determine this much easier in Real Mode, but is this even relevant anymore when we're in PMode? Or is this information useless? I can't seem to find any standards on this about knowing the actual device with certainty; which I think could be very important. The spec doesn't seem to offer much insight here. Will I just need to come up with something original to determine this because BIOSes are too diverse in this area?
Wow, this is getting way too long, so let me try to wrap it up... I'm trying to learn more about how some working, modern operating systems work. It's been hard to find certain things, since I really don't know what to search for or it's simply non-existent. For example, there are plenty of very broad/general diagrams about how all the major operating system components relate, but practically nothing along the lines of deeper, more detailed diagrams about what goes on between them. Anyone know where some are? I've also been unable to find any info/diagrams about the things that go on AFTER booting and BEFORE the shell is initialized in modern operating systems. All that nitty-gritty initialization work is a bit mysterious to me, and so far I've just made stuff up (varying degrees of success). Most articles and those little pictures of all the stuff (like the kernel, HAL, drivers, etc) are nice, but demonstrate nothing along the lines of how all that gets setup in the first place.
I'm also starting to try to dissect MINIX in hopes that it can teach me alot about how a compact, Unix-like system works. That's great and all, but there are 497 files in my copy and the names of most files/folders reveal little to me. I'm unable to find any outline of directories and their contents or any diagrams of how everything fits together. I also can't extract the floppy image to see the final deployment structure. So this is starting to seem like a long, tedious, Sherlock Holmes mystery. So to end this, if anyone knows where I can find a "handbook" to the structure and implementation of MINIX, please point me to it (other than Tannenbaum's $120+ book, for now). I think it can be a great teacher, but I hate to have to spend eons (or hundreds $$$) just figuring out what's IN the thing.
Thanks, and my apologies for the wall-O-text! Just starting to get more and more curious as I learn! Any other insight you can offer me about organizing and planning this thing will be greatly appreciated as well!