OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:42 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 52 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: Re: My OS does not boot in real hardware
PostPosted: Mon Feb 18, 2019 3:22 pm 
Offline
Member
Member

Joined: Wed Dec 12, 2018 12:16 pm
Posts: 119
If I remember correctly, GRUB enables the protected mode, A20 and GDT?


Top
 Profile  
 
 Post subject: Re: My OS does not boot in real hardware
PostPosted: Mon Feb 18, 2019 3:30 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
The CPU will be in protected mode. The A20 line will be enabled. The GDT will not be set up, so you must set up your own GDT before you can load any segment registers.

That's all explained in the multiboot specification in section 3.3, "I386 machine state". You should search the specification before asking here; otherwise you'll just get a lot of answers telling you to look in the spec.


Top
 Profile  
 
 Post subject: Re: My OS does not boot in real hardware
PostPosted: Mon Feb 18, 2019 3:32 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
GRUB enables A20, enters 32-bit Protected mode with its own GDT. However, this is important - you should be establishing your own GDT because The Multiboot spec makes it clear the GDT record that gets loaded with LGDT should be considered invalid. You also don't know which selectors GRUB will use for code and data. The first time you attempt to load/reload a selector it could cause a crash. This is a real possibility if you enable your Interrupt Descriptor table and establish your own interrupt handlers. The documentation for Multiboot (legacy) is here: https://www.gnu.org/software/grub/manua ... iboot.html


Top
 Profile  
 
 Post subject: Re: My OS does not boot in real hardware
PostPosted: Mon Feb 18, 2019 3:35 pm 
Offline
Member
Member

Joined: Wed Dec 12, 2018 12:16 pm
Posts: 119
Thanks for the info. I'm gonna to port my OS to use GRUB.


Top
 Profile  
 
 Post subject: Re: My OS does not boot in real hardware
PostPosted: Mon Feb 18, 2019 4:46 pm 
Offline
Member
Member

Joined: Wed Dec 12, 2018 12:16 pm
Posts: 119
Hi, again here (as expected). I ported almost successfully my OS to GRUB, but I get this error:
Code:
error: no multiboot header found

I already searched the error in Google, but I find no solution. (that can help me)
Here is bootg.asm:
Code:
bits 32

%include "gdt.inc"
%include "idt.inc"

global start
extern kernelmain

start:
    mov esp, _sys_stack   
    jmp stublet

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

    call InstallGDT

    call kernelmain
stublet:
    jmp $

SECTION .bss
    resb 8192             
_sys_stack:


The linker script is the same that can be finded in Bare bones


Top
 Profile  
 
 Post subject: Re: My OS does not boot in real hardware
PostPosted: Tue Feb 19, 2019 12:20 am 
Offline
Member
Member
User avatar

Joined: Mon Jul 13, 2009 5:52 am
Posts: 99
Location: Denmark
I'm not entirely sure this is the reason you get "no multiboot header found", but your header is incomplete. When using the MULTIBOOT_AOUT_KLUDGE you need to specify information about the layout of your binary file. Have a look here https://www.gnu.org/software/grub/manua ... der-layout

For example, in my own loader I have the following header:
Code:
mboot:
    dd MULTIBOOT_HEADER_MAGIC
    dd MULTIBOOT_HEADER_FLAGS
    dd MULTIBOOT_CHECKSUM
    dd  mboot                    ; Location of this descriptor
    dd  code                     ; Start of the .text (code) section (defined in linker script)
    dd  bss                      ; End of the .data section (defined in linker script)
    dd  end                      ; End of loader (defined in linker script)
    dd  start                    ; Entry point below


Top
 Profile  
 
 Post subject: Re: My OS does not boot in real hardware
PostPosted: Tue Feb 19, 2019 7:18 am 
Offline
Member
Member

Joined: Wed Dec 12, 2018 12:16 pm
Posts: 119
zity wrote:
I'm not entirely sure this is the reason you get "no multiboot header found"

Also, I don't know, just bad luck I think. Using the bare bones NASM bootloader I get "invalid arch dependent elf magic" error.
#-o


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 52 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot], SemrushBot [Bot] and 78 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