Hey all.
I have a question.
... How can I Send a Parameter to my Kernel?
Id like to send it the Amount of Memory my system has.
This is the later code... in teh Bootloader. JUST before it calls the Kernel.
lgdt [citadel_gdt_descriptor] ; Load the Global Descriptor Table.
mov eax, cr0 ; Enable PE Bit in CR0
or eax, 1
mov cr0, eax
mov eax, 0x09
push eax
jmp 0x08:clear_pipe
Id like to know how to pass it a Number, that being the Number of RAM I have.
Ive tried moving a valu einto EAX and pushing EAX, but nothing happens.
Any advice would be helpful.
Thanks!
Sending Parameters to Kernel?
Re:Sending Parameters to Kernel?
Hmm. Example, eax is including memory size.
----- asm file -----------
...
; Enter protected mode
mov ebx, eax
mov eax, cr0
or al, 1
mov cr0, eax
...
...
; Copy memory size
mov eax, ebx
mov esi, 0x100
mov [esi], eax
-----------------------------
In kernel, you can read 0x100 in your C kernel.
----- asm file -----------
...
; Enter protected mode
mov ebx, eax
mov eax, cr0
or al, 1
mov cr0, eax
...
...
; Copy memory size
mov eax, ebx
mov esi, 0x100
mov [esi], eax
-----------------------------
In kernel, you can read 0x100 in your C kernel.
Re:Sending Parameters to Kernel?
;setting up cr0, flushing prefetch q etc
;assuming mem in ebx, lets say
pushl %ebx
jmp cmain
and the cmain should be defined like
.... cmain(unsigned int ram_available){...}
make sure you dont declare cmain as gcc attribute regparm.
but the better way around is to use GRUB, and use the map it provides. in that case, you just have to save one pointer in asm code into some global variable, which you can use in your c code later on. and, afaik, the memory map is quite reliable and i dont find many reasons why you should care about counting the RAM all by yourself.
;assuming mem in ebx, lets say
pushl %ebx
jmp cmain
and the cmain should be defined like
.... cmain(unsigned int ram_available){...}
make sure you dont declare cmain as gcc attribute regparm.
but the better way around is to use GRUB, and use the map it provides. in that case, you just have to save one pointer in asm code into some global variable, which you can use in your c code later on. and, afaik, the memory map is quite reliable and i dont find many reasons why you should care about counting the RAM all by yourself.
Re:Sending Parameters to Kernel?
I also use the stack to send my kernel the current memory map. Make sure that when your in protected mode that you set up ss selector and esp accordingly with the real mode setting. For me I used a 80:800h (linear 1000h) stack in real mode, and in protected mode I use a zero based data selector and code selector (for now anyways). That means I would have to add 800h to esp (not resetting it) and load ss to the data selector. After it is okay to start popping.