Bootloader design issues

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
freelancerdev
Posts: 3
Joined: Tue Sep 19, 2017 10:03 pm
Libera.chat IRC: freelancer
Location: La Habana, Cuba

Bootloader design issues

Post by freelancerdev »

Hello, my name is Javier and I live in Cuba. I'm 16 years old and I'm new here, so, forgive me if this is a nonsense topic, but I want to design a new multiboot compliant bootloader. I got the GNU GRUB bootloader source code (in its two "flavours"), so I got a small and humble basis in how that kind of things should work.
I copyied the stage 1 code from GRUB, and i found it was pretty straightforward, but I analize, and analize the code and I can't fix a bug where the bootloader shows me not one, but five notification strings and then halt. I analized the control flow of the program and everything seems normal to me!! I don't know why it behaves that way. :?:

Sorry for any poor english you may found in this post. Greetings from Cuba :D Javier
Join us now and share the software, You'll be free, hackers, you'll be free...
dseller
Member
Member
Posts: 84
Joined: Thu Jul 03, 2014 5:18 am
Location: The Netherlands
Contact:

Re: Bootloader design issues

Post by dseller »

Can you show us the source code?
User avatar
freelancerdev
Posts: 3
Joined: Tue Sep 19, 2017 10:03 pm
Libera.chat IRC: freelancer
Location: La Habana, Cuba

Re: Bootloader design issues

Post by freelancerdev »

Sure, here it is!! ( This is the code from GRUB in its 0.93 version )
I copyied the code just as it is there.

Perhaps the problem is not the source code at all, perhaps it was my mistake
when installing it to the iso image. I'm not sure.

In any case, thank you very much for your reply. :mrgreen: :mrgreen:

[The extension s has been deactivated and can no longer be displayed.]

Join us now and share the software, You'll be free, hackers, you'll be free...
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Bootloader design issues

Post by Brendan »

Hi,
freelancerdev wrote:Sure, here it is!! ( This is the code from GRUB in its 0.93 version )
I copyied the code just as it is there.

Perhaps the problem is not the source code at all, perhaps it was my mistake
when installing it to the iso image. I'm not sure.
If it worked in GRUB 0.93, you changed nothing, and it doesn't work for you; then it'd have to be a problem with how you're using it (and not a problem with the source code itself).

Note that I'd recommend writing your own code anyway. More specifically, you'd (eventually) want:
  • A 1st stage boot loader for "floppy on BIOS"
  • A 1st stage boot loader for "MBR partitioned hard disk on BIOS"
  • A 1st stage boot loader for "GPT partitioned hard disk on BIOS"
  • A 1st stage boot loader for "no emulation El Torito/CD on BIOS"
  • A 1st stage boot loader for "PXE/network boot on BIOS"
  • Maybe a boot loader for UEFI (depending on which version/s of multi-boot you're planning to support)
For all of these cases, there's enough differences to make it impractical/silly to attempt to cover 2 or more situations with the same code. For example, for the boot loader in an ISO/CD image (the "no emulation El Torito" one), the BIOS loads the entire boot loader (up to about 600 KiB and not just the first 512 bytes); and the boot loader needs to use 2 KiB sectors (not 512 byte sectors), needs to use "int 0x15 extensions" (and never CHS), needs to handle the ISO9660 file system (and not raw sectors or partitions), etc.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
freelancerdev
Posts: 3
Joined: Tue Sep 19, 2017 10:03 pm
Libera.chat IRC: freelancer
Location: La Habana, Cuba

Re: Bootloader design issues

Post by freelancerdev »

First of all, thanks to Brendan for his gentle reply!! :D :D

I understand, there are differences between the different ways a machine boots. Thanks for making me notice that! I'll test my own code later when I have time for coding, cause' I'm studying all the day!! Now I see why GRUB 2 places boot code in so many folders. I recently adquired a copy of the multiboot specification document ( yeah, it sounds unimportand but that kind of things are pretty rare here ), so I'll be working in the second stage. I hope having something practical in not too many time. BTW, I was going to name it Clover, but I noticed it was already being used. All the suggestions are accepted. :)

Cheers, Javier

PD: Nice avatar Brendan!!! :D :D :D :mrgreen:
Join us now and share the software, You'll be free, hackers, you'll be free...
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Bootloader design issues

Post by Antti »

Brendan wrote:
  • A 1st stage boot loader for "GPT partitioned hard disk on BIOS"
What is your current idea of implementing this? To be specific, where should be the auxiliary code for doing the proper parsing of the GPT structures. I have not thought about this lately but I do remember that there were some problems / inelegancy no matter how much I tried. :D

Perhaps there is a solution that makes sense.
Post Reply