All of lore.kernel.org
 help / color / mirror / Atom feed
* Idea: Move kernel to upper memory
@ 2008-08-29 11:15 Bean
  2008-08-30 12:40 ` Robert Millan
  2009-04-19 15:45 ` Vladimir Serbinenko
  0 siblings, 2 replies; 10+ messages in thread
From: Bean @ 2008-08-29 11:15 UTC (permalink / raw)
  To: The development of GRUB 2

Hi,

The traditional memory is quite small, and is used by real mode apps.
By moving grub2 kernel to upper memory, it's possible to keep it after
dos started, and we can invoke grub2 service using interrupts. One
important usage is to provide disk related function to dos via int 13,
for example, loopback device, ata/usb disk or linux software raid. It
would also be possible to reenter grub2 at any time.

I have thought of a method to implement this. First, we put kernel
code in a module kernel.mod. The platform initialization code is
separated and placed in startup.img. Startup.img would do things like
getting memory map, relocate real mode trunk and save the information
in a platform dependent structure. It then pass it to the first
module, which would be kernel.mod. kernel.mod relocates itself and
other embedded modules to upper memory, then calls the entry point for
further tasks.

One advantage of this scheme is that symlist.c is not longer needed.
Kernel is a module, other module can use its exported function. And
platform dependent data and function, such as efi system table, x86
interrupt call, etc, can be passed using a structure.

-- 
Bean



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-08-29 11:15 Idea: Move kernel to upper memory Bean
@ 2008-08-30 12:40 ` Robert Millan
  2008-08-30 15:15   ` Bean
  2008-09-03 10:45   ` BVK Chaitanya
  2009-04-19 15:45 ` Vladimir Serbinenko
  1 sibling, 2 replies; 10+ messages in thread
From: Robert Millan @ 2008-08-30 12:40 UTC (permalink / raw)
  To: The development of GRUB 2

On Fri, Aug 29, 2008 at 07:15:43PM +0800, Bean wrote:
> Hi,
> 
> The traditional memory is quite small, and is used by real mode apps.
> By moving grub2 kernel to upper memory, it's possible to keep it after
> dos started, and we can invoke grub2 service using interrupts. One
> important usage is to provide disk related function to dos via int 13,
> for example, loopback device, ata/usb disk or linux software raid. It
> would also be possible to reenter grub2 at any time.
> 
> I have thought of a method to implement this. First, we put kernel
> code in a module kernel.mod. The platform initialization code is
> separated and placed in startup.img. Startup.img would do things like
> getting memory map, relocate real mode trunk and save the information
> in a platform dependent structure. It then pass it to the first
> module, which would be kernel.mod. kernel.mod relocates itself and
> other embedded modules to upper memory, then calls the entry point for
> further tasks.
> 
> One advantage of this scheme is that symlist.c is not longer needed.
> Kernel is a module, other module can use its exported function. And
> platform dependent data and function, such as efi system table, x86
> interrupt call, etc, can be passed using a structure.

On one hand, I think being useful as a kind of "driver library" for DOS-based
systems (specially FreeDOS) would be a cool thing.  Our hardware drivers
would become more exposed and we could get more people to test them.

On the other, I think we should be careful about going too much out of our
way.  GRUB is a bootloader, and its main strength is that it works well at
what it does.  For example, some have tried to make Linux work as a
bootloader, but it doesn't work well, because it hasn't been built from
the ground up for this purpose.

Similarly, other projects strive to provide a free BIOS [1], like SeaBIOS.
For the same reasons, I think SeaBIOS is better suited for being a BIOS than
GRUB is.

The first concern that comes to mind is how would GRUB coexist with the
payload area which precisely starts at 0x100000.  But I expect we'd face
many unexpected issues.

Another approach with similar result could be to ditch the legacy interface
and provide the glue that would allow FreeDOS to link directly with GRUB.
Maybe that would be as much useful?

