OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:44 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 6:46 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 18, 2009 5:47 pm
Posts: 208
Location: Alexandria, Egypt | Ottawa, Canada
Hello Again!
I would like my kernel to run with 'multiboot2' command of GRUB2. but can't find any specification online that standards MULTIBOOT2. i made a multiboot2 header in my kernel (at the start of text section), but GRUB2 says: "multiboot header not found". here is my header:
Code:
asm(".long   0xe85250d6         "); // Magic Number.
asm(".long   0x00000000         "); // Architecture = 32-bit Intel PMode.
asm(".long   0x00000010         "); // Header Length
asm(".long   -(0x10+0xe85250d6)      "); // Checksum


Any help would be appreciated.
Regards.


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 8:13 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
Are you sure that the multiboot 2 header looks like that ? The following code is from the file multiboot2.h in the latest Grub2 release.
Code:
  ...

/* The magic field should contain this.  */
#define MULTIBOOT2_HEADER_MAGIC         0xe85250d6

  ...

struct multiboot_header
{
  /* Must be MULTIBOOT_MAGIC - see above.  */
  multiboot_uint32_t magic;

  /* Feature flags.  */
  multiboot_uint32_t flags;

  /* The above fields plus this one must equal 0 mod 2^32. */
  multiboot_uint32_t checksum;

  ...
};
Where did you get the information for the new header format ?

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 8:21 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 18, 2009 5:47 pm
Posts: 208
Location: Alexandria, Egypt | Ottawa, Canada
Wow it works fine now!
Thanks gerryg400, but could i know from where i can get multiboot2.h?
I searched for it online with no result...


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 8:23 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
It's in the Grub 1.98 source.

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 8:41 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 18, 2009 5:47 pm
Posts: 208
Location: Alexandria, Egypt | Ottawa, Canada
thanks, i got the file and included it in my kernel.
right now, is there any way to know the size of the kernel from GRUB or the boot loader?? i need the kernel to know the size of itself every time it boots in order to mark its memory space as used in an implemented memory map. this will help allocating free memory space in an accurate way. do u have any idea, plz???
Regards,


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 9:00 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
mostafazizo wrote:
thanks, i got the file and included it in my kernel.
right now, is there any way to know the size of the kernel from GRUB or the boot loader?? i need the kernel to know the size of itself every time it boots in order to mark its memory space as used in an implemented memory map. this will help allocating free memory space in an accurate way. do u have any idea, plz???
Regards,
I don't know how to get it from Grub. I feel the best way is to define a variable in your linker script that marks the end of the loadable image. I think this will probably work.
Code:
SECTIONS
{
   .text 0x100000 :
     ALIGN (0x1000)
     { *(.text) }

   .data :
     ALIGN (0x1000)
     { *(.data) }
   
   .bss :
     ALIGN (0x1000)
     { *(.bss) }
    
   .unused_section :
     ALIGN (0x1000)
     { kernel_end = . ; }

}

You can refer to kernel_end from within your code.
Code:
   extern uint32_t kernel_end;

   /* Get the physical address of the end of the image */
   pfree = (uint32_t)&kernel_end;

It's a little messy ( == there is probably a better way ) but it should work.

_________________
If a trainstation is where trains stop, what is a workstation ?


Last edited by gerryg400 on Thu Sep 02, 2010 9:08 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 9:05 pm 
Offline
Member
Member

Joined: Wed Feb 27, 2008 12:40 am
Posts: 162
It doesn't need to be in a section, just inside the SECTIONS block.


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 10:04 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 18, 2009 5:47 pm
Posts: 208
Location: Alexandria, Egypt | Ottawa, Canada
thanks gerryg400! thanks Hangin10!
the code works fine!
Here is my ld script:

Code:
ENTRY (init)

SECTIONS {
   . = 0x100000;

   ld_kernel_start = . ;
   
   .text   : {   *(.text  )   }
   .bss   : {   *(.bss   )   }
   .data   : {   *(.data  )   }
   .rodata   : {   *(.rodata)   }
   
   ld_kernel_end = . ;
   
}


I wonder if i could know the boot device path (PCI bus/dev/func and so on) from GRUB2. do u have any idea? any help is appreciated...
sorry for the large quantity of questions, but this is only because i stayed months developing my kernel neglecting this part of it, cause it is full of obstacles.
Regards,


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 10:35 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
mostafazizo wrote:
I wonder if i could know the boot device path (PCI bus/dev/func and so on) from GRUB2. do u have any idea? any help is appreciated...
sorry for the large quantity of questions, but this is only because i stayed months developing my kernel neglecting this part of it, cause it is full of obstacles.
Regards,
You can get the bios drive number and the partition numbers from the multiboot_info struct.

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 11:02 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 18, 2009 5:47 pm
Posts: 208
Location: Alexandria, Egypt | Ottawa, Canada
gerryg400 wrote:
mostafazizo wrote:
I wonder if i could know the boot device path (PCI bus/dev/func and so on) from GRUB2. do u have any idea? any help is appreciated...
sorry for the large quantity of questions, but this is only because i stayed months developing my kernel neglecting this part of it, cause it is full of obstacles.
Regards,
You can get the bios drive number and the partition numbers from the multiboot_info struct.


I know well :D but the BIOS Drive Number is not enough for a kernel that supports ATA/SATA HDDs, CD-ROMs, USB Mass Storage Devices and USB CD-ROMs to know which of those devices is the boot device...


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Thu Sep 02, 2010 11:38 pm 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
mostafazizo wrote:
I know well :D but the BIOS Drive Number is not enough for a kernel that supports ATA/SATA HDDs, CD-ROMs, USB Mass Storage Devices and USB CD-ROMs to know which of those devices is the boot device...
I don't think there is one easy way. This thread may help.

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Fri Sep 03, 2010 12:58 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Multiboot 2. You're welcome! :)

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Fri Sep 03, 2010 1:54 am 
Offline
Member
Member

Joined: Thu Mar 25, 2010 11:26 pm
Posts: 1801
Location: Melbourne, Australia
Love4Boobies wrote:
Multiboot 2. You're welcome! :)
The problem with that document is that it doesn't match the current version of Grub (1.98). The version of multiboot2.h in the Grub distro and the version in the multiboot documentation are quite different. Oddly the magic numbers are the same. I'm not sure what the Grub guys are doing.

I think Grub 1.98 (and multiboot2.h in particular) are not Multiboot 2 compliant.

_________________
If a trainstation is where trains stop, what is a workstation ?


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Fri Sep 03, 2010 1:58 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
They are obviously being uber-awesome again... :roll: Better build the PDF from http://bzr.savannah.gnu.org/r/grub/branches/multiboot2/ instead (you'll need the Bazaar versioning system).

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Multiboot 2 Specification
PostPosted: Fri Sep 03, 2010 2:07 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
gerryg400 wrote:
extern uint32_t kernel_end;

You don't actually want to refer to a value in the first 32 bit of the kernel, so I prefer to declare it as what it really is:

Code:
extern const void kernel_end;


Doesn't work in C++, though, as far as I know.

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 66 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group