Grub MultiBoot
Posted: Mon Aug 14, 2006 8:11 pm
im trying to load my kernel with grub, i have the multi kernel headers inside my asm file, but when ever i try to link the asm file with my c code grub says the file isnt supported. But it works if i dont link to the c file.
The code i have is
kernel.asm
kernel.c
link.ld
I should also note that im using a linux system to develop this.
Edit: I ended up working it out, after looking through just about every post in here and seeing someone else's linker script i noticed i didnt have *(.rodata) I added that compiled it all together and it works fine now, well kind of. I just have to work out why it isnt actually printing to the screen.
The code i have is
kernel.asm
Code: Select all
[BITS 32]
global start
start:
extern YaOS_main
call YaOS_main
cli;
hlt;
ALIGN 4
mboot:
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
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
dd mboot
dd code
dd bss
dd end
dd start
Code: Select all
#define TEXT 0x07
void YaOS_clearScreen();
void YaOS_updateCursor(int row, int col);
unsigned int YaOS_printf(char *msg, unsigned int line);
//Entry point for the OS (like main in a normal program)
YaOS_main() {
YaOS_clearScreen();
YaOS_printf("Welcome to YaOS (Yet another Operating System)\nVersion:0.1", 0);
};
void YaOS_clearScreen() {
char *vid =(char *) 0xb8000;
unsigned int i =0;
while(i <(80*25*2)) {
vid[i] =' ';
i++;
vid[i] =TEXT;
i++;
};
};
unsigned int YaOS_printf(char *msg, unsigned int line) {
char *vid =(char *) 0x8000;
unsigned int i =(line*80*2);
while(*msg !=0) {
if(*msg ='\n') {
line++;
i =(line*80*2);
*msg++;
} else {
vid[i] =*msg;
i++;
vid[i] =TEXT;
i++;
};
};
};
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Edit: I ended up working it out, after looking through just about every post in here and seeing someone else's linker script i noticed i didnt have *(.rodata) I added that compiled it all together and it works fine now, well kind of. I just have to work out why it isnt actually printing to the screen.