Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Programming Operating Systems Software IT Technology

A Look At Bootstrapping 30

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."
This discussion has been archived. No new comments can be posted.

A Look At Bootstrapping

Comments Filter:
  • Here I was hoping it was going to be a story about the commercialization of space.
  • x86 is a fossil (Score:3, Insightful)

    by kyouteki ( 835576 ) <kyouteki@@@gmail...com> on Monday November 07, 2005 @01:37AM (#13967511) Homepage
    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.
    • Re:x86 is a fossil (Score:5, Insightful)

      by Anonymous Coward on Monday November 07, 2005 @02:44AM (#13967736)
      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.
    • Re:x86 is a fossil (Score:3, Interesting)

      by John Nowak ( 872479 )
      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).
      • Re:x86 is a fossil (Score:3, Insightful)

        by stevey ( 64018 )

        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 [google.com].

        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.

    • Re:x86 is a fossil (Score:3, Interesting)

      by RAMMS+EIN ( 578166 )
      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
      • 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.

        Propably because the 64-bit AMD processors need to support 32-bit mode too, and support it well. The 64-bit and 32-bit mode likely share as many components as possible, to keep the total amount of components as small as possible, and this is of course easier if t

        • ``Propably because the 64-bit AMD processors need to support 32-bit mode too, and support it well.''

          AFAIK, the first thing that happens to x86 instructions is that they are decoded to micro-ops, which are much like RISC instructions. The rest of the CPU than operates on these micro-ops. To me, it seems these micro-ops could just as well come from a different decoder unit, so AMD could as well have designed a proper RISC architecture for the 64-bit mode.

          ``Besides, the x86 architechture has proven itself capa
      • 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 deco

    • by Julian Morrison ( 5575 ) on Monday November 07, 2005 @09:24AM (#13969115)
      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".
  • by HotNeedleOfInquiry ( 598897 ) on Monday November 07, 2005 @01:42AM (#13967536)
    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
    • Back in High School, I used to have a modified version of Apple ][ DOS on all my floppies that would ask for a password during the boot process. Every wrong character you entered would result in one more character from "You are a rotting, slime-covered filth." displaying. Ah, those were the good olde dayes... My copy of "Beneath Apple DOS" saw a lot of use... Basically there were some unused chunks of memory in Apple DOS, where you could stick some of your own code and call it at the right point in the
  • Here's [linuxbios.org] 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.
    • by Anonymous Coward
      Why not look at LinuxBIOS? Perhaps because it is totally irrelevant? It is a replacement of traditional proprietary BIOS systems, not a tutorial on the post-BIOS x86 bootstrapping process. I know this is Slashdot and that anything with Tux is free moderation, but Jesus Christ, this has NO relevance whatsoever.
    • I agree with the sentiments here, that bootstrap code, or any code within reason, is easier to maintain and generally to understand if written in a high level language (such as C). But I come from a mainframe background where bootstrap (or IPL) code has to use machine-specific instructions. Perhaps one day we'll get to the stage of 'standardising' on hardware level controls so that all functionality could be controlled without the need to 'resort' to assembler.

      Until then I'm keeping my assembler reference

  • Woohoo! (Score:4, Funny)

    by Deliveranc3 ( 629997 ) <<deliverance> <at> <level4.org>> on Monday November 07, 2005 @02:38AM (#13967716) Journal
    Slashdot has an Article JUST FOR ME!
  • by Kawahee ( 901497 ) on Monday November 07, 2005 @02:48AM (#13967755) Homepage Journal
    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.
  • by teewurstmann ( 755953 ) on Monday November 07, 2005 @05:29AM (#13968217) Homepage
    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 [reactos.org]. 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!
    • "but as soon as ReactOS can run everything I need, I'll switch for sure!"

      I said the same thing not but eight months ago. Then, about two months ago, I installed a Linux distro on my home desktop. I've installed plenty of them before, but they never stuck. Even the one I'm using right now (Gentoo) [gentoo.org] has been on this system at least half-a-dozen times. However, this time it stuck.

      "And why's that?", you may ask. Well, over the past few years I've been migrating to Open Source Software! Replacing Microsoft O
      • With "then I'll switch for sure" I meant replacing the Win98 in QEMU with Reactos. I know and I love Gentoo, I've been using it for over 3 years now, at home and at work. But I wanted a system that "just works" at home, and that's why I bought a Mac mini earlier this year and I love it, Mac OS X is a great OS. It's based on BSD, so you can do all your UNIX stuff on it (in fact, I just got a book called "Mac OS X Tiger for Unix Geeks"). So I share your love for Linux, esp. Gentoo, to a large degree. But some
        • "...I wanted a system that "just works" at home..."

          I hear you on that :P As for myself, I'm neck-deep in the Windows world every day at work and at school, and I'm a MCP. So I wanted something different at home.

          "...I meant replacing the Win98 in QEMU with Reactos."

          Ahh, misunderstanding. Still, got to drop a line about Linux every now and then, eh?

          Thanks for the feedback,
          QBRADQ
  • I'm part of the OS dev community and this has been detailed time and time again, what makes this so special?

To be awake is to be alive. -- Henry David Thoreau, in "Walden"

Working...