[1] Not to be confused with a core initialization program, such as coreboot

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-08-30 12:40 ` Robert Millan
@ 2008-08-30 15:15   ` Bean
  2008-08-31 13:28     ` Robert Millan
  2008-08-31 13:30     ` Robert Millan
  2008-09-03 10:45   ` BVK Chaitanya
  1 sibling, 2 replies; 10+ messages in thread
From: Bean @ 2008-08-30 15:15 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Aug 30, 2008 at 8:40 PM, Robert Millan <rmh@aybabtu.com> wrote:
> On Fri, Aug 29, 2008 at 07:15:43PM +0800, Bean wrote:
>> Hi,
>>
>> The traditional memory is quite small, and is used by real mode apps.
>> By moving grub2 kernel to upper memory, it's possible to keep it after
>> dos started, and we can invoke grub2 service using interrupts. One
>> important usage is to provide disk related function to dos via int 13,
>> for example, loopback device, ata/usb disk or linux software raid. It
>> would also be possible to reenter grub2 at any time.
>>
>> I have thought of a method to implement this. First, we put kernel
>> code in a module kernel.mod. The platform initialization code is
>> separated and placed in startup.img. Startup.img would do things like
>> getting memory map, relocate real mode trunk and save the information
>> in a platform dependent structure. It then pass it to the first
>> module, which would be kernel.mod. kernel.mod relocates itself and
>> other embedded modules to upper memory, then calls the entry point for
>> further tasks.
>>
>> One advantage of this scheme is that symlist.c is not longer needed.
>> Kernel is a module, other module can use its exported function. And
>> platform dependent data and function, such as efi system table, x86
>> interrupt call, etc, can be passed using a structure.
>
> On one hand, I think being useful as a kind of "driver library" for DOS-based
> systems (specially FreeDOS) would be a cool thing.  Our hardware drivers
> would become more exposed and we could get more people to test them.
>
> On the other, I think we should be careful about going too much out of our
> way.  GRUB is a bootloader, and its main strength is that it works well at
> what it does.  For example, some have tried to make Linux work as a
> bootloader, but it doesn't work well, because it hasn't been built from
> the ground up for this purpose.
>
> Similarly, other projects strive to provide a free BIOS [1], like SeaBIOS.
> For the same reasons, I think SeaBIOS is better suited for being a BIOS than
> GRUB is.
>
> The first concern that comes to mind is how would GRUB coexist with the
> payload area which precisely starts at 0x100000.  But I expect we'd face
> many unexpected issues.
>
> Another approach with similar result could be to ditch the legacy interface
> and provide the glue that would allow FreeDOS to link directly with GRUB.
> Maybe that would be as much useful?
>
> [1] Not to be confused with a core initialization program, such as coreboot

Hi,

Yep, come to think of it, this method may be too complicated to be
useful.There are easier way to do similar thing.

Speaking of library, I think we can provide a dynamic library for core
grub2 function. Apps written properly can be executed in both native
os and grub2. For example:

int main()
{
  grub_printf ("Hello world\n");
  return 0;
}

gcc hello.c -o hello -lgrub2

-- 
Bean



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-08-30 15:15   ` Bean
@ 2008-08-31 13:28     ` Robert Millan
  2008-08-31 13:30     ` Robert Millan
  1 sibling, 0 replies; 10+ messages in thread
From: Robert Millan @ 2008-08-31 13:28 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Aug 30, 2008 at 11:15:35PM +0800, Bean wrote:
> 
> Speaking of library, I think we can provide a dynamic library for core
> grub2 function. Apps written properly can be executed in both native
> os and grub2. For example:
> 
> int main()
> {
>   grub_printf ("Hello world\n");
>   return 0;
> }
> 
> gcc hello.c -o hello -lgrub2

Or it could even be POSIX/C compliant and provide printf() etc.  We discussed
something like this for the Parted GSoC [1].

[1] http://www.gnu.org/software/grub/grub-soc.html

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-08-30 15:15   ` Bean
  2008-08-31 13:28     ` Robert Millan
@ 2008-08-31 13:30     ` Robert Millan
  2008-08-31 13:55       ` Bean
  1 sibling, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-08-31 13:30 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Aug 30, 2008 at 11:15:35PM +0800, Bean wrote:
> 
> gcc hello.c -o hello -lgrub2

Ah, what I meant about linking was to make it easy to link external code into
GRUB modules.  Standalone executables sound more overkill to me.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-08-31 13:30     ` Robert Millan
@ 2008-08-31 13:55       ` Bean
  0 siblings, 0 replies; 10+ messages in thread
From: Bean @ 2008-08-31 13:55 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Aug 31, 2008 at 9:30 PM, Robert Millan <rmh@aybabtu.com> wrote:
> On Sat, Aug 30, 2008 at 11:15:35PM +0800, Bean wrote:
>>
>> gcc hello.c -o hello -lgrub2
>
> Ah, what I meant about linking was to make it easy to link external code into
> GRUB modules.  Standalone executables sound more overkill to me.

Hi,

Yep, I know. My point is, if we provide a properly wrapper, external
tool can be built as grub module as well as standalone executable.
This make it easier to debug the code (similar to grub-emu).

-- 
Bean



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-08-30 12:40 ` Robert Millan
  2008-08-30 15:15   ` Bean
@ 2008-09-03 10:45   ` BVK Chaitanya
  2008-09-04 19:19     ` Robert Millan
  1 sibling, 1 reply; 10+ messages in thread
From: BVK Chaitanya @ 2008-09-03 10:45 UTC (permalink / raw)
  To: The development of GRUB 2

Hi,


What is the conclusion of this thread?  is this idea still explored?


Robert Millan wrote:
> 
> The first concern that comes to mind is how would GRUB coexist with the
> payload area which precisely starts at 0x100000.  But I expect we'd face
> many unexpected issues.
> 

