From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] UUID boot on ieee1275 (Re: [PATCH] use UUIDs for cross-disk installs (Re: Issue with boot != root and chainloading))
Date: Sun, 27 Jul 2008 22:13:19 +0200 [thread overview]
Message-ID: <20080727201319.GA5378@thorin> (raw)
In-Reply-To: <20080727192857.GA7361@thorin>
[-- Attachment #1: Type: text/plain, Size: 1159 bytes --]
On Sun, Jul 27, 2008 at 09:28:58PM +0200, Robert Millan wrote:
> On Sun, Jul 27, 2008 at 08:37:37PM +0200, Robert Millan wrote:
> > I'm not satisfied with the current user interface of that script, but I
> > couldn't think of any better way to do it back then. If you can improve
> > it that'd be much welcome.
> >
> > Btw, I'm currently working on adding --prefix / uuid support to our
> > ieee1275 ports. I'll send a patch RSN.
>
> Here it is. For powerpc it'd need some adjustment to start.S. Unfortunately
> my patch appears to uncover a memory corruption problem somewhere else, which
> I haven't managed to track down yet.
>
> But I'd still like to know if it works on other setups.
OTOH, if --prefix is used to override prefix to a value that is not of
the '(UUID=xxx)' form, it works just fine.
So I'm submitting a patch that implements --prefix, without having grub-install
use it. This is useful already (for manual installs), and I'd like to use that
--prefix option for Coreboot later too.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
[-- Attachment #2: ofw_uuid.diff --]
[-- Type: text/x-diff, Size: 5984 bytes --]
2008-07-27 Robert Millan <rmh@aybabtu.com>
* kern/ieee1275/init.c (grub_machine_set_prefix): If `grub_prefix'
is non-empty, use it to set the `prefix' environment variable instead
of the usual approach.
* kern/i386/ieee1275/startup.S: Include `<grub/machine/kernel.h>'.
(start): Insert a data section, with `grub_prefix' variable.
* include/grub/powerpc/ieee1275/kernel.h [!ASM_FILE] (grub_prefix):
New variable reference.
* include/grub/i386/ieee1275/kernel.h (GRUB_KERNEL_MACHINE_PREFIX):
New macro. Defines offset of `grub_prefix' within startup.S (relative
to `start').
(GRUB_KERNEL_MACHINE_DATA_END): New macro. Defines the end of data
section within startup.S (relative to `start').
* util/elf/grub-mkimage.c (add_segments): Receive `prefix' parameter.
Overwrite grub_prefix with its contents, at the beginning of the
first segment.
(main): Understand -p|--prefix.
Index: kern/ieee1275/init.c
===================================================================
--- kern/ieee1275/init.c (revision 1734)
+++ kern/ieee1275/init.c (working copy)
@@ -84,6 +84,13 @@
/* We already set prefix in grub_machine_init(). */
return;
+ if (grub_prefix[0])
+ {
+ grub_env_set ("prefix", grub_prefix);
+ /* Prefix is hardcoded in kernel.elf. */
+ return;
+ }
+
if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", &bootpath,
sizeof (bootpath), 0))
{
Index: kern/i386/ieee1275/startup.S
===================================================================
--- kern/i386/ieee1275/startup.S (revision 1734)
+++ kern/i386/ieee1275/startup.S (working copy)
@@ -19,6 +19,7 @@
#define ASM_FILE 1
#include <grub/symbol.h>
+#include <grub/machine/kernel.h>
#include <grub/machine/memory.h>
#include <grub/cpu/linux.h>
#include <multiboot.h>
@@ -38,6 +39,24 @@
start:
_start:
+ jmp codestart
+
+ /*
+ * This is a special data area at a fixed offset from the beginning.
+ */
+
+ . = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+
+VARIABLE(grub_prefix)
+ /* to be filled by grub-mkimage */
+
+ /*
+ * Leave some breathing room for the prefix.
+ */
+
+ . = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+
+codestart:
movl %eax, EXT_C(grub_ieee1275_entry_fn)
jmp EXT_C(grub_main)
Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================
--- include/grub/powerpc/ieee1275/kernel.h (revision 1734)
+++ include/grub/powerpc/ieee1275/kernel.h (working copy)
@@ -28,7 +28,15 @@
rewrite grub-mkimage to generate valid ELF files. */
#define GRUB_MOD_GAP 0x8000
+#ifndef ASM_FILE
+
void EXPORT_FUNC (grub_reboot) (void);
void EXPORT_FUNC (grub_halt) (void);
+/* The prefix which points to the directory where GRUB modules and its
+ configuration file are located. */
+extern char grub_prefix[];
+
+#endif
+
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
Index: include/grub/i386/ieee1275/kernel.h
===================================================================
--- include/grub/i386/ieee1275/kernel.h (revision 1734)
+++ include/grub/i386/ieee1275/kernel.h (working copy)
@@ -1 +1,4 @@
#include <grub/powerpc/ieee1275/kernel.h>
+
+#define GRUB_KERNEL_MACHINE_PREFIX 0x2
+#define GRUB_KERNEL_MACHINE_DATA_END 0x42
Index: util/elf/grub-mkimage.c
===================================================================
--- util/elf/grub-mkimage.c (revision 1734)
+++ util/elf/grub-mkimage.c (working copy)
@@ -158,7 +158,7 @@
}
void
-add_segments (char *dir, FILE *out, int chrp, char *mods[])
+add_segments (char *dir, char *prefix, FILE *out, int chrp, char *mods[])
{
Elf32_Ehdr ehdr;
Elf32_Phdr *phdrs = NULL;
@@ -166,7 +166,7 @@
FILE *in;
char *kernel_path;
grub_addr_t grub_end = 0;
- off_t offset;
+ off_t offset, first_segment;
int i, phdr_size;
/* Read ELF header. */
@@ -192,6 +192,8 @@
phdrs = xmalloc (phdr_size);
offset += ALIGN_UP (phdr_size, GRUB_TARGET_SIZEOF_LONG);
+ first_segment = offset;
+
/* Copy all existing segments. */
for (i = 0; i < grub_target_to_host16 (ehdr.e_phnum); i++)
{
@@ -272,6 +274,13 @@
/* Write ELF header. */
grub_util_write_image_at (&ehdr, sizeof (ehdr), 0, out);
+ if (prefix)
+ {
+ if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
+ grub_util_error ("prefix too long");
+ grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_MACHINE_PREFIX, out);
+ }
+
free (phdrs);
free (kernel_path);
}
@@ -279,6 +288,7 @@
static struct option options[] =
{
{"directory", required_argument, 0, 'd'},
+ {"prefix", required_argument, 0, 'p'},
{"output", required_argument, 0, 'o'},
{"help", no_argument, 0, 'h'},
{"note", no_argument, 0, 'n'},
@@ -299,6 +309,7 @@
Make a bootable image of GRUB.\n\
\n\
-d, --directory=DIR use images and modules under DIR [default=%s]\n\
+-p, --prefix=DIR set grub_prefix directory\n\
-o, --output=FILE output a generated image to FILE\n\
-h, --help display this message and exit\n\
-n, --note add NOTE segment for CHRP Open Firmware\n\
@@ -317,13 +328,14 @@
FILE *fp;
char *output = NULL;
char *dir = NULL;
+ char *prefix = NULL;
int chrp = 0;
progname = "grub-mkimage";
while (1)
{
- int c = getopt_long (argc, argv, "d:o:hVvn", options, 0);
+ int c = getopt_long (argc, argv, "d:p:o:hVvn", options, 0);
if (c == -1)
break;
@@ -334,6 +346,11 @@
free (dir);
dir = xstrdup (optarg);
break;
+ case 'p':
+ if (prefix)
+ free (prefix);
+ prefix = xstrdup (optarg);
+ break;
case 'h':
usage (0);
break;
@@ -364,7 +381,7 @@
if (! fp)
grub_util_error ("cannot open %s", output);
- add_segments (dir ? : GRUB_LIBDIR, fp, chrp, argv + optind);
+ add_segments (dir ? : GRUB_LIBDIR, prefix, fp, chrp, argv + optind);
fclose (fp);
next prev parent reply other threads:[~2008-07-27 20:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-22 13:34 Issue with boot != root and chainloading Andy Kittner
2008-07-22 13:50 ` Pavel Roskin
2008-07-22 14:01 ` Felix Zielcke
2008-07-22 23:58 ` Pavel Roskin
2008-07-24 9:12 ` Felix Zielcke
2008-07-24 10:25 ` Felix Zielcke
2008-07-24 11:00 ` Felix Zielcke
2008-07-24 16:49 ` Pavel Roskin
2008-07-25 21:08 ` Robert Millan
2008-07-25 21:47 ` Pavel Roskin
2008-07-25 22:10 ` [PATCH] use UUIDs for cross-disk installs (Re: Issue with boot != root and chainloading) Robert Millan
2008-07-26 1:08 ` Pavel Roskin
2008-07-27 12:19 ` Robert Millan
2008-07-27 16:29 ` Pavel Roskin
2008-07-27 18:37 ` Robert Millan
2008-07-27 19:28 ` UUID boot on ieee1275 (Re: [PATCH] use UUIDs for cross-disk installs (Re: Issue with boot != root and chainloading)) Robert Millan
2008-07-27 20:13 ` Robert Millan [this message]
2008-07-27 20:36 ` [PATCH] " Robert Millan
2008-07-30 10:41 ` Robert Millan
2008-08-03 11:09 ` [PATCH] use UUIDs for cross-disk installs (Re: Issue with boot != root and chainloading) Isaac Dupree
2008-08-03 12:08 ` Robert Millan
2008-08-03 12:23 ` Robert Millan
2008-08-03 17:04 ` Isaac Dupree
2008-08-03 19:19 ` Treacherous Computing (Re: [PATCH] use UUIDs for cross-disk installs) Robert Millan
2008-07-27 18:27 ` [PATCH] use UUIDs for cross-disk installs (Re: Issue with boot != root and chainloading) Robert Millan
2008-07-30 10:43 ` Robert Millan
2008-07-22 15:09 ` Issue with boot != root and chainloading Andy Kittner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080727201319.GA5378@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.