Slashdot Mirror


A Look At Bootstrapping

markmcb writes "OmniNerd posted an interesting article on the often-overlooked process of bootstrapping. The author does a nice job of showing how to take an x86 system from BIOS to OS once it's powered on. A complete set of commented code is provided and explained in the article."

11 of 30 comments (clear)

  1. x86 is a fossil by kyouteki · · Score: 3, Insightful

    All this article says to me is how old and convoluted the x86 architecture is. I mean, all these memory restrictions and limits, all there for the sake of backwards compatibility. And we've just kept building on the same platform, so there's no way out.

    --
    A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    1. Re:x86 is a fossil by Anonymous Coward · · Score: 5, Insightful

      Old it is. Convoluted? Is that such a simple asm program that's giving you headaches? That's REALLY REALLY simple stuff for anyone who's ever done asm at all (on x86). Plain 386 instructions, nothing 32bit (no "db 66" or e?x registers even). No interrupt handlers, no direct I/O to the hardware, etc. If you find this complex, it just goes to say you've never coded asm, perhaps on any platform (I've coded in asm on several - motorola, PICs, Atmels, etc - and all programs were typically more complicated than this little "bootloader"). I find it's one of the easiest platforms when it comes down to machine code, coding things like a simple PLC emulator (that runs ladder) in asm, interfaced over the parallel port is pretty much trivial (did that in a weekend as a teen, just for fun). Extensive documentation was easy to find (schematic of the XT boards - whose chips were easy to understand and control, ralf brown's interrupt list, etc). Interfacing was easy too, just throw a 8255 on a "blank" ISA card and you were pretty much set (24 IOs at TTL level), although PICs have changed this whole thing quite a bit. I still miss these days - I loved coding in asm. Those were the best days of my life (as a geek/programmer/computer hobbyist), things just aren't the same anymore, and programming lacks that little something...

      We're "stuck" on x86 mostly by choice - backward compatibility is a great thing. You can buy a dual core high end machine and install anything from say, dos 3.3 to XP (and every version between) and most of it will run just fine (and other OS'es). That's very important to a lot of people. Decent hardware for the platform is quite cheap really, readily avaialble virtually everywhere, and you can get parts that fits your needs no matter what (slow or fast, be it a CPU, video card or whatever). You can assemble what you exactly need. There's tons of reasons to stay on x86, I can't see myself switching to something else anytime soon.

    2. Re:x86 is a fossil by John+Nowak · · Score: 3, Interesting

      This actually doesn't look that bad at all. I mean, I'm technically a *design* student, but I've wrote assembly of similar length for things like atmel avr microcontrollers before. I can actually follow a good portion of this, and being as I'm not a computer scientists, I'd say that makes it fairly easy (in the grand scheme of things -- there is a lot of C++ code that just goes WAY over my head).

    3. Re:x86 is a fossil by stevey · · Score: 3, Insightful

      And yet despite the fact that there are lots of existing bootloaders out there (lilo, grub, chos, etc) and writing a new one is fairly simple nearly every week there will be a new post asking for help in writing a bootloader on alt.os.development.

      I can only assume it is because people first start writing an operating system by coding the bootloader. Still given the number of people who have problems with that it is no wonder that few actually write something functional.

    4. Re:x86 is a fossil by RAMMS+EIN · · Score: 2, Interesting

      I agree. And the thing that puzzled me most is why it isn't ditched even when there is a chance to do so. For example, when AMD designed x86-64, which is incompatible with x86 by nature, they still made i t almost like x86, shortcomings and all. It has few registers (although they recognized the problem and gave x86-64 more registers), and the instructions are variable length, complex, irregular in format, and with various side effects, making them hard for compilers to target and hard for the CPU to decode.

      --
      Please correct me if I got my facts wrong.
  2. Takes me back to my youth... by HotNeedleOfInquiry · · Score: 5, Funny

    When I modified the boot sector of some floppy disks and spread them around at work. If you tried to boot them, you'd see the following message:

    You can't boot this floppy. Pull the floppy out of the drive and your head out of your ass and try again

    --
    "Eve of Destruction", it's not just for old hippies anymore...
  3. Meh, why not just look at LinuxBIOS? by DeathPenguin · · Score: 2, Informative

    Here's a bootstrapper that's written in over 99% C, boots Linux off several commercial mainboards, and isn't limited to just x86.

    I guess TFA is a good technical resource, but it's also a good reminder as to why big wads of assembly suck.

  4. Woohoo! by Deliveranc3 · · Score: 3, Funny

    Slashdot has an Article JUST FOR ME!

  5. I agree with the other guy by Kawahee · · Score: 3, Insightful

    Finally! A /. article just for me! I've written an OS before, a small one. It didn't do much. But I didn't understand shit about the ASM involved, or even why 0x700h or whatever was the correct place to put the stack. So kudos to /.. Kudos.

    --
    I'll subscribe to Slashdot when I see a month without a dupe, a typo, or an article the "editors" didn't read.
  6. Ummmm..... let's write a new OS! by teewurstmann · · Score: 3, Interesting

    That's a very insightful article. You know, I'm always amazed by people that sit down and start writing a new OS. I was impressed by BeOS and am very impressed by ReactOS. I'm using a Mac, and I only run Win98 inside Qemu, but as soon as ReactOS can run everything I need, I'll switch for sure! I just wish I had time to contribute to such wonderful projects!

  7. Fossil is a bad analogy. Try "modern mammal". by Julian+Morrison · · Score: 3, Interesting

    To you it might look old and convoluted. To me, it looks like a design sharpened by natural selection. The old 16-bit modes stay, because they have vestigial uses and they aren't sufficiently problematic to make the chip "evolutionarily unfit".