* [PATCH] a.out kernel loader
@ 2008-01-27 18:53 Bean
2008-01-27 19:41 ` Robert Millan
0 siblings, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-27 18:53 UTC (permalink / raw)
To: The development of GRUB 2
Hi,
This patch add support for a.out kernel, which includes the 4th loader
of BSD system. For example, to start FreeBSD:
set root=(hd0,0,a)
aout /boot/loader
* conf/i386-pc.rmk (pkglib_MODULES): Add aout.mod and _aout.mod.
(aout_mod_SOURCES): New variable.
(aout_mod_CFLAGS): Likewise.
(aout_mod_LDFLAGS): Likewise.
(_aout_mod_SOURCES): New variable.
(_aout_mod_CFLAGS): Likewise.
(_aout_mod_LDFLAGS): Likewise.
* loader/i386/pc/aout.c: New file.
* loader/i386/pc/aout_normal.c: New file.
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index 52dc06b..2d30a81 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -150,8 +150,8 @@ grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in
# Modules.
pkglib_MODULES = biosdisk.mod _chain.mod _linux.mod linux.mod normal.mod \
- _multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
- vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
+ _multiboot.mod chain.mod multiboot.mod _aout.mod aout.mod reboot.mod \
+ halt.mod vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod \
ata.mod vga.mod memdisk.mod jpeg.mod
@@ -180,6 +180,16 @@ linux_mod_SOURCES = loader/i386/pc/linux_normal.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For _aout.mod.
+_aout_mod_SOURCES = loader/i386/pc/aout.c
+_aout_mod_CFLAGS = $(COMMON_CFLAGS)
+_aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For aout.mod.
+aout_mod_SOURCES = loader/i386/pc/aout_normal.c
+aout_mod_CFLAGS = $(COMMON_CFLAGS)
+aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
# For normal.mod.
normal_mod_DEPENDENCIES = grub_script.tab.c grub_script.tab.h
normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
diff --git a/loader/i386/pc/aout.c b/loader/i386/pc/aout.c
new file mode 100755
index 0000000..61133dd
--- /dev/null
+++ b/loader/i386/pc/aout.c
@@ -0,0 +1,267 @@
+/* aout.c - boot a.out loader (*BSD) */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/machine/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/rescue.h>
+#include <grub/dl.h>
+
+static grub_dl_t my_mod;
+
+#define __LDPGSZ 0x1000
+
+#define N_GETMAGIC(ex) \
+ ( (ex).a_midmag & 0xffff )
+#define N_GETMID(ex) \
+ ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
+ ((ex).a_midmag >> 16) & 0x03ff )
+#define N_GETFLAG(ex) \
+ ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
+ ((ex).a_midmag >> 26) & 0x3f )
+#define N_SETMAGIC(ex,mag,mid,flag) \
+ ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
+ ((mag) & 0xffff) )
+
+#define N_GETMAGIC_NET(ex) \
+ (grub_be_to_cpu32((ex).a_midmag) & 0xffff)
+#define N_GETMID_NET(ex) \
+ ((grub_be_to_cpu32((ex).a_midmag) >> 16) & 0x03ff)
+#define N_GETFLAG_NET(ex) \
+ ((grub_be_to_cpu32((ex).a_midmag) >> 26) & 0x3f)
+#define N_SETMAGIC_NET(ex,mag,mid,flag) \
+ ( (ex).a_midmag = grub_cpu_to_be32( (((flag)&0x3f)<<26) |
(((mid)&0x03ff)<<16) | \
+ (((mag)&0xffff)) ) )
+
+#define N_ALIGN(ex,x) \
+ (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
+ N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
+ ((x) + __LDPGSZ - 1) & ~(unsigned long)(__LDPGSZ - 1) : (x))
+
+/* Valid magic number check. */
+#define N_BADMAG(ex) \
+ (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
+ N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
+ N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
+ N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
+
+/* Address of the bottom of the text segment. */
+#define N_TXTADDR(ex) \
+ ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
+ N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
+
+/* Address of the bottom of the data segment. */
+#define N_DATADDR(ex) \
+ N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
+
+/* Text segment offset. */
+#define N_TXTOFF(ex) \
+ (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
+ N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct aout_header))
+
+/* Data segment offset. */
+#define N_DATOFF(ex) \
+ N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
+
+/* Relocation table offset. */
+#define N_RELOFF(ex) \
+ N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
+
+/* Symbol table offset. */
+#define N_SYMOFF(ex) \
+ (N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
+
+/* String table offset. */
+#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
+
+/*
+ * Header prepended to each a.out file.
+ * only manipulate the a_midmag field via the
+ * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
+ */
+
+struct aout_header
+{
+ grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
+ grub_uint32_t a_text; /* text segment size */
+ grub_uint32_t a_data; /* initialized data size */
+ grub_uint32_t a_bss; /* uninitialized data size */
+ grub_uint32_t a_syms; /* symbol table size */
+ grub_uint32_t a_entry; /* entry point */
+ grub_uint32_t a_trsize; /* text relocation size */
+ grub_uint32_t a_drsize; /* data relocation size */
+};
+
+/* a_magic */
+#define OMAGIC 0x107 /* 0407 old impure format */
+#define NMAGIC 0x108 /* 0410 read-only text */
+#define ZMAGIC 0x10b /* 0413 demand load format */
+#define QMAGIC 0xcc /* 0314 "compact" demand load format */
+
+/* a_mid */
+#define MID_ZERO 0 /* unknown - implementation dependent */
+#define MID_SUN010 1 /* sun 68010/68020 binary */
+#define MID_SUN020 2 /* sun 68020-only binary */
+#define MID_I386 134 /* i386 BSD binary */
+#define MID_SPARC 138 /* sparc */
+#define MID_HP200 200 /* hp200 (68010) BSD binary */
+#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
+#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
+#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
+
+/*
+ * a_flags
+ */
+#define EX_PIC 0x10 /* contains position independant code */
+#define EX_DYNAMIC 0x20 /* contains run-time link-edit info */
+#define EX_DPMASK 0x30 /* mask for the above */
+
+static grub_addr_t entry;
+
+static grub_err_t
+grub_aout_boot (void)
+{
+ grub_multiboot_real_boot (entry, 0);
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_aout_unload (void)
+{
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_rescue_cmd_aout (int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ struct aout_header ah;
+ grub_addr_t cur_addr;
+ int align_4k;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0]);
+ if (!file)
+ goto fail;
+
+ if ((grub_size_t) grub_file_size (file) > grub_os_area_size)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "too big kernel (0x%x > 0x%x)",
+ (grub_size_t) grub_file_size (file), grub_os_area_size);
+ goto fail;
+ }
+
+ if (grub_file_read (file, (char *) &ah, sizeof (ah)) != sizeof (ah))
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "cannot read the a.out header");
+ goto fail;
+ }
+
+ if (N_BADMAG (ah))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
+ goto fail;
+ }
+
+ entry = ah.a_entry & 0xFFFFFF;
+
+ if (*((char *) &ah) == 0xb && (*((char *) &ah + 1) == 1))
+ {
+ cur_addr = entry;
+ align_4k = 0;
+ }
+ else
+ {
+ cur_addr = entry & 0xF00000;
+ align_4k = 1;
+ }
+
+ grub_file_seek (file, N_TXTOFF (ah));
+
+ if (grub_errno)
+ goto fail;
+
+ if (cur_addr < 0x100000)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "load address below 1M");
+ goto fail;
+ }
+
+ if (grub_file_read (file, (char *) cur_addr, ah.a_text) != (int) ah.a_text)
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "read text fails");
+ goto fail;
+ }
+
+ cur_addr += ah.a_text;
+
+ if (align_4k)
+ cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
+
+ if (grub_file_read (file, (char *) cur_addr, ah.a_data) != (int) ah.a_data)
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "read data fails");
+ goto fail;
+ }
+
+ cur_addr += ah.a_data;
+
+ if (align_4k)
+ cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
+
+ if (ah.a_bss)
+ grub_memset ((char *) cur_addr, 0, ah.a_bss);
+
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_loader_set (grub_aout_boot, grub_aout_unload, 1);
+
+fail:
+
+ if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ grub_dl_unref (my_mod);
+}
+
+GRUB_MOD_INIT (aout)
+{
+ grub_rescue_register_command ("aout", grub_rescue_cmd_aout, "load a.out");
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (aout)
+{
+ grub_rescue_unregister_command ("aout");
+}
diff --git a/loader/i386/pc/aout_normal.c b/loader/i386/pc/aout_normal.c
new file mode 100755
index 0000000..b90e3af
--- /dev/null
+++ b/loader/i386/pc/aout_normal.c
@@ -0,0 +1,44 @@
+/* aout_normal.c - boot a.out loader (*BSD) */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/machine/loader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+
+static grub_err_t
+grub_normal_aout_command (struct grub_arg_list *state
+ __attribute__ ((unused)), int argc, char **args)
+{
+ grub_rescue_cmd_aout (argc, args);
+ return grub_errno;
+}
+
+GRUB_MOD_INIT (aout_normal)
+{
+ (void) mod; /* To stop warning. */
+ grub_register_command ("aout", grub_normal_aout_command,
+ GRUB_COMMAND_FLAG_BOTH,
+ "aout FILE [ARGS...]", "Load an a.out kernel.", 0);
+}
+
+GRUB_MOD_FINI (aout_normal)
+{
+ grub_unregister_command ("aout");
+}
--
Bean
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-27 18:53 [PATCH] a.out kernel loader Bean
@ 2008-01-27 19:41 ` Robert Millan
2008-01-27 19:55 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: Robert Millan @ 2008-01-27 19:41 UTC (permalink / raw)
To: The development of GRUB 2
On Mon, Jan 28, 2008 at 02:53:14AM +0800, Bean wrote:
> Hi,
>
> This patch add support for a.out kernel, which includes the 4th loader
> of BSD system. For example, to start FreeBSD:
Cool!
How FreeBSD-specific is this? Will the same module apply to other a.out
binaries ? (I ask since you gave it a generic name)
> +++ b/loader/i386/pc/aout.c
How i386-specific is it? Can it possibly work for non-i386 objects in the
future?
> +/* a_mid */
> +#define MID_ZERO 0 /* unknown - implementation dependent */
> +#define MID_SUN010 1 /* sun 68010/68020 binary */
> +#define MID_SUN020 2 /* sun 68020-only binary */
> +#define MID_I386 134 /* i386 BSD binary */
> +#define MID_SPARC 138 /* sparc */
> +#define MID_HP200 200 /* hp200 (68010) BSD binary */
> +#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
> +#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
> +#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
These aren't used through the code. Did you copy them from a standard
header or so?
> +static grub_err_t
> +grub_aout_boot (void)
> +{
> + grub_multiboot_real_boot (entry, 0);
Ugh :-)
Is there really anything desired from grub_multiboot_real_boot? (other than
grub_dl_unload_all and grub_stop_floppy)
I wonder if it makes sense to split grub_dl_unload_all/grub_stop_floppy out
of grub_multiboot_real_boot to make a generic "real_boot" function that
lives in kernel and is used by grub_multiboot_real_boot and directly by
modules like this one.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-27 19:41 ` Robert Millan
@ 2008-01-27 19:55 ` Bean
2008-01-27 20:06 ` Robert Millan
0 siblings, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-27 19:55 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 28, 2008 3:41 AM, Robert Millan <rmh@aybabtu.com> wrote:
> On Mon, Jan 28, 2008 at 02:53:14AM +0800, Bean wrote:
> > Hi,
> >
> > This patch add support for a.out kernel, which includes the 4th loader
> > of BSD system. For example, to start FreeBSD:
>
> Cool!
>
> How FreeBSD-specific is this? Will the same module apply to other a.out
> binaries ? (I ask since you gave it a generic name)
it's an old format of the unix system:
http://en.wikipedia.org/wiki/A.out
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-27 19:55 ` Bean
@ 2008-01-27 20:06 ` Robert Millan
2008-01-27 20:10 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: Robert Millan @ 2008-01-27 20:06 UTC (permalink / raw)
To: The development of GRUB 2
On Mon, Jan 28, 2008 at 03:55:19AM +0800, Bean wrote:
> On Jan 28, 2008 3:41 AM, Robert Millan <rmh@aybabtu.com> wrote:
> > On Mon, Jan 28, 2008 at 02:53:14AM +0800, Bean wrote:
> > > Hi,
> > >
> > > This patch add support for a.out kernel, which includes the 4th loader
> > > of BSD system. For example, to start FreeBSD:
> >
> > Cool!
> >
> > How FreeBSD-specific is this? Will the same module apply to other a.out
> > binaries ? (I ask since you gave it a generic name)
>
> it's an old format of the unix system:
>
> http://en.wikipedia.org/wiki/A.out
I know.. I was referring to your loader.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-27 20:06 ` Robert Millan
@ 2008-01-27 20:10 ` Bean
2008-01-28 9:11 ` Robert Millan
0 siblings, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-27 20:10 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 28, 2008 4:06 AM, Robert Millan <rmh@aybabtu.com> wrote:
>
> On Mon, Jan 28, 2008 at 03:55:19AM +0800, Bean wrote:
> > On Jan 28, 2008 3:41 AM, Robert Millan <rmh@aybabtu.com> wrote:
> > > On Mon, Jan 28, 2008 at 02:53:14AM +0800, Bean wrote:
> > > > Hi,
> > > >
> > > > This patch add support for a.out kernel, which includes the 4th loader
> > > > of BSD system. For example, to start FreeBSD:
> > >
> > > Cool!
> > >
> > > How FreeBSD-specific is this? Will the same module apply to other a.out
> > > binaries ? (I ask since you gave it a generic name)
> >
> > it's an old format of the unix system:
> >
> > http://en.wikipedia.org/wiki/A.out
>
> I know.. I was referring to your loader.
it should be generic, but i only test it using the loader from freebsd.
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-27 20:10 ` Bean
@ 2008-01-28 9:11 ` Robert Millan
2008-01-28 11:48 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: Robert Millan @ 2008-01-28 9:11 UTC (permalink / raw)
To: The development of GRUB 2
On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
> > > >
> > > > How FreeBSD-specific is this? Will the same module apply to other a.out
> > > > binaries ? (I ask since you gave it a generic name)
> > >
> > > it's an old format of the unix system:
> > >
> > > http://en.wikipedia.org/wiki/A.out
> >
> > I know.. I was referring to your loader.
>
> it should be generic, but i only test it using the loader from freebsd.
In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
Moving files on CVS is a PITA :-/
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-28 9:11 ` Robert Millan
@ 2008-01-28 11:48 ` Bean
2008-01-28 14:37 ` walt
2008-01-29 8:48 ` Marco Gerards
0 siblings, 2 replies; 26+ messages in thread
From: Bean @ 2008-01-28 11:48 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 28, 2008 5:11 PM, Robert Millan <rmh@aybabtu.com> wrote:
> On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
> > > > >
> > > > > How FreeBSD-specific is this? Will the same module apply to other a.out
> > > > > binaries ? (I ask since you gave it a generic name)
> > > >
> > > > it's an old format of the unix system:
> > > >
> > > > http://en.wikipedia.org/wiki/A.out
> > >
> > > I know.. I was referring to your loader.
> >
> > it should be generic, but i only test it using the loader from freebsd.
>
> In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
>
> Moving files on CVS is a PITA :-/
ok, here is the new patch.
* conf/i386-pc.rmk (pkglib_MODULES): Add aout.mod and _aout.mod.
(aout_mod_SOURCES): New variable.
(aout_mod_CFLAGS): Likewise.
(aout_mod_LDFLAGS): Likewise.
(_aout_mod_SOURCES): New variable.
(_aout_mod_CFLAGS): Likewise.
(_aout_mod_LDFLAGS): Likewise.
* loader/aout.c: New file.
* loader/aout_normal.c: New file.
* loader/i386/pc/aout.c: New file.
* include/grub/aout_loader.h: New file.
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index ff02332..36af7de 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -151,8 +151,8 @@ grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in
# Modules.
pkglib_MODULES = biosdisk.mod _chain.mod _linux.mod linux.mod normal.mod \
- _multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
- vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
+ _multiboot.mod chain.mod multiboot.mod _aout.mod aout.mod reboot.mod \
+ halt.mod vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod \
ata.mod vga.mod memdisk.mod jpeg.mod
@@ -221,6 +221,16 @@ multiboot_mod_SOURCES = loader/multiboot_loader_normal.c
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For _aout.mod.
+_aout_mod_SOURCES = loader/aout.c loader/i386/pc/aout.c
+_aout_mod_CFLAGS = $(COMMON_CFLAGS)
+_aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For aout.mod.
+aout_mod_SOURCES = loader/aout_normal.c
+aout_mod_CFLAGS = $(COMMON_CFLAGS)
+aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
# For vbe.mod.
vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
video/i386/pc/vbefill.c video/i386/pc/vbeutil.c
diff --git a/include/grub/aout_loader.h b/include/grub/aout_loader.h
new file mode 100755
index 0000000..64311eb
--- /dev/null
+++ b/include/grub/aout_loader.h
@@ -0,0 +1,134 @@
+/* aout_loader.h - a.out loader header file. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef GRUB_AOUT_LOADER_HEADER
+#define GRUB_AOUT_LOADER_HEADER 1
+
+#define __LDPGSZ 0x1000
+
+#define N_GETMAGIC(ex) \
+ ( (ex).a_midmag & 0xffff )
+#define N_GETMID(ex) \
+ ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
+ ((ex).a_midmag >> 16) & 0x03ff )
+#define N_GETFLAG(ex) \
+ ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
+ ((ex).a_midmag >> 26) & 0x3f )
+#define N_SETMAGIC(ex,mag,mid,flag) \
+ ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
+ ((mag) & 0xffff) )
+
+#define N_GETMAGIC_NET(ex) \
+ (grub_be_to_cpu32((ex).a_midmag) & 0xffff)
+#define N_GETMID_NET(ex) \
+ ((grub_be_to_cpu32((ex).a_midmag) >> 16) & 0x03ff)
+#define N_GETFLAG_NET(ex) \
+ ((grub_be_to_cpu32((ex).a_midmag) >> 26) & 0x3f)
+#define N_SETMAGIC_NET(ex,mag,mid,flag) \
+ ( (ex).a_midmag = grub_cpu_to_be32( (((flag)&0x3f)<<26) |
(((mid)&0x03ff)<<16) | \
+ (((mag)&0xffff)) ) )
+
+#define N_ALIGN(ex,x) \
+ (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
+ N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
+ ((x) + __LDPGSZ - 1) & ~(unsigned long)(__LDPGSZ - 1) : (x))
+
+/* Valid magic number check. */
+#define N_BADMAG(ex) \
+ (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
+ N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
+ N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
+ N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
+
+/* Address of the bottom of the text segment. */
+#define N_TXTADDR(ex) \
+ ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
+ N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
+
+/* Address of the bottom of the data segment. */
+#define N_DATADDR(ex) \
+ N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
+
+/* Text segment offset. */
+#define N_TXTOFF(ex) \
+ (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
+ N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct aout_header))
+
+/* Data segment offset. */
+#define N_DATOFF(ex) \
+ N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
+
+/* Relocation table offset. */
+#define N_RELOFF(ex) \
+ N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
+
+/* Symbol table offset. */
+#define N_SYMOFF(ex) \
+ (N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
+
+/* String table offset. */
+#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
+
+/*
+ * Header prepended to each a.out file.
+ * only manipulate the a_midmag field via the
+ * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
+ */
+
+struct aout_header
+{
+ grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
+ grub_uint32_t a_text; /* text segment size */
+ grub_uint32_t a_data; /* initialized data size */
+ grub_uint32_t a_bss; /* uninitialized data size */
+ grub_uint32_t a_syms; /* symbol table size */
+ grub_uint32_t a_entry; /* entry point */
+ grub_uint32_t a_trsize; /* text relocation size */
+ grub_uint32_t a_drsize; /* data relocation size */
+};
+
+/* a_magic */
+#define OMAGIC 0x107 /* 0407 old impure format */
+#define NMAGIC 0x108 /* 0410 read-only text */
+#define ZMAGIC 0x10b /* 0413 demand load format */
+#define QMAGIC 0xcc /* 0314 "compact" demand load format */
+
+/* a_mid */
+#define MID_ZERO 0 /* unknown - implementation dependent */
+#define MID_SUN010 1 /* sun 68010/68020 binary */
+#define MID_SUN020 2 /* sun 68020-only binary */
+#define MID_I386 134 /* i386 BSD binary */
+#define MID_SPARC 138 /* sparc */
+#define MID_HP200 200 /* hp200 (68010) BSD binary */
+#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
+#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
+#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
+
+/*
+ * a_flags
+ */
+#define EX_PIC 0x10 /* contains position independant code */
+#define EX_DYNAMIC 0x20 /* contains run-time link-edit info */
+#define EX_DPMASK 0x30 /* mask for the above */
+
+void grub_aout_arch_boot (grub_addr_t entry);
+void grub_rescue_cmd_aout (int argc, char *argv[]);
+
+#endif /* ! GRUB_AOUT_LOADER_HEADER */
diff --git a/loader/aout.c b/loader/aout.c
new file mode 100644
index 0000000..584f93a
--- /dev/null
+++ b/loader/aout.c
@@ -0,0 +1,149 @@
+/* aout.c - boot a.out loader (*BSD) */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/file.h>
+#include <grub/err.h>
+#include <grub/rescue.h>
+#include <grub/dl.h>
+#include <grub/aout_loader.h>
+
+static grub_dl_t my_mod;
+
+static grub_addr_t entry;
+
+static grub_err_t
+grub_aout_boot (void)
+{
+ grub_aout_arch_boot (entry);
+
+ /* Not reached. */
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_aout_unload (void)
+{
+ grub_dl_unref (my_mod);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_rescue_cmd_aout (int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ struct aout_header ah;
+ grub_addr_t cur_addr;
+ int align_4k;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0]);
+ if (!file)
+ goto fail;
+
+ if (grub_file_read (file, (char *) &ah, sizeof (ah)) != sizeof (ah))
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "cannot read the a.out header");
+ goto fail;
+ }
+
+ if (N_BADMAG (ah))
+ {
+ grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
+ goto fail;
+ }
+
+ entry = ah.a_entry & 0xFFFFFF;
+
+ if (*((char *) &ah) == 0xb && (*((char *) &ah + 1) == 1))
+ {
+ cur_addr = entry;
+ align_4k = 0;
+ }
+ else
+ {
+ cur_addr = entry & 0xF00000;
+ align_4k = 1;
+ }
+
+ grub_file_seek (file, N_TXTOFF (ah));
+
+ if (grub_errno)
+ goto fail;
+
+ if (cur_addr < 0x100000)
+ {
+ grub_error (GRUB_ERR_BAD_OS, "load address below 1M");
+ goto fail;
+ }
+
+ if (grub_file_read (file, (char *) cur_addr, ah.a_text) != (int) ah.a_text)
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "read text fails");
+ goto fail;
+ }
+
+ cur_addr += ah.a_text;
+
+ if (align_4k)
+ cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
+
+ if (grub_file_read (file, (char *) cur_addr, ah.a_data) != (int) ah.a_data)
+ {
+ grub_error (GRUB_ERR_READ_ERROR, "read data fails");
+ goto fail;
+ }
+
+ cur_addr += ah.a_data;
+
+ if (align_4k)
+ cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
+
+ if (ah.a_bss)
+ grub_memset ((char *) cur_addr, 0, ah.a_bss);
+
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_loader_set (grub_aout_boot, grub_aout_unload, 1);
+
+fail:
+
+ if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ grub_dl_unref (my_mod);
+}
+
+GRUB_MOD_INIT (aout)
+{
+ grub_rescue_register_command ("aout", grub_rescue_cmd_aout, "load a.out");
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (aout)
+{
+ grub_rescue_unregister_command ("aout");
+}
diff --git a/loader/aout_normal.c b/loader/aout_normal.c
new file mode 100644
index 0000000..6dc0b3e
--- /dev/null
+++ b/loader/aout_normal.c
@@ -0,0 +1,45 @@
+/* aout_normal.c - boot a.out loader (*BSD) */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/aout_loader.h>
+
+static grub_err_t
+grub_normal_aout_command (struct grub_arg_list *state
+ __attribute__ ((unused)), int argc, char **args)
+{
+ grub_rescue_cmd_aout (argc, args);
+ return grub_errno;
+}
+
+GRUB_MOD_INIT (aout_normal)
+{
+ (void) mod; /* To stop warning. */
+ grub_register_command ("aout", grub_normal_aout_command,
+ GRUB_COMMAND_FLAG_BOTH,
+ "aout FILE [ARGS...]", "Load an a.out kernel.", 0);
+}
+
+GRUB_MOD_FINI (aout_normal)
+{
+ grub_unregister_command ("aout");
+}
diff --git a/loader/i386/pc/aout.c b/loader/i386/pc/aout.c
new file mode 100755
index 0000000..179d70f
--- /dev/null
+++ b/loader/i386/pc/aout.c
@@ -0,0 +1,28 @@
+/* aout.c - boot an aout OS image. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/machine/loader.h>
+#include <grub/aout_loader.h>
+
+void
+grub_aout_arch_boot (grub_addr_t entry)
+{
+ grub_multiboot2_real_boot (entry, 0);
+}
--
Bean
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-28 11:48 ` Bean
@ 2008-01-28 14:37 ` walt
2008-01-28 14:42 ` Bean
2008-01-29 7:11 ` jakllsch
2008-01-29 8:48 ` Marco Gerards
1 sibling, 2 replies; 26+ messages in thread
From: walt @ 2008-01-28 14:37 UTC (permalink / raw)
To: grub-devel
On Mon, 2008-01-28 at 19:48 +0800, Bean wrote:
> On Jan 28, 2008 5:11 PM, Robert Millan <rmh@aybabtu.com> wrote:
> > On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
> > > > > >
> > > > > > How FreeBSD-specific is this? Will the same module apply to other a.out
> > > > > > binaries ? (I ask since you gave it a generic name)
> > > > >
> > > > > it's an old format of the unix system:
> > > > >
> > > > > http://en.wikipedia.org/wiki/A.out
> > > >
> > > > I know.. I was referring to your loader.
> > >
> > > it should be generic, but i only test it using the loader from freebsd.
> >
> > In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
> >
> > Moving files on CVS is a PITA :-/
>
> ok, here is the new patch...
Good news and bad news. With this patch and your most recent ufs patch
I can aout /boot/loader or multiboot /netbsd from a UFS partition, that
is the good news.
The bad news is that when I type 'boot', /boot/loader prints out its one
line of text to identify itself and then hangs forever.
When I type 'boot' after loading the netbsd kernel with multiboot, the
machine reboots instantly instead of starting the OS.
Any ideas?
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-28 14:37 ` walt
@ 2008-01-28 14:42 ` Bean
2008-01-28 22:04 ` walt
2008-01-29 7:11 ` jakllsch
1 sibling, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-28 14:42 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 28, 2008 10:37 PM, walt <wa1ter@myrealbox.com> wrote:
>
> On Mon, 2008-01-28 at 19:48 +0800, Bean wrote:
> > On Jan 28, 2008 5:11 PM, Robert Millan <rmh@aybabtu.com> wrote:
> > > On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
> > > > > > >
> > > > > > > How FreeBSD-specific is this? Will the same module apply to other a.out
> > > > > > > binaries ? (I ask since you gave it a generic name)
> > > > > >
> > > > > > it's an old format of the unix system:
> > > > > >
> > > > > > http://en.wikipedia.org/wiki/A.out
> > > > >
> > > > > I know.. I was referring to your loader.
> > > >
> > > > it should be generic, but i only test it using the loader from freebsd.
> > >
> > > In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
> > >
> > > Moving files on CVS is a PITA :-/
> >
> > ok, here is the new patch...
>
> Good news and bad news. With this patch and your most recent ufs patch
> I can aout /boot/loader or multiboot /netbsd from a UFS partition, that
> is the good news.
>
> The bad news is that when I type 'boot', /boot/loader prints out its one
> line of text to identify itself and then hangs forever.
>
> When I type 'boot' after loading the netbsd kernel with multiboot, the
> machine reboots instantly instead of starting the OS.
>
> Any ideas?
is grub legacy ok ?
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-28 14:42 ` Bean
@ 2008-01-28 22:04 ` walt
2008-01-29 6:53 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: walt @ 2008-01-28 22:04 UTC (permalink / raw)
To: grub-devel
Bean wrote:
> On Jan 28, 2008 10:37 PM, walt<wa1ter@myrealbox.com> wrote:
...
>> Good news and bad news. With this patch and your most recent ufs patch
>> I can aout /boot/loader or multiboot /netbsd from a UFS partition, that
>> is the good news.
>>
>> The bad news is that when I type 'boot', /boot/loader prints out its one
>> line of text to identify itself and then hangs forever.
>>
>> When I type 'boot' after loading the netbsd kernel with multiboot, the
>> machine reboots instantly instead of starting the OS.
>>
>> Any ideas?
> is grub legacy ok ?
I'm not sure what information you are asking for. Nothing has changed
at my end concerning legacy. It still works, but why should it not?
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-28 22:04 ` walt
@ 2008-01-29 6:53 ` Bean
2008-01-30 12:24 ` walt
0 siblings, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-29 6:53 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 29, 2008 6:04 AM, walt <wa1ter@myrealbox.com> wrote:
> Bean wrote:
> > On Jan 28, 2008 10:37 PM, walt<wa1ter@myrealbox.com> wrote:
> ...
> >> Good news and bad news. With this patch and your most recent ufs patch
> >> I can aout /boot/loader or multiboot /netbsd from a UFS partition, that
> >> is the good news.
> >>
> >> The bad news is that when I type 'boot', /boot/loader prints out its one
> >> line of text to identify itself and then hangs forever.
> >>
> >> When I type 'boot' after loading the netbsd kernel with multiboot, the
> >> machine reboots instantly instead of starting the OS.
> >>
> >> Any ideas?
>
> > is grub legacy ok ?
>
> I'm not sure what information you are asking for. Nothing has changed
> at my end concerning legacy. It still works, but why should it not?
this is strange, it's working for me. perhaps you can try to load
netnsd kernel from the ufs image you sent.
loopback loop (hd0,0)/ufs
multiboot (loop)/netbsd
boot
ufs is better placed in non ufs partition.
If this works, then it means there is still bug in the ufs driver.
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-28 14:37 ` walt
2008-01-28 14:42 ` Bean
@ 2008-01-29 7:11 ` jakllsch
2008-01-29 7:20 ` Bean
2008-01-29 8:56 ` Robert Millan
1 sibling, 2 replies; 26+ messages in thread
From: jakllsch @ 2008-01-29 7:11 UTC (permalink / raw)
To: The development of GRUB 2
On Mon, Jan 28, 2008 at 06:37:16AM -0800, walt wrote:
>
> When I type 'boot' after loading the netbsd kernel with multiboot, the
> machine reboots instantly instead of starting the OS.
>
> Any ideas?
>
I've encountered this in qemu where it tells you you are executing code
outside ram/rom at the kernel virtual entry address of 0xc0100000. The
NetBSD/i386 kernel needs to be loaded/entered at physical address
0x00100000, it's, however, linked to run at 0xc0100000.
This is trivial to fix, but the trivial fix may not be the right fix.
Now if only I was having more luck when grub2 was loaded from coreboot.
But that's another thread maybe.
Jonathan Kollasch
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 7:11 ` jakllsch
@ 2008-01-29 7:20 ` Bean
2008-01-29 18:11 ` jakllsch
2008-01-29 8:56 ` Robert Millan
1 sibling, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-29 7:20 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 29, 2008 3:11 PM, <jakllsch@kollasch.net> wrote:
> On Mon, Jan 28, 2008 at 06:37:16AM -0800, walt wrote:
> >
> > When I type 'boot' after loading the netbsd kernel with multiboot, the
> > machine reboots instantly instead of starting the OS.
> >
> > Any ideas?
> >
>
> I've encountered this in qemu where it tells you you are executing code
> outside ram/rom at the kernel virtual entry address of 0xc0100000. The
> NetBSD/i386 kernel needs to be loaded/entered at physical address
> 0x00100000, it's, however, linked to run at 0xc0100000.
>
> This is trivial to fix, but the trivial fix may not be the right fix.
>
> Now if only I was having more luck when grub2 was loaded from coreboot.
> But that's another thread maybe.
my previous multiboot patch fix this problem.
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-28 11:48 ` Bean
2008-01-28 14:37 ` walt
@ 2008-01-29 8:48 ` Marco Gerards
2008-01-29 9:02 ` Bean
1 sibling, 1 reply; 26+ messages in thread
From: Marco Gerards @ 2008-01-29 8:48 UTC (permalink / raw)
To: The development of GRUB 2
Bean <bean123ch@gmail.com> writes:
> On Jan 28, 2008 5:11 PM, Robert Millan <rmh@aybabtu.com> wrote:
>> On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
>> > > > >
>> > > > > How FreeBSD-specific is this? Will the same module apply to other a.out
>> > > > > binaries ? (I ask since you gave it a generic name)
>> > > >
>> > > > it's an old format of the unix system:
>> > > >
>> > > > http://en.wikipedia.org/wiki/A.out
>> > >
>> > > I know.. I was referring to your loader.
>> >
>> > it should be generic, but i only test it using the loader from freebsd.
>>
>> In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
>>
>> Moving files on CVS is a PITA :-/
>
> ok, here is the new patch.
It would be nice if a.out support could be shared so it can be used
for multiboot as well.
> * conf/i386-pc.rmk (pkglib_MODULES): Add aout.mod and _aout.mod.
> (aout_mod_SOURCES): New variable.
> (aout_mod_CFLAGS): Likewise.
> (aout_mod_LDFLAGS): Likewise.
> (_aout_mod_SOURCES): New variable.
> (_aout_mod_CFLAGS): Likewise.
> (_aout_mod_LDFLAGS): Likewise.
>
> * loader/aout.c: New file.
>
> * loader/aout_normal.c: New file.
>
> * loader/i386/pc/aout.c: New file.
>
> * include/grub/aout_loader.h: New file.
>
>
> diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
> index ff02332..36af7de 100644
> --- a/conf/i386-pc.rmk
> +++ b/conf/i386-pc.rmk
> @@ -151,8 +151,8 @@ grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in
>
> # Modules.
> pkglib_MODULES = biosdisk.mod _chain.mod _linux.mod linux.mod normal.mod \
> - _multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
> - vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
> + _multiboot.mod chain.mod multiboot.mod _aout.mod aout.mod reboot.mod \
> + halt.mod vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
> videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod \
> ata.mod vga.mod memdisk.mod jpeg.mod
>
> @@ -221,6 +221,16 @@ multiboot_mod_SOURCES = loader/multiboot_loader_normal.c
> multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
> multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
>
> +# For _aout.mod.
> +_aout_mod_SOURCES = loader/aout.c loader/i386/pc/aout.c
> +_aout_mod_CFLAGS = $(COMMON_CFLAGS)
> +_aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
> +
> +# For aout.mod.
> +aout_mod_SOURCES = loader/aout_normal.c
> +aout_mod_CFLAGS = $(COMMON_CFLAGS)
> +aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
> +
> # For vbe.mod.
> vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
> video/i386/pc/vbefill.c video/i386/pc/vbeutil.c
> diff --git a/include/grub/aout_loader.h b/include/grub/aout_loader.h
> new file mode 100755
> index 0000000..64311eb
> --- /dev/null
> +++ b/include/grub/aout_loader.h
> @@ -0,0 +1,134 @@
> +/* aout_loader.h - a.out loader header file. */
> +/*
> + * GRUB -- GRand Unified Bootloader
> + * Copyright (C) 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
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * GRUB is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +
> +#ifndef GRUB_AOUT_LOADER_HEADER
> +#define GRUB_AOUT_LOADER_HEADER 1
> +
> +#define __LDPGSZ 0x1000
> +
> +#define N_GETMAGIC(ex) \
> + ( (ex).a_midmag & 0xffff )
> +#define N_GETMID(ex) \
> + ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
> + ((ex).a_midmag >> 16) & 0x03ff )
> +#define N_GETFLAG(ex) \
> + ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
> + ((ex).a_midmag >> 26) & 0x3f )
> +#define N_SETMAGIC(ex,mag,mid,flag) \
> + ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
> + ((mag) & 0xffff) )
> +
> +#define N_GETMAGIC_NET(ex) \
> + (grub_be_to_cpu32((ex).a_midmag) & 0xffff)
> +#define N_GETMID_NET(ex) \
> + ((grub_be_to_cpu32((ex).a_midmag) >> 16) & 0x03ff)
> +#define N_GETFLAG_NET(ex) \
> + ((grub_be_to_cpu32((ex).a_midmag) >> 26) & 0x3f)
> +#define N_SETMAGIC_NET(ex,mag,mid,flag) \
> + ( (ex).a_midmag = grub_cpu_to_be32( (((flag)&0x3f)<<26) |
> (((mid)&0x03ff)<<16) | \
> + (((mag)&0xffff)) ) )
> +
> +#define N_ALIGN(ex,x) \
> + (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
> + N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
> + ((x) + __LDPGSZ - 1) & ~(unsigned long)(__LDPGSZ - 1) : (x))
> +
> +/* Valid magic number check. */
Please use two spaces after a `.'. I know this sounds minor, but I'd
like to keep a consistent coding style. Same for the other comments.
> +#define N_BADMAG(ex) \
> + (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
> + N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
> + N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
> + N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
> +
> +/* Address of the bottom of the text segment. */
> +#define N_TXTADDR(ex) \
> + ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
> + N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
> +
> +/* Address of the bottom of the data segment. */
> +#define N_DATADDR(ex) \
> + N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
> +
> +/* Text segment offset. */
> +#define N_TXTOFF(ex) \
> + (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
> + N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct aout_header))
> +
> +/* Data segment offset. */
> +#define N_DATOFF(ex) \
> + N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
> +
> +/* Relocation table offset. */
> +#define N_RELOFF(ex) \
> + N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
> +
> +/* Symbol table offset. */
> +#define N_SYMOFF(ex) \
> + (N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
> +
> +/* String table offset. */
> +#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
> +
> +/*
> + * Header prepended to each a.out file.
> + * only manipulate the a_midmag field via the
> + * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
> + */
Please do not use comments like this with a asterix on each line.
> +struct aout_header
> +{
> + grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
> + grub_uint32_t a_text; /* text segment size */
> + grub_uint32_t a_data; /* initialized data size */
> + grub_uint32_t a_bss; /* uninitialized data size */
> + grub_uint32_t a_syms; /* symbol table size */
> + grub_uint32_t a_entry; /* entry point */
> + grub_uint32_t a_trsize; /* text relocation size */
> + grub_uint32_t a_drsize; /* data relocation size */
> +};
Please fix these comments. Same for those below.
> +/* a_magic */
> +#define OMAGIC 0x107 /* 0407 old impure format */
> +#define NMAGIC 0x108 /* 0410 read-only text */
> +#define ZMAGIC 0x10b /* 0413 demand load format */
> +#define QMAGIC 0xcc /* 0314 "compact" demand load format */
> +
> +/* a_mid */
> +#define MID_ZERO 0 /* unknown - implementation dependent */
> +#define MID_SUN010 1 /* sun 68010/68020 binary */
> +#define MID_SUN020 2 /* sun 68020-only binary */
> +#define MID_I386 134 /* i386 BSD binary */
> +#define MID_SPARC 138 /* sparc */
> +#define MID_HP200 200 /* hp200 (68010) BSD binary */
> +#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
> +#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
> +#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
Like Robert asked, did you type this yourself?
> +/*
> + * a_flags
> + */
> +#define EX_PIC 0x10 /* contains position independant code */
> +#define EX_DYNAMIC 0x20 /* contains run-time link-edit info */
> +#define EX_DPMASK 0x30 /* mask for the above */
> +
> +void grub_aout_arch_boot (grub_addr_t entry);
> +void grub_rescue_cmd_aout (int argc, char *argv[]);
> +
> +#endif /* ! GRUB_AOUT_LOADER_HEADER */
> diff --git a/loader/aout.c b/loader/aout.c
> new file mode 100644
> index 0000000..584f93a
> --- /dev/null
> +++ b/loader/aout.c
> @@ -0,0 +1,149 @@
> +/* aout.c - boot a.out loader (*BSD) */
> +/*
> + * GRUB -- GRand Unified Bootloader
> + * Copyright (C) 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
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * GRUB is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <grub/loader.h>
> +#include <grub/file.h>
> +#include <grub/err.h>
> +#include <grub/rescue.h>
> +#include <grub/dl.h>
> +#include <grub/aout_loader.h>
> +
> +static grub_dl_t my_mod;
> +
> +static grub_addr_t entry;
> +
> +static grub_err_t
> +grub_aout_boot (void)
> +{
> + grub_aout_arch_boot (entry);
> +
> + /* Not reached. */
> + return GRUB_ERR_NONE;
> +}
> +
> +static grub_err_t
> +grub_aout_unload (void)
> +{
> + grub_dl_unref (my_mod);
> + return GRUB_ERR_NONE;
> +}
> +
> +void
> +grub_rescue_cmd_aout (int argc, char *argv[])
> +{
> + grub_file_t file = 0;
> + struct aout_header ah;
> + grub_addr_t cur_addr;
> + int align_4k;
> +
> + grub_dl_ref (my_mod);
> +
> + if (argc == 0)
> + {
> + grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
> + goto fail;
> + }
> +
> + file = grub_file_open (argv[0]);
> + if (!file)
> + goto fail;
> +
> + if (grub_file_read (file, (char *) &ah, sizeof (ah)) != sizeof (ah))
> + {
> + grub_error (GRUB_ERR_READ_ERROR, "cannot read the a.out header");
> + goto fail;
> + }
> +
> + if (N_BADMAG (ah))
> + {
> + grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
> + goto fail;
> + }
> +
> + entry = ah.a_entry & 0xFFFFFF;
> +
> + if (*((char *) &ah) == 0xb && (*((char *) &ah + 1) == 1))
> + {
> + cur_addr = entry;
> + align_4k = 0;
> + }
> + else
> + {
> + cur_addr = entry & 0xF00000;
> + align_4k = 1;
> + }
> +
> + grub_file_seek (file, N_TXTOFF (ah));
> +
> + if (grub_errno)
> + goto fail;
> +
> + if (cur_addr < 0x100000)
> + {
> + grub_error (GRUB_ERR_BAD_OS, "load address below 1M");
> + goto fail;
> + }
> +
> + if (grub_file_read (file, (char *) cur_addr, ah.a_text) != (int) ah.a_text)
> + {
> + grub_error (GRUB_ERR_READ_ERROR, "read text fails");
> + goto fail;
> + }
> +
> + cur_addr += ah.a_text;
> +
> + if (align_4k)
> + cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
> +
> + if (grub_file_read (file, (char *) cur_addr, ah.a_data) != (int) ah.a_data)
> + {
> + grub_error (GRUB_ERR_READ_ERROR, "read data fails");
> + goto fail;
> + }
> +
> + cur_addr += ah.a_data;
> +
> + if (align_4k)
> + cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
> +
> + if (ah.a_bss)
> + grub_memset ((char *) cur_addr, 0, ah.a_bss);
> +
> + if (grub_errno == GRUB_ERR_NONE)
> + grub_loader_set (grub_aout_boot, grub_aout_unload, 1);
> +
> +fail:
> +
> + if (file)
> + grub_file_close (file);
> +
> + if (grub_errno != GRUB_ERR_NONE)
> + grub_dl_unref (my_mod);
> +}
> +
> +GRUB_MOD_INIT (aout)
> +{
> + grub_rescue_register_command ("aout", grub_rescue_cmd_aout, "load a.out");
> + my_mod = mod;
> +}
> +
> +GRUB_MOD_FINI (aout)
> +{
> + grub_rescue_unregister_command ("aout");
> +}
> diff --git a/loader/aout_normal.c b/loader/aout_normal.c
> new file mode 100644
> index 0000000..6dc0b3e
> --- /dev/null
> +++ b/loader/aout_normal.c
> @@ -0,0 +1,45 @@
> +/* aout_normal.c - boot a.out loader (*BSD) */
> +/*
> + * GRUB -- GRand Unified Bootloader
> + * Copyright (C) 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
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * GRUB is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <grub/loader.h>
> +#include <grub/err.h>
> +#include <grub/normal.h>
> +#include <grub/dl.h>
> +#include <grub/aout_loader.h>
> +
> +static grub_err_t
> +grub_normal_aout_command (struct grub_arg_list *state
> + __attribute__ ((unused)), int argc, char **args)
> +{
> + grub_rescue_cmd_aout (argc, args);
> + return grub_errno;
> +}
> +
> +GRUB_MOD_INIT (aout_normal)
> +{
> + (void) mod; /* To stop warning. */
> + grub_register_command ("aout", grub_normal_aout_command,
> + GRUB_COMMAND_FLAG_BOTH,
> + "aout FILE [ARGS...]", "Load an a.out kernel.", 0);
> +}
> +
> +GRUB_MOD_FINI (aout_normal)
> +{
> + grub_unregister_command ("aout");
> +}
> diff --git a/loader/i386/pc/aout.c b/loader/i386/pc/aout.c
> new file mode 100755
> index 0000000..179d70f
> --- /dev/null
> +++ b/loader/i386/pc/aout.c
> @@ -0,0 +1,28 @@
> +/* aout.c - boot an aout OS image. */
> +/*
> + * GRUB -- GRand Unified Bootloader
> + * Copyright (C) 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
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * GRUB is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <grub/loader.h>
> +#include <grub/machine/loader.h>
> +#include <grub/aout_loader.h>
> +
> +void
> +grub_aout_arch_boot (grub_addr_t entry)
> +{
> + grub_multiboot2_real_boot (entry, 0);
> +}
>
>
> --
> Bean
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 7:11 ` jakllsch
2008-01-29 7:20 ` Bean
@ 2008-01-29 8:56 ` Robert Millan
1 sibling, 0 replies; 26+ messages in thread
From: Robert Millan @ 2008-01-29 8:56 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Jan 29, 2008 at 01:11:57AM -0600, jakllsch@kollasch.net wrote:
>
> Now if only I was having more luck when grub2 was loaded from coreboot.
> But that's another thread maybe.
Could you bring this up? (please change Subject if you do)
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 8:48 ` Marco Gerards
@ 2008-01-29 9:02 ` Bean
2008-01-29 9:14 ` Marco Gerards
0 siblings, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-29 9:02 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 29, 2008 4:48 PM, Marco Gerards <mgerards@xs4all.nl> wrote:
> Bean <bean123ch@gmail.com> writes:
>
> > On Jan 28, 2008 5:11 PM, Robert Millan <rmh@aybabtu.com> wrote:
> >> On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
> >> > > > >
> >> > > > > How FreeBSD-specific is this? Will the same module apply to other a.out
> >> > > > > binaries ? (I ask since you gave it a generic name)
> >> > > >
> >> > > > it's an old format of the unix system:
> >> > > >
> >> > > > http://en.wikipedia.org/wiki/A.out
> >> > >
> >> > > I know.. I was referring to your loader.
> >> >
> >> > it should be generic, but i only test it using the loader from freebsd.
> >>
> >> In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
> >>
> >> Moving files on CVS is a PITA :-/
> >
> > ok, here is the new patch.
>
> It would be nice if a.out support could be shared so it can be used
> for multiboot as well.
you mean adding it to the multiboot module ?
> > +/* a_mid */
> > +#define MID_ZERO 0 /* unknown - implementation dependent */
> > +#define MID_SUN010 1 /* sun 68010/68020 binary */
> > +#define MID_SUN020 2 /* sun 68020-only binary */
> > +#define MID_I386 134 /* i386 BSD binary */
> > +#define MID_SPARC 138 /* sparc */
> > +#define MID_HP200 200 /* hp200 (68010) BSD binary */
> > +#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
> > +#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
> > +#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
>
> Like Robert asked, did you type this yourself?
the header is copied from grub legacy image_aout.h, maybe i can format
it properly.
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 9:02 ` Bean
@ 2008-01-29 9:14 ` Marco Gerards
2008-01-29 13:56 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: Marco Gerards @ 2008-01-29 9:14 UTC (permalink / raw)
To: The development of GRUB 2
Bean <bean123ch@gmail.com> writes:
> On Jan 29, 2008 4:48 PM, Marco Gerards <mgerards@xs4all.nl> wrote:
>> Bean <bean123ch@gmail.com> writes:
>>
>> > On Jan 28, 2008 5:11 PM, Robert Millan <rmh@aybabtu.com> wrote:
>> >> On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
>> >> > > > >
>> >> > > > > How FreeBSD-specific is this? Will the same module apply to other a.out
>> >> > > > > binaries ? (I ask since you gave it a generic name)
>> >> > > >
>> >> > > > it's an old format of the unix system:
>> >> > > >
>> >> > > > http://en.wikipedia.org/wiki/A.out
>> >> > >
>> >> > > I know.. I was referring to your loader.
>> >> >
>> >> > it should be generic, but i only test it using the loader from freebsd.
>> >>
>> >> In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
>> >>
>> >> Moving files on CVS is a PITA :-/
>> >
>> > ok, here is the new patch.
>>
>> It would be nice if a.out support could be shared so it can be used
>> for multiboot as well.
>
> you mean adding it to the multiboot module ?
The multiboot standard supports a.out. It would be nice if it was
also capable of a.out. So this code can somehow be shared, like ELF
support is shared now.
>> > +/* a_mid */
>> > +#define MID_ZERO 0 /* unknown - implementation dependent */
>> > +#define MID_SUN010 1 /* sun 68010/68020 binary */
>> > +#define MID_SUN020 2 /* sun 68020-only binary */
>> > +#define MID_I386 134 /* i386 BSD binary */
>> > +#define MID_SPARC 138 /* sparc */
>> > +#define MID_HP200 200 /* hp200 (68010) BSD binary */
>> > +#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
>> > +#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
>> > +#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
>>
>> Like Robert asked, did you type this yourself?
>
> the header is copied from grub legacy image_aout.h, maybe i can format
> it properly.
Please do not blindly assume the copyright assignments for GRUB Legacy
are ok... Perhaps they are not, I can't check...
--
Marco
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 9:14 ` Marco Gerards
@ 2008-01-29 13:56 ` Bean
2008-01-29 14:21 ` Robert Millan
0 siblings, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-29 13:56 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 29, 2008 5:14 PM, Marco Gerards <mgerards@xs4all.nl> wrote:
> Bean <bean123ch@gmail.com> writes:
>
> > On Jan 29, 2008 4:48 PM, Marco Gerards <mgerards@xs4all.nl> wrote:
> >> Bean <bean123ch@gmail.com> writes:
> >>
> >> > On Jan 28, 2008 5:11 PM, Robert Millan <rmh@aybabtu.com> wrote:
> >> >> On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote:
> >> >> > > > >
> >> >> > > > > How FreeBSD-specific is this? Will the same module apply to other a.out
> >> >> > > > > binaries ? (I ask since you gave it a generic name)
> >> >> > > >
> >> >> > > > it's an old format of the unix system:
> >> >> > > >
> >> >> > > > http://en.wikipedia.org/wiki/A.out
> >> >> > >
> >> >> > > I know.. I was referring to your loader.
> >> >> >
> >> >> > it should be generic, but i only test it using the loader from freebsd.
> >> >>
> >> >> In that case, I'd suggest putting it directly in loader/ (without i386/pc/).
> >> >>
> >> >> Moving files on CVS is a PITA :-/
> >> >
> >> > ok, here is the new patch.
> >>
> >> It would be nice if a.out support could be shared so it can be used
> >> for multiboot as well.
> >
> > you mean adding it to the multiboot module ?
>
> The multiboot standard supports a.out. It would be nice if it was
> also capable of a.out. So this code can somehow be shared, like ELF
> support is shared now.
but it doesn't have the multiboot header, or the header is not
necessary in multiboot 2 ?
btw, where can i find spec on multiboot 2 ?
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 13:56 ` Bean
@ 2008-01-29 14:21 ` Robert Millan
2008-01-29 14:37 ` Marco Gerards
0 siblings, 1 reply; 26+ messages in thread
From: Robert Millan @ 2008-01-29 14:21 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Jan 29, 2008 at 09:56:38PM +0800, Bean wrote:
> >
> > The multiboot standard supports a.out. It would be nice if it was
> > also capable of a.out. So this code can somehow be shared, like ELF
> > support is shared now.
>
> but it doesn't have the multiboot header, or the header is not
> necessary in multiboot 2 ?
It has a header, but that is the part that cannot be shared, of course. I
think what Marco means is to split generic a.out stuff like we do for ELF
(we have ELF in kernel because it's used by the module loader, but for
a.out maybe it's better to use a separate module?).
For example we could have:
- aout.mod: provides generic a.out routines.
- freebsd-loader.mod: freebsd-specific part (relies on aout routines).
- multiboot.mod: may be improved to rely on aout.mod when necessary.
> btw, where can i find spec on multiboot 2 ?
See http://grub.enbug.org/MultibootDraft
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 14:21 ` Robert Millan
@ 2008-01-29 14:37 ` Marco Gerards
0 siblings, 0 replies; 26+ messages in thread
From: Marco Gerards @ 2008-01-29 14:37 UTC (permalink / raw)
To: The development of GRUB 2
Robert Millan <rmh@aybabtu.com> writes:
> On Tue, Jan 29, 2008 at 09:56:38PM +0800, Bean wrote:
>> >
>> > The multiboot standard supports a.out. It would be nice if it was
>> > also capable of a.out. So this code can somehow be shared, like ELF
>> > support is shared now.
>>
>> but it doesn't have the multiboot header, or the header is not
>> necessary in multiboot 2 ?
>
> It has a header, but that is the part that cannot be shared, of course. I
> think what Marco means is to split generic a.out stuff like we do for ELF
> (we have ELF in kernel because it's used by the module loader, but for
> a.out maybe it's better to use a separate module?).
>
> For example we could have:
>
> - aout.mod: provides generic a.out routines.
> - freebsd-loader.mod: freebsd-specific part (relies on aout routines).
> - multiboot.mod: may be improved to rely on aout.mod when necessary.
Right! I need a rml extension for gnus that transforms my brainwaves
into an email ;-)
--
Marco
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 7:20 ` Bean
@ 2008-01-29 18:11 ` jakllsch
2008-01-29 18:26 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: jakllsch @ 2008-01-29 18:11 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Jan 29, 2008 at 03:20:12PM +0800, Bean wrote:
> On Jan 29, 2008 3:11 PM, <jakllsch@kollasch.net> wrote:
> > On Mon, Jan 28, 2008 at 06:37:16AM -0800, walt wrote:
> > >
> > > When I type 'boot' after loading the netbsd kernel with multiboot, the
> > > machine reboots instantly instead of starting the OS.
> > >
> > > Any ideas?
> > >
> >
> > I've encountered this in qemu where it tells you you are executing code
> > outside ram/rom at the kernel virtual entry address of 0xc0100000. The
> > NetBSD/i386 kernel needs to be loaded/entered at physical address
> > 0x00100000, it's, however, linked to run at 0xc0100000.
> >
> > This is trivial to fix, but the trivial fix may not be the right fix.
> >
> > Now if only I was having more luck when grub2 was loaded from coreboot.
> > But that's another thread maybe.
>
> my previous multiboot patch fix this problem.
Did that make it into the repository yet?
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 18:11 ` jakllsch
@ 2008-01-29 18:26 ` Bean
0 siblings, 0 replies; 26+ messages in thread
From: Bean @ 2008-01-29 18:26 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 30, 2008 2:11 AM, <jakllsch@kollasch.net> wrote:
>
> On Tue, Jan 29, 2008 at 03:20:12PM +0800, Bean wrote:
> > On Jan 29, 2008 3:11 PM, <jakllsch@kollasch.net> wrote:
> > > On Mon, Jan 28, 2008 at 06:37:16AM -0800, walt wrote:
> > > >
> > > > When I type 'boot' after loading the netbsd kernel with multiboot, the
> > > > machine reboots instantly instead of starting the OS.
> > > >
> > > > Any ideas?
> > > >
> > >
> > > I've encountered this in qemu where it tells you you are executing code
> > > outside ram/rom at the kernel virtual entry address of 0xc0100000. The
> > > NetBSD/i386 kernel needs to be loaded/entered at physical address
> > > 0x00100000, it's, however, linked to run at 0xc0100000.
> > >
> > > This is trivial to fix, but the trivial fix may not be the right fix.
> > >
> > > Now if only I was having more luck when grub2 was loaded from coreboot.
> > > But that's another thread maybe.
> >
> > my previous multiboot patch fix this problem.
>
> Did that make it into the repository yet?
no, you need to find it among the replies.
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-29 6:53 ` Bean
@ 2008-01-30 12:24 ` walt
2008-01-30 12:42 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: walt @ 2008-01-30 12:24 UTC (permalink / raw)
To: grub-devel
On Tue, 2008-01-29 at 14:53 +0800, Bean wrote:
> On Jan 29, 2008 6:04 AM, walt <wa1ter@myrealbox.com> wrote:
> > Bean wrote:
> > > On Jan 28, 2008 10:37 PM, walt<wa1ter@myrealbox.com> wrote:
> > ...
> > >> Good news and bad news. With this patch and your most recent ufs patch
> > >> I can aout /boot/loader or multiboot /netbsd from a UFS partition, that
> > >> is the good news.
> > >>
> > >> The bad news is that when I type 'boot', /boot/loader prints out its one
> > >> line of text to identify itself and then hangs forever.
> > >>
> > >> When I type 'boot' after loading the netbsd kernel with multiboot, the
> > >> machine reboots instantly instead of starting the OS.
> > >>
> > >> Any ideas?
> >
> > > is grub legacy ok ?
> >
> > I'm not sure what information you are asking for. Nothing has changed
> > at my end concerning legacy. It still works, but why should it not?
>
> this is strange, it's working for me. perhaps you can try to load
> netnsd kernel from the ufs image you sent.
>
> loopback loop (hd0,0)/ufs
> multiboot (loop)/netbsd
> boot
>
> ufs is better placed in non ufs partition.
>
> If this works, then it means there is still bug in the ufs driver.
Sorry, I gave you incomplete information. I can use 'multiboot' to load
the netbsd from any kind of fs, but it makes no difference: 'boot' then
causes the machine to reboot instantly. The same applies to aout: I
can aout load from any fs, but then 'boot' make the machine hang. The
type of fs makes no difference.
I can still 'chainload +1' or 'linux' successfully.
All of the above applies to the latest grub2 from cvs with your most
recent ufs and aout patches applied.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-30 12:24 ` walt
@ 2008-01-30 12:42 ` Bean
2008-02-01 1:46 ` walt
0 siblings, 1 reply; 26+ messages in thread
From: Bean @ 2008-01-30 12:42 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 30, 2008 8:24 PM, walt <wa1ter@myrealbox.com> wrote:
> Sorry, I gave you incomplete information. I can use 'multiboot' to load
> the netbsd from any kind of fs, but it makes no difference: 'boot' then
> causes the machine to reboot instantly. The same applies to aout: I
> can aout load from any fs, but then 'boot' make the machine hang. The
> type of fs makes no difference.
>
> I can still 'chainload +1' or 'linux' successfully.
>
> All of the above applies to the latest grub2 from cvs with your most
> recent ufs and aout patches applied.
in this case, the ufs driver should be ok.
btw, do you remember to apply the multiboot patch ? you can also make
a qemu image for me to test.
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-01-30 12:42 ` Bean
@ 2008-02-01 1:46 ` walt
2008-02-01 3:12 ` Bean
0 siblings, 1 reply; 26+ messages in thread
From: walt @ 2008-02-01 1:46 UTC (permalink / raw)
To: grub-devel
Bean wrote:
> On Jan 30, 2008 8:24 PM, walt<wa1ter@myrealbox.com> wrote:
>> Sorry, I gave you incomplete information. I can use 'multiboot' to load
>> the netbsd from any kind of fs, but it makes no difference: 'boot' then
>> causes the machine to reboot instantly. The same applies to aout: I
>> can aout load from any fs, but then 'boot' make the machine hang. The
>> type of fs makes no difference.
>>
>> I can still 'chainload +1' or 'linux' successfully.
>>
>> All of the above applies to the latest grub2 from cvs with your most
>> recent ufs and aout patches applied.
>
> in this case, the ufs driver should be ok.
>
> btw, do you remember to apply the multiboot patch ? you can also make
> a qemu image for me to test.
Aha! I forgot the multiboot patch :o( Now I can multiboot netbsd from
any filesystem and it 'just works'. Most excellent, thank you!
Sadly, 'aout /boot/loader' still hangs when I type 'boot'. The loader
is obviously probing the floppy drive because I can hear it seeking just
like it does when the machine reboots. This is not what happens when
/boot/loader is working normally -- it should immediately load the kernel
from the hard disk with no additional hardware probing.
Let me know if I can give you any more info.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH] a.out kernel loader
2008-02-01 1:46 ` walt
@ 2008-02-01 3:12 ` Bean
0 siblings, 0 replies; 26+ messages in thread
From: Bean @ 2008-02-01 3:12 UTC (permalink / raw)
To: The development of GRUB 2
On Feb 1, 2008 9:46 AM, walt <wa1ter@myrealbox.com> wrote:
>
> Bean wrote:
> > On Jan 30, 2008 8:24 PM, walt<wa1ter@myrealbox.com> wrote:
> >> Sorry, I gave you incomplete information. I can use 'multiboot' to load
> >> the netbsd from any kind of fs, but it makes no difference: 'boot' then
> >> causes the machine to reboot instantly. The same applies to aout: I
> >> can aout load from any fs, but then 'boot' make the machine hang. The
> >> type of fs makes no difference.
> >>
> >> I can still 'chainload +1' or 'linux' successfully.
> >>
> >> All of the above applies to the latest grub2 from cvs with your most
> >> recent ufs and aout patches applied.
> >
> > in this case, the ufs driver should be ok.
> >
> > btw, do you remember to apply the multiboot patch ? you can also make
> > a qemu image for me to test.
>
> Aha! I forgot the multiboot patch :o( Now I can multiboot netbsd from
> any filesystem and it 'just works'. Most excellent, thank you!
>
> Sadly, 'aout /boot/loader' still hangs when I type 'boot'. The loader
> is obviously probing the floppy drive because I can hear it seeking just
> like it does when the machine reboots. This is not what happens when
> /boot/loader is working normally -- it should immediately load the kernel
> from the hard disk with no additional hardware probing.
>
> Let me know if I can give you any more info.
i see, perhaps i need to set %dl properly before jumping to the code.
--
Bean
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2008-02-01 3:12 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-27 18:53 [PATCH] a.out kernel loader Bean
2008-01-27 19:41 ` Robert Millan
2008-01-27 19:55 ` Bean
2008-01-27 20:06 ` Robert Millan
2008-01-27 20:10 ` Bean
2008-01-28 9:11 ` Robert Millan
2008-01-28 11:48 ` Bean
2008-01-28 14:37 ` walt
2008-01-28 14:42 ` Bean
2008-01-28 22:04 ` walt
2008-01-29 6:53 ` Bean
2008-01-30 12:24 ` walt
2008-01-30 12:42 ` Bean
2008-02-01 1:46 ` walt
2008-02-01 3:12 ` Bean
2008-01-29 7:11 ` jakllsch
2008-01-29 7:20 ` Bean
2008-01-29 18:11 ` jakllsch
2008-01-29 18:26 ` Bean
2008-01-29 8:56 ` Robert Millan
2008-01-29 8:48 ` Marco Gerards
2008-01-29 9:02 ` Bean
2008-01-29 9:14 ` Marco Gerards
2008-01-29 13:56 ` Bean
2008-01-29 14:21 ` Robert Millan
2008-01-29 14:37 ` Marco Gerards
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.