Results 1 to 9 of 9

Thread: OS bootloader

  1. #1
    Senior Member
    Join Date
    Jun 2004
    Posts
    112

    OS bootloader

    I am starting to write an OS so I can learn a bit more about how my computer works with it's hardware. I am trying to write it strictly in C++. I have been looking for the C++ source for a boot loader that I can study so I can see how it works. Does anyone by chance know where I can find something like this? I am sorry to ask b/c it is probably something I should already know but all I can find is stuff in assembly. Thanks in advance.

  2. #2
    Senior Member DeadAddict's Avatar
    Join Date
    Jun 2003
    Posts
    2,583
    Take a look at linux freebsd Etc they are all open source you just have to find the folder it is located in or search the web.

  3. #3
    Senior Member gore's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    7,177
    Have you looked at GRUB? It's not Assembler. If I recall it's 32-Bit C, and if you're writing an OS, I don't think you'll have a problem taking C and turning it into C++. Also, I think KDE is done in C++ so you might want to check that out of you're making a GUI.

  4. #4
    BANNED
    Join Date
    Nov 2003
    Location
    San Diego
    Posts
    724
    http://www.pscode.com/vb/scripts/Bro...t=Alphabetical

    Anytime you need source code in any language check out planet source code.
    When death sleeps it dreams of you...

  5. #5
    Senior Member
    Join Date
    Jun 2003
    Posts
    723
    Do unto others as you would have them do unto you.
    The international ban against torturing prisoners of war does not necessarily apply to suspects detained in America\'s war on terror, Attorney General John Ashcroft told a Senate oversight committee
    -- true colors revealed, a brown shirt and jackboots

  6. #6
    T3h 1337 N00b kryptonic's Avatar
    Join Date
    Sep 2003
    Location
    Seattle, Washington.
    Posts
    523
    Hmm ya know ive also been wanting to code an OS but im not to sure of what language to code it in/what languages i need to know.....hobbdebub could you please contact me via PM as in i would be interested in the resources you are useing.

  7. #7
    Senior Member
    Join Date
    Jun 2004
    Posts
    112
    I have looked around and I do believe that if I am going to write an OS I need to learn assembly. It is need I guess to deal with the lower level aspects of dealing with the hardware. Seems to learn one thing I have to learn 2 more.

  8. #8
    Senior Member
    Join Date
    Apr 2004
    Posts
    1,130
    u can write almost of an O/S in C. However, in some specific areas, on specific hardwares, we need to deal with assembly. Here some example of why:

    a) you need to use instructions that cant be mapped to C. You need for example, to craft a special instruction to talk to a device. Or use instructions that change control registers. You cant do it on C
    b) you need a very very small program. Some routine, such as 1st level interrupt handler or loader has a size limit. So you need to write it in assemly instead C.

    You face those problem on IA-32 architecture for instance. You somebody show you an O/S for IA-32 that is "pure" C, believe me, its b/s. You will need some assembly to finish it.

    Other platforms, like PA-RISC, all drivers can be written in C, since device are all memory-mapped.

    Anyway, i do recommend that you learn assembly. It will be usefull even if you only code in C. At least for debugging purpose
    Meu sítio

    FORMAT C: Yes ...Yes??? ...Nooooo!!! ^C ^C ^C ^C ^C
    If I die before I sleep, I pray the Lord my soul to encrypt.
    If I die before I wake, I pray the Lord my soul to brake.

  9. #9
    Senior Member
    Join Date
    Jan 2002
    Posts
    1,207
    You are unlikely to find a bootloader written in C or C++. Seeing as these bootloaders all run in real-mode (in intel), they need to call bios routines. Writing one in C would be awkward because you'd have to write a new C library which would work in real mode, but not call DOS routines (as DOS is not present).

    So they use asm.

    Also the first part of the bootloader needs to fit in under 512 bytes (can't remember how many). Then you have a second part and sometimes a third part.

    Typically all the parts are written in asm. I'm not sure whether the bootloader switches to pmode, or whether the OS does. But in any case, at some point the CPU switches to pmode. In the case of Linux, I'm pretty sure it only switches to pmode after it's loaded the kernel fully (which it does using the bios block IO routines)

    Slarty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •