Page 1 of 1

a beginner question

Posted: Sat Oct 19, 2002 1:46 pm
by adeelmahmood1
hi
i m a beginner in OS dev and still woking on collecting info and trying to start something in it.. actually i need a working bootstrap loader but a very very simple one which has no extra features .. it could just boot by a floppy and a C kernel which could just print "Hello" ..
i just need to see what actually going on .. if some one could help me and show me what i m asking ...
and plz remeber that dont add any extra features .. bootstrap loader should only boot and give the control to kernel and kernel should only display "Hello" ..
and also tell me how to compile ur program and how to run it etc..
thanx for ur help

Re:a beginner question

Posted: Sat Oct 19, 2002 2:31 pm
by adeelmahmood1
hi another thing i m confused about is .. that some time they say that the BIOS loads the kernel code at 07C0 and some time they say that it loads it at 1 meg 100000.. now which thing is right ??? or i m confusing something with it ???
plz help me in the problem

Re:a beginner question

Posted: Sat Oct 19, 2002 3:08 pm
by Slasher
hi,
bios loads the boot code at 7c00h.
it is now up to the boot code to decide where to load the kernel.
most people load their kernel at the 1mb mark inorder to avoid corrupting memory that might be used by some device ie video card.
so that kernel load address is up to the programmer to decide where to put the kernel ;D

Re:a beginner question

Posted: Sat Oct 19, 2002 3:13 pm
by dronkit
You're talking about different things. When you power your computer on, the first thing it executes is the bios code, this is called POST (Power On Self Test), which basically tests some computer components (halts on errors), calls other roms (like video) and then procedes to load your operating system from the target boot device. On floppy, this is the first sector (or sector 0), which is called the "boot sector".

The MBR (Master Boot Record) of a hard disk is located at cylinder 0, head 0, sector 1 or in sector 0 in LBA mode, and sector 0:0:1 in CHS mode in a hard disk.

The MBR is for a hard disk as a boot sector is for a floppy.

This sector (no matter from where it came from) is loaded at absolut memory position 7c00h (the 'h' is for hexadecimal, meaning decimal memory offset 31744).

In real mode, the memory is segmented, so every memory access is done using a "segment" and an "offset". This has the following form:

Code: Select all

cs:ip
Where cs means "code segment" and ip is "instruction pointer". There
are other segments like ds, es and ss for data, extra and stack segmentes respectively.

An absolute position in real mode is calculated multiplying the segment value by 16 and then adding the offset, so:

0:7c00 = (0 h* 16) + 7c00h = 7c00h absolute
07c0:0 = (07c0h * 16) + 0h = 7c00h absolute

both reference to same memory position. So the initial code, the bootstrapper code, the first one the computer loads for transferring control to user programs, is loaded here.

This code can be no longer than 512 bytes (the size of a boot sector) so if you write this code you'll probably want to load some more sector from memory (so you can write more code) and then jump to it.

loading this code at 1Meg position is a wide adopted standard ;)

hope it helps.

Re:a beginner question

Posted: Sat Oct 19, 2002 3:26 pm
by adeelmahmood1
alright so wat i udnerstood was that the BIOS maps the boorstrap loader code at 07C0h and then its up to this code that where it wants to load the Kernel and usually the standard is to load it at 1 meg ..
another questions is still there ...
looking for a simple loader and kernel
thanx for ur help