OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 29, 2024 2:39 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Higher Half Kernel Entry Point Isn't Segment Error
PostPosted: Wed Oct 18, 2023 7:10 am 
Offline

Joined: Tue Apr 04, 2023 9:00 am
Posts: 7
Hello,

I am trying to convert my x86 kernel into a higher half kernel. I'm using GNU GRUB version 2.06 and without higer half modification my kernel works perfectly.
But when i tried the convert it to higher half i get
Code:
error: entry point isn't a segment
. Here is my updated bootloader code:

loader.asm:
Code:
MBALIGN     equ  1<<0
MEMINFO     equ  1<<1
FLAGS       equ  MBALIGN | MEMINFO
MAGIC       equ  0x1BADB002
CHECKSUM    equ -(MAGIC + FLAGS)
;constants for loading higher half kernel
VM_BASE     equ 0xC0000000
PDE_INDEX   equ (VM_BASE >> 22)
PSE_BIT     equ 0x00000010
PG_BIT      equ 0x80000000

section .multiboot
align 4
    dd MAGIC
    dd FLAGS
    dd CHECKSUM

section .data
align 4096
global TEMP_PAGE_DIRECTORY
TEMP_PAGE_DIRECTORY:
    dd 0x00000083
    times(PDE_INDEX - 1) dd 0
    dd 0x00000083
    times(1024 - PDE_INDEX - 1) dd 0

section .initial_stack, nobits
align 4
stack_bottom:
    ; 1mb of uninitialized data(1024*1024=104856)
    resb 104856
stack_top:

; Kernel entry
section .text
global kernel_entry
global low_kernel_entry
low_kernel_entry equ (kernel_entry - VM_BASE)
kernel_entry:
    mov ecx, (TEMP_PAGE_DIRECTORY - VM_BASE)
    mov cr3, ecx

    mov ecx, cr4;
    or ecx, PSE_BIT
    mov cr4, ecx

    mov ecx, cr0
    or ecx, PG_BIT
    mov cr0, ecx

    lea ecx, [higher_half]
    jmp ecx
higher_half:
    mov dword[TEMP_PAGE_DIRECTORY], 0
    invlpg[0]

    mov esp, stack_top
    extern kernel_main
    push ebx
    call kernel_main
loop:
    jmp loop


and here is my linker.ld:

Code:
OUTPUT_FORMAT("elf32-i386")
ENTRY(low_kernel_entry)
SECTIONS
{
   
    . = 0xC0100000;
   
    .text ALIGN(4K) : AT(ADDR(.text)-0xC0000000)
    {
        *(.multiboot)
        *(.text)
    }
    .rodata ALIGN (4K) : AT(ADDR(.rodata)-0xC0000000)
    {
        *(.rodata)
    }
     
    .bss ALIGN(4K) : AT(ADDR(.bss)-0xC0000000)
    {
        *(.COMMON)
        *(.bss)
        *(.initial_stack)
    }
    .data ALIGN(4K) : AT(ADDR(.data)-0xC0000000)
    {
        *(.data)
    }

   
    end = .;
}


I tried to change manipulate -0xC0000000 parts by assigning them to variables and substracking the variables instead of constants but nothing changed.
I will be thankfull for any help!


Top
 Profile  
 
 Post subject: Re: Higher Half Kernel Entry Point Isn't Segment Error
PostPosted: Wed Oct 18, 2023 7:37 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
Have you tried the suggestions from this thread yet?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group