Does this mean, GRUB needs to fit within 1MB limit when all its modules 
are loaded?  More clearly, are there any limits on where (and how many) 
grub modules can be dynamically loaded currently?

Since payload(s) needs to be present at their precise positions only 
after the boot command, we can always deterministically /schedule/ 
memmove operation to be executed as part of boot command.

Since boot command is the last command executed by GRUB (correct me if 
not), we can overwrite any GRUB code/data at that point.  This also 
needs boot command to exist in low memory.

The main advantage i see here is that it removes any arbitrary limits on 
number of modules or their placement, if at all limits exists.


thanks,
--
bvk-chaitanya



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-09-03 10:45   ` BVK Chaitanya
@ 2008-09-04 19:19     ` Robert Millan
  2008-09-06 14:14       ` BVK
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-09-04 19:19 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, Sep 03, 2008 at 04:15:33PM +0530, BVK Chaitanya wrote:
> Hi,
> 
> 
> What is the conclusion of this thread?  is this idea still explored?
> 
> 
> Robert Millan wrote:
> >
> >The first concern that comes to mind is how would GRUB coexist with the
> >payload area which precisely starts at 0x100000.  But I expect we'd face
> >many unexpected issues.
> >
> 
> Does this mean, GRUB needs to fit within 1MB limit when all its modules 
> are loaded?  More clearly, are there any limits on where (and how many) 
> grub modules can be dynamically loaded currently?
> 
> Since payload(s) needs to be present at their precise positions only 
> after the boot command, we can always deterministically /schedule/ 
> memmove operation to be executed as part of boot command.
> 
> Since boot command is the last command executed by GRUB (correct me if 
> not), we can overwrite any GRUB code/data at that point.  This also 
> needs boot command to exist in low memory.

This is already done.  See grub_multiboot_{forward,backward}_relocator
variables and how they're used in the multiboot loader.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-09-04 19:19     ` Robert Millan
@ 2008-09-06 14:14       ` BVK
  0 siblings, 0 replies; 10+ messages in thread
From: BVK @ 2008-09-06 14:14 UTC (permalink / raw)
  To: The development of GRUB 2

On Fri, Sep 5, 2008 at 12:49 AM, Robert Millan <rmh@aybabtu.com> wrote:
> On Wed, Sep 03, 2008 at 04:15:33PM +0530, BVK Chaitanya wrote:
>>
>> Since payload(s) needs to be present at their precise positions only
>> after the boot command, we can always deterministically /schedule/
>> memmove operation to be executed as part of boot command.
>>
>> Since boot command is the last command executed by GRUB (correct me if
>> not), we can overwrite any GRUB code/data at that point.  This also
>> needs boot command to exist in low memory.
>
> This is already done.  See grub_multiboot_{forward,backward}_relocator
> variables and how they're used in the multiboot loader.
>

OK, fine :-)


-- 
bvk-chaitanya



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Idea: Move kernel to upper memory
  2008-08-29 11:15 Idea: Move kernel to upper memory Bean
  2008-08-30 12:40 ` Robert Millan
@ 2009-04-19 15:45 ` Vladimir Serbinenko
  1 sibling, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2009-04-19 15:45 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

Hello, I resurrect this thread because of the recent developement in
preboot, mmap and drivemap this subject becomes very actual

On Fri, Aug 29, 2008 at 1:15 PM, Bean <bean123ch@gmail.com> wrote:

> Hi,
>
> The traditional memory is quite small, and is used by real mode apps.
> By moving grub2 kernel to upper memory, it's possible to keep it after
> dos started, and we can invoke grub2 service using interrupts. One
> important usage is to provide disk related function to dos via int 13,
> for example, loopback device, ata/usb disk or linux software raid. It
> would also be possible to reenter grub2 at any time.
>
> I have thought of a method to implement this. First, we put kernel
> code in a module kernel.mod. The platform initialization code is
> separated and placed in startup.img. Startup.img would do things like
> getting memory map, relocate real mode trunk and save the information
> in a platform dependent structure. It then pass it to the first
> module, which would be kernel.mod. kernel.mod relocates itself and
> other embedded modules to upper memory, then calls the entry point for
> further tasks.
>
> One advantage of this scheme is that symlist.c is not longer needed.
> Kernel is a module, other module can use its exported function. And
> platform dependent data and function, such as efi system table, x86
> interrupt call, etc, can be passed using a structure.
>
> --
> Bean
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 2072 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-04-19 15:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-29 11:15 Idea: Move kernel to upper memory Bean
2008-08-30 12:40 ` Robert Millan
2008-08-30 15:15   ` Bean
2008-08-31 13:28     ` Robert Millan
2008-08-31 13:30     ` Robert Millan
2008-08-31 13:55       ` Bean
2008-09-03 10:45   ` BVK Chaitanya
2008-09-04 19:19     ` Robert Millan
2008-09-06 14:14       ` BVK
2009-04-19 15:45 ` Vladimir Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.