diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-11-12 20:54:55 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-11-12 20:54:55 +0000 |
commit | a5d5bcd47bf86d538bb87dbd8bc3ed2954f83e20 (patch) | |
tree | a583d5a7e4e84e6099816675e69618eacf374e14 /usr.sbin/eeprom | |
parent | ccb902dbe2c74025e39a268790d5b6427589ef89 (diff) |
Make this compile on macppc (OpenPROM support only) and build it there.
ok deraadt@
Diffstat (limited to 'usr.sbin/eeprom')
-rw-r--r-- | usr.sbin/eeprom/Makefile | 11 | ||||
-rw-r--r-- | usr.sbin/eeprom/defs.h | 8 | ||||
-rw-r--r-- | usr.sbin/eeprom/main.c | 45 | ||||
-rw-r--r-- | usr.sbin/eeprom/ophandlers.c | 3 | ||||
-rw-r--r-- | usr.sbin/eeprom/optree.c | 11 |
5 files changed, 40 insertions, 38 deletions
diff --git a/usr.sbin/eeprom/Makefile b/usr.sbin/eeprom/Makefile index cf17a23d638..82b5824c962 100644 --- a/usr.sbin/eeprom/Makefile +++ b/usr.sbin/eeprom/Makefile @@ -1,15 +1,16 @@ -# $OpenBSD: Makefile,v 1.10 2007/09/04 23:28:26 fgsch Exp $ +# $OpenBSD: Makefile,v 1.11 2007/11/12 20:54:54 kettenis Exp $ -.if ${MACHINE} == "sparc" || ${MACHINE} == "sparc64" +.if ${MACHINE} == "macppc" || ${MACHINE} == "sparc" || ${MACHINE} == "sparc64" PROG= eeprom BINGRP= kmem BINMODE=2555 -SRCS= eehandlers.c getdate.c main.c +SRCS= getdate.c main.c +SRCS+= ophandlers.c optree.c . if ${MACHINE} == "sparc" || ${MACHINE} == "sparc64" -SRCS+= ophandlers.c optree.c +SRCS+= eehandlers.c . endif CLEANFILES+=getdate.c y.tab.h @@ -18,6 +19,6 @@ NOPROG=yes .endif MAN= eeprom.8 -MANSUBDIR=sparc sparc64 +MANSUBDIR=macppc sparc sparc64 .include <bsd.prog.mk> diff --git a/usr.sbin/eeprom/defs.h b/usr.sbin/eeprom/defs.h index a5c629e95bb..ed89fe12ef8 100644 --- a/usr.sbin/eeprom/defs.h +++ b/usr.sbin/eeprom/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.5 2007/09/04 23:28:26 fgsch Exp $ */ +/* $OpenBSD: defs.h,v 1.6 2007/11/12 20:54:54 kettenis Exp $ */ /* $NetBSD: defs.h,v 1.2 1996/02/28 01:13:20 thorpej Exp $ */ /*- @@ -75,7 +75,6 @@ struct strvaltabent { u_char sv_val; /* ... and the value */ }; -#ifdef __sparc__ /* * This is an entry in a table which describes a set of `exceptions'. * In other words, these are Openprom fields that we either can't @@ -86,7 +85,6 @@ struct extabent { void (*ex_handler)(struct extabent *, struct opiocdesc *, char *); /* handler function for this entry */ }; -#endif /* __sparc__ */ /* Sun 3/4 EEPROM handlers. */ void ee_hwupdate(struct keytabent *, char *); @@ -106,9 +104,7 @@ u_char ee_checksum(u_char *, size_t); void ee_updatechecksums(void); void ee_verifychecksums(void); -#ifdef __sparc__ -/* Sparc Openprom handlers. */ +/* OpenPROM handlers. */ char *op_handler(char *, char *); void op_dump(void); void op_tree(void); -#endif /* __sparc__ */ diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c index fe1319e47c4..0ed2964c875 100644 --- a/usr.sbin/eeprom/main.c +++ b/usr.sbin/eeprom/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.15 2007/09/07 13:54:43 jmc Exp $ */ +/* $OpenBSD: main.c,v 1.16 2007/11/12 20:54:54 kettenis Exp $ */ /* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */ /*- @@ -49,16 +49,16 @@ #include <limits.h> #include <sys/sysctl.h> #include <machine/cpu.h> +#include <machine/eeprom.h> +#endif #include <machine/openpromio.h> -static char *nlistf = NULL; -#endif /* __sparc__ */ - -#include <machine/eeprom.h> - #include "defs.h" +#ifdef __sparc__ +static char *nlistf = NULL; + struct keytabent eekeytab[] = { { "hwupdate", 0x10, ee_hwupdate }, { "memsize", 0x14, ee_num8 }, @@ -94,6 +94,7 @@ struct keytabent eekeytab[] = { { "password", 0, ee_notsupp }, { NULL, 0, ee_notsupp }, }; +#endif static void action(char *); static void dump_prom(void); @@ -121,12 +122,8 @@ main(int argc, char *argv[]) { int ch, do_stdin = 0; char *cp, line[BUFSIZE]; -#ifdef __sparc__ gid_t gid; char *optstring = "cf:ipvN:-"; -#else - char *optstring = "cf:i-"; -#endif /* __sparc__ */ while ((ch = getopt(argc, argv, optstring)) != -1) switch (ch) { @@ -145,7 +142,7 @@ main(int argc, char *argv[]) case 'i': ignore_checksum = 1; break; -#ifdef __sparc__ + case 'p': print_tree = 1; break; @@ -154,11 +151,11 @@ main(int argc, char *argv[]) verbose = 1; break; +#ifdef __sparc__ case 'N': nlistf = optarg; break; - -#endif /* __sparc__ */ +#endif case '?': default: @@ -174,18 +171,20 @@ main(int argc, char *argv[]) err(1, "setresgid"); } if (getcputype() != CPU_SUN4) +#endif /* __sparc__ */ use_openprom = 1; if (print_tree && use_openprom) { op_tree(); exit(0); } -#endif /* __sparc__ */ +#ifdef __sparc__ if (use_openprom == 0) { ee_verifychecksums(); if (fix_checksum || cksumfail) exit(cksumfail); } +#endif if (do_stdin) { while (fgets(line, BUFSIZE, stdin) != NULL) { @@ -210,11 +209,13 @@ main(int argc, char *argv[]) } } +#ifdef __sparc__ if (use_openprom == 0) if (update_checksums) { ++writecount; ee_updatechecksums(); } +#endif exit(eval + cksumfail); } @@ -253,7 +254,6 @@ action(char *line) if ((arg = strrchr(keyword, '=')) != NULL) *arg++ = '\0'; -#ifdef __sparc__ if (use_openprom) { /* * The whole point of the Openprom is that one @@ -264,14 +264,16 @@ action(char *line) if ((cp = op_handler(keyword, arg)) != NULL) warnx("%s", cp); return; - } else -#endif /* __sparc__ */ + } +#ifdef __sparc__ + else for (ktent = eekeytab; ktent->kt_keyword != NULL; ++ktent) { if (strcmp(ktent->kt_keyword, keyword) == 0) { (*ktent->kt_handler)(ktent, arg); return; } } +#endif /* __sparc__ */ warnx("unknown keyword %s", keyword); ++eval; @@ -285,16 +287,17 @@ dump_prom(void) { struct keytabent *ktent; -#ifdef __sparc__ if (use_openprom) { /* * We have a special dump routine for this. */ op_dump(); - } else -#endif /* __sparc__ */ + } +#ifdef __sparc__ + else for (ktent = eekeytab; ktent->kt_keyword != NULL; ++ktent) (*ktent->kt_handler)(ktent, NULL); +#endif /* __sparc__ */ } static void @@ -307,7 +310,7 @@ usage(void) __progname); #else fprintf(stderr, - "usage: %s [-ci] [-f device] [field[=value] ...]\n", + "usage: %s [-cipv] [-f device] [field[=value] ...]\n", __progname); #endif /* __sparc__ */ exit(1); diff --git a/usr.sbin/eeprom/ophandlers.c b/usr.sbin/eeprom/ophandlers.c index 3fb666d7cbb..3e5eb1a75bb 100644 --- a/usr.sbin/eeprom/ophandlers.c +++ b/usr.sbin/eeprom/ophandlers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ophandlers.c,v 1.10 2007/09/04 23:28:26 fgsch Exp $ */ +/* $OpenBSD: ophandlers.c,v 1.11 2007/11/12 20:54:54 kettenis Exp $ */ /* $NetBSD: ophandlers.c,v 1.2 1996/02/28 01:13:30 thorpej Exp $ */ /*- @@ -49,7 +49,6 @@ #include <unistd.h> #include <vis.h> -#include <machine/eeprom.h> #include <machine/openpromio.h> #include "defs.h" diff --git a/usr.sbin/eeprom/optree.c b/usr.sbin/eeprom/optree.c index 5e1419447e6..67ea883e53a 100644 --- a/usr.sbin/eeprom/optree.c +++ b/usr.sbin/eeprom/optree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: optree.c,v 1.2 2007/09/09 14:19:28 fgsch Exp $ */ +/* $OpenBSD: optree.c,v 1.3 2007/11/12 20:54:54 kettenis Exp $ */ /* * Copyright (c) 2007 Federico G. Schwindt <fgsch@openbsd.org> @@ -26,7 +26,6 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <machine/openpromio.h> #include <sys/ioctl.h> #include <err.h> #include <fcntl.h> @@ -34,6 +33,10 @@ #include <string.h> #include <unistd.h> +#include <machine/openpromio.h> + +#include "defs.h" + extern char *path_openprom; static void @@ -93,8 +96,8 @@ op_print(struct opiocdesc *opio, int depth) void op_nodes(int fd, int node, int depth) { - char op_buf[BUFSIZ * 4]; - char op_name[BUFSIZ]; + char op_buf[BUFSIZE * 8]; + char op_name[BUFSIZE]; struct opiocdesc opio; opio.op_nodeid = node; |