Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/mkubootimage Add the -O option to set the OS type, w...
details: https://anonhg.NetBSD.org/src/rev/8f0ff17b217a
branches: trunk
changeset: 762738:8f0ff17b217a
user: phx <phx%NetBSD.org@localhost>
date: Sat Feb 26 20:03:09 2011 +0000
description:
Add the -O option to set the OS type, which defaults to NetBSD when missing.
This is needed, because some vendors have stripped U-Boot so much that it
only accepts Linux kernel modules.
Also allow 'standalone' as module type.
diffstat:
usr.bin/mkubootimage/mkubootimage.c | 39 ++++++++++++++++++++++++++++++++----
usr.bin/mkubootimage/uboot.h | 11 ++++++++-
2 files changed, 43 insertions(+), 7 deletions(-)
diffs (135 lines):
diff -r ee6073f4d85e -r 8f0ff17b217a usr.bin/mkubootimage/mkubootimage.c
--- a/usr.bin/mkubootimage/mkubootimage.c Sat Feb 26 19:17:37 2011 +0000
+++ b/usr.bin/mkubootimage/mkubootimage.c Sat Feb 26 20:03:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkubootimage.c,v 1.5 2011/01/31 03:37:28 matt Exp $ */
+/* $NetBSD: mkubootimage.c,v 1.6 2011/02/26 20:03:09 phx Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkubootimage.c,v 1.5 2011/01/31 03:37:28 matt Exp $");
+__RCSID("$NetBSD: mkubootimage.c,v 1.6 2011/02/26 20:03:09 phx Exp $");
#include <sys/mman.h>
#include <sys/stat.h>
@@ -53,6 +53,7 @@
extern uint32_t crc32(const void *, size_t);
+static enum uboot_image_os image_os = IH_OS_NETBSD;
static enum uboot_image_arch image_arch = IH_ARCH_UNKNOWN;
static enum uboot_image_type image_type = IH_TYPE_UNKNOWN;
static enum uboot_image_comp image_comp = IH_COMP_NONE;
@@ -60,6 +61,29 @@
static uint32_t image_entrypoint = 0;
static char *image_name;
+struct uboot_os {
+ enum uboot_image_os os;
+ const char *name;
+} uboot_os[] = {
+ { IH_OS_OPENBSD, "openbsd" },
+ { IH_OS_NETBSD, "netbsd" },
+ { IH_OS_FREEBSD, "freebsd" },
+ { IH_OS_LINUX, "linux" },
+};
+
+static enum uboot_image_os
+get_os(const char *name)
+{
+ unsigned int i;
+
+ for (i = 0; i < __arraycount(uboot_os); i++) {
+ if (strcmp(uboot_os[i].name, name) == 0)
+ return uboot_os[i].os;
+ }
+
+ return IH_OS_UNKNOWN;
+}
+
struct uboot_arch {
enum uboot_image_arch arch;
const char *name;
@@ -87,6 +111,7 @@
enum uboot_image_type type;
const char *name;
} uboot_type[] = {
+ { IH_TYPE_STANDALONE, "standalone" },
{ IH_TYPE_KERNEL, "kernel" },
{ IH_TYPE_RAMDISK, "ramdisk" },
{ IH_TYPE_FILESYSTEM, "fs" },
@@ -131,8 +156,9 @@
usage(void)
{
fprintf(stderr, "usage: mkubootimage -A <arm|mips|mips64|powerpc>");
- fprintf(stderr, " -T <kernel|ramdisk|fs>");
fprintf(stderr, " -C <none|gz|bz2>");
+ fprintf(stderr, " -O <openbsd|netbsd|freebsd|linux>");
+ fprintf(stderr, " -T <standalone|kernel|ramdisk|fs>");
fprintf(stderr, " -a <addr> [-e <ep>] -n <name>");
fprintf(stderr, " <srcfile> <dstfile>\n");
@@ -192,7 +218,7 @@
hdr->ih_load = htonl(image_loadaddr);
hdr->ih_ep = htonl(image_entrypoint);
hdr->ih_dcrc = htonl(crc);
- hdr->ih_os = IH_OS_NETBSD;
+ hdr->ih_os = image_os;
hdr->ih_arch = image_arch;
hdr->ih_type = image_type;
hdr->ih_comp = image_comp;
@@ -238,7 +264,7 @@
int ch;
unsigned long num;
- while ((ch = getopt(argc, argv, "A:C:T:a:e:hn:")) != -1) {
+ while ((ch = getopt(argc, argv, "A:C:O:T:a:e:hn:")) != -1) {
switch (ch) {
case 'A': /* arch */
image_arch = get_arch(optarg);
@@ -246,6 +272,9 @@
case 'C': /* comp */
image_comp = get_comp(optarg);
break;
+ case 'O': /* os */
+ image_os = get_os(optarg);
+ break;
case 'T': /* type */
image_type = get_type(optarg);
break;
diff -r ee6073f4d85e -r 8f0ff17b217a usr.bin/mkubootimage/uboot.h
--- a/usr.bin/mkubootimage/uboot.h Sat Feb 26 19:17:37 2011 +0000
+++ b/usr.bin/mkubootimage/uboot.h Sat Feb 26 20:03:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uboot.h,v 1.2 2011/01/31 03:37:28 matt Exp $ */
+/* $NetBSD: uboot.h,v 1.3 2011/02/26 20:03:09 phx Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,13 @@
#ifndef _HAVE_UBOOT_H
#define _HAVE_UBOOT_H
-#define IH_OS_NETBSD 2
+enum uboot_image_os {
+ IH_OS_UNKNOWN = 0,
+ IH_OS_OPENBSD = 1,
+ IH_OS_NETBSD = 2,
+ IH_OS_FREEBSD = 3,
+ IH_OS_LINUX = 5
+};
enum uboot_image_arch {
IH_ARCH_UNKNOWN = 0,
@@ -40,6 +46,7 @@
enum uboot_image_type {
IH_TYPE_UNKNOWN = 0,
+ IH_TYPE_STANDALONE = 1,
IH_TYPE_KERNEL = 2,
IH_TYPE_RAMDISK = 3,
IH_TYPE_FILESYSTEM = 7,
Home |
Main Index |
Thread Index |
Old Index