* [PATCH] Let user specify OpenBSD root device.
@ 2009-08-25 20:37 Vladimir 'phcoder' Serbinenko
2009-08-26 0:34 ` Robert Millan
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-08-25 20:37 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 375 bytes --]
OpenBSD recieves a root specification in a form of pair <device,
partition>. I thought that device number referred to biosnumber AND'ed
with 0x7f as it was implemented but experiments with grub-qemu showed
that OpenBSD doesn't rely on BIOS at all. So hence this patch
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
[-- Attachment #2: openbsdroot.diff --]
[-- Type: text/plain, Size: 3833 bytes --]
diff --git a/ChangeLog b/ChangeLog
index 1de68ad..717904e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2009-08-25 Vladimir Serbinenko <phcoder@gmail.com>
+ Let user specify OpenBSD root device.
+
+ * loader/i386/bsd.c (openbsd_root): New variable.
+ (openbsd_opts): New option 'root'.
+ (OPENBSD_ROOT_ARG): New macro.
+ (grub_openbsd_boot): Use 'openbsd_root'.
+ (grub_cmd_openbsd): Fill 'openbsd_root'.
+
+2009-08-25 Vladimir Serbinenko <phcoder@gmail.com>
+
Cleanup NetBSD root support.
* loader/i386/bsd.c (grub_netbsd_boot): Remove call to
diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c
index 0b9a2b4..503a0ef 100644
--- a/loader/i386/bsd.c
+++ b/loader/i386/bsd.c
@@ -57,6 +57,7 @@ static char *mod_buf;
static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs;
static int is_elf_kernel, is_64bit;
static char *netbsd_root = NULL;
+static grub_uint32_t openbsd_root;
static const struct grub_arg_option freebsd_opts[] =
{
@@ -93,6 +94,7 @@ static const struct grub_arg_option openbsd_opts[] =
{"config", 'c', 0, "Change configured devices.", 0, 0},
{"single", 's', 0, "Boot into single mode.", 0, 0},
{"kdb", 'd', 0, "Enter in KDB on boot.", 0, 0},
+ {"root", 'r', 0, "Set root device.", "wdXY", ARG_TYPE_STRING},
{0, 0, 0, 0, 0, 0}
};
@@ -102,6 +104,8 @@ static const grub_uint32_t openbsd_flags[] =
OPENBSD_RB_SINGLE, OPENBSD_RB_KDB, 0
};
+#define OPENBSD_ROOT_ARG (ARRAY_SIZE (openbsd_flags) - 1)
+
static const struct grub_arg_option netbsd_opts[] =
{
{"no-smp", '1', 0, "Disable SMP.", 0, 0},
@@ -560,7 +564,6 @@ grub_openbsd_boot (void)
char *buf = (char *) GRUB_BSD_TEMP_BUFFER;
struct grub_openbsd_bios_mmap *pm;
struct grub_openbsd_bootargs *pa;
- grub_uint32_t bootdev, biosdev, unit, slice, part;
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
@@ -609,11 +612,7 @@ grub_openbsd_boot (void)
pa->ba_type = OPENBSD_BOOTARG_END;
pa++;
- grub_bsd_get_device (&biosdev, &unit, &slice, &part);
- bootdev = (OPENBSD_B_DEVMAGIC + (unit << OPENBSD_B_UNITSHIFT) +
- (part << OPENBSD_B_PARTSHIFT));
-
- grub_unix_real_boot (entry, bootflags, bootdev, OPENBSD_BOOTARG_APIVER,
+ grub_unix_real_boot (entry, bootflags, openbsd_root, OPENBSD_BOOTARG_APIVER,
0, (grub_uint32_t) (grub_mmap_get_upper () >> 10),
(grub_uint32_t) (grub_mmap_get_lower () >> 10),
(char *) pa - buf, buf);
@@ -950,11 +949,39 @@ grub_cmd_freebsd (grub_extcmd_t cmd, int argc, char *argv[])
static grub_err_t
grub_cmd_openbsd (grub_extcmd_t cmd, int argc, char *argv[])
{
+ grub_uint32_t bootdev;
+
kernel_type = KERNEL_TYPE_OPENBSD;
bootflags = grub_bsd_parse_flags (cmd->state, openbsd_flags);
+ if (cmd->state[OPENBSD_ROOT_ARG].set)
+ {
+ const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
+ int unit, part;
+ if (*(arg++) != 'w' || *(arg++) != 'd')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Only device specifications of form "
+ "wd<number><lowercase letter> are supported.");
+
+ unit = grub_strtoul (arg, (char **) &arg, 10);
+ if (! (arg && *arg >= 'a' && *arg <= 'z'))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Only device specifications of form "
+ "wd<number><letter> are supported.");
+
+ part = *arg - 'a';
+
+ bootdev = (OPENBSD_B_DEVMAGIC + (unit << OPENBSD_B_UNITSHIFT) +
+ (part << OPENBSD_B_PARTSHIFT));
+ }
+ else
+ bootdev = 0;
+
if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
- grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 1);
+ {
+ grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 1);
+ openbsd_root = bootdev;
+ }
return grub_errno;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Let user specify OpenBSD root device.
2009-08-25 20:37 [PATCH] Let user specify OpenBSD root device Vladimir 'phcoder' Serbinenko
@ 2009-08-26 0:34 ` Robert Millan
2009-08-26 0:39 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 6+ messages in thread
From: Robert Millan @ 2009-08-26 0:34 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Aug 25, 2009 at 10:37:33PM +0200, Vladimir 'phcoder' Serbinenko wrote:
> + if (cmd->state[OPENBSD_ROOT_ARG].set)
> + {
> + const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
> + int unit, part;
> + if (*(arg++) != 'w' || *(arg++) != 'd')
> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
> + "Only device specifications of form "
> + "wd<number><lowercase letter> are supported.");
> +
> + unit = grub_strtoul (arg, (char **) &arg, 10);
> + if (! (arg && *arg >= 'a' && *arg <= 'z'))
> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
> + "Only device specifications of form "
> + "wd<number><letter> are supported.");
Looks like the first error string could be used for both cases, saving
a few bytes.
--
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] 6+ messages in thread
* Re: [PATCH] Let user specify OpenBSD root device.
2009-08-26 0:34 ` Robert Millan
@ 2009-08-26 0:39 ` Vladimir 'phcoder' Serbinenko
2009-10-16 11:00 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-08-26 0:39 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1474 bytes --]
On Wed, Aug 26, 2009 at 2:34 AM, Robert Millan<rmh@aybabtu.com> wrote:
> On Tue, Aug 25, 2009 at 10:37:33PM +0200, Vladimir 'phcoder' Serbinenko wrote:
>> + if (cmd->state[OPENBSD_ROOT_ARG].set)
>> + {
>> + const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
>> + int unit, part;
>> + if (*(arg++) != 'w' || *(arg++) != 'd')
>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
>> + "Only device specifications of form "
>> + "wd<number><lowercase letter> are supported.");
>> +
>> + unit = grub_strtoul (arg, (char **) &arg, 10);
>> + if (! (arg && *arg >= 'a' && *arg <= 'z'))
>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
>> + "Only device specifications of form "
>> + "wd<number><letter> are supported.");
>
> Looks like the first error string could be used for both cases, saving
> a few bytes.
>
> --
> 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
>
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
[-- Attachment #2: openbsdroot.diff --]
[-- Type: text/plain, Size: 3854 bytes --]
diff --git a/ChangeLog b/ChangeLog
index 54b3e48..9aba062 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2009-08-25 Vladimir Serbinenko <phcoder@gmail.com>
+ Let user specify OpenBSD root device.
+
+ * loader/i386/bsd.c (openbsd_root): New variable.
+ (openbsd_opts): New option 'root'.
+ (OPENBSD_ROOT_ARG): New macro.
+ (grub_openbsd_boot): Use 'openbsd_root'.
+ (grub_cmd_openbsd): Fill 'openbsd_root'.
+
+2009-08-25 Vladimir Serbinenko <phcoder@gmail.com>
+
NetBSD memory map support.
* include/grub/i386/bsd.h (NETBSD_BTINFO_MEMMAP): New definition.
diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c
index 1accfb6..1afac9e 100644
--- a/loader/i386/bsd.c
+++ b/loader/i386/bsd.c
@@ -57,6 +57,7 @@ static char *mod_buf;
static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs;
static int is_elf_kernel, is_64bit;
static char *netbsd_root = NULL;
+static grub_uint32_t openbsd_root;
static const struct grub_arg_option freebsd_opts[] =
{
@@ -93,6 +94,7 @@ static const struct grub_arg_option openbsd_opts[] =
{"config", 'c', 0, "Change configured devices.", 0, 0},
{"single", 's', 0, "Boot into single mode.", 0, 0},
{"kdb", 'd', 0, "Enter in KDB on boot.", 0, 0},
+ {"root", 'r', 0, "Set root device.", "wdXY", ARG_TYPE_STRING},
{0, 0, 0, 0, 0, 0}
};
@@ -102,6 +104,8 @@ static const grub_uint32_t openbsd_flags[] =
OPENBSD_RB_SINGLE, OPENBSD_RB_KDB, 0
};
+#define OPENBSD_ROOT_ARG (ARRAY_SIZE (openbsd_flags) - 1)
+
static const struct grub_arg_option netbsd_opts[] =
{
{"no-smp", '1', 0, "Disable SMP.", 0, 0},
@@ -564,7 +568,6 @@ grub_openbsd_boot (void)
char *buf = (char *) GRUB_BSD_TEMP_BUFFER;
struct grub_openbsd_bios_mmap *pm;
struct grub_openbsd_bootargs *pa;
- grub_uint32_t bootdev, biosdev, unit, slice, part;
auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
@@ -613,11 +616,7 @@ grub_openbsd_boot (void)
pa->ba_type = OPENBSD_BOOTARG_END;
pa++;
- grub_bsd_get_device (&biosdev, &unit, &slice, &part);
- bootdev = (OPENBSD_B_DEVMAGIC + (unit << OPENBSD_B_UNITSHIFT) +
- (part << OPENBSD_B_PARTSHIFT));
-
- grub_unix_real_boot (entry, bootflags, bootdev, OPENBSD_BOOTARG_APIVER,
+ grub_unix_real_boot (entry, bootflags, openbsd_root, OPENBSD_BOOTARG_APIVER,
0, (grub_uint32_t) (grub_mmap_get_upper () >> 10),
(grub_uint32_t) (grub_mmap_get_lower () >> 10),
(char *) pa - buf, buf);
@@ -1011,11 +1010,39 @@ grub_cmd_freebsd (grub_extcmd_t cmd, int argc, char *argv[])
static grub_err_t
grub_cmd_openbsd (grub_extcmd_t cmd, int argc, char *argv[])
{
+ grub_uint32_t bootdev;
+
kernel_type = KERNEL_TYPE_OPENBSD;
bootflags = grub_bsd_parse_flags (cmd->state, openbsd_flags);
+ if (cmd->state[OPENBSD_ROOT_ARG].set)
+ {
+ const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
+ int unit, part;
+ if (*(arg++) != 'w' || *(arg++) != 'd')
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Only device specifications of form "
+ "wd<number><lowercase letter> are supported.");
+
+ unit = grub_strtoul (arg, (char **) &arg, 10);
+ if (! (arg && *arg >= 'a' && *arg <= 'z'))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ "Only device specifications of form "
+ "wd<number><lowercase letter> are supported.");
+
+ part = *arg - 'a';
+
+ bootdev = (OPENBSD_B_DEVMAGIC + (unit << OPENBSD_B_UNITSHIFT) +
+ (part << OPENBSD_B_PARTSHIFT));
+ }
+ else
+ bootdev = 0;
+
if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
- grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 1);
+ {
+ grub_loader_set (grub_openbsd_boot, grub_bsd_unload, 1);
+ openbsd_root = bootdev;
+ }
return grub_errno;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Let user specify OpenBSD root device.
2009-08-26 0:39 ` Vladimir 'phcoder' Serbinenko
@ 2009-10-16 11:00 ` Vladimir 'phcoder' Serbinenko
2009-10-16 18:31 ` Robert Millan
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-10-16 11:00 UTC (permalink / raw)
To: The development of GRUB 2
Vladimir 'phcoder' Serbinenko wrote:
> On Wed, Aug 26, 2009 at 2:34 AM, Robert Millan<rmh@aybabtu.com> wrote:
>
>> On Tue, Aug 25, 2009 at 10:37:33PM +0200, Vladimir 'phcoder' Serbinenko wrote:
>>
>>> + if (cmd->state[OPENBSD_ROOT_ARG].set)
>>> + {
>>> + const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
>>> + int unit, part;
>>> + if (*(arg++) != 'w' || *(arg++) != 'd')
>>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
>>> + "Only device specifications of form "
>>> + "wd<number><lowercase letter> are supported.");
>>> +
>>> + unit = grub_strtoul (arg, (char **) &arg, 10);
>>> + if (! (arg && *arg >= 'a' && *arg <= 'z'))
>>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
>>> + "Only device specifications of form "
>>> + "wd<number><letter> are supported.");
>>>
>> Looks like the first error string could be used for both cases, saving
>> a few bytes.
>>
>>
This was fixed. Can this patch be comitted before release to avoid
changing command syntax after release?
>> --
>> 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
>>
>>
>
>
>
>
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Let user specify OpenBSD root device.
2009-10-16 11:00 ` Vladimir 'phcoder' Serbinenko
@ 2009-10-16 18:31 ` Robert Millan
2009-10-16 20:21 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 6+ messages in thread
From: Robert Millan @ 2009-10-16 18:31 UTC (permalink / raw)
To: The development of GRUB 2
On Fri, Oct 16, 2009 at 01:00:31PM +0200, Vladimir 'phcoder' Serbinenko wrote:
> Vladimir 'phcoder' Serbinenko wrote:
> > On Wed, Aug 26, 2009 at 2:34 AM, Robert Millan<rmh@aybabtu.com> wrote:
> >
> >> On Tue, Aug 25, 2009 at 10:37:33PM +0200, Vladimir 'phcoder' Serbinenko wrote:
> >>
> >>> + if (cmd->state[OPENBSD_ROOT_ARG].set)
> >>> + {
> >>> + const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
> >>> + int unit, part;
> >>> + if (*(arg++) != 'w' || *(arg++) != 'd')
> >>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
> >>> + "Only device specifications of form "
> >>> + "wd<number><lowercase letter> are supported.");
> >>> +
> >>> + unit = grub_strtoul (arg, (char **) &arg, 10);
> >>> + if (! (arg && *arg >= 'a' && *arg <= 'z'))
> >>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
> >>> + "Only device specifications of form "
> >>> + "wd<number><letter> are supported.");
> >>>
> >> Looks like the first error string could be used for both cases, saving
> >> a few bytes.
> >>
> >>
> This was fixed. Can this patch be comitted before release to avoid
> changing command syntax after release?
Ok.
--
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] 6+ messages in thread
* Re: [PATCH] Let user specify OpenBSD root device.
2009-10-16 18:31 ` Robert Millan
@ 2009-10-16 20:21 ` Vladimir 'phcoder' Serbinenko
0 siblings, 0 replies; 6+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-10-16 20:21 UTC (permalink / raw)
To: The development of GRUB 2
Robert Millan wrote:
> On Fri, Oct 16, 2009 at 01:00:31PM +0200, Vladimir 'phcoder' Serbinenko wrote:
>
>> Vladimir 'phcoder' Serbinenko wrote:
>>
>>> On Wed, Aug 26, 2009 at 2:34 AM, Robert Millan<rmh@aybabtu.com> wrote:
>>>
>>>
>>>> On Tue, Aug 25, 2009 at 10:37:33PM +0200, Vladimir 'phcoder' Serbinenko wrote:
>>>>
>>>>
>>>>> + if (cmd->state[OPENBSD_ROOT_ARG].set)
>>>>> + {
>>>>> + const char *arg = cmd->state[OPENBSD_ROOT_ARG].arg;
>>>>> + int unit, part;
>>>>> + if (*(arg++) != 'w' || *(arg++) != 'd')
>>>>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
>>>>> + "Only device specifications of form "
>>>>> + "wd<number><lowercase letter> are supported.");
>>>>> +
>>>>> + unit = grub_strtoul (arg, (char **) &arg, 10);
>>>>> + if (! (arg && *arg >= 'a' && *arg <= 'z'))
>>>>> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
>>>>> + "Only device specifications of form "
>>>>> + "wd<number><letter> are supported.");
>>>>>
>>>>>
>>>> Looks like the first error string could be used for both cases, saving
>>>> a few bytes.
>>>>
>>>>
>>>>
>> This was fixed. Can this patch be comitted before release to avoid
>> changing command syntax after release?
>>
>
> Ok.
>
>
Comitted
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-10-16 20:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-25 20:37 [PATCH] Let user specify OpenBSD root device Vladimir 'phcoder' Serbinenko
2009-08-26 0:34 ` Robert Millan
2009-08-26 0:39 ` Vladimir 'phcoder' Serbinenko
2009-10-16 11:00 ` Vladimir 'phcoder' Serbinenko
2009-10-16 18:31 ` Robert Millan
2009-10-16 20:21 ` Vladimir 'phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.