Page 1 of 2

MBR- Help

Posted: Sun Jul 06, 2008 8:03 pm
by PatrickV
Hi ya

My Name is PatrickV. I've been working on creating my os for 3 months and got the hang of using a floppy disk. I decide to make my own os so i have control. Not linux which damaged my motherboard or windows. I understand the funderments of the MBR I know you have 2 bootsectors of a hard drive. But i want to create my own MBR, not use grub or any other MBR.
i even type "MBR" in many ways in google and came clean, Nothing. I want to be able to make my own standard MBR which load the bootsector of the active partition. I know how the partition table works but what to put the code before it, i don't know. Can anyone can point me in the write direction with nasm source code or examples. I would be great full. I need ergent help. :)

PS. i am looking for devlopers to help me build the operating system if anyone is instrested and e-mail @: [email protected]

Re: MBR- Help

Posted: Sun Jul 06, 2008 8:10 pm
by 01000101
you might want to be substituting the acronym 'MBR' for the word bootloader or bootstrap. You should head over to osdever.net or check out the wiki here to look for boot theorem and code to get you started.

Also, I'm kind of bewildered by your claim that linux 'damaged' your motherboard... while semi-possible, very unlikely.

Re: MBR- Help

Posted: Sun Jul 06, 2008 8:17 pm
by PatrickV
Thanks for that, already been their, Nothing that i am looking for
MBR (Master boot record) i am after. The Nasm code for it. I looked hi and low for MBR help, i just can't seem to find it. Grub is to large and complicated what i have in mind

Re: MBR- Help

Posted: Mon Jul 07, 2008 2:12 am
by M-Saunders
PatrickV: my OS has a simple MBR that loads a kernel (from a FAT12 filesystem) and executes it. Download:

http://mikeos.berlios.de

In the source/ directory you'll see bootload.asm -- that's what you want. Many other hobbyist/tutorial OSes include small bootloaders too.

M

Re: MBR- Help

Posted: Mon Jul 07, 2008 3:56 am
by jnc100
Hmm, how about checking the GRUB sources?

Regards,
John.

Re: MBR- Help

Posted: Mon Jul 07, 2008 8:30 am
by bewing
On osdever.net, a good start is John Fine's dual booting SMBR. http://www.osdever.net/downloads/bootse ... bmbr03.zip

On the wiki here, you will find http://wiki.osdev.org/MBR_%28x86%29 -- but it needs a bit of a rewrite.

Basically, the BIOS loads your MBR (one sector only, including partition table) off the disk and into memory at 0x7c00, then jumps to the beginning of it. You have a little over 400 bytes of code (in 16 bit Real Mode) to load your "bootsector" from the active partition into memory, and jump to the beginning of that. You will need to use BIOS functions (INT calls) to read the disk for you, after you parse the Partition Table.

If you don't care about loading anyone else's bootsectors, then life is easier.

Most bootsectors expect to also be loaded at 0x7c00, unfortunately. Since your MBR is already loaded at 0x7c00, this causes problems. Most bootsectors also expect to be passed a pointer to the beginning of the memory copy of the active (booted) partition in ESI.

All of low memory from 0x500 to 0x7ffff is available, but you need to use the segment registers to access all of it.

I recommend loading your bootsector at 0x500, and I also recommend loading 14 or 16 sectors of "bootsector", in your MBR. Loading only one is not wise. (You may run into trouble later if you try to load more than 18, though.)

Re: MBR- Help

Posted: Mon Jul 07, 2008 5:42 pm
by PatrickV
thanks, not much i use from it, but thanks for the insites, now i have the tricky part of putting it together, which i have no idea where to start and which code goes where

Re: MBR- Help

Posted: Mon Jul 07, 2008 10:50 pm
by Adek336
I think you try too hardly to reuse already availlable code; there is a lot of details you need to understand to reuse such code. The way we recommend here at osdev is first to write a part (if not all) of the code yourself; that way you reassure yourself that you know what you should be careful about, when combining others' code.
I believe a good first step would be to write an assembler DOS program, which writes text putting it directly into video memory and the second step writing and installing on a floppy a bootstrap which writes text using video memory access. If you'll try to understand how this is done and not only blindly reusing code, I believe the wiki, old forum threads, the pages mentioned may be of much help :D

Re: MBR- Help

Posted: Tue Jul 08, 2008 8:27 am
by Dex
When you start writing the code yourself this link will help:
http://thestarman.pcministry.com/asm/mbr/index.html

Re: MBR- Help

Posted: Tue Jul 08, 2008 5:06 pm
by PatrickV
Hey dex, thanks but the site does not tell all. By the way, i like your dexos and tried it on vm, it is a bit buggy and crashed a fewtimes, i guess that is comoan when it is a cd image

Re: MBR- Help

Posted: Tue Jul 08, 2008 7:33 pm
by Dex
PatrickV wrote:Hey dex, thanks but the site does not tell all. By the way, i like your dexos and tried it on vm, it is a bit buggy and crashed a fewtimes, i guess that is comoan when it is a cd image
Cd image makes no difference, it much more likely to do with vm not emulating the x86 100%.
This may sound big headed, but DexOS's biggest plue point, is it's so stable.
Its stable by design eg: design to be KISS, I also have a very large number of test PC, laptops etc and run many tests.
Also other have tested it, note the word stable not mine words others http://forum.osdev.org/viewtopic.php?f= ... 76&start=0
So if you test it on a real PC/laptop and get any bugs, please give full details and i will try to reproduce any bugs, but most OS Dev's are working on two fronts, they have to get round the bugs in emulators and fix real PC bugs, i for one take no notest of emulators and put 100% effort into real PC.
So thanks for trying DexOS and do your self a favour and try it on a real PC.

MBR Build- Help

Posted: Sun Jul 13, 2008 8:56 pm
by PatrickV
Hey this is my update of my MBR of my os but i've run into a bit of a snag and i don't know what to do next can someone help me. This is a temp one and is not yet stable and not finished.

Code: Select all

;Patricknet Master Boot Record
;This is for the first sector of the hard drive which has the Partition Paramter Table in it
;This Master Boot Record is free for anyone to use
;Be warned that is might cause loss of data
		
	xor ax, ax
	cli
	mov ss, ax
	mov sp, 0x7c00
	sti
	
unbootable:
	jmp unbootable
	
	times 410 db 0 ;Has to be at this point for partion table to in correct address
	
partition_table:
	db 0                ; non-bootable partition
	db 1, 1, 0          ; cylinder/head/sector
	db 0x12             ; configuration partition
	db 0xef, 0xbf, 0x62 ; C/H/S of last sector
	dd 0x0000003f       ; logical block address
	dd 0x008cf6f1       ; size in sectors

	db 0x80             ; bootable partition
	db 0, 0x81, 0x63    ; cylinder/head/sector
	db 0x07             ; Windows NTFS
	db 0xef, 0xff, 0xff ; C/H/S of last sector
	dd 0x008cf730       ; logical block address
	dd 0x041b5bd0       ; size in sectors

	times 16 db 0       ; no third partition
	times 16 db 0       ; no fourth partition
	
	dw 0xaa55

Re: MBR- Help

Posted: Mon Jul 14, 2008 12:08 am
by bewing
You didn't mention what your "snag" might be, but one of your partitions has a "start sector number" of 0 -- and a sector number == 0 is always illegal.

Re: MBR Build- Help

Posted: Mon Jul 14, 2008 1:00 am
by egos

Code: Select all

	org 0x7C00
	
unbootable:
	jmp unbootable
	
	times 7DBE-$ db 0 ; rb 7DBE-$
	
partition_table:

Re: MBR- Help

Posted: Mon Jul 14, 2008 7:25 pm
by PatrickV
well it's a temp, you guys are so mean to me you know i am trying my best to learn. I am just figureing it out, well you guys don't have tutorial of this stuff step by step like you did for baby steps so forgive me i seem a bit angry where can not find any examples full tutuorials that has partition table. Give Me a break will ya. :evil: [-X #-o :x :cry: [-o<