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.
I have finally started to use grub as bootloader. I have my kernel compiled, I put it on the floppy.
Then if I start bochs, it load grub. I select my kernel, and it loads it. And then it's freezing, while it should give me a nice "Welcome to LaBOS" greeting.
I get a screen like this and i'm sure my kernels 'kmain' get's called.
any idea what i'm doing wrong?
thanks in advance,
assainator
Every human has to do something idiot to prevent becoming a complete one
Well, it would help if you posted your linker script, sources, and Makefile.
Give a man Linux, you feed the nearest optician ( Been staring at the PC too long again? ).
Give a man OS X, you feed the nearest NVidia outlet ( I need more GPU power!! )
Give a man Windows, you feed the entire Tylenol company ( Self explanatory )
; This is the kernel's entry point. We could either call main here,
; or we can use this to setup the stack or other nice stuff, like
; perhaps setting up the GDT and segments. Please note that interrupts
; are disabled at this point: More on interrupts later!
[BITS 32]
global start
start:
mov esp, _sys_stack ; This points the stack to our new stack area
jmp stublet
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
; Multiboot macros to make a few lines later more readable
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
; This is the GRUB Multiboot header. A boot signature
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge - must be physical addresses. Make a note of these:
; The linker script fills in the data for these ones!
dd mboot
dd code
dd bss
dd end
dd start
; This is an endless loop here. Make a note of this: Later on, we
; will insert an 'extern _main', followed by 'call _main', right
; before the 'jmp $'.
stublet:
extern _kmain
call _kmain
jmp $
; Shortly we will add code for loading the GDT right here!
; In just a few pages in this tutorial, we will add our Interrupt
; Service Routines (ISRs) right here!
; Here is the definition of our BSS section. Right now, we'll use
; it just to store the stack. Remember that a stack actually grows
; downwards, so we declare the size of the data before declaring
; the identifier '_sys_stack'
SECTION .bss
resb 8192 ; This reserves 8KBytes of memory here
_sys_stack:
Well, it doesn't print "Welcome to LaBOS" because there is absolutely no code that would do that. The only thing your code does is writing some value at the beginning of video RAM which probably should display the letter "o" - but it won't do that either, because there is some simple mistake in your code. It should be something like this:
XenOS wrote:Well, it doesn't print "Welcome to LaBOS" because there is absolutely no code that would do that. The only thing your code does is writing some value at the beginning of video RAM which probably should display the letter "o" - but it won't do that either, because there is some simple mistake in your code. It should be something like this:
void kmain()
{
//print a character. That way I can see if something is happening.
short *VidMem = (short *)0x0b8000;
VidMem[0] = 'o' | (0x0f << 8);
}
The attribute byte is the second byte, so you need to shift it by 8 bits. This will display the letter "o" in the top left corner of the screen.
Yes, that's true, after i posted i removed all of the printing code so that i would have less code to cover.
sometimes i feel like such an idiot for making a simple mistake like you pointed out.
Every human has to do something idiot to prevent becoming a complete one