I've managed to confuse myself...

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.
Post Reply
Saint Michael

I've managed to confuse myself...

Post by Saint Michael »

The 8 Guinness I had this morning probably didn't help.

Ok, some history for you. 2 weeks ago, I threw together a basic bootloader. Few days later, I added code to the bootloader to enable a20 & load kernel. Then I developed a kernel which had 'int 21h' with 3 functions - write string (ah = 1), clear screen, reboot (ah = 3).

... then early this week, I optimized the bootloader c0de & threw in Pmode stuff, made it setup a larger stack & load kernel further in memory (x09000) then jump to it. When I came to test it... nothing printed (Kernel is supposed to print verification message). Of course, after slapping myself sober the old "no BIOS interrupts in Pmode" came to me. My print string routine (func 1, int 21h) relied on BIOS int 10h (used a loop to print chars). So now, that's not working. I wasn't gonna keep it, anyways - I was gonna mod it to write to ports & whatnot. So on studying ports... I am lead to believe (nothing actually SAID this) that each monitor has different ports & handlers & everything... so does this mean I'd need to use divice drivers? I also checked out some new links and.. I saw people using MSDOS int 21h (ah = 9) ... how the ****? And file systems... that's confused me. Everything is suddenly confusing me and I got a horrible headache. Even loading the kernel is no longer possible, as it relies on int 13h. I aren't expecting many people here to be able to help, as I assume most of you will be C devvers (my kernel is/will be pure ASM)

So, I'm gonna go slam my head into a desk. Can some of you like.. unconfuse me? Explain some stuff? Explain my options? To be honest, I've got no real 'design' for the kernel. I'm not keeping to mono, micro, whatever... I'm just making it work good & fast (I got some friends to help me, also - just to make sure alcohol doesn't influence my work)

All help is appreciated.
Warrior

Re:I've managed to confuse myself...

Post by Warrior »

Text Memory is mapped to 0xB8000

Check out OSDever.net for some tutorials on printing to the screen, which come with explinations on how to calculate screen offset, manipulate colors, etc..

Goodluck.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:I've managed to confuse myself...

Post by bubach »

You start with loading your kernel & drivers+whatever _before_ you enter pmode, when you still can use int 13h.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
Saint Michael

Re:I've managed to confuse myself...

Post by Saint Michael »

@ Nelson: You've lost me. The text output worked before. Now I cannot use BIOS interrupts due to Pmode, I cannot use my old routine. The ones at BFOSD all use INT 10h. I might be drunk, but it still makes sense.

@ b: Yeah, that would make sense ;)

Oh, and sorry for incorrect placement ;p
zloba

Re:I've managed to confuse myself...

Post by zloba »

Printing in text mode (80*25): that's easy, you don't need ports immediately. The videobuffer is mapped to memory at 0xB8000, it contains pairs of bytes - {ASCII, attributes}, (attributes = color (text and background)).

Code: Select all

mov ebx, 0xb8000  ; video buffer base
mov byte [ebx],'A' ; at top-left corner (line 0 pos 0)
mov byte [ebx+1],15 ; white on black
mov byte [ebx+2],'B' ; at (line 0 pos 1)
mov byte [ebx+3],14 ; yellow, i think
edit again: that needed size prefixes.

Reading the disk - you can either:
- have your custom bootloader load more of your kernel while still in real mode, as bubach said,
OR
- switch to a Multiboot bootloader (such as GRUB), which loads your entire kernel and enters the Protected Mode for you, then jumps to your kernel. IMHO this is a much easier, nicer start. Then you can proceed directly to writing to video buffer, setting up interrupts and whatnot.
Saint Michael

Re:I've managed to confuse myself...

Post by Saint Michael »

I'll give that code a play. And um.. I'd much prefer to keep to my own bootloader :P I might aswell, considering it all.. works. I'll just have to load the kern before entering Pmode.
Post Reply