* [PATCH] cleanup in EFI Linux loader
@ 2008-08-17 20:35 Robert Millan
2008-08-17 20:42 ` Robert Millan
0 siblings, 1 reply; 7+ messages in thread
From: Robert Millan @ 2008-08-17 20:35 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]
Hi,
I've been working on a pure 32-bit Linux loader that is firmware-agnostic
and can be used on coreboot (and probably others later on). I used the EFI
Linux loader as a base.
Due to the large amount of changes, and the way EFI operates (in which it
retains control of memory management, much differently than all other
platforms), I don't think it will be possible to maintain a single loader
that can work on both EFI & the rest (unless drastic changes were performed
to the EFI port).
So I will propose to add a separate loader. I'll send a new mail about
that later, but first I'd like to see if a few of the changes can be
harmonized with the current EFI loader, so that the code doesn't differ
so much.
I'm attaching a patch with a few minor changes that will make it easier
to move code back & forth in the future.
Since I have no EFI setup to test with, would be nice if it can be tested
as well as reviewed.
--
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."
[-- Attachment #2: efi_cleanup.diff --]
[-- Type: text/x-diff, Size: 6050 bytes --]
2008-08-17 Robert Millan <rmh@aybabtu.com>
* include/grub/i386/linux.h (LINUX_LOADER_ID_LILO)
(LINUX_LOADER_ID_LOADLIN, LINUX_LOADER_ID_BOOTSECT)
(LINUX_LOADER_ID_SYSLINUX, LINUX_LOADER_ID_ETHERBOOT)
(LINUX_LOADER_ID_ELILO, LINUX_LOADER_ID_GRUB, LINUX_LOADER_ID_UBOOT)
(LINUX_LOADER_ID_XEN, LINUX_LOADER_ID_GUJIN, LINUX_LOADER_ID_QEMU):
New macros.
(GRUB_LINUX_CL_OFFSET, GRUB_LINUX_CL_END_OFFSET): Move from here ...
* loader/i386/pc/linux.c (GRUB_LINUX_CL_OFFSET)
(GRUB_LINUX_CL_END_OFFSET): ... to here.
* loader/i386/efi/linux.c (GRUB_EFI_CL_OFFSET): Rename to ...
(GRUB_LINUX_CL_OFFSET): ... this. Update all users.
(GRUB_EFI_CL_END_OFFSET): Rename to ...
(GRUB_LINUX_CL_END_OFFSET): ... this. Update all users.
(grub_rescue_cmd_linux): Macroify `type_of_loader' initialization.
Initialize `params->video_cursor_x' and `params->video_cursor_y'
portably using grub_getxy().
Remove '-EFI' suffix from boot message.
Index: include/grub/i386/linux.h
===================================================================
--- include/grub/i386/linux.h (revision 1817)
+++ include/grub/i386/linux.h (working copy)
@@ -39,8 +39,6 @@
#define GRUB_LINUX_VID_MODE_EXTENDED 0xFFFE
#define GRUB_LINUX_VID_MODE_ASK 0xFFFD
-#define GRUB_LINUX_CL_OFFSET 0x9000
-#define GRUB_LINUX_CL_END_OFFSET 0x90FF
#define GRUB_LINUX_SETUP_MOVE_SIZE 0x9100
#define GRUB_LINUX_CL_MAGIC 0xA33F
@@ -104,6 +102,17 @@ struct linux_kernel_header
grub_uint16_t start_sys; /* The load-low segment (obsolete) */
grub_uint16_t kernel_version; /* Points to kernel version string */
grub_uint8_t type_of_loader; /* Boot loader identifier */
+#define LINUX_LOADER_ID_LILO 0x0
+#define LINUX_LOADER_ID_LOADLIN 0x1
+#define LINUX_LOADER_ID_BOOTSECT 0x2
+#define LINUX_LOADER_ID_SYSLINUX 0x3
+#define LINUX_LOADER_ID_ETHERBOOT 0x4
+#define LINUX_LOADER_ID_ELILO 0x5
+#define LINUX_LOADER_ID_GRUB 0x7
+#define LINUX_LOADER_ID_UBOOT 0x8
+#define LINUX_LOADER_ID_XEN 0x9
+#define LINUX_LOADER_ID_GUJIN 0xa
+#define LINUX_LOADER_ID_QEMU 0xb
grub_uint8_t loadflags; /* Boot protocol option flags */
grub_uint16_t setup_move_size; /* Move to high memory size */
grub_uint32_t code32_start; /* Boot loader hook */
Index: loader/i386/pc/linux.c
===================================================================
--- loader/i386/pc/linux.c (revision 1817)
+++ loader/i386/pc/linux.c (working copy)
@@ -31,6 +31,9 @@
#include <grub/dl.h>
#include <grub/cpu/linux.h>
+#define GRUB_LINUX_CL_OFFSET 0x9000
+#define GRUB_LINUX_CL_END_OFFSET 0x90FF
+
static grub_dl_t my_mod;
static grub_size_t linux_mem_size;
Index: loader/i386/efi/linux.c
===================================================================
--- loader/i386/efi/linux.c (revision 1817)
+++ loader/i386/efi/linux.c (working copy)
@@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2006,2007 Free Software Foundation, Inc.
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,8 +33,8 @@
#include <grub/efi/uga_draw.h>
#include <grub/pci.h>
-#define GRUB_EFI_CL_OFFSET 0x1000
-#define GRUB_EFI_CL_END_OFFSET 0x2000
+#define GRUB_LINUX_CL_OFFSET 0x1000
+#define GRUB_LINUX_CL_END_OFFSET 0x2000
#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
@@ -166,7 +166,7 @@ allocate_pages (grub_size_t prot_size)
grub_size_t real_size;
/* Make sure that each size is aligned to a page boundary. */
- real_size = GRUB_EFI_CL_END_OFFSET;
+ real_size = GRUB_LINUX_CL_END_OFFSET;
prot_size = page_align (prot_size);
mmap_size = find_mmap_size ();
@@ -634,7 +634,7 @@ grub_rescue_cmd_linux (int argc, char *a
goto fail;
params = (struct linux_kernel_params *) real_mode_mem;
- grub_memset (params, 0, GRUB_EFI_CL_END_OFFSET);
+ grub_memset (params, 0, GRUB_LINUX_CL_END_OFFSET);
grub_memcpy (¶ms->setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1);
params->ps_mouse = params->padding10 = 0;
@@ -647,7 +647,7 @@ grub_rescue_cmd_linux (int argc, char *a
}
/* XXX Linux assumes that only elilo can boot Linux on EFI!!! */
- params->type_of_loader = 0x50;
+ params->type_of_loader = (LINUX_LOADER_ID_ELILO << 4);
params->cl_magic = GRUB_LINUX_CL_MAGIC;
params->cl_offset = 0x1000;
@@ -664,8 +664,8 @@ grub_rescue_cmd_linux (int argc, char *a
params->ext_mem = ((32 * 0x100000) >> 10);
params->alt_mem = ((32 * 0x100000) >> 10);
- params->video_cursor_x = grub_efi_system_table->con_out->mode->cursor_column;
- params->video_cursor_y = grub_efi_system_table->con_out->mode->cursor_row;
+ params->video_cursor_x = grub_getxy () >> 8;
+ params->video_cursor_y = grub_getxy () & 0xff;
params->video_page = 0; /* ??? */
params->video_mode = grub_efi_system_table->con_out->mode->mode;
params->video_width = (grub_getwh () >> 8);
@@ -758,7 +758,7 @@ grub_rescue_cmd_linux (int argc, char *a
grub_file_seek (file, real_size + GRUB_DISK_SECTOR_SIZE);
/* XXX there is no way to know if the kernel really supports EFI. */
- grub_printf (" [Linux-EFI, setup=0x%x, size=0x%x]\n",
+ grub_printf (" [Linux, setup=0x%x, size=0x%x]\n",
(unsigned) real_size, (unsigned) prot_size);
/* Detect explicitly specified memory size, if any. */
@@ -814,7 +814,7 @@ grub_rescue_cmd_linux (int argc, char *a
}
/* Specify the boot file. */
- dest = grub_stpcpy ((char *) real_mode_mem + GRUB_EFI_CL_OFFSET,
+ dest = grub_stpcpy ((char *) real_mode_mem + GRUB_LINUX_CL_OFFSET,
"BOOT_IMAGE=");
dest = grub_stpcpy (dest, argv[0]);
@@ -822,7 +822,7 @@ grub_rescue_cmd_linux (int argc, char *a
for (i = 1;
i < argc
&& dest + grub_strlen (argv[i]) + 1 < ((char *) real_mode_mem
- + GRUB_EFI_CL_END_OFFSET);
+ + GRUB_LINUX_CL_END_OFFSET);
i++)
{
*dest++ = ' ';
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] cleanup in EFI Linux loader
2008-08-17 20:35 [PATCH] cleanup in EFI Linux loader Robert Millan
@ 2008-08-17 20:42 ` Robert Millan
2008-08-18 10:57 ` Bean
2008-08-18 16:21 ` Stefan Reinauer
0 siblings, 2 replies; 7+ messages in thread
From: Robert Millan @ 2008-08-17 20:42 UTC (permalink / raw)
To: grub-devel
On Sun, Aug 17, 2008 at 10:35:38PM +0200, Robert Millan wrote:
> - grub_printf (" [Linux-EFI, setup=0x%x, size=0x%x]\n",
> + grub_printf (" [Linux, setup=0x%x, size=0x%x]\n",
I looked at the other Linux loaders, and to be consistent this would have to
be "Linux-bzImage" instead. I propose using that then.
--
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] 7+ messages in thread* Re: [PATCH] cleanup in EFI Linux loader
2008-08-17 20:42 ` Robert Millan
@ 2008-08-18 10:57 ` Bean
2008-08-18 13:00 ` Robert Millan
2008-08-18 16:21 ` Stefan Reinauer
1 sibling, 1 reply; 7+ messages in thread
From: Bean @ 2008-08-18 10:57 UTC (permalink / raw)
To: The development of GRUB 2
On Mon, Aug 18, 2008 at 4:42 AM, Robert Millan <rmh@aybabtu.com> wrote:
> On Sun, Aug 17, 2008 at 10:35:38PM +0200, Robert Millan wrote:
>> - grub_printf (" [Linux-EFI, setup=0x%x, size=0x%x]\n",
>> + grub_printf (" [Linux, setup=0x%x, size=0x%x]\n",
>
> I looked at the other Linux loaders, and to be consistent this would have to
> be "Linux-bzImage" instead. I propose using that then.
Hi,
I check it with my macbook, the linux loader is still working with this patch.
--
Bean
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] cleanup in EFI Linux loader
2008-08-18 10:57 ` Bean
@ 2008-08-18 13:00 ` Robert Millan
0 siblings, 0 replies; 7+ messages in thread
From: Robert Millan @ 2008-08-18 13:00 UTC (permalink / raw)
To: The development of GRUB 2
On Mon, Aug 18, 2008 at 06:57:44PM +0800, Bean wrote:
> On Mon, Aug 18, 2008 at 4:42 AM, Robert Millan <rmh@aybabtu.com> wrote:
> > On Sun, Aug 17, 2008 at 10:35:38PM +0200, Robert Millan wrote:
> >> - grub_printf (" [Linux-EFI, setup=0x%x, size=0x%x]\n",
> >> + grub_printf (" [Linux, setup=0x%x, size=0x%x]\n",
> >
> > I looked at the other Linux loaders, and to be consistent this would have to
> > be "Linux-bzImage" instead. I propose using that then.
>
> Hi,
>
> I check it with my macbook, the linux loader is still working with this patch.
Thanks for the test. I'm checking it in.
--
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] 7+ messages in thread
* Re: [PATCH] cleanup in EFI Linux loader
2008-08-17 20:42 ` Robert Millan
2008-08-18 10:57 ` Bean
@ 2008-08-18 16:21 ` Stefan Reinauer
2008-08-18 22:48 ` Robert Millan
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Reinauer @ 2008-08-18 16:21 UTC (permalink / raw)
To: The development of GRUB 2
Robert Millan wrote:
> On Sun, Aug 17, 2008 at 10:35:38PM +0200, Robert Millan wrote:
>
>> - grub_printf (" [Linux-EFI, setup=0x%x, size=0x%x]\n",
>> + grub_printf (" [Linux, setup=0x%x, size=0x%x]\n",
>>
>
> I looked at the other Linux loaders, and to be consistent this would have to
> be "Linux-bzImage" instead. I propose using that then
What about printing the Linux version number there?
--
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: info@coresystems.de • http://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] cleanup in EFI Linux loader
2008-08-18 16:21 ` Stefan Reinauer
@ 2008-08-18 22:48 ` Robert Millan
0 siblings, 0 replies; 7+ messages in thread
From: Robert Millan @ 2008-08-18 22:48 UTC (permalink / raw)
To: The development of GRUB 2
On Mon, Aug 18, 2008 at 06:21:10PM +0200, Stefan Reinauer wrote:
> Robert Millan wrote:
> > On Sun, Aug 17, 2008 at 10:35:38PM +0200, Robert Millan wrote:
> >
> >> - grub_printf (" [Linux-EFI, setup=0x%x, size=0x%x]\n",
> >> + grub_printf (" [Linux, setup=0x%x, size=0x%x]\n",
> >>
> >
> > I looked at the other Linux loaders, and to be consistent this would have to
> > be "Linux-bzImage" instead. I propose using that then
> What about printing the Linux version number there?
Not bad. If we do this, I suppose we'll also want to do the same for the
other Linux loaders.
What does everyone think?
--
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] 7+ messages in thread
* Re: [PATCH] cleanup in EFI Linux loader
@ 2008-08-18 8:57 Guy Forssman
0 siblings, 0 replies; 7+ messages in thread
From: Guy Forssman @ 2008-08-18 8:57 UTC (permalink / raw)
To: The development of GRUB 2
Hi Robert,
I don't have real apple gear, but I can boot already EFI on a GPT partition on my PC laptop....
If you would like me tot test, please tell me how to proceed
Guy Forssman
>----- Oorspronkelijk bericht -----
>Van: Robert Millan [mailto:rmh@aybabtu.com]
>Verzonden: zondag, augustus 17, 2008 10:42 PM
>Aan: grub-devel@gnu.org
>Onderwerp: Re: [PATCH] cleanup in EFI Linux loader
>
>On Sun, Aug 17, 2008 at 10:35:38PM +0200, Robert Millan wrote:
>> - grub_printf (" [Linux-EFI, setup=0x%x, size=0x%x]\n",
>> + grub_printf (" [Linux, setup=0x%x, size=0x%x]\n",
>
>I looked at the other Linux loaders, and to be consistent this would have to
>be "Linux-bzImage" instead. I propose using that then.
>
>--
>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."
>
>
>_______________________________________________
>Grub-devel mailing list
>Grub-devel@gnu.org
>http://lists.gnu.org/mailman/listinfo/grub-devel
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-08-18 22:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-17 20:35 [PATCH] cleanup in EFI Linux loader Robert Millan
2008-08-17 20:42 ` Robert Millan
2008-08-18 10:57 ` Bean
2008-08-18 13:00 ` Robert Millan
2008-08-18 16:21 ` Stefan Reinauer
2008-08-18 22:48 ` Robert Millan
-- strict thread matches above, loose matches on Subject: below --
2008-08-18 8:57 Guy Forssman
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.