• Recent Tutorials

  • Up is down - Baremetal Programming & Pascal as Low As It Gets

    Step 1: Dependencies

    I'll be using my faithful old Mint 11 x32 virtual machine - things should not change much (if at all) for ubuntu 32 bit or mint 12. HOWEVER: if you run an x64 system I highly recommend getting a 32 bit virtual machine for compilation, the ia32 packages are prone to weird behavior and nothing here is designed for x64. You could, of course, dual boot ubuntu 32 bit if you wished but thats a different story.

    First, we will need nasm, fpc and bintuils with elf support (the ld command) as well as a copy of qemu. To set this up a quick
    Code:
    sudo apt-get install fpc nasm binutils qemu
    If you want, a copy of Geany - an excellent editor is recommended in which case adding geany to the end of the above command should see you through or a separate:
    Code:
    sudo apt-get install geany
    Will do just as fine.

    Step 2: Some Source code.

    First, we will need a folder in the home directory - or somewhere you can find the files where you haw r/w and execute permissions.

    I've added all the sources for Helios in one nice zip file right here: http://dl.dropbox.com/u/4853895/PGD Files/Helios_Source_03122011.zip so once you have a copy of that just extract the files into the helios directory we made earlier.

    Step 3: Compiling the OS and doing a test boot.

    First we'll need a terminal window - on ubuntu a Ctrl + Alt + T gets you there followed by a
    Code:
    cd ~/helios
    Or wherever you put the source files.

    Once there we need to make sure the build.sh and run.sh scripts are executable - doing the following will ensure that is the case:
    Code:
    chmod +x run.sh
    chmod +x build.sh
    Now its all unpacked and ready for action - lets compile an operating system:
    Code:
    ./build.sh
    And we're done!

    As for running the OS:
    Code:
    ./run.sh
    The latter will bring up a qemu window, write the startup string followed by OK which will promptly vanished to be replaced byt he debug roots of a shell continuosly writing '>' followed by numbers - the key code of the key you just pressed. Not pretty but turn over to the next page and I'll show you why.

    Comments 5 Comments
    1. chronozphere's Avatar
      chronozphere -
      Impressive! I didn't know that this was possible using pascal. Although its not really necessary, since we allready have linux, its great to play with :-D

      I fear that I won't have any time for it though.
    1. code_glitch's Avatar
      code_glitch -
      Its true we have linux - but lets say you needed to calculate some numbers of pi as fast as you could with zero overhead (or only a few bytes of it ).

      As a concept though, I think this demonstrates the true power of pascal - I've heard all too many critiques of it saying its too high level, no direct memory management and how limiting managed pointers can be. This, though, is the transformation of 'theoretically' to a much more practical approach to saying: it may be high level, but give it a line or two of ASM, tell the compiler to scrap the beautification and off you go: baremetal programming

      It is a shame the OSDev site only goes as far as basic VGA - if we had opengl drivers/code available I would have been able to compile prometheus and that could have been a sight to behold. Although I have not given up on the idea of finding some ATI docs on the matter and looking if there is any common ground between the driver .so files procedure wise. Because if that is the case it may be possible to scrap together a quick and dirty solution to the OpenGL solution. Still looking into this a bit at a time as it were.
    1. Ñuño Martínez's Avatar
      Ñuño Martínez -
      Man, I was looking for something like this for decades. Actually. Thank you for make it public!
    1. code_glitch's Avatar
      code_glitch -
      Nuno: No problem at all... I was actually getting worried by the silence of the comments box I'd posted one of the few topics no one needed/was interested in

      At least now its helped at least one person I am more or less satisfied...
    1. Ñuño Martínez's Avatar
      Ñuño Martínez -
      Quote Originally Posted by code_glitch View Post
      At least now its helped at least one person I am more or less satisfied...
      You know: Tanenbaum's book is so complex... I know your HeliOS isn't a full kernel but it helps to understand and testing ideas and so.
Comodo SSL