Sorry for my English,
I've been rewriting my kernel and adding some features to my OS, and I've decided to rewrite my entry point to AT&t assembler. After that when I booting my kernel GRUB returns error #13 (Invalid or unsupported executable format)
There are sources:
start.S
Code: Select all
include <config.h>
#include <arch/x86/page.h>
#include <multiboot.h>
#define STACKSIZE 0x4000 // that is, 16k.
// setting up the Multiboot header - see GRUB docs for details
.section .mboot
.global start
start:
jmp stage1
.align 4
mboot_header:
.long MBOOT_MAGIC
.long MBOOT_FLAGS
.long MBOOT_CHECKSUM
.text
.extern pagedir
.extern pagetab
#ifdef __CONFIG_CPU_PAE
.extern pagedir_ptr
#endif
.global stage1
stage1:
mov $(stack + STACKSIZE - KERNEL_BASE_ADDR), %esp
push %eax
push %ebx
#ifdef __CONFIG_CPU_PAE
movl $4, %ecx
movl pagedir_ptr, %esi
subl $KERNEL_BASE_ADDR, %esi
.fill_ptr:
movl $0, (%esi)
addl $8, %esi
loop .fill_ptr
#endif
movl $PGTAB_MAX, %ecx
#ifdef __CONFIG_CPU_PAE
// Map 4 MB!
shll $1, %ecx
#endif
xorl %edx, %edx
movl $KERNEL_TO_PSYH(pagetab), %esi
.fill_pagetab:
movl %edx, (%esi)
orl $0x3, (%esi)
addl $PAGE_SIZE, %edx
addl $PAGE_ENTRY_SIZE, %esi
loop .fill_pagetab
movl $PGDIR_MAX, %ecx
movl $KERNEL_TO_PSYH(pagedir), %esi
.clear_pgdir:
movl $0, (%esi)
addl $PAGE_ENTRY_SIZE, %esi
loop .clear_pgdir
movl $KERNEL_TO_PSYH(pagedir), %esi
movl $KERNEL_TO_PSYH(pagetab), %edi
#ifdef __CONFIG_CPU_PAE
movl %edi, (%esi)
orl $0x3, (%esi)
#else
addl $(768 * 4), %esi
movl %edx, (%esi)
orl $0x3, (%esi)
#endif
#ifdef __CONFIG_CPU_PAE
movl $KERNEL_TO_PSYH(pagedir_ptr), %esi
movl $KERNEL_TO_PSYH(pagedir), %edi
movl %edi, 32(%esi)
movl %edi, (%esi)
orl $0x01, 32(%esi)
orl $0x01, (%esi)
movl %cr4, %edx
orl $0x20, %edx
movl %edx, %cr4
movl $KERNEL_TO_PSYH(pagedir_ptr), %edx
movl %edx, %cr3
#else
movl $KERNEL_TO_PSYH(pagedir), %edx
movl %edx, %cr3
#endif
movl %cr0, %edx
orl $0x80000000, %edx
movl %edx, %cr0
lea (stage2), %ecx
jmp *%ecx
stage2:
addl $KERNEL_BASE_ADDR, %esp
.extern main
call main
.bss
// reserve initial kernel stack space
.comm stack, STACKSIZE, 32 // reserve 16k stack on a quadword boundary
Code: Select all
ENTRY(start)
OUTPUT_FORMAT("elf32-i386")
OUTPUT_ARCH("i386")
SECTIONS {
/* The kernel will live at 3GB + 1MB in the virtual
address space, which will be mapped to 1MB in the
physical address space. */
. = 0xC0100000;
.text : AT(ADDR(.text) - 0xC0000000) {
arch/x86/start.o(.mboot)
*(.text)
*(.rodata*)
}
.data ALIGN (0x1000) : AT(ADDR(.data) - 0xC0000000) {
tty_vga = .; . += 8 * 0x1000;
*(.data)
}
.bss : AT(ADDR(.bss) - 0xC0000000) {
_sbss = .;
*(COMMON)
*(.bss)
_ebss = .;
}
end = . ; _end = . ;
}