This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Oct 13 13:48:56 CEST 2006 - olh@suse.de
|
||||
|
||||
- handle short writes to /dev/nvram, current kernels limit write
|
||||
size to PAGE_SIZE
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon May 15 11:25:31 CEST 2006 - olh@suse.de
|
||||
|
||||
- the kernel ibmvscsis patch was updated to provide the type
|
||||
field again. remove last patch again (173880 - LTC23729)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Apr 29 14:25:10 CEST 2006 - olh@suse.de
|
||||
|
||||
- /sys/bus/vio/drivers/ibmvscsis/30000003/bus0/target0/type was
|
||||
removed from sles10, it was always unused.
|
||||
remove it from vscsisadmin and ibmvscsis.conf man page
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 28 14:40:10 CEST 2006 - olh@suse.de
|
||||
|
||||
- allow bootlist -m normal eth0, no further options required
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Feb 20 16:43:17 CET 2006 - olh@suse.de
|
||||
|
||||
- correct vscsi path detection (#142637)
|
||||
update to powerpc-utils 1.0.0
|
||||
* Added devball target to builds.
|
||||
update to powerpc-utils-papr 1.0.1
|
||||
* Updated usysident with the ability to manipulate SES-controlled LEDs.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Feb 6 15:45:22 CET 2006 - olh@suse.de
|
||||
|
||||
- use show_of_path.sh in ofpathname for scsi (#142637)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 31 18:48:17 CET 2006 - olh@suse.de
|
||||
|
||||
- strip neededforbuild, remove libselinux
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jan 27 11:28:39 CET 2006 - olh@suse.de
|
||||
|
||||
- move lsprop and nvsetenv from util-linux
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jan 23 12:01:00 CET 2006 - olh@suse.de
|
||||
|
||||
- rename to powerpc-utils 0.0.1, includes further fixes
|
||||
(fate #140406 - 144758)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Oct 28 13:17:51 CEST 2005 - olh@suse.de
|
||||
|
||||
- update to version 2.5.3 (130214 - LTC19273)
|
||||
fixes for ofpathname
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 26 14:37:53 CEST 2005 - olh@suse.de
|
||||
|
||||
- add LSB header to ibmvscsis runlevel script
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 26 14:10:47 CEST 2005 - olh@suse.de
|
||||
|
||||
- update to version 2.5.2 (130214 - LTC19273)
|
||||
small fix for rtas_dump
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 19 10:02:11 CEST 2005 - olh@suse.de
|
||||
|
||||
- update to version 2.5, many new cmdline utils
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Oct 18 17:59:52 CEST 2004 - olh@suse.de
|
||||
|
||||
- update to version 1.1 (#47323 - LTC11869)
|
||||
force of the block size to 4k in update_flash;
|
||||
this is required for flasing firmware on power5 systems
|
||||
(the firmware image will be corrupted otherwise)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Jun 13 18:38:08 CEST 2004 - meissner@suse.de
|
||||
|
||||
- Updated to latest IBM requested version. LTC#9266/SUSE#41907
|
||||
- lots of enhancements to nvram, and update_flash.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Dec 14 12:22:18 CET 2003 - olh@suse.de
|
||||
|
||||
- read nvram in small chunks, not at once
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 8 13:02:37 CEST 2003 - olh@suse.de
|
||||
|
||||
- update to current version
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 6 11:05:23 CET 2003 - olh@suse.de
|
||||
|
||||
- inital package version 0.4
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
#
|
||||
# spec file for package powerpc-utils (Version 1.0.0)
|
||||
#
|
||||
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# This file and all modifications and additions to the pristine
|
||||
# package are under the same license as the package itself.
|
||||
#
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
# norootforbuild
|
||||
|
||||
Name: powerpc-utils
|
||||
BuildRequires: librtas
|
||||
Obsoletes: powerpc-utils-papr
|
||||
Obsoletes: ppc64-utils
|
||||
Provides: ppc64-utils
|
||||
Version: 1.0.0
|
||||
Release: 200610131432
|
||||
License: IBM Public License
|
||||
URL: http://powerpc-utils.ozlabs.org/
|
||||
Group: System/Management
|
||||
Summary: Utilities for PowerPC Hardware
|
||||
PreReq: %insserv_prereq %fillup_prereq
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%define papr_version 1.0.1
|
||||
Source0: powerpc-utils-%{version}.tar.gz
|
||||
Source1: powerpc-utils-papr-%{papr_version}.tar.gz
|
||||
Patch0: powerpc-utils-nvsetenv.patch
|
||||
Patch1: powerpc-utils-lsprop.patch
|
||||
Patch2: powerpc-utils.ofpathname.show_of_path.patch
|
||||
Patch3: powerpc-utils.ofpathname.correct-vscsi-scan.patch
|
||||
Patch4: powerpc-utils.bootlist.easy-network-dev.patch
|
||||
Patch5: powerpc-utils.nvram.short-write.patch
|
||||
|
||||
%description
|
||||
IBM PPC64 hardware utilities for accessing NVRAM, flashing firmware,
|
||||
configuring an VSCSI server, other maintenance related utilities.
|
||||
lsprop to dump the /proc/device-tree contents in human readable form.
|
||||
|
||||
|
||||
|
||||
Authors:
|
||||
--------
|
||||
Nathan Fontenot <nfont@austin.ibm.com>
|
||||
Michael Strosaker <strosake@austin.ibm.com>
|
||||
|
||||
%prep
|
||||
%setup -q -a 1
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
cd powerpc-utils-papr-%{papr_version}
|
||||
|
||||
%build
|
||||
make CFLAGS="$RPM_OPT_FLAGS" %{?jobs:-j%jobs}
|
||||
cd powerpc-utils-papr-%{papr_version}
|
||||
make CFLAGS="$RPM_OPT_FLAGS" %{?jobs:-j%jobs}
|
||||
cd ..
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install \
|
||||
DESTDIR=$RPM_BUILD_ROOT \
|
||||
rasdir=/usr/sbin \
|
||||
mandir=%{_mandir}
|
||||
mkdir $RPM_BUILD_ROOT/sbin
|
||||
mv $RPM_BUILD_ROOT/usr/sbin/{lsprop,nvsetenv} $RPM_BUILD_ROOT/sbin
|
||||
cd powerpc-utils-papr-%{papr_version}
|
||||
make install \
|
||||
DESTDIR=$RPM_BUILD_ROOT \
|
||||
rasdir=/usr/sbin \
|
||||
mandir=%{_mandir}
|
||||
mv README ../README.papr
|
||||
cd ..
|
||||
rm -rf $RPM_BUILD_ROOT/usr/share/doc/packages
|
||||
|
||||
%files
|
||||
%defattr(444, root, root,555)
|
||||
%doc README README.papr COPYRIGHT
|
||||
%{_mandir}/man*/*
|
||||
%attr (755,root,root) /*bin/*
|
||||
%attr (755,root,root) /usr/*bin/*
|
||||
%config %attr (755,root,root) /etc/init.d/ibmvscsis.sh
|
||||
|
||||
%changelog -n powerpc-utils
|
||||
* Fri Oct 13 2006 - olh@suse.de
|
||||
- handle short writes to /dev/nvram, current kernels limit write
|
||||
size to PAGE_SIZE
|
||||
* Mon May 15 2006 - olh@suse.de
|
||||
- the kernel ibmvscsis patch was updated to provide the type
|
||||
field again. remove last patch again (173880 - LTC23729)
|
||||
* Sat Apr 29 2006 - olh@suse.de
|
||||
- /sys/bus/vio/drivers/ibmvscsis/30000003/bus0/target0/type was
|
||||
removed from sles10, it was always unused.
|
||||
remove it from vscsisadmin and ibmvscsis.conf man page
|
||||
* Tue Mar 28 2006 - olh@suse.de
|
||||
- allow bootlist -m normal eth0, no further options required
|
||||
* Mon Feb 20 2006 - olh@suse.de
|
||||
- correct vscsi path detection (#142637)
|
||||
update to powerpc-utils 1.0.0
|
||||
* Added devball target to builds.
|
||||
update to powerpc-utils-papr 1.0.1
|
||||
* Updated usysident with the ability to manipulate SES-controlled LEDs.
|
||||
* Mon Feb 06 2006 - olh@suse.de
|
||||
- use show_of_path.sh in ofpathname for scsi (#142637)
|
||||
* Tue Jan 31 2006 - olh@suse.de
|
||||
- strip neededforbuild, remove libselinux
|
||||
* Fri Jan 27 2006 - olh@suse.de
|
||||
- move lsprop and nvsetenv from util-linux
|
||||
* Mon Jan 23 2006 - olh@suse.de
|
||||
- rename to powerpc-utils 0.0.1, includes further fixes
|
||||
(fate #140406 - 144758)
|
||||
* Fri Oct 28 2005 - olh@suse.de
|
||||
- update to version 2.5.3 (130214 - LTC19273)
|
||||
fixes for ofpathname
|
||||
* Wed Oct 26 2005 - olh@suse.de
|
||||
- add LSB header to ibmvscsis runlevel script
|
||||
* Wed Oct 26 2005 - olh@suse.de
|
||||
- update to version 2.5.2 (130214 - LTC19273)
|
||||
small fix for rtas_dump
|
||||
* Wed Oct 19 2005 - olh@suse.de
|
||||
- update to version 2.5, many new cmdline utils
|
||||
* Mon Oct 18 2004 - olh@suse.de
|
||||
- update to version 1.1 (#47323 - LTC11869)
|
||||
force of the block size to 4k in update_flash;
|
||||
this is required for flasing firmware on power5 systems
|
||||
(the firmware image will be corrupted otherwise)
|
||||
* Sun Jun 13 2004 - meissner@suse.de
|
||||
- Updated to latest IBM requested version. LTC#9266/SUSE#41907
|
||||
- lots of enhancements to nvram, and update_flash.
|
||||
* Sun Dec 14 2003 - olh@suse.de
|
||||
- read nvram in small chunks, not at once
|
||||
* Mon Sep 08 2003 - olh@suse.de
|
||||
- update to current version
|
||||
* Thu Feb 06 2003 - olh@suse.de
|
||||
- inital package version 0.4
|
||||
@@ -0,0 +1,24 @@
|
||||
*.changes merge=merge-changes
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
@@ -0,0 +1,4 @@
|
||||
*.obscpio
|
||||
*.osc
|
||||
_build.*
|
||||
.pbuild
|
||||
@@ -0,0 +1,2 @@
|
||||
#! /bin/sh
|
||||
env -i - TZ=GMT date +%Y%m%d%H%M
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,232 @@
|
||||
cmds/Makefile | 5 +
|
||||
cmds/lsprop.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 205 insertions(+), 1 deletion(-)
|
||||
|
||||
Index: powerpc-utils-0.0.1/cmds/lsprop.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ powerpc-utils-0.0.1/cmds/lsprop.c
|
||||
@@ -0,0 +1,201 @@
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <unistd.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <dirent.h>
|
||||
+
|
||||
+static int recurse = 0;
|
||||
+static int maxbytes = 64 * 1024;
|
||||
+static unsigned char *buf;
|
||||
+
|
||||
+static void lsprop(FILE * f, char *name)
|
||||
+{
|
||||
+ int n, nw, npl, i, j;
|
||||
+
|
||||
+ n = fread(buf, 1, maxbytes, f);
|
||||
+ if (n < 0) {
|
||||
+ printf("%s: read error\n", name);
|
||||
+ return;
|
||||
+ }
|
||||
+ printf("%-16s", name);
|
||||
+ for (i = 0; i < n; ++i)
|
||||
+ if (buf[i] >= 0x7f || (buf[i] < 0x20 && buf[i] != '\r' && buf[i] != '\n' && buf[i] != '\t' && buf[i] != 0))
|
||||
+ break;
|
||||
+ if (i == n && n != 0 && (n == 1 || buf[0] != 0) && buf[n - 1] == 0) {
|
||||
+ printf(" \"");
|
||||
+ for (i = 0; i < n - 1; ++i)
|
||||
+ if (buf[i] == 0)
|
||||
+ printf("\"\n\t\t \"");
|
||||
+ else if (buf[i] == '\r' || buf[i] == '\n')
|
||||
+ printf("\n\t\t ");
|
||||
+ else
|
||||
+ putchar(buf[i]);
|
||||
+ putchar('"');
|
||||
+ } else if ((n & 3) == 0) {
|
||||
+ nw = n >> 2;
|
||||
+ if (nw == 1) {
|
||||
+ i = *(int *)buf;
|
||||
+ printf(" %.8x", i);
|
||||
+ if (i > -0x10000 && !(i >= 0 && i <= 9))
|
||||
+ printf(" (%d)", i);
|
||||
+ } else {
|
||||
+ if ((nw % 6) == 0)
|
||||
+ npl = 6;
|
||||
+ else if ((nw % 5) == 0)
|
||||
+ npl = 5;
|
||||
+ else
|
||||
+ npl = 4;
|
||||
+ for (i = 0; i < nw; i += npl) {
|
||||
+ if (i != 0)
|
||||
+ printf("\n\t\t");
|
||||
+ for (j = 0; j < npl && i + j < nw; ++j)
|
||||
+ printf(" %.8x", ((unsigned int *)buf)[i + j]);
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (i = 0; i < n; i += 16) {
|
||||
+ if (i != 0)
|
||||
+ printf("\n\t\t");
|
||||
+ for (j = 0; j < 16 && i + j < n; ++j)
|
||||
+ printf(" %.2x", buf[i + j]);
|
||||
+ for (; j < 16; ++j)
|
||||
+ printf(" ");
|
||||
+ for (j = 0; j < 16 && i + j < n; ++j)
|
||||
+ if (buf[i + j] > 0x20 && buf[i + j] <= 0x7e)
|
||||
+ putchar(buf[i + j]);
|
||||
+ else
|
||||
+ putchar('.');
|
||||
+ }
|
||||
+ }
|
||||
+ printf("\n");
|
||||
+ if (n == maxbytes) {
|
||||
+ while ((i = fread(buf, 1, maxbytes, f)) > 0)
|
||||
+ n += i;
|
||||
+ if (n > maxbytes)
|
||||
+ printf("\t\t [%d bytes total]\n", n);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void lsdir(char *name)
|
||||
+{
|
||||
+ DIR *d;
|
||||
+ struct dirent *de;
|
||||
+ char *p, *q;
|
||||
+ struct stat sb;
|
||||
+ FILE *f;
|
||||
+ int np = 0;
|
||||
+
|
||||
+ d = opendir(name);
|
||||
+ if (d == NULL) {
|
||||
+ perror(name);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ p = malloc(strlen(name) + 520);
|
||||
+ if (p == 0) {
|
||||
+ fprintf(stderr, "%s: virtual memory exhausted\n", name);
|
||||
+ closedir(d);
|
||||
+ return;
|
||||
+ }
|
||||
+ strcpy(p, name);
|
||||
+ q = p + strlen(p);
|
||||
+ while (q > p && q[-1] == '/')
|
||||
+ --q;
|
||||
+ if (q == p + 1 && p[0] == '.')
|
||||
+ q = p;
|
||||
+ else
|
||||
+ *q++ = '/';
|
||||
+
|
||||
+ while ((de = readdir(d)) != NULL) {
|
||||
+ if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
|
||||
+ continue;
|
||||
+ strcpy(q, de->d_name);
|
||||
+ if (stat(p, &sb) < 0) {
|
||||
+ perror(p);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (S_ISREG(sb.st_mode)) {
|
||||
+ f = fopen(p, "r");
|
||||
+ if (f == NULL) {
|
||||
+ perror(p);
|
||||
+ } else {
|
||||
+ lsprop(f, de->d_name);
|
||||
+ fclose(f);
|
||||
+ ++np;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ rewinddir(d);
|
||||
+ while ((de = readdir(d)) != NULL) {
|
||||
+ if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
|
||||
+ continue;
|
||||
+ strcpy(q, de->d_name);
|
||||
+ if (lstat(p, &sb) < 0) {
|
||||
+ perror(p);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if ((S_ISDIR(sb.st_mode)) && recurse) {
|
||||
+ if (np)
|
||||
+ printf("\n");
|
||||
+ printf("%s:\n", p);
|
||||
+ lsdir(p);
|
||||
+ ++np;
|
||||
+ }
|
||||
+ }
|
||||
+ free(p);
|
||||
+ closedir(d);
|
||||
+}
|
||||
+
|
||||
+int main(int ac, char **av)
|
||||
+{
|
||||
+ FILE *f;
|
||||
+ int i;
|
||||
+ struct stat sb;
|
||||
+ char *endp;
|
||||
+
|
||||
+ while ((i = getopt(ac, av, "Rm:")) != EOF) {
|
||||
+ switch (i) {
|
||||
+ case 'R':
|
||||
+ recurse = 1;
|
||||
+ break;
|
||||
+ case 'm':
|
||||
+ maxbytes = strtol(optarg, &endp, 0);
|
||||
+ if (endp == optarg) {
|
||||
+ fprintf(stderr, "%s: bad argument (%s) to -m option\n", av[0], optarg);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ maxbytes = (maxbytes + 15) & -16;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ buf = malloc(maxbytes);
|
||||
+ if (buf == 0) {
|
||||
+ fprintf(stderr, "%s: virtual memory exhausted\n", av[0]);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (optind == ac)
|
||||
+ lsdir(".");
|
||||
+ else
|
||||
+ for (i = optind; i < ac; ++i) {
|
||||
+ if (stat(av[i], &sb) < 0) {
|
||||
+ perror(av[i]);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (S_ISREG(sb.st_mode)) {
|
||||
+ f = fopen(av[i], "r");
|
||||
+ if (f == NULL) {
|
||||
+ perror(av[i]);
|
||||
+ continue;
|
||||
+ }
|
||||
+ lsprop(f, av[i]);
|
||||
+ fclose(f);
|
||||
+ } else if (S_ISDIR(sb.st_mode)) {
|
||||
+ lsdir(av[i]);
|
||||
+ }
|
||||
+ }
|
||||
+ exit(0);
|
||||
+}
|
||||
Index: powerpc-utils-0.0.1/cmds/Makefile
|
||||
===================================================================
|
||||
--- powerpc-utils-0.0.1.orig/cmds/Makefile
|
||||
+++ powerpc-utils-0.0.1/cmds/Makefile
|
||||
@@ -4,13 +4,16 @@
|
||||
|
||||
include ../rules.mk
|
||||
|
||||
-CMDS = nvram nvsetenv
|
||||
+CMDS = nvram lsprop nvsetenv
|
||||
|
||||
all: $(CMDS)
|
||||
|
||||
nvram: nvram.o
|
||||
@echo "LD $(WORK_DIR)/$@"
|
||||
@$(CC) -o $@ $^ -ldl
|
||||
+lsprop: lsprop.o
|
||||
+ @echo "LD $(WORK_DIR)/$@"
|
||||
+ @$(CC) -o $@ $^ -ldl
|
||||
nvsetenv: nvsetenv.o
|
||||
@echo "LD $(WORK_DIR)/$@"
|
||||
@$(CC) -o $@ $^ -ldl
|
||||
@@ -0,0 +1,827 @@
|
||||
cmds/Makefile | 5
|
||||
cmds/nvsetenv.c | 558 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
doc/Makefile | 2
|
||||
doc/nvsetenv.8 | 218 +++++++++++++++++++++
|
||||
4 files changed, 781 insertions(+), 2 deletions(-)
|
||||
|
||||
Index: powerpc-utils-0.0.1/cmds/nvsetenv.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ powerpc-utils-0.0.1/cmds/nvsetenv.c
|
||||
@@ -0,0 +1,558 @@
|
||||
+/* nvsetnv.c
|
||||
+
|
||||
+ used to set the Envenrioment variables in power macs NVram.
|
||||
+ Decides via /proc/cpuinfo which type of machine is used.
|
||||
+
|
||||
+ Copyright (C) 1996-1998 by Paul Mackerras.
|
||||
+ nwcode: Copyright (C) 2000 by Klaus Halfmann
|
||||
+
|
||||
+ see README for details
|
||||
+*/
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#define __USE_GNU 1 // need strnlen
|
||||
+#include <string.h>
|
||||
+#include <unistd.h>
|
||||
+#include <fcntl.h>
|
||||
+
|
||||
+#define NVSTART 0x1800 // Start of ???
|
||||
+#define NVSIZE 0x800 // Size of of the NVRam
|
||||
+#define MXSTRING 128
|
||||
+#define N_NVVARS (int)(sizeof(nvvars) / sizeof(nvvars[0]))
|
||||
+#define NVMAGIC 0x1275
|
||||
+
|
||||
+static int nvstr_used;
|
||||
+static char nvstrbuf[NVSIZE];
|
||||
+
|
||||
+struct nvram {
|
||||
+ unsigned short magic; /* 0x1275 */
|
||||
+ unsigned char char2;
|
||||
+ unsigned char char3;
|
||||
+ unsigned short cksum;
|
||||
+ unsigned short end_vals;
|
||||
+ unsigned short start_strs;
|
||||
+ unsigned short word5;
|
||||
+ unsigned long bits;
|
||||
+ unsigned long vals[1];
|
||||
+};
|
||||
+
|
||||
+typedef union {
|
||||
+ struct nvram nv;
|
||||
+ char c[NVSIZE];
|
||||
+ unsigned short s[NVSIZE / 2];
|
||||
+} nvbuftype;
|
||||
+
|
||||
+nvbuftype nvbuf;
|
||||
+
|
||||
+enum nvtype {
|
||||
+ boolean,
|
||||
+ word,
|
||||
+ string
|
||||
+};
|
||||
+
|
||||
+struct nvvar {
|
||||
+ const char *name;
|
||||
+ enum nvtype type;
|
||||
+} nvvars[] = {
|
||||
+ {
|
||||
+ "little-endian?", boolean}, {
|
||||
+ "real-mode?", boolean}, {
|
||||
+ "auto-boot?", boolean}, {
|
||||
+ "diag-switch?", boolean}, {
|
||||
+ "fcode-debug?", boolean}, {
|
||||
+ "oem-banner?", boolean}, {
|
||||
+ "oem-logo?", boolean}, {
|
||||
+ "use-nvramrc?", boolean}, {
|
||||
+ "real-base", word}, {
|
||||
+ "real-size", word}, {
|
||||
+ "virt-base", word}, {
|
||||
+ "virt-size", word}, {
|
||||
+ "load-base", word}, {
|
||||
+ "pci-probe-list", word}, {
|
||||
+ "screen-#columns", word}, {
|
||||
+ "screen-#rows", word}, {
|
||||
+ "selftest-#megs", word}, {
|
||||
+ "boot-device", string}, {
|
||||
+ "boot-file", string}, {
|
||||
+ "diag-device", string}, {
|
||||
+ "diag-file", string}, {
|
||||
+ "input-device", string}, {
|
||||
+ "output-device", string}, {
|
||||
+ "oem-banner", string}, {
|
||||
+ "oem-logo", string}, {
|
||||
+ "nvramrc", string}, {
|
||||
+"boot-command", string},};
|
||||
+
|
||||
+ // Calculated number of variables
|
||||
+#define N_NVVARS (int)(sizeof(nvvars) / sizeof(nvvars[0]))
|
||||
+
|
||||
+union nvval {
|
||||
+ unsigned long word_val;
|
||||
+ char *str_val;
|
||||
+} nvvals[32];
|
||||
+
|
||||
+// #define MXSTRING 128:
|
||||
+// #define N_NVVARS (int)(sizeof(nvvars) / sizeof(nvvars[0]))
|
||||
+// #define NVMAGIC 0x1275
|
||||
+
|
||||
+/* CHRP NVRAM header */
|
||||
+typedef struct {
|
||||
+ unsigned char signature;
|
||||
+ unsigned char cksum;
|
||||
+ unsigned short len;
|
||||
+ char name[12];
|
||||
+ // unsigned char data[0];
|
||||
+} chrp_header;
|
||||
+
|
||||
+/* Check in proc/cpuinfo if this is a new world machine */
|
||||
+
|
||||
+/* "pmac-generation" is only in /proc/cpuinfo >= 2.2.16.
|
||||
+ * Check /proc/device-tree/compatible instead for bw compatibility - Hollis
|
||||
+ */
|
||||
+static int checkNewWorld(void)
|
||||
+{
|
||||
+ FILE *cpuf = fopen("/proc/device-tree/compatible", "r");
|
||||
+ char buf[256], *ret;
|
||||
+ if (!cpuf) {
|
||||
+ perror("Couldn't open /proc/device-tree/compatible");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ ret = fgets(buf, 255, cpuf);
|
||||
+ if (!ret) {
|
||||
+ perror("fgets");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ fclose(cpuf);
|
||||
+
|
||||
+ if (!strncmp(buf, "AAPL", 4))
|
||||
+ // saw AAPL, must be Old World
|
||||
+ return 0;
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/* seek NVRAM until common (OF) part
|
||||
+ return the lenght of the part in case of sucess,
|
||||
+ 0 otherwise.
|
||||
+ chrph is set to the value of the "coommon" blocek eventually found
|
||||
+ *nvstart is set to the seekpoint where common block starts.
|
||||
+*/
|
||||
+
|
||||
+static int nvscan(int nvfd, chrp_header * chrph, int *nvstart)
|
||||
+{
|
||||
+ int start = 0;
|
||||
+
|
||||
+ while (read(nvfd, chrph, sizeof(chrp_header)) == sizeof(chrp_header)) {
|
||||
+ int size = chrph->len * 0x10 - sizeof(chrp_header);
|
||||
+ if (!strncmp(chrph->name, "common", 7)) {
|
||||
+ *nvstart = start;
|
||||
+ return size; // seeked upto start
|
||||
+ }
|
||||
+ if (lseek(nvfd, size, SEEK_CUR) < 0)
|
||||
+ break;
|
||||
+ start += size + sizeof(chrp_header);
|
||||
+ }
|
||||
+ fprintf(stderr, "No common Block found\n");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+}
|
||||
+
|
||||
+static char *nvload(int nvfd, int nvsize)
|
||||
+{
|
||||
+ char *nvbuf = malloc(nvsize);
|
||||
+ ssize_t r, count = 0;
|
||||
+
|
||||
+ if (!nvbuf) {
|
||||
+ perror("Error allocating buffer");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ do {
|
||||
+ r = read(nvfd, nvbuf + count, nvsize - count);
|
||||
+ if (r < 0) {
|
||||
+ perror("Error reading /dev/nvram");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ count += r;
|
||||
+ } while (count < nvsize && r);
|
||||
+
|
||||
+ return nvbuf;
|
||||
+}
|
||||
+
|
||||
+static void print_vars(char *nvbuf, int nvsize)
|
||||
+{
|
||||
+ int i = 0;
|
||||
+
|
||||
+ while (i < nvsize) {
|
||||
+ int size = strnlen(nvbuf, nvsize);
|
||||
+ if (size == 0)
|
||||
+ break;
|
||||
+ printf("%s\n", nvbuf);
|
||||
+ nvbuf += (size + 1); // count 0-byte, too
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* move memory around to insert the value.
|
||||
+ *
|
||||
+ * @param nvbufend byte AFTER the end of the buffer
|
||||
+ * @param varsize length of the variable name
|
||||
+ * @param buf byte where varaible NAME starts
|
||||
+ * @param newval new value to replace old one
|
||||
+ * @param foundsize lenght of varible + '=' + value
|
||||
+ * @param equalpos position relative to buf where '=' was found
|
||||
+ */
|
||||
+static void insert_val(char *nvbufend, int varsize, char *buf, char *newval, int foundsize, int equalpos)
|
||||
+{
|
||||
+ int oldlen = foundsize - equalpos - 1; // account for the '='
|
||||
+ int newlen = strlen(newval);
|
||||
+ char *valpos = buf + varsize + 1;
|
||||
+ int delta = newlen - oldlen;
|
||||
+
|
||||
+ if (delta > 0) // expand mem
|
||||
+ memmove(valpos + newlen, valpos + oldlen, (nvbufend - valpos - newlen));
|
||||
+ else if (delta < 0) // shrink mem
|
||||
+ {
|
||||
+ memmove(valpos + newlen, valpos + oldlen, (nvbufend - valpos - oldlen));
|
||||
+ memset(nvbufend + delta, 0, -delta);
|
||||
+ }
|
||||
+ strncpy(valpos, newval, newlen);
|
||||
+}
|
||||
+
|
||||
+/* return position where variable is found,
|
||||
+ * newval may be null.
|
||||
+ */
|
||||
+
|
||||
+static char *set_var(char *nvbuf, int nvsize, char *varname, char *newval)
|
||||
+{
|
||||
+ int i = 0;
|
||||
+ int varsize = strlen(varname);
|
||||
+ int equalpos;
|
||||
+ while (i < nvsize) {
|
||||
+ char *buf = &nvbuf[i];
|
||||
+ int foundsize = strnlen(buf, nvsize - i);
|
||||
+ if (foundsize == 0)
|
||||
+ break;
|
||||
+ equalpos = (int)(strchr(buf, '=') - buf);
|
||||
+ if (equalpos == varsize && !strncmp(buf, varname, equalpos)) {
|
||||
+ if (newval) // set the value
|
||||
+ insert_val(nvbuf + nvsize, varsize, buf, newval, foundsize, equalpos);
|
||||
+ return buf;
|
||||
+ }
|
||||
+ i += foundsize + 1; // count 0-byte, too
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void print_var(char *nvbuf, int nvsize, char *varname)
|
||||
+{
|
||||
+ char *buf = set_var(nvbuf, nvsize, varname, NULL);
|
||||
+ if (buf)
|
||||
+ printf("%s\n", buf);
|
||||
+}
|
||||
+
|
||||
+#if 0
|
||||
+/* This fucntion is not used here, it is left
|
||||
+ here for the curious */
|
||||
+
|
||||
+static unsigned short chrp_checksum(chrp_header * hdr, char *nvbuf, int nvsize)
|
||||
+{
|
||||
+ unsigned char *ptr = (unsigned char *)&hdr->len;
|
||||
+ unsigned char *end = ptr + sizeof(chrp_header);
|
||||
+ unsigned short sum = hdr->signature;
|
||||
+ // this in fact skips the checksum
|
||||
+ for (; ptr < end; ptr++)
|
||||
+ sum += *ptr;
|
||||
+ while (sum > 0xFF)
|
||||
+ sum = (sum & 0xFF) + (sum >> 8);
|
||||
+ return sum;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static void nvstore(int nvfd, char *nvbuf, int nvstart, int nvsize)
|
||||
+{
|
||||
+ // mmh, the checksum is calculated for the header only
|
||||
+ // since we did not modify the header we can just ignore it.
|
||||
+ size_t count = 0;
|
||||
+ off_t w, seek = nvstart + sizeof(chrp_header);
|
||||
+ w = lseek(nvfd, seek, SEEK_SET);
|
||||
+ if (w != seek) {
|
||||
+ fprintf(stderr, "Error seeking /dev/nvram\n");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ do {
|
||||
+ w = write(nvfd, nvbuf + count, nvsize - count);
|
||||
+ if (w < 0) {
|
||||
+ perror("Error writing /dev/nvram");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ count += w;
|
||||
+ } while (count < (size_t)nvsize);
|
||||
+}
|
||||
+
|
||||
+/* print / set the New World NVRAM */
|
||||
+
|
||||
+static void nvNew(int ac, char **av, int nvfd)
|
||||
+{
|
||||
+ int nvsize, nvstart;
|
||||
+ chrp_header chrph;
|
||||
+ char *nvbuf;
|
||||
+
|
||||
+ nvsize = nvscan(nvfd, &chrph, &nvstart);
|
||||
+ nvbuf = nvload(nvfd, nvsize);
|
||||
+
|
||||
+ switch (ac) {
|
||||
+ case 1:
|
||||
+ print_vars(nvbuf, nvsize);
|
||||
+ break;
|
||||
+
|
||||
+ case 2:
|
||||
+ print_var(nvbuf, nvsize, av[1]);
|
||||
+ break;
|
||||
+
|
||||
+ case 3:
|
||||
+ set_var(nvbuf, nvsize, av[1], av[2]);
|
||||
+ nvstore(nvfd, nvbuf, nvstart, nvsize);
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int nvcsum(void)
|
||||
+{
|
||||
+ int i;
|
||||
+ unsigned c;
|
||||
+
|
||||
+ c = 0;
|
||||
+ for (i = 0; i < NVSIZE / 2; ++i)
|
||||
+ c += nvbuf.s[i];
|
||||
+ c = (c & 0xffff) + (c >> 16);
|
||||
+ c += (c >> 16);
|
||||
+ return c & 0xffff;
|
||||
+}
|
||||
+
|
||||
+static void nvloadOld(int nvfd)
|
||||
+{
|
||||
+ int s;
|
||||
+ ssize_t r, count = 0;
|
||||
+ char *buf = (char *)&nvbuf;
|
||||
+
|
||||
+ if ((off_t)-1 == lseek(nvfd, NVSTART, 0)) {
|
||||
+ perror("Error seeking /dev/nvram");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ do {
|
||||
+ r = read(nvfd, buf + count, NVSIZE - count);
|
||||
+ if (r < 0) {
|
||||
+ perror("Error reading /dev/nvram");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ count += r;
|
||||
+ } while (count < NVSIZE && r);
|
||||
+
|
||||
+ if (nvbuf.nv.magic != NVMAGIC)
|
||||
+ fprintf(stderr, "Warning: Bad magic number %x\n", nvbuf.nv.magic);
|
||||
+ s = nvcsum();
|
||||
+ if (s != 0xffff)
|
||||
+ fprintf(stderr, "Warning: checksum error (%x) on nvram\n", s ^ 0xffff);
|
||||
+
|
||||
+}
|
||||
+
|
||||
+static void nvstoreOld(int nvfd)
|
||||
+{
|
||||
+ char *p = (char *)&nvbuf;
|
||||
+ size_t count = 0;
|
||||
+ off_t w;
|
||||
+
|
||||
+ if ((off_t)-1 == lseek(nvfd, NVSTART, 0)) {
|
||||
+ perror("Error seeking /dev/nvram");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ do {
|
||||
+ w = write(nvfd, p + count, NVSIZE - count);
|
||||
+ if (w < 0) {
|
||||
+ perror("Error writing /dev/nvram");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ count += w;
|
||||
+ } while (count < NVSIZE);
|
||||
+}
|
||||
+
|
||||
+static void nvunpackOld(void)
|
||||
+{
|
||||
+ int i;
|
||||
+ unsigned long bmask;
|
||||
+ int vi, off, len;
|
||||
+
|
||||
+ nvstr_used = 0;
|
||||
+ bmask = 0x80000000;
|
||||
+ vi = 0;
|
||||
+ for (i = 0; i < N_NVVARS; ++i) {
|
||||
+ switch (nvvars[i].type) {
|
||||
+ case boolean:
|
||||
+ nvvals[i].word_val = (nvbuf.nv.bits & bmask) ? 1 : 0;
|
||||
+ bmask >>= 1;
|
||||
+ break;
|
||||
+ case word:
|
||||
+ nvvals[i].word_val = nvbuf.nv.vals[vi++];
|
||||
+ break;
|
||||
+ case string:
|
||||
+ off = nvbuf.nv.vals[vi] >> 16;
|
||||
+ len = nvbuf.nv.vals[vi++] & 0xffff;
|
||||
+ nvvals[i].str_val = nvstrbuf + nvstr_used;
|
||||
+ memcpy(nvvals[i].str_val, nvbuf.c + off - NVSTART, (size_t) len);
|
||||
+ nvvals[i].str_val[len] = (char)0;
|
||||
+ nvstr_used += len + 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void nvpackOld(void)
|
||||
+{
|
||||
+ int i, vi;
|
||||
+ size_t off, len;
|
||||
+ unsigned long bmask;
|
||||
+
|
||||
+ bmask = 0x80000000;
|
||||
+ vi = 0;
|
||||
+ off = NVSIZE;
|
||||
+ nvbuf.nv.bits = 0;
|
||||
+ for (i = 0; i < N_NVVARS; ++i) {
|
||||
+ switch (nvvars[i].type) {
|
||||
+ case boolean:
|
||||
+ if (nvvals[i].word_val != 0)
|
||||
+ nvbuf.nv.bits |= bmask;
|
||||
+ bmask >>= 1;
|
||||
+ break;
|
||||
+ case word:
|
||||
+ nvbuf.nv.vals[vi++] = nvvals[i].word_val;
|
||||
+ break;
|
||||
+ case string:
|
||||
+ len = strlen(nvvals[i].str_val);
|
||||
+ off -= len;
|
||||
+ memcpy(nvbuf.c + off, nvvals[i].str_val, len);
|
||||
+ nvbuf.nv.vals[vi++] = ((off + NVSTART) << 16) + len;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ nvbuf.nv.magic = 0x1275;
|
||||
+ nvbuf.nv.cksum = 0;
|
||||
+ nvbuf.nv.end_vals = NVSTART + (unsigned)&nvbuf.nv.vals[vi]
|
||||
+ - (unsigned)&nvbuf;
|
||||
+ nvbuf.nv.start_strs = (unsigned short int)(off + NVSTART);
|
||||
+ memset(&nvbuf.c[nvbuf.nv.end_vals - NVSTART], 0, (size_t) (nvbuf.nv.start_strs - nvbuf.nv.end_vals));
|
||||
+ nvbuf.nv.cksum = (unsigned short int)(~nvcsum());
|
||||
+}
|
||||
+
|
||||
+static void print_varOld(int i, int indent)
|
||||
+{
|
||||
+ char *p;
|
||||
+
|
||||
+ switch (nvvars[i].type) {
|
||||
+ case boolean:
|
||||
+ printf("%s", nvvals[i].word_val != 0 ? "true" : "false");
|
||||
+ break;
|
||||
+ case word:
|
||||
+ printf("0x%lx", nvvals[i].word_val);
|
||||
+ break;
|
||||
+ case string:
|
||||
+ for (p = nvvals[i].str_val; *p; ++p)
|
||||
+ if (*p != '\r')
|
||||
+ putchar(*p);
|
||||
+ else
|
||||
+ printf("\n%*s", indent, "");
|
||||
+ break;
|
||||
+ }
|
||||
+ printf("\n");
|
||||
+}
|
||||
+
|
||||
+static void parse_val(int i, char *str)
|
||||
+{
|
||||
+ char *endp;
|
||||
+
|
||||
+ switch (nvvars[i].type) {
|
||||
+ case boolean:
|
||||
+ if (strcmp(str, "true") == 0)
|
||||
+ nvvals[i].word_val = 1;
|
||||
+ else if (strcmp(str, "false") == 0)
|
||||
+ nvvals[i].word_val = 0;
|
||||
+ else {
|
||||
+ fprintf(stderr, "bad boolean value '%s' for %s\n", str, nvvars[i].name);
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ break;
|
||||
+ case word:
|
||||
+ nvvals[i].word_val = strtoul(str, &endp, 16);
|
||||
+ if (str == endp) {
|
||||
+ fprintf(stderr, "bad hexadecimal value '%s' for %s\n", str, nvvars[i].name);
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ break;
|
||||
+ case string:
|
||||
+ nvvals[i].str_val = str;
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void nvOld(int ac, char **av, int i, int nvfd)
|
||||
+{
|
||||
+ nvloadOld(nvfd);
|
||||
+ nvunpackOld();
|
||||
+
|
||||
+ switch (ac) {
|
||||
+ case 1:
|
||||
+ for (i = 0; i < N_NVVARS; ++i) {
|
||||
+ printf("%-16s", nvvars[i].name);
|
||||
+ print_varOld(i, 16);
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ case 2:
|
||||
+ print_varOld(i, 0);
|
||||
+ break;
|
||||
+
|
||||
+ case 3:
|
||||
+ parse_val(i, av[2]);
|
||||
+ nvpackOld();
|
||||
+ nvstoreOld(nvfd);
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int main(int ac, char **av)
|
||||
+{
|
||||
+ int i = 0, nvfd, newWorld;
|
||||
+
|
||||
+ if (ac > 3) {
|
||||
+ fprintf(stderr, "Usage: %s [variable [value]]\n", av[0]);
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ newWorld = checkNewWorld();
|
||||
+
|
||||
+ if (!newWorld && ac >= 2) {
|
||||
+ for (i = 0; i < N_NVVARS; ++i)
|
||||
+ if (strcmp(av[1], nvvars[i].name) == 0)
|
||||
+ break;
|
||||
+ if (i >= N_NVVARS) {
|
||||
+ fprintf(stderr, "%s: no variable called '%s'\n", av[1], av[1]);
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ nvfd = open("/dev/nvram", ac <= 2 ? O_RDONLY : O_RDWR);
|
||||
+ if (nvfd < 0) {
|
||||
+ perror("Couldn't open /dev/nvram");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ if (newWorld)
|
||||
+ nvNew(ac, av, nvfd);
|
||||
+ else
|
||||
+ nvOld(ac, av, i, nvfd);
|
||||
+
|
||||
+ close(nvfd);
|
||||
+ exit(EXIT_SUCCESS);
|
||||
+}
|
||||
Index: powerpc-utils-0.0.1/cmds/Makefile
|
||||
===================================================================
|
||||
--- powerpc-utils-0.0.1.orig/cmds/Makefile
|
||||
+++ powerpc-utils-0.0.1/cmds/Makefile
|
||||
@@ -4,13 +4,16 @@
|
||||
|
||||
include ../rules.mk
|
||||
|
||||
-CMDS = nvram
|
||||
+CMDS = nvram nvsetenv
|
||||
|
||||
all: $(CMDS)
|
||||
|
||||
nvram: nvram.o
|
||||
@echo "LD $(WORK_DIR)/$@"
|
||||
@$(CC) -o $@ $^ -ldl
|
||||
+nvsetenv: nvsetenv.o
|
||||
+ @echo "LD $(WORK_DIR)/$@"
|
||||
+ @$(CC) -o $@ $^ -ldl
|
||||
|
||||
install: all
|
||||
@$(call install_sbin,$(CMDS),$(DESTDIR))
|
||||
Index: powerpc-utils-0.0.1/doc/nvsetenv.8
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ powerpc-utils-0.0.1/doc/nvsetenv.8
|
||||
@@ -0,0 +1,218 @@
|
||||
+.if n .ds Q \&"
|
||||
+.if t .ds Q ``
|
||||
+.if n .ds U \&"
|
||||
+.if t .ds U ''
|
||||
+.TH "NVSETENV" 8
|
||||
+.tr \&
|
||||
+.nr bi 0
|
||||
+.nr ll 0
|
||||
+.nr el 0
|
||||
+.de DS
|
||||
+..
|
||||
+.de DE
|
||||
+..
|
||||
+.de Pp
|
||||
+.ie \\n(ll>0 \{\
|
||||
+.ie \\n(bi=1 \{\
|
||||
+.nr bi 0
|
||||
+.if \\n(t\\n(ll=0 \{.IP \\(bu\}
|
||||
+.if \\n(t\\n(ll=1 \{.IP \\n+(e\\n(el.\}
|
||||
+.\}
|
||||
+.el .sp
|
||||
+.\}
|
||||
+.el \{\
|
||||
+.ie \\nh=1 \{\
|
||||
+.LP
|
||||
+.nr h 0
|
||||
+.\}
|
||||
+.el .PP
|
||||
+.\}
|
||||
+..
|
||||
+.SH NAME
|
||||
+
|
||||
+.Pp
|
||||
+\fBnvsetenv\fP - change/view OF's environment boot-variables
|
||||
+.Pp
|
||||
+.SH SYNOPSIS
|
||||
+
|
||||
+.Pp
|
||||
+\fBnvsetenv\fP [\fIvariable\fP [\fIvalue\fP]]
|
||||
+.Pp
|
||||
+.SH DESCRIPTION
|
||||
+
|
||||
+.Pp
|
||||
+\fBnvsetenv\fP is a program to adjust or view the Open Firmware (OF)
|
||||
+boot parameters stored in non-volatile (battery-powered) RAM on your
|
||||
+Macintosh computer.
|
||||
+\fBnvsetenv\fP will show the current values of all OF's environment
|
||||
+variables when no parameters are given.
|
||||
+.Pp
|
||||
+.SH OPTIONS
|
||||
+
|
||||
+.Pp
|
||||
+.nr ll +1
|
||||
+.nr t\n(ll 2
|
||||
+.if \n(ll>1 .RS
|
||||
+.IP "\fIvariable\fP"
|
||||
+.nr bi 1
|
||||
+.Pp
|
||||
+nvsetenv will show current value of an OF's
|
||||
+variable, if no value is given
|
||||
+.IP "\fIvariable value\fP"
|
||||
+.nr bi 1
|
||||
+.Pp
|
||||
+nvsetenv will set \fIvariable\fP to
|
||||
+\fIvalue\fP
|
||||
+.if \n(ll>1 .RE
|
||||
+.nr ll -1
|
||||
+.Pp
|
||||
+.SH EXAMPLES
|
||||
+
|
||||
+.Pp
|
||||
+This example will set the boot device to the first SCSI disk on the
|
||||
+internal SCSI bus, using /vmlinux as boot image, trying to
|
||||
+use the third partition as root partition.
|
||||
+.DS
|
||||
+.sp
|
||||
+.ft RR
|
||||
+.nf
|
||||
+ > nvsetenv boot-device \&"scsi-int/sd@0:0\&"
|
||||
+ > nvsetenv boot-file \&" /vmlinux root=/dev/sda3\&"
|
||||
+.DE
|
||||
+.fi
|
||||
+.ec
|
||||
+.ft P
|
||||
+.sp
|
||||
+.Pp
|
||||
+Alternatives boot devices are:
|
||||
+.DS
|
||||
+.sp
|
||||
+.ft RR
|
||||
+.nf
|
||||
+ scsi/sd@1:0 SCSI disk at ID 1
|
||||
+ ata/ata-disk@0:0 Internal IDE disk
|
||||
+.DE
|
||||
+.fi
|
||||
+.ec
|
||||
+.ft P
|
||||
+.sp
|
||||
+.Pp
|
||||
+You can also boot from a floppy, you need a XCOFF-format kernel image
|
||||
+(in this example: vmlinux.coff), copied to a HFS format high-density
|
||||
+(1.44Mb) floppy.
|
||||
+.DS
|
||||
+.sp
|
||||
+.ft RR
|
||||
+.nf
|
||||
+ > nvsetenv boot-device \&"fd:vmlinux.coff\&"
|
||||
+ > nvsetenv boot-file \&" root=/dev/sda3\&"
|
||||
+.DE
|
||||
+.fi
|
||||
+.ec
|
||||
+.ft P
|
||||
+.sp
|
||||
+
|
||||
+To return to MacOS, do:
|
||||
+.DS
|
||||
+.sp
|
||||
+.ft RR
|
||||
+.nf
|
||||
+ > nvsetenv boot-device \&"/AAPL,ROM\&"
|
||||
+.DE
|
||||
+.fi
|
||||
+.ec
|
||||
+.ft P
|
||||
+.sp
|
||||
+.Pp
|
||||
+Valid values for \&"input-devices\&" are:
|
||||
+.DS
|
||||
+.sp
|
||||
+.ft RR
|
||||
+.nf
|
||||
+ ttya Modem serial port
|
||||
+ ttyb Printer serial port
|
||||
+ kbd Keyboard
|
||||
+ enet Ethernet interface
|
||||
+.DE
|
||||
+.fi
|
||||
+.ec
|
||||
+.ft P
|
||||
+.sp
|
||||
+.Pp
|
||||
+Valid values for \&"output-devices\&" are (machine and/or OF dependent):
|
||||
+.DS
|
||||
+.sp
|
||||
+.ft RR
|
||||
+.nf
|
||||
+ screen Screen display (newer machines)
|
||||
+ /chaos/control Screen display (7500, 7600 and 8500)
|
||||
+ /bandit/ATY,264GT-B Screen display (6500)
|
||||
+.DE
|
||||
+.fi
|
||||
+.ec
|
||||
+.ft P
|
||||
+.sp
|
||||
+.Pp
|
||||
+OF is not designed to wait for your hard disk to spin up
|
||||
+(remember MacOS boots from ROM).
|
||||
+Use the following setting to have OF retry to boot from your disk
|
||||
+until is has spun up:
|
||||
+.DS
|
||||
+.sp
|
||||
+.ft RR
|
||||
+.nf
|
||||
+ > nvsetenv boot-command \&"begin ['] boot catch 1000 ms cr again\&"
|
||||
+.DE
|
||||
+.fi
|
||||
+.ec
|
||||
+.ft P
|
||||
+.sp
|
||||
+.Pp
|
||||
+You only have to append an \&"S\&" to the \&"boot-file\&" variable to boot
|
||||
+Linux in single user mode.
|
||||
+.Pp
|
||||
+.SH FILES
|
||||
+
|
||||
+.Pp
|
||||
+\fBnvsetenv\fP
|
||||
+needs the following device:
|
||||
+.nr ll +1
|
||||
+.nr t\n(ll 2
|
||||
+.if \n(ll>1 .RS
|
||||
+.IP "\fI/dev/nvram\fP"
|
||||
+.nr bi 1
|
||||
+.Pp
|
||||
+character device with major number 1yy
|
||||
+and minor number 10
|
||||
+.IP "\fI/proc/cpuinfo\fP"
|
||||
+.nr bi 1
|
||||
+.Pp
|
||||
+to identify New/Old-World machines
|
||||
+.if \n(ll>1 .RE
|
||||
+.nr ll -1
|
||||
+.Pp
|
||||
+.SH BUGS
|
||||
+
|
||||
+.Pp
|
||||
+On NewWorld machines setting an undefined variable is not implemented.
|
||||
+.Pp
|
||||
+NewWorld machines contain binary values those are not specially treated.
|
||||
+.Pp
|
||||
+Also it is not a bug take care when setting special characters (\e\e) with
|
||||
+a shell.
|
||||
+.Pp
|
||||
+.SH FILES
|
||||
+
|
||||
+.Pp
|
||||
+macos(8)
|
||||
+.Pp
|
||||
+.SH AUTHORS
|
||||
+
|
||||
+.Pp
|
||||
+Paul Mackerras \f(CR<paulus@cs.anu.edu.au>\fP (program)
|
||||
+.Pp
|
||||
+Richard van Hees \f(CR<R.M.vanHees@fys.ruu.nl>\fP (documentation)
|
||||
+.Pp
|
||||
+Klaus Halfmann \f(CR<halfmann@libra.de>\fP
|
||||
+(NewWorld code, additional documentation)
|
||||
+.Pp
|
||||
Index: powerpc-utils-0.0.1/doc/Makefile
|
||||
===================================================================
|
||||
--- powerpc-utils-0.0.1.orig/doc/Makefile
|
||||
+++ powerpc-utils-0.0.1/doc/Makefile
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
include ../rules.mk
|
||||
|
||||
-MANPAGES8 = snap.8 bootlist.8 ofpathname.8
|
||||
+MANPAGES8 = snap.8 bootlist.8 ofpathname.8 nvsetenv.8
|
||||
|
||||
SUBDIRS = nvram
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
allow 'bootlist -m normal eth0'
|
||||
Just using the full device path appears to work ok.
|
||||
Its like 'nvsetenv boot-device `cat /sys/class/net/eth0/device/devspec`'
|
||||
|
||||
---
|
||||
scripts/bootlist | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
Index: powerpc-utils-1.0.0/scripts/bootlist
|
||||
===================================================================
|
||||
--- powerpc-utils-1.0.0.orig/scripts/bootlist
|
||||
+++ powerpc-utils-1.0.0/scripts/bootlist
|
||||
@@ -84,6 +84,12 @@ update_eth_dev()
|
||||
fi
|
||||
done
|
||||
|
||||
+ # if no additional option was specified, just use the full path without options
|
||||
+ if [[ -z $bserver && -z $gateway && -z $client ]]; then
|
||||
+ OF_DEVPATH[$eth_index]=${OF_DEVPATH[$eth_index]}
|
||||
+ return
|
||||
+ fi
|
||||
+
|
||||
# Parameter Checking
|
||||
if [[ -z $bserver || -z $gateway || -z $client ]]; then
|
||||
echo "You must provide the IP Address for the BOOTP server, the"
|
||||
@@ -0,0 +1,47 @@
|
||||
/usr/sbin/nvram: ERROR: only wrote 4096 bytes of the "common" partition back
|
||||
to /dev/nvram, expected to write 8192 bytes
|
||||
---
|
||||
cmds/nvram.c | 19 ++++++++++++++-----
|
||||
1 file changed, 14 insertions(+), 5 deletions(-)
|
||||
|
||||
Index: powerpc-utils-1.0.0/cmds/nvram.c
|
||||
===================================================================
|
||||
--- powerpc-utils-1.0.0.orig/cmds/nvram.c
|
||||
+++ powerpc-utils-1.0.0/cmds/nvram.c
|
||||
@@ -1342,10 +1342,12 @@ update_of_config_var(struct nvram *nvram
|
||||
struct partition_header *phead, *new_phead;
|
||||
char *data_offset;
|
||||
char *new_part;
|
||||
+ char *new_part_p;
|
||||
char *new_part_offset, *new_part_end;
|
||||
char *tmp_offset;
|
||||
int config_name_len;
|
||||
int len, part_size, found = 0;
|
||||
+ int written;
|
||||
|
||||
phead = nvram_find_partition(nvram, 0, pname, NULL);
|
||||
if (phead == NULL) {
|
||||
@@ -1446,11 +1448,18 @@ update_of_config_var(struct nvram *nvram
|
||||
}
|
||||
|
||||
/* write the partition out to nvram */
|
||||
- len = write(nvram->fd, new_part, part_size);
|
||||
- if (len != part_size) {
|
||||
- err_msg("only wrote %d bytes of the \"%s\" partition back\n"
|
||||
- "\tto %s, expected to write %d bytes\n",
|
||||
- len, pname, nvram->filename, part_size);
|
||||
+ new_part_p = new_part;
|
||||
+ written = part_size;
|
||||
+ while (written > 0) {
|
||||
+ len = write(nvram->fd, new_part_p, written);
|
||||
+ if (len < 0) {
|
||||
+ perror(nvram->filename);
|
||||
+ break;
|
||||
+ }
|
||||
+ if (len == 0 && written)
|
||||
+ break;
|
||||
+ written -= len;
|
||||
+ new_part_p +=len;
|
||||
}
|
||||
|
||||
free(new_part);
|
||||
@@ -0,0 +1,23 @@
|
||||
Subject: [Bug 142637] L3: bootlist command fails
|
||||
|
||||
the bug is in l2of_scsi(), it simply loops through all devices (the last one
|
||||
wins), instead of just picking the right one in the first place.
|
||||
|
||||
scripts/ofpathname | 4 +---
|
||||
1 files changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
Index: powerpc-utils-0.0.1/scripts/ofpathname
|
||||
===================================================================
|
||||
--- powerpc-utils-0.0.1.orig/scripts/ofpathname
|
||||
+++ powerpc-utils-0.0.1/scripts/ofpathname
|
||||
@@ -328,9 +328,7 @@ l2of_scsi()
|
||||
local i vdiskno
|
||||
cd host*
|
||||
cd target*
|
||||
- for i in *:*:*:*; do
|
||||
- vdiskno=`get_vdisk_no $i`
|
||||
- done
|
||||
+ vdiskno=`get_vdisk_no $i`
|
||||
|
||||
OF_PATH=$OF_PATH/disk\@$vdiskno
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
show_of_path handles more block device types (#142637)
|
||||
|
||||
scripts/ofpathname | 10 +++++++++-
|
||||
1 files changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
Index: powerpc-utils-0.0.1/scripts/ofpathname
|
||||
===================================================================
|
||||
--- powerpc-utils-0.0.1.orig/scripts/ofpathname
|
||||
+++ powerpc-utils-0.0.1/scripts/ofpathname
|
||||
@@ -212,7 +212,7 @@ logical_to_ofpathname()
|
||||
|
||||
case $DEVICE in
|
||||
eth*) l2of_ethernet ;;
|
||||
- sd* | sr*) l2of_scsi ;;
|
||||
+ sd* | sr*) l2of_scsi_show_of_path ;;
|
||||
hd*) l2of_ide ;;
|
||||
fd*) echo "no fd support yet" ;;
|
||||
esac
|
||||
@@ -279,6 +279,14 @@ l2of_ethernet()
|
||||
fi
|
||||
}
|
||||
|
||||
+l2of_scsi_show_of_path()
|
||||
+{
|
||||
+ if test -b /dev/$DEVICE
|
||||
+ then
|
||||
+ OF_PATH="`/bin/show_of_path.sh /dev/$DEVICE`"
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
#
|
||||
# l2of_scsi
|
||||
# Converion routine for logical => OF path of scsi devices
|
||||
Reference in New Issue
Block a user