OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 9:50 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 145 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next
Author Message
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 5:59 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
Still, without macros, you would need to copy-paste entire loading and jumping code into every filesystem's bootsector...

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:03 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3193
Shikhin wrote:
Hi,

rdos wrote:
That information is put in the image itself. It knows that it wants to be loaded in protected mode with paging disabled, or that it wants to be loaded in long mode with paging enabled. It is better to let the OS image supply this data rather than a configuration file, which eventually would be edited by an user that might not know the details of the OS image.


So that when a monitor doesn't accept some sort of a VBE mode (and the OS can't detect that), the user won't be able to change the configurations (or do so via something more tough than just changing a file)?


While I know this is part of UEFI, I don't think the boot-loader should mess with VBE modes. That task should be left to the device-driver that handles VBE. For instance, I'll refuse to accept the idea that video mode should be setup at boot time, and I will keep my functionality to dynamically change video mode as much as possible, and letting the VBE driver emulate video-mode changes (particulary text mode) only if absolutely necessary.


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:06 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
As far as I was observing what Windows (8 at least) does at boot, it first changes mode into something lower than my max resolution (probably 1024x768), and I think that's because it wants to have ANY video mode before loading device drivers. And STAYS in it if there is none. I'm fairly sure it doesn't use crazy magic of 8086 emulation to do just that. In theory, that's why you have VBE/UEFI video protocols - to set up something temporary in easy way, and fall back to using it longer if you have no drivers for present hardware.

So, rdos, you just went full of retard.

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:10 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
My FAT16 code consist of 10 lines of code for the jump and registers setup, the other 90% code is the ReadFile API.

I could imagine each FS-stage has 10 lines of code in common, it's just not worth to introduce an entity - and by the way, the jump for HDD is different for CD, and there is no jump for PXE - so you can't actually do a universal macro for all loaders.


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:14 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
You know, there is a difference between "each bootloader" and "1st stage for FSes that loads 2nd stage/FS driver/whatever". This was meant for bootsectors only, for partitions with "standard" boot from HDD - that is, read X sectors from Yth sector and jump to it. It's pretty the same for each filesystem out there - unless you do heavy filesystem parsing just in 1st stage...

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:18 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
It is the same if:
1. the VBR itself contain all the required FS code (we call that stage 1).
2. the VBR in turn loads extra sector for required FS code (we may call that stage 1 + 1.5).

For all intent and purpose it's the same in current discussion context, either way the code shared by different stage 1 ( or stage1+1.5 combo) is narrow, and not all stage 1 (or stage 1+1.5) have the same prologue code.

And if we limit the FS code to a restricted functionality(you don't need code to delete file, or decide to don't support sub-directory), it can be easily fit into the VBR.


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:41 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
So in your scheme, without providing FS-agnostic parts, FS driver etc., someone implementing his own FS would need to reimplement the bootloader - not just implement FS support for it. I don't see the point of writing generic bootloader, then.

Also, there are other common things to be done than loading - memory map getting, parsing and sanitizing, VBE mode to be set, PIT/(IOA)PIC to be masked. In that way, if 1st stage barely loads X sectors from Yth sector (and I'm positive that it's possible to do with every FS out there - I mean, continuous sectors for one specific file, or reserved sectors) that contain 2nd stage, which does all the remaining things - memory map, vbe mode chaning, CPU mode setting, interrupt masking etc. - and only uses Z sectors starting from Wth sector as filesystem driver with strictly defined API to load specific file from filesystem - the common code never needs to be reimplemented, and in case of common 2nd stage code, never needs to be reassembled, when using different filesystem. The only things that would need to be reassembled would be bootsector (so it doesn't override some FS structures, or BPB if required, or w/e) - using exactly same code, but at potentially different offsets for different filesystems - and FS driver.

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:44 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
No, perhaps you missed the post about my design.

In short, the VBR (and there is no reason you cannot load more sectors behind the scene unless the specification forbid it) contain the FS specific code, and load boot.bin, it's the boot.bin that handle the business logic - using uniform API exposed by former stages.


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:48 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3193
Griwes wrote:
As far as I was observing what Windows (8 at least) does at boot, it first changes mode into something lower than my max resolution (probably 1024x768), and I think that's because it wants to have ANY video mode before loading device drivers. And STAYS in it if there is none. I'm fairly sure it doesn't use crazy magic of 8086 emulation to do just that. In theory, that's why you have VBE/UEFI video protocols - to set up something temporary in easy way, and fall back to using it longer if you have no drivers for present hardware.

So, rdos, you just went full of retard.


64-bit Windows no longer supports running the command shell in text-mode because it cannot use V86 mode to call the video-BIOS to change modes. And when the protected mode VBE interface is buggy (and thus unusable), they have no other choice.

Thus, this idea that you cannot change video-mode dynamically is not a design-feature, rather a consequence of bad design-choices by hardware manufacturers and BIOS developpers.


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 6:52 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
rdos wrote:
Griwes wrote:
As far as I was observing what Windows (8 at least) does at boot, it first changes mode into something lower than my max resolution (probably 1024x768), and I think that's because it wants to have ANY video mode before loading device drivers. And STAYS in it if there is none. I'm fairly sure it doesn't use crazy magic of 8086 emulation to do just that. In theory, that's why you have VBE/UEFI video protocols - to set up something temporary in easy way, and fall back to using it longer if you have no drivers for present hardware.

So, rdos, you just went full of retard.


64-bit Windows no longer supports running the command shell in text-mode because it cannot use V86 mode to call the video-BIOS to change modes. And when the protected mode VBE interface is buggy (and thus unusable), they have no other choice.

Thus, this idea that you cannot change video-mode dynamically is not a design-feature, rather a consequence of bad design-choices by hardware manufacturers and BIOS developpers.

rdos wrote:
While I know this is part of UEFI, I don't think the boot-loader should mess with VBE modes. That task should be left to the device-driver that handles VBE. For instance, I'll refuse to accept the idea that video mode should be setup at boot time, and I will keep my functionality to dynamically change video mode as much as possible, and letting the VBE driver emulate video-mode changes (particulary text mode) only if absolutely necessary.

Oh, so now you disagree with yourself.

Also, it's rather natural that you cannot change the video mode dynamically if you don't have video drivers; both BIOS and UEFI need specific execution environments, that just cannot be kept endlessly. It's rather a technical impossibility to have a graphic-card agnostic way to change video mode dynamically... unless you make graphic card manufacturers to create common standard MMIO interface, which they won't for obvious reasons.

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 7:03 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3193
Griwes wrote:
rdos wrote:
Griwes wrote:
As far as I was observing what Windows (8 at least) does at boot, it first changes mode into something lower than my max resolution (probably 1024x768), and I think that's because it wants to have ANY video mode before loading device drivers. And STAYS in it if there is none. I'm fairly sure it doesn't use crazy magic of 8086 emulation to do just that. In theory, that's why you have VBE/UEFI video protocols - to set up something temporary in easy way, and fall back to using it longer if you have no drivers for present hardware.

So, rdos, you just went full of retard.


64-bit Windows no longer supports running the command shell in text-mode because it cannot use V86 mode to call the video-BIOS to change modes. And when the protected mode VBE interface is buggy (and thus unusable), they have no other choice.

Thus, this idea that you cannot change video-mode dynamically is not a design-feature, rather a consequence of bad design-choices by hardware manufacturers and BIOS developpers.

rdos wrote:
While I know this is part of UEFI, I don't think the boot-loader should mess with VBE modes. That task should be left to the device-driver that handles VBE. For instance, I'll refuse to accept the idea that video mode should be setup at boot time, and I will keep my functionality to dynamically change video mode as much as possible, and letting the VBE driver emulate video-mode changes (particulary text mode) only if absolutely necessary.

Oh, so now you disagree with yourself.


Not at all. Windows cannot do it because they cannot switch to protected mode dynamically. However, I suppose we discuss boot-loaders that can load OSes that run in various modes, and it is only long mode OSes that cannot handle dynamically switching VBE mode.

Griwes wrote:
Also, it's rather natural that you cannot change the video mode dynamically if you don't have video drivers; both BIOS and UEFI need specific execution environments, that just cannot be kept endlessly. It's rather a technical impossibility to have a graphic-card agnostic way to change video mode dynamically... unless you make graphic card manufacturers to create common standard MMIO interface, which they won't for obvious reasons.


The UEFI guys could have put video mode changes as a dynamic service that could be run at any time. The BIOS guys could have provided a bug-free protected mode VBE interface. AMD could have supported V86 mode in long mode. There is no need for a common MMIO interface, but rather a piece of software that the OS can use to switch modes.


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Thu Dec 06, 2012 7:09 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
Quote:
Not at all. Windows cannot do it because they cannot switch to protected mode dynamically. However, I suppose we discuss boot-loaders that can load OSes that run in various modes, and it is only long mode OSes that cannot handle dynamically switching VBE mode.
Add "dynamically switching VBE mode without stupid hacks" and you can extend "long mode OSes" to "pmode and lmode OSes".

Quote:
The UEFI guys could have put video mode changes as a dynamic service that could be run at any time. The BIOS guys could have provided a bug-free protected mode VBE interface. AMD could have supported V86 mode in long mode. There is no need for a common MMIO interface, but rather a piece of software that the OS can use to switch modes.
@UEFI: no, because you might've changed something card specific and it could not work. @BIOS, keep in mind that there was no point to do so, since you generally set VBE mode at boot and it's JUST A FALLBACK in case you don't have device drivers that are responsible for providing dynamic mode switching functionality. @AMD, bless them for dropping that silly hack.

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Fri Dec 07, 2012 8:23 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
It seems to me that you're designing GRUB here, folks.

No trolling, despite some weaklings attempting to pose it so.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Sat Dec 08, 2012 4:36 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
You already made your point two pages back. You've been given counterarguments in return. Now you repeat the exact same point just for the sake of it which is a really bad idea - it adds absolutely nothing to the discussion and only gets more frustrations aimed at you.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Generic bootloader
PostPosted: Sat Dec 08, 2012 7:43 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
Sorry, it just seems way to obvious to me.

You want to support different boot modes via modules - grub has them, you wan to support different filesystems support through modules and different stages - grub has them, and so on.

_________________
Learn to read.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 145 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next

All times are UTC - 6 hours


Who is online

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