Newbie-Tutorial1

From OSDev Wiki

Jump to: navigation, search
Difficulty level
Image:Difficulty 0.png
Not rated

This page is a work in progress!

I added some comments about misfacts and other things you might want to revise - Combuster 22:37, 28 October 2008 (UTC)

Contents

Tutorial 1: How To Start

Hello Everybody!

I would like to welcome you to the first tutorial for newbies. In this tutorial we will be talking about planning your very own operating system. But before we can start pressing the key's on our keyboard hard out, we need to know what to. Every good operating system requires planning. Planning helps to make sure that you research and know what expected result you get. How ever most of the time we need to do a lot of debugging and tweaking to get it right. Operating Systems are very hard to program and take lots of time. It is not a walk in the park. You need good programming skills to pull it off. So when you carry on through my tutorials you will notice it will get harder and more complicated. But for now, it will be easy. Just warning you.

Stage 1: Planning For Bootloaders

Stage 1! This is the most important part of creating your very own Operating System. We are not going to create your own Bootloader just yet. When creating an Operating System you'll require a bootloader. There are many open source bootloaders out there that you can use for your Operating System. The most known for open soure is GRUB. You can use one of them or create your own. But be careful! Some open source bootloaders may have licence restrictions. I have created a link on the Newbie Basics page for a list of bootloaders you can use. You may think this is a lot of writing, but it holds key information that you need.

Bootloaders! What are they? When are they used? Why are they being used?

A lot of people go mash potatoes over this. They get confused which term is correct. Congrat's you are not the only one. I've been there my self. A Bootloader is a piece of software that sits in your bootsector. So what is a bootsector you may ask? A disk is broken down into little blocks known as sectors and each sector can hold 512 bytes of data. The bootsector is the very first sector of the disk. When a computer starts, the BIOS tells the hardware to go to this address of the disk: head 0, track 0, sector 1 and that is the location where our bootloader is stored. You think that this is simple and straight to the point. WRONG! The question is: "How does the computer know it's a vaild bootsector?" That's when the bootloader comes in. Every bootloader has a 2 byte string which reads: "DW 0xAA55". This string is also known as the boot signature. This Boot signature tells the BIOS that the bootsector and the bootloader is vaild. This boot signature has to be located at the end of your boot loader and nothing is allowed to be put after it. Without that, you will have an operating system that doesn't work. Just a black screen.

What is GRUB?

GRUB! It may be your friend if your a hard out linux fan. GRUB is one of the many bootloaders out their that are open source. As I said before, each bootloader must have a boot signature. GRUB has that. What is so diffrent about GRUB is that the bootloader is broken down into 2 stages. A normal bootloader is fitted into 1 sector only. But GRUB is designed to for 2 sectors. These stages are called stage1 and stage2. However sometimes their is a third stage known as stage 1.5. The fist stage fits on the first sector and loads the secound stage into memory or stage 1.5. You can choose GRUB for your operating system. At this stage we are not going to use it in our tutorials. GRUB requires further work.

Stage 2: Planning For Kernels

Kernels! Now that will put a kink in your back. Depending on the nature of your operating systems, kernels are the hard part to program. To get our kernel loaded into memory, we need to use our old friend the bootloader as we talked about in stage 1.

This part of creating your operating system requires more planning than the bootloader. The reason for that is the kernel is the backbone of your OS. It will be used everytime, can handle you memory management and much more depending on what it is designed for.

To get the most out of your kernel, it is recommended that you use a high level langauage such as C compared to a low level language like assembly. However, you have to choose which is the best way to program your kernel. High level will give you more control and will be easier to program to create your kernel and will be suited for GUI (Graphical User Interface). I am only talking about what i know in knowlege and their is different languages that i have not meantion. I see that look on your face. You are wondering what the jumping monkeys is he talking about. Well you must be dumb enough. lol If you noticed that Windows, Mac OS, and Linux Uses GUI. If you are already that dumb, how come you can click on your desktop. Desktops is one of the features that can be incoprated with the GUI. Basically it is anything that is graphical depending how far you denfine the meaning of it. However linux/unix have custom GUI which when the project started many years ago it was only text command base.

I'ved used all of my information in my little brain for this section. Kernels can be an endlist topic so I gave the short version. You can find more information about kernels just by searching on google or search it on OSDev wiki. I have wiki page that youn can find information about Kernels on the Newbie Basics page.

Stage 3: Tools Of The Trade

The tools of the trade. The most important part of create an operating system. There are 3 common types of tools we use to create our Operating sytem. They are: assemblers, compilers, and linkers.

Assemblers

The most common one that I use is NASM. If you are going to create an operating system. I recommend that you use NASM. If you are on linux I would recommend GAS. Yet again there are so many assemblers out their that we can use. Now you need to know what it does. What assemblers do is compiled the code into binary form which the computers can understand. Binary is known as ZERO's and ONE's

Compilers

There are a lot of compilers out their for people to compile their code. Compilers are not used to for binary. They most compile things like c, c++, basic, pascal. The one that they use in the barebones they use is GCC.

Linkers

There are a quite a few linkers out there.

Stage 4: Testing Your Operating System

( Information Needed )


Until Next Time! You Have Completed Tutorial 1

[Marked For Editing - Not Finished: I Am Happy For Anyone To Finish It Off]

Return To Newbie Basics

Personal tools