OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: A New method to bootloader your OS using a extended GRUB2
PostPosted: Wed Sep 24, 2014 10:23 am 
Offline

Joined: Wed Sep 24, 2014 10:03 am
Posts: 17
This method just added a command to grub2 (safe to replace the current version of grub2)

* Your kernel file can be located in any existing filesystem(because Grub can find it out).
* The bootloader read the specified kernel(a single file) into memory at a specified location and start to run it from the first byte.
* You don't need to break your harddisk structure by making new partitions.
* You probably don't need to break your current boot method if you develop on linux, because grub2 is the default bootloader for most of Linux distro.

example grub.cfg

menuentry "YourOS" {
insmod part_msdos
insmod ext2
set root='hd0,msdos7'
osimg /boot/youros.bin 0x7c00
}


It is open sourced, check it out from:

https://github.com/neoedmund/grub-2.0.0/tree/osimg

Feel free to leave a comment.


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Wed Sep 24, 2014 1:16 pm 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
What is the advantage compared to Multiboot?

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


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Wed Sep 24, 2014 1:25 pm 
Offline
Member
Member
User avatar

Joined: Wed Jul 23, 2014 8:00 am
Posts: 96
Location: The Netherlands
OSDeving on Windows just became a hell of a lot easier. Darn you PE-only GCC which refuses to compile for ELF as target and TCC not having ELF support on Windows.

Thank you, sir.

_________________
My post is up there, not down here.


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Wed Sep 24, 2014 2:15 pm 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
neoe wrote:
This method just added a command to grub2 (safe to replace the current version of grub2)

* Your kernel file can be located in any existing filesystem(because Grub can find it out).
* The bootloader read the specified kernel(a single file) into memory at a specified location and start to run it from the first byte.
* You don't need to break your harddisk structure by making new partitions.
* You probably don't need to break your current boot method if you develop on linux, because grub2 is the default bootloader for most of Linux distro.

example grub.cfg

menuentry "YourOS" {
insmod part_msdos
insmod ext2
set root='hd0,msdos7'
osimg /boot/youros.bin 0x7c00
}


It is open sourced, check it out from:

https://github.com/neoedmund/grub-2.0.0/tree/osimg

Feel free to leave a comment.


Does it emulate a disk like memdisk from syslinux?

_________________
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Wed Sep 24, 2014 3:00 pm 
Offline

Joined: Wed Sep 24, 2014 10:03 am
Posts: 17
Kevin wrote:
What is the advantage compared to Multiboot?


They both make things easy by load kernel by file in filesystem instead of raw sectors on disk.
The difference is, Multiboot, has a header format to fill and an information structure to read. To use it you must read and implements the spec which has about 64k letters.
Using "osimg", you don't bother to know there is a Multiboot on the earth.
But of course you should know bootsector, because it is the really thing works, you cannot pass it.
If you know bootsector, you know "osimg", no more concept, just variable changed, not 1 sector but 1 file, not 0x7c00 but anywhere you specify.

In one word, save your brain.


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Wed Sep 24, 2014 3:07 pm 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
neoe wrote:
Kevin wrote:
What is the advantage compared to Multiboot?


They both make things easy by load kernel by file in filesystem instead of raw sectors on disk.
The difference is, Multiboot, has a header format to fill and an information structure to read. To use it you must read and implements the spec which has about 64k letters.
Using "osimg", you don't bother to know there is a Multiboot on the earth.
But of course you should know bootsector, because it is the really thing works, you cannot pass it.
If you know bootsector, you know "osimg", no more concept, just variable changed, not 1 sector but 1 file, not 0x7c00 but anywhere you specify.

In one word, save your brain.


Why not to create a small partition and use GRUB's chainloader?

_________________
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Wed Sep 24, 2014 3:13 pm 
Offline

Joined: Wed Sep 24, 2014 10:03 am
Posts: 17
Roman wrote:
neoe wrote:
This method just added a command to grub2 (safe to replace the current version of grub2)

* Your kernel file can be located in any existing filesystem(because Grub can find it out).
* The bootloader read the specified kernel(a single file) into memory at a specified location and start to run it from the first byte.
* You don't need to break your harddisk structure by making new partitions.
* You probably don't need to break your current boot method if you develop on linux, because grub2 is the default bootloader for most of Linux distro.

example grub.cfg

menuentry "YourOS" {
insmod part_msdos
insmod ext2
set root='hd0,msdos7'
osimg /boot/youros.bin 0x7c00
}


It is open sourced, check it out from:

https://github.com/neoedmund/grub-2.0.0/tree/osimg

Feel free to leave a comment.


Does it emulate a disk like memdisk from syslinux?


It's Not. I don't know it until read your post :lol: , memdisk from syslinux hooks INT 13h and INT 15h to emulate a disk as if it really exists.
"osimg" use grub2 to read file to memory location and execute from there.
Different approach, should be used in different conditions, see which works, which fit your needs better.


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Wed Sep 24, 2014 3:29 pm 
Offline

Joined: Wed Sep 24, 2014 10:03 am
Posts: 17
Roman wrote:
neoe wrote:
Kevin wrote:
What is the advantage compared to Multiboot?


They both make things easy by load kernel by file in filesystem instead of raw sectors on disk.
The difference is, Multiboot, has a header format to fill and an information structure to read. To use it you must read and implements the spec which has about 64k letters.
Using "osimg", you don't bother to know there is a Multiboot on the earth.
But of course you should know bootsector, because it is the really thing works, you cannot pass it.
If you know bootsector, you know "osimg", no more concept, just variable changed, not 1 sector but 1 file, not 0x7c00 but anywhere you specify.

In one word, save your brain.


Why not to create a small partition and use GRUB's chainloader?



* Chainloader only read 512 bytes(as far as I read the grub code) and verifies a 55AA signature. You need to load next stages using INT13 or something.
* If the partition is not the beginning of a disk, you need to find out where is it.
* When you use partition, you need to use "dd" or something, which is a little dangerous, if used it wrong, may destroy an existing filesystem.
Instead, using "osimg", It's done when the kernel image is generated on your develop environment. you don't need further steps to copy it around or "dd" it to somewhere.


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Thu Sep 25, 2014 1:21 am 
Online
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5101
SoLDMG wrote:
PE-only GCC which refuses to compile for ELF as target
It sounds like you're not using a cross-compiler. If you install MSYS, you can use the MSYS shell and follow the wiki's instructions to build your cross-compiler.

(For my toolchain, I installed MSYS/GCC using the instructions here.)


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Thu Sep 25, 2014 4:19 am 
Offline
Member
Member
User avatar

Joined: Wed Jul 23, 2014 8:00 am
Posts: 96
Location: The Netherlands
Octocontrabass wrote:
SoLDMG wrote:
PE-only GCC which refuses to compile for ELF as target
It sounds like you're not using a cross-compiler. If you install MSYS, you can use the MSYS shell and follow the wiki's instructions to build your cross-compiler.

(For my toolchain, I installed MSYS/GCC using the instructions here.)

That's not what I meant. I tried to compile GCC with ELF as the target (a crosscompiler) but for some reason it errors some random error. I use a VM with Debian for ELF compiling and then sync the ELF file with Dropbox and use that for testing with GRUB.

_________________
My post is up there, not down here.


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Thu Sep 25, 2014 4:54 am 
Online
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5101
SoLDMG wrote:
but for some reason it errors some random error.
If you followed the wiki's instructions and still got an error, please make a thread about it. If the wiki is wrong, I'd like to fix it.


Top
 Profile  
 
 Post subject: Re: A New method to bootloader your OS using a extended GRUB
PostPosted: Thu Sep 25, 2014 7:57 am 
Offline
Member
Member
User avatar

Joined: Wed Jul 23, 2014 8:00 am
Posts: 96
Location: The Netherlands
Octocontrabass wrote:
SoLDMG wrote:
but for some reason it errors some random error.
If you followed the wiki's instructions and still got an error, please make a thread about it. If the wiki is wrong, I'd like to fix it.

I don't know what error it is anymore. I'm working on a different project right now. I'll try it again soon though, and see if I can get it working then.

_________________
My post is up there, not down here.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 28 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