Hi all, I finished Bran's Kernel Development Tutorial and stuck right after. The memory manager. I read about the memory manager form Bonafide and all that. So I edited the linker script adding Virt and the rest of it. (Problem 1) Don't really know how to make the kernel link to 0xC0000000 altho it complied no problem.
But GRUB give me Error#28. So I found that adding *rodata can solve it, so i did and its fine, but it reboots. So i had to use the simple version linker script. So I tried other things. Any clues...?
I read the wiki for "Memory management the howto " from here. Looked at the Multiboot data structure for GRUB.
So I thought at last...something clue for memory manager. I try to read system information from GRUB.
(Problem 2)But I don't understand how to use it with my existing kernel. I am using .asm code whereas the multiboot specification is gas code from here:
http://www.gnu.org/software/grub/manual ... %20systems
Then I tried the code from GRUB tutorial. They use asm code. But I don't know how it worked.
http://www.openbg.net/sto/os/xml/grub.html
Also can anyone tell me what to do to read information from GRUB please?
And how can i make the kernel locate at 0xC0000000 but loaded at 0x100000 without encounter error#28?
Sorry if I am talking rubbish, not get to the point, being stupid etc...Still, can anyone give me some pointers please. Been stuck for few days now.
Thanks in advance.
Passing system information from GRUB to your kernel
-
Mark
Re:Passing system information from GRUB to your kernel
Hi,
Here is the linker script I use for my learning OS.
All the boot type stuff is linked to 0x00100000
My main code is physically located at 0x00110000 but linked as if it's at 0xC0000000
Before I can call any of that code I need to setup some mapping in my boot sequence. Once mapped I'm free to jump into the main kernel and off I go.
my physical mem manager reclaim the the boot memory - would be a waste to loose it
OUTPUT_FORMAT("elf32-i386")
ENTRY (_loader)
SECTIONS
{
. = 0x00100000;
.boot :
{
src/obj/startup.o(.text)
src/obj/boot.o(.text)
src/obj/kernelscreen.o(.text)
src/obj/startup.o(.rodata)
src/obj/boot.o(.rodata)
src/obj/kernelscreen.o(.rodata)
}
.boot_bss ALIGN(0x1000) :
{
src/obj/startup.o(.bss)
src/obj/boot.o(.bss)
src/obj/kernelscreen.o(.bss)
}
.boot_data ALIGN(0x1000) :
{
src/obj/startup.o(.data)
}
.data ALIGN (0x1000) :
{
*(.data)
}
.bss 0xD0000000 : AT(0x0010C000)
{
*(.bss)
}
.text 0xC0000000 : AT(0x00110000)
{
*(.text)
*(.rodata)
}
}
Here is the linker script I use for my learning OS.
All the boot type stuff is linked to 0x00100000
My main code is physically located at 0x00110000 but linked as if it's at 0xC0000000
Before I can call any of that code I need to setup some mapping in my boot sequence. Once mapped I'm free to jump into the main kernel and off I go.
my physical mem manager reclaim the the boot memory - would be a waste to loose it
OUTPUT_FORMAT("elf32-i386")
ENTRY (_loader)
SECTIONS
{
. = 0x00100000;
.boot :
{
src/obj/startup.o(.text)
src/obj/boot.o(.text)
src/obj/kernelscreen.o(.text)
src/obj/startup.o(.rodata)
src/obj/boot.o(.rodata)
src/obj/kernelscreen.o(.rodata)
}
.boot_bss ALIGN(0x1000) :
{
src/obj/startup.o(.bss)
src/obj/boot.o(.bss)
src/obj/kernelscreen.o(.bss)
}
.boot_data ALIGN(0x1000) :
{
src/obj/startup.o(.data)
}
.data ALIGN (0x1000) :
{
*(.data)
}
.bss 0xD0000000 : AT(0x0010C000)
{
*(.bss)
}
.text 0xC0000000 : AT(0x00110000)
{
*(.text)
*(.rodata)
}
}
-
calpis
Re:Passing system information from GRUB to your kernel
Thanks for the linker script and reply.
Anyway I tried to change the asm file. It was actually the same...So I tried to modified it according to the higherhalf barebone:
http://www.osdev.org/osfaq2/index.php/H ... fBareBones . And nasm accepted. The only problem is, when bochs boot the kernel, it continuously rebooting itself. How do I solve it? Here is the output from the bochs. Thanks in advance.
00002385123e[HD ] device set to 1 which does not exist
00002724880i[BIOS ] int15: Func 24h, subfunc 01h, A20 gate control not supported
00002738185i[BIOS ] int13_harddisk: function 41, unmapped device for DL=81
00002742689i[BIOS ] int13_harddisk: function 08, unmapped device for DL=81
00002747223i[BIOS ] *** int 15h function AX=00C0, BX=0000 not yet supported!
00002751703i[BIOS ] *** int 15h function AX=5300, BX=0000 not yet supported!
00002756118i[BIOS ] *** int 15h function AX=5304, BX=0000 not yet supported!
00003933994i[CPU ] MOV_RdCd: read of CR4
00003933996i[CPU ] #GP(0): SetCR4: Write of 0x00000010 not supported (allowMask=0x0)
00003933996e[CPU ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
Anyway I tried to change the asm file. It was actually the same...So I tried to modified it according to the higherhalf barebone:
http://www.osdev.org/osfaq2/index.php/H ... fBareBones . And nasm accepted. The only problem is, when bochs boot the kernel, it continuously rebooting itself. How do I solve it? Here is the output from the bochs. Thanks in advance.
00002385123e[HD ] device set to 1 which does not exist
00002724880i[BIOS ] int15: Func 24h, subfunc 01h, A20 gate control not supported
00002738185i[BIOS ] int13_harddisk: function 41, unmapped device for DL=81
00002742689i[BIOS ] int13_harddisk: function 08, unmapped device for DL=81
00002747223i[BIOS ] *** int 15h function AX=00C0, BX=0000 not yet supported!
00002751703i[BIOS ] *** int 15h function AX=5300, BX=0000 not yet supported!
00002756118i[BIOS ] *** int 15h function AX=5304, BX=0000 not yet supported!
00003933994i[CPU ] MOV_RdCd: read of CR4
00003933996i[CPU ] #GP(0): SetCR4: Write of 0x00000010 not supported (allowMask=0x0)
00003933996e[CPU ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
-
AR
Re:Passing system information from GRUB to your kernel
That says you're using "mov cr4, eax" or something like that.