MBR- Help

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: MBR- Help

Post by bewing »

We're not trying to be mean. We are just pointing out some potential errors.

All partition tables are different. There is no way to give you any kind of tutorial example. The wiki entry for the Partition_Table is pretty complete. If you want to see what a partition table for a particular drive should look like, then partition it with fdisk or your favorite partitioning software, and use some kind of disk editing software to examine LBA 0, and see what the partition table says. It's easier to copy a working example than to try to type an entry in by hand, and hope it works right.
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Re: MBR- Help

Post by PatrickV »

doesn't partition table has to follow the IBM Standards.So theoraticly it should be the same as far i was reading. Thanks for the link i will check it out once it's finished
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: MBR- Help

Post by bewing »

PatrickV wrote:doesn't partition table has to follow the IBM Standards?
Not entirely, no. Only one bit in the first byte (the "active" flag) is defined. What do the other bits do? IBM never said. I have proposed to use bit 0 as a "48 bit lba" flag for the partition table, which means that the CHS fields don't exist.

The IBM standard also never covered the "Filesystem type" byte (#4). It never said what happens when a disk grows bigger than would fit in the CHS fields (which happened a long time ago). Or what would happen when disks grow bigger than would fit in the LBA fields. So there is a lot of stuff that isn't covered by the IBM standard.
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Re: MBR- Help

Post by PatrickV »

can anyone help me out or point to someone i can talk to who created something like this, because looks like you guys know about it but you don't code your own
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: MBR- Help

Post by Brynet-Inc »

PatrickV wrote:can anyone help me out or point to someone i can talk to who created something like this, because looks like you guys know about it but you don't code your own
Don't expect members to spoon feed you code, that article on the Wiki is all you'll possibly need... assuming you have at least moderately notable programming skills.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Re: MBR- Help

Post by PatrickV »

I only got old style VB 4.0 programming skills, Their i don't creat stacks and use opcodes and assembly language. But thanks anyway and point my greadyness to learn from source code
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: MBR- Help

Post by pcmattman »

PatrickV wrote:I only got old style VB 4.0 programming skills, Their i don't creat stacks and use opcodes and assembly language.
Then writing an OS is not for you.
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Re: MBR- Help

Post by PatrickV »

Hey, don't mock me man, i am trying somthing new.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Re: MBR- Help

Post by Alboin »

PatrickV wrote:Hey, don't mock me man, i am trying somthing new.
He meant that you're going to have to learn some lower level languages as only knowing VB and not wanting to get your hands dirty will simply not work in osdev.
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: MBR- Help

Post by Combuster »

He meant that you're going to have to learn some lower level languages as only knowing VB and not wanting to get your hands dirty will simply not work in osdev.
*The resident BASIC guru agrees with this sentiment*
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: MBR- Help

Post by pcmattman »

Learn something like C, which will help to get you into a mindset for coding an OS. Assembly is also suggested, but unless you want to write an all-assembly OS (which, by the looks of your goals, will mean it'll take you much longer) you will need to know C.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: MBR- Help

Post by Omega »

PatrickV. First off I think it is great that you introduced yourself as PatrickV when clearly your post denotes that fact. You seemed very cute and nice but then you became hypersensitive, what happened there? Listen, writing your own OS isn't something you are going to fly right through, it is going to take years before you get something worthwhile bragging about. You only know VB 4.0, are you a caveman? I started developing my OS having more than 6 years experience in user-mode programming where I have written everything from Switch Sniffers to Fuzzers and I still have major issues writing certain things. I often write code for days and then later delete it all and start again. I have wanted to give up many times and do for months at a time, but I kept trying and I keep learning as much as I can and I get through it; right now I am writing my drivers (I never thought I'd even get past my loader; it took me 5 months until I saw my first response from the keyboard!). My point is, you are taking on a life's challenge that will not end soon and you have started on the wrong foot.

My advice. Don't write your own loader right now (use GRUB). Forget about this MBR business, you're just talking about a single stage loader which will get you nowhere fast. Focus on what your goals are and first evaluate the likelihood of them being met and adjust them accordingly (like don't think your going to be the first person to successfully create a full-fledged NTFS driver, because right now you won't and no one else that can will help you). I am not saying that a few years from now you won't become a great coder, because you might but as of now VB 4.0 is not going to cut it down here; where is your low-level experience?

Now, don't get discouraged or yell at me for this post, I am only trying to slap you back into reality. So, go on and start again and ask us nicely, "How do I write a single stage bootloader?" and I will say:

Code: Select all

[BITS 16] ; Real Mode

[ORG 0x7C00] ; BIOS looks for us right here

mov ax,0x0000 ; Initialize the DS reg
mov ds,ax ; Store our message offset

mov si,sMessage ; Store our String

mov ah,0Eh ; The function to display a character (teletype)
mov bh,00h ; Page number
mov bl,07h ; Normal text attribute

.nextchar ; Internal label
lodsb ; Check for end of string '0'
or al,al ; Set AL=0
jz .return ; If the zero flag has been set then goto quit
int 10h ; Run the BIOS video interrupt
jmp .nextchar ; Loop back round to the top
.return ; quit

; wait for key press
mov ah,00h ; BIOS Scan Keycode
int 16h ; Execute Command

jmp reboot ; We're done, reboot!

reboot:
jmp 0ffffh:0000h ; reboot!
ret ; End Function

sMessage db "Hello, World!",13,10,0

times 510-($-$$) db 0 ; Fill her up to 512

dw 0AA55h ; Look see, I am a boot loader
Happy Coding!
Free energy is indeed evil for it absorbs the light.
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Re: MBR- Help

Post by PatrickV »

Thanks for the input omega. On the other hand i don't have c lanaguage skills. If need c and can anyone point out where i can start. Using grubs is an issue becasue i am using windows first of but i need to create a kernel image which i have no idea how to create for linux. The code you gave me is very useful which i was thinking to apply to my os "Patricknet" But i am still intrested coding my own MBR which you said that everything takes time and i understand that
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: MBR- Help

Post by Zenith »

Then in what language are you planning to write your OS in? VB.NET?

Sorry to be critical, but you obviously need to read >> Getting Started << on the wiki. Do you meet the Requirements?

Some viable options other than C/C++ include Assembly (but from what we've seen, you're not that skilled at it), FreeBASIC (vaguely related to VB), and Pascal (if you know it).

And if you're going to do OS development and just learn C/C++/Pascal along the way, forget about it. Your time and effort will definitely be better spent working on something else.

Anyway, most people with operating systems already installed might not appreciate you overwriting their MBR. Wikipedia is also a good, language-independent reference about MBRs - http://en.wikipedia.org/wiki/Master_boot_record
"Sufficiently advanced stupidity is indistinguishable from malice."
Post Reply