summaryrefslogtreecommitdiffstats
path: root/perl-install/c
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/c')
-rw-r--r--perl-install/c/.cvsignore9
-rw-r--r--perl-install/c/Makefile18
-rw-r--r--perl-install/c/Makefile.PL23
-rw-r--r--perl-install/c/README3
-rw-r--r--perl-install/c/sbus.c156
-rw-r--r--perl-install/c/silo.c817
-rw-r--r--perl-install/c/smp-test.c6
-rw-r--r--perl-install/c/smp.c509
-rw-r--r--perl-install/c/smp.h6
-rw-r--r--perl-install/c/stuff.pm34
-rw-r--r--perl-install/c/stuff.xs.pm579
11 files changed, 0 insertions, 2160 deletions
diff --git a/perl-install/c/.cvsignore b/perl-install/c/.cvsignore
deleted file mode 100644
index 665b57e54..000000000
--- a/perl-install/c/.cvsignore
+++ /dev/null
@@ -1,9 +0,0 @@
-Makefile
-Makefile_c
-stuff.c
-stuff.bs
-pm_to_blib
-Makefile_c.old
-blib
-stuff.xs
-pcmcia_probe.c
diff --git a/perl-install/c/Makefile b/perl-install/c/Makefile
deleted file mode 100644
index a494da760..000000000
--- a/perl-install/c/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-.PHONY: clean
-
-C_RPM = 1
-C_DRAKX = 1
-
-stuff: %: %.xs
- test -e Makefile_c || C_RPM=$(C_RPM) C_DRAKX=$(C_DRAKX) perl Makefile.PL
- $(MAKE) -f Makefile_c LD_RUN_PATH= || $(MAKE) -f Makefile_c LD_RUN_PATH=
- rm -f ../auto/c ; ln -s ../c/blib/arch/auto ../auto/c
-
-clean:
- test ! -e Makefile_c || $(MAKE) -f Makefile_c clean
- rm -f *~ *.o stuff.xs pcmcia_probe.c
-
-stuff.xs: %: %.pm
- rm -f $@
- C_RPM=$(C_RPM) C_DRAKX=$(C_DRAKX) perl $< > $@
- chmod a-w $@
diff --git a/perl-install/c/Makefile.PL b/perl-install/c/Makefile.PL
deleted file mode 100644
index 9a27c3592..000000000
--- a/perl-install/c/Makefile.PL
+++ /dev/null
@@ -1,23 +0,0 @@
-use ExtUtils::MakeMaker;
-use Config;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
-
-my $libs = '-lldetect -lext2fs';
-$libs .= ' -L/usr/X11R6/lib -lX11 -lgdk -lXxf86misc' if $ENV{C_DRAKX};
-$libs .= ' -lrpm -lrpmdb -lrpmio -lpopt -lz' if $ENV{C_RPM};
-
-my $pcmcia_dir = $ENV{C_DRAKX} && $Config{archname} =~ /i.86/ ? '../../mdk-stage1/pcmcia_' : '';
-
-symlink "$pcmcia_dir/probe.c", "probe.c" if $pcmcia_dir;
-
-WriteMakefile(
- 'NAME' => 'stuff',
- 'OPTIMIZE' => '-Os',
- 'MAKEFILE' => 'Makefile_c',
- 'OBJECT' => "stuff.o smp.o sbus.o silo.o" . ($pcmcia_dir && " probe.o"),
- 'VERSION_FROM' => 'stuff.pm', # finds $VERSION
- 'LIBS' => [$libs], # e.g., '-lm'
- 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
- 'INC' => "-I/usr/include/rpm `gtk-config --cflags` `glib-config --cflags`" . ($pcmcia_dir && " -I$pcmcia_dir -I$pcmcia_dir/.."),
-);
diff --git a/perl-install/c/README b/perl-install/c/README
deleted file mode 100644
index b5ad1224f..000000000
--- a/perl-install/c/README
+++ /dev/null
@@ -1,3 +0,0 @@
-md5.c, md5_crypt.c and md5.h are taken from pam (dir modules/pam_pwdb)
-
-smp.c is taken from RedHat's install
diff --git a/perl-install/c/sbus.c b/perl-install/c/sbus.c
deleted file mode 100644
index 85d44fa79..000000000
--- a/perl-install/c/sbus.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* This file is inspired from source code of kudzu from Red Hat, Inc.
- * It has been modified to keep only "what is needed" in C, the prom_walk
- * has been rewritten in perl for convenience :-)
- *
- * Copyright notice from original version.
- * sbus.c: Probe for Sun SBUS and UPA framebuffers using OpenPROM,
- * SBUS SCSI and Ethernet cards and SBUS or EBUS audio chips.
- *
- * Copyright (C) 1998, 1999 Jakub Jelinek (jj@ultra.linux.cz)
- * (C) 1999 Red Hat, Inc.
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- */
-
-#ifdef __sparc__
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <asm/openpromio.h>
-
-static char *promdev = "/dev/openprom";
-static int promfd = -1;
-static int prom_current_node;
-#define MAX_PROP 128
-#define MAX_VAL (4096-128-4)
-static char buf[4096];
-#define DECL_OP(size) struct openpromio *op = (struct openpromio *)buf; op->oprom_size = (size)
-
-int prom_open()
-{
- int prom_root_node;
-
- if (promfd == -1) {
- promfd = open(promdev, O_RDONLY);
- if (promfd == -1)
- return 0;
- }
- prom_root_node = prom_getsibling(0);
- if (!prom_root_node) {
- close(promfd);
- promfd = -1;
- return 0;
- }
- return prom_root_node;
-}
-
-void prom_close()
-{
- if (promfd != -1) {
- close(promfd);
- promfd = -1;
- }
-}
-
-int prom_getsibling(int node)
-{
- DECL_OP(sizeof(int));
-
- if (node == -1) return 0;
- *(int *)op->oprom_array = node;
- if (ioctl (promfd, OPROMNEXT, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-int prom_getchild(int node)
-{
- DECL_OP(sizeof(int));
-
- if (!node || node == -1) return 0;
- *(int *)op->oprom_array = node;
- if (ioctl (promfd, OPROMCHILD, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-char *prom_getopt(char *var, int *lenp)
-{
- DECL_OP(MAX_VAL);
-
- strcpy (op->oprom_array, var);
- if (ioctl (promfd, OPROMGETOPT, op) < 0)
- return 0;
- if (lenp) *lenp = op->oprom_size;
- return op->oprom_array;
-}
-
-void prom_setopt(char *var, char *value) {
- DECL_OP(MAX_VAL);
-
- strcpy (op->oprom_array, var);
- strcpy (op->oprom_array + strlen (var) + 1, value);
- ioctl (promfd, OPROMSETOPT, op);
-}
-
-char *prom_getproperty(char *prop, int *lenp)
-{
- DECL_OP(MAX_VAL);
-
- strcpy (op->oprom_array, prop);
- if (ioctl (promfd, OPROMGETPROP, op) < 0)
- return 0;
- if (lenp) *lenp = op->oprom_size;
- return op->oprom_array;
-}
-
-int prom_getbool(char *prop)
-{
- DECL_OP(0);
-
- *(int *)op->oprom_array = 0;
- for (;;) {
- op->oprom_size = MAX_PROP;
- if (ioctl(promfd, OPROMNXTPROP, op) < 0)
- return 0;
- if (!op->oprom_size)
- return 0;
- if (!strcmp (op->oprom_array, prop))
- return 1;
- }
-}
-
-int prom_pci2node(int bus, int devfn) {
- DECL_OP(2*sizeof(int));
-
- ((int *)op->oprom_array)[0] = bus;
- ((int *)op->oprom_array)[1] = devfn;
- if (ioctl (promfd, OPROMPCI2NODE, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-#else
-int prom_open() { return 0; }
-void prom_close() {}
-int prom_getsibling(int node) { return 0; }
-int prom_getchild(int node) { return 0; }
-char *prom_getopt(char *var, int *lenp) { return 0; /* NULL */ }
-void prom_setopt(char *var, char *value) {}
-char *prom_getproperty(char *prop, int *lenp) { return 0; /* NULL */ }
-int prom_getbool(char *prop) { return 0; }
-int prom_pci2node(int bus, int devfn) { return 0; }
-#endif /* __sparc__ */
diff --git a/perl-install/c/silo.c b/perl-install/c/silo.c
deleted file mode 100644
index 2fd621f4e..000000000
--- a/perl-install/c/silo.c
+++ /dev/null
@@ -1,817 +0,0 @@
-/* silo.c: Conversions between SCSI and IDE disk names
- * and OpenPROM fully qualified paths.
- *
- * Modified for DrakX light integration.
- * Copyright (C) 1999, 2000 Jakub Jelinek <jakub@redhat.com>
- *
- * This software may be freely redistributed under the terms of the GNU
- * public license.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifdef __sparc__
-
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <asm/openpromio.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-
-#ifndef OPROMSETCUR
-#define OPROMSETCUR 0x20004FF0
-#define OPROMPCI2NODE 0x20004FF1
-#define OPROMPATH2NODE 0x20004FF2
-#endif
-
-static int hasaliases;
-static char *promdev = "/dev/openprom";
-static int promfd;
-static char sd_targets[10] = "31204567";
-static int p1275 = 0;
-static int prom_root_node, prom_current_node;
-static int promvers;
-static void (*prom_walk_callback)(int node);
-static char prom_path[1024];
-#define MAX_PROP 128
-#define MAX_VAL (4096-128-4)
-static char buf[4096];
-static char regstr[40];
-#define DECL_OP(size) struct openpromio *op = (struct openpromio *)buf; op->oprom_size = (size)
-
-static int
-prom_setcur(int node) {
- DECL_OP(sizeof(int));
-
- if (node == -1) return 0;
- *(int *)op->oprom_array = node;
- if (ioctl (promfd, OPROMSETCUR, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-static int
-prom_getsibling(int node) {
- DECL_OP(sizeof(int));
-
- if (node == -1) return 0;
- *(int *)op->oprom_array = node;
- if (ioctl (promfd, OPROMNEXT, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-static int
-prom_getchild(int node) {
- DECL_OP(sizeof(int));
-
- if (!node || node == -1) return 0;
- *(int *)op->oprom_array = node;
- if (ioctl (promfd, OPROMCHILD, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-static char *
-prom_getproperty(char *prop, int *lenp) {
- DECL_OP(MAX_VAL);
-
- strcpy (op->oprom_array, prop);
- if (ioctl (promfd, OPROMGETPROP, op) < 0)
- return 0;
- if (lenp) *lenp = op->oprom_size;
- return op->oprom_array;
-}
-
-static char *
-prom_getopt(char *var, int *lenp) {
- DECL_OP(MAX_VAL);
-
- strcpy (op->oprom_array, var);
- if (ioctl (promfd, OPROMGETOPT, op) < 0)
- return 0;
- if (lenp) *lenp = op->oprom_size;
- return op->oprom_array;
-}
-
-static void
-prom_setopt(char *var, char *value) {
- DECL_OP(MAX_VAL);
-
- strcpy (op->oprom_array, var);
- strcpy (op->oprom_array + strlen (var) + 1, value);
- ioctl (promfd, OPROMSETOPT, op);
-}
-
-static int
-prom_getbool(char *prop) {
- DECL_OP(0);
-
- *(int *)op->oprom_array = 0;
- for (;;) {
- op->oprom_size = MAX_PROP;
- if (ioctl(promfd, OPROMNXTPROP, op) < 0)
- return 0;
- if (!op->oprom_size)
- return 0;
- if (!strcmp (op->oprom_array, prop))
- return 1;
- }
-}
-
-static int
-prom_pci2node(int bus, int devfn) {
- DECL_OP(2*sizeof(int));
-
- ((int *)op->oprom_array)[0] = bus;
- ((int *)op->oprom_array)[1] = devfn;
- if (ioctl (promfd, OPROMPCI2NODE, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-static int
-prom_path2node(char *path) {
- DECL_OP(MAX_VAL);
-
- strcpy (op->oprom_array, path);
- if (ioctl (promfd, OPROMPATH2NODE, op) < 0)
- return 0;
- prom_current_node = *(int *)op->oprom_array;
- return *(int *)op->oprom_array;
-}
-
-#define PW_TYPE_SBUS 1
-#define PW_TYPE_PCI 2
-#define PW_TYPE_EBUS 3
-
-static void
-prom_walk(char *path, int parent, int node, int type) {
- int nextnode;
- int len, ntype = type;
- char *prop;
-
- prop = prom_getproperty("name", &len);
- if (prop && len > 0) {
- if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type)
- ntype = PW_TYPE_SBUS;
- else if (!strcmp(prop, "ebus") && type == PW_TYPE_PCI)
- ntype = PW_TYPE_EBUS;
- else if (!strcmp(prop, "pci") && !type)
- ntype = PW_TYPE_PCI;
- }
- *path = '/';
- strcpy (path + 1, prop);
- prop = prom_getproperty("reg", &len);
- if (prop && len >= 4) {
- unsigned int *reg = (unsigned int *)prop;
- int cnt = 0;
- if (!p1275 || (type == PW_TYPE_SBUS))
- sprintf (regstr, "@%x,%x", reg[0], reg[1]);
- else if (type == PW_TYPE_PCI) {
- if ((reg[0] >> 8) & 7)
- sprintf (regstr, "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7);
- else
- sprintf (regstr, "@%x", (reg[0] >> 11) & 0x1f);
- } else if (len == 4)
- sprintf (regstr, "@%x", reg[0]);
- else {
- unsigned int regs[2];
-
- /* Things get more complicated on UPA. If upa-portid exists,
- then address is @upa-portid,second-int-in-reg, otherwise
- it is @first-int-in-reg/16,second-int-in-reg (well, probably
- upa-portid always exists, but just to be safe). */
- memcpy (regs, reg, sizeof(regs));
- prop = prom_getproperty("upa-portid", &len);
- if (prop && len == 4) {
- reg = (unsigned int *)prop;
- sprintf (regstr, "@%x,%x", reg[0], regs[1]);
- } else
- sprintf (regstr, "@%x,%x", regs[0] >> 4, regs[1]);
- }
- for (nextnode = prom_getchild(parent); nextnode; nextnode = prom_getsibling(nextnode)) {
- prop = prom_getproperty("name", &len);
- if (prop && len > 0 && !strcmp (path + 1, prop))
- cnt++;
- }
- if (cnt > 1)
- strcat (path, regstr);
- }
-
- prom_walk_callback(node);
-
- nextnode = prom_getchild(node);
- if (nextnode)
- prom_walk(strchr (path, 0), node, nextnode, ntype);
- nextnode = prom_getsibling(node);
- if (nextnode)
- prom_walk(path, parent, nextnode, type);
-}
-
-static int
-prom_init(int mode) {
- struct utsname u;
-
- promfd = open(promdev, mode);
- if (promfd == -1)
- return -1;
- prom_root_node = prom_getsibling(0);
- if (!prom_root_node)
- return -1;
-
- if (!uname (&u) && !strcmp (u.machine, "sparc64"))
- p1275 = 1;
- return 0;
-}
-
-#define SDSK_TYPE_IDE 1
-#define SDSK_TYPE_SD 2
-#define SDSK_TYPE_PLN 3
-#define SDSK_TYPE_FC 4
-
-static struct sdsk_disk {
- unsigned int prom_node;
- unsigned int type, host, hi, mid, lo;
- unsigned char *prom_name;
-} *hd = NULL, *sd = NULL;
-static int hdlen, sdlen;
-
-static void
-scan_walk_callback(int node) {
- int nextnode;
- char *prop;
- int len, disk;
- static int v0ctrl = 0;
-
- for (disk = 0; disk < hdlen + sdlen; disk++) {
- if (hd[disk].prom_node == node) {
- switch (hd[disk].type) {
- case SDSK_TYPE_IDE:
- for (nextnode = prom_getchild(node); nextnode; nextnode = prom_getsibling(nextnode)) {
- prop = prom_getproperty("name", &len);
- if (prop && len > 0 && (!strcmp (prop, "ata") || !strcmp (prop, "disk")))
- break;
- }
- if (!nextnode)
- continue;
- if (prop[0] == 'a')
- sprintf (prop, "/ata@%x,0/cmdk@%x,0", hd[disk].hi, hd[disk].lo);
- else
- sprintf (prop, "/disk@%x,0", hd[disk].hi * 2 + hd[disk].lo);
- break;
- case SDSK_TYPE_SD:
- for (nextnode = prom_getchild(node); nextnode; nextnode = prom_getsibling(nextnode)) {
- prop = prom_getproperty("compatible", &len);
- if (prop && len > 0 && !strcmp (prop, "sd"))
- break;
- prop = prom_getproperty("name", &len);
- if (prop && len > 0 && (!strcmp (prop, "sd") || !strcmp (prop, "disk")))
- break;
- }
- if (!nextnode || hd[disk].hi)
- continue;
- if (promvers) {
- char name[1024];
- prop = prom_getproperty("name", &len);
- if (prop && len > 0)
- strcpy (name, prop);
- else
- strcpy (name, "sd");
- if (!prop)
- prop = ((struct openpromio *)buf)->oprom_array;
- sprintf (prop, "/%s@%x,%x", name, hd[disk].mid, hd[disk].lo);
- } else {
- int i;
- for (i = 0; sd_targets[i]; i++)
- if (sd_targets[i] == '0' + hd[disk].mid)
- break;
- if (!sd_targets[i])
- i = hd[disk].mid;
- sprintf (prop, "sd(%d,%d,", v0ctrl, i);
- }
- break;
- case SDSK_TYPE_PLN:
- prop = ((struct openpromio *)buf)->oprom_array;
- sprintf (prop, "/SUNW,pln@%x,%x/SUNW,ssd@%x,%x",
- hd[disk].lo & 0xf0000000, hd[disk].lo & 0xffffff,
- hd[disk].hi, hd[disk].mid);
- break;
- case SDSK_TYPE_FC:
- prop = ((struct openpromio *)buf)->oprom_array;
- sprintf (prop, "/sf@0,0/ssd@w%08x%08x,%x", hd[disk].hi, hd[disk].mid, hd[disk].lo);
- break;
- default:
- continue;
- }
- hd[disk].prom_name = malloc (strlen (prom_path) + strlen(prop) + 3);
- if (!hd[disk].prom_name)
- continue;
- if (promvers)
- strcpy (hd[disk].prom_name, prom_path);
- else
- hd[disk].prom_name[0] = '\0';
- strcat (hd[disk].prom_name, prop);
- }
- }
- v0ctrl++;
-}
-
-static int
-scan_ide(void) {
- DIR * dir;
- char path[80];
- char buffer[512];
- int fd, i, disk;
- struct dirent * ent;
- int pci_bus, pci_devfn;
-
- if (access("/proc/ide", R_OK)) return 0;
-
- if (!(dir = opendir("/proc/ide"))) {
- return 1;
- }
-
- while ((ent = readdir(dir))) {
- if (ent->d_name[0] == 'h' && ent->d_name[1] == 'd' &&
- ent->d_name[2] >= 'a' && ent->d_name[2] <= 'z' &&
- ent->d_name[3] == '\0') {
- disk = ent->d_name[2] - 'a';
- if (disk >= hdlen) {
- hd = (struct sdsk_disk *)realloc(hd, ((disk&~3)+4)*sizeof(struct sdsk_disk));
- memset (hd + hdlen, 0, ((disk&~3)+4-hdlen)*sizeof(struct sdsk_disk));
- hdlen = (disk&~3)+4;
- }
- for (i = (disk & ~3); i <= (disk | 3); i++) {
- if (hd[i].type)
- break;
- }
- if (i > (disk | 3)) {
- sprintf(path, "/proc/ide/%s", ent->d_name);
- if (readlink(path, buffer, 512) < 5)
- continue;
- if (strncmp(buffer, "ide", 3) ||
- !isdigit(buffer[3]) ||
- buffer[4] != '/')
- continue;
- buffer[4] = 0;
- sprintf(path, "/proc/ide/%s/config", buffer);
- if ((fd = open(path, O_RDONLY)) < 0)
- continue;
- i = read(fd, buffer, 50);
- close(fd);
- if (i < 50) continue;
- if (sscanf (buffer, "pci bus %x device %x ",
- &pci_bus, &pci_devfn) != 2)
- continue;
- hd[disk].prom_node = prom_pci2node (pci_bus, pci_devfn);
- } else
- hd[disk].prom_node = hd[i].prom_node;
- hd[disk].type = SDSK_TYPE_IDE;
- hd[disk].hi = (disk & 2) >> 1;
- hd[disk].lo = (disk & 1);
- }
- }
-
- closedir(dir);
-
- return 0;
-}
-
-static int
-scan_scsi(void) {
- FILE *f;
- DIR * dir, *dirhba;
- struct dirent * ent, *enthba;
- struct stat st;
- char * p, * q;
- char buf[512];
- char path[128];
- int disk = 0;
- int host, channel, id, lun;
- int prom_node, pci_bus, pci_devfn;
-
- if (access("/proc/scsi/scsi", R_OK)) {
- return 0;
- }
-
- f = fopen("/proc/scsi/scsi", "r");
- if (f == NULL) return 1;
-
- if (fgets(buf, sizeof(buf), f) == NULL) {
- fclose(f);
- return 1;
- }
- if (!strcmp(buf, "Attached devices: none\n")) {
- fclose(f);
- return 0;
- }
-
- while (fgets(buf, sizeof(buf), f) != NULL) {
- if (sscanf(buf, "Host: scsi%d Channel: %d Id: %d Lun: %d\n",
- &host, &channel, &id, &lun) != 4)
- break;
- if (fgets(buf, sizeof(buf), f) == NULL)
- break;
- if (strncmp(buf, " Vendor:", 9))
- break;
- if (fgets(buf, sizeof(buf), f) == NULL)
- break;
- if (strncmp(buf, " Type: ", 10))
- break;
- if (!strncmp(buf+10, "Direct-Access", 13)) {
- if (disk >= sdlen) {
- hd = (struct sdsk_disk *)
- realloc(hd, (hdlen+(disk&~3)+4)*sizeof(struct sdsk_disk));
- sd = hd + hdlen;
- memset (sd + sdlen, 0,
- ((disk&~3)+4-sdlen)*sizeof(struct sdsk_disk));
- sdlen = (disk&~3)+4;
- }
- sd[disk].type = SDSK_TYPE_SD;
- sd[disk].host = host;
- sd[disk].hi = channel;
- sd[disk].mid = id;
- sd[disk].lo = lun;
- disk++;
- }
- }
- fclose (f);
-
- if (!(dir = opendir("/proc/scsi"))) {
- if (!hdlen && hd) {
- free(hd);
- hd = NULL;
- }
- sd = NULL;
- sdlen = 0;
- return 1;
- }
-
- while ((ent = readdir(dir))) {
- if (!strcmp (ent->d_name, "scsi") || ent->d_name[0] == '.')
- continue;
- sprintf (path, "/proc/scsi/%s", ent->d_name);
- if (stat (path, &st) < 0 || !S_ISDIR (st.st_mode))
- continue;
- if (!(dirhba = opendir(path)))
- continue;
-
- while ((enthba = readdir(dirhba))) {
- if (enthba->d_name[0] == '.')
- continue;
- host = atoi(enthba->d_name);
- sprintf (path, "/proc/scsi/%s/%s", ent->d_name, enthba->d_name);
- f = fopen (path, "r");
- if (f == NULL) continue;
-
- if (!strcmp (ent->d_name, "esp") ||
- !strcmp (ent->d_name, "qlogicpti") ||
- !strcmp (ent->d_name, "fcal"))
- p = "PROM node";
- else if (!strcmp (ent->d_name, "pluto"))
- p = "serial ";
- else
- p = "PCI bus";
- while (fgets (buf, sizeof(buf), f) != NULL) {
- q = strstr (buf, p);
- if (q == NULL) continue;
- prom_node = 0;
- switch (p[1]) {
- case 'R':
- if (sscanf (q, "PROM node %x", &prom_node) == 1)
- q = NULL;
- break;
- case 'e':
- if (sscanf (q, "serial 000000%x %*dx%*d on soc%*d port %x PROM node %x",
- &id, &lun, &prom_node) == 3 &&
- lun >= 10 && lun <= 11) {
- q = NULL;
- }
- break;
- case 'C':
- if (sscanf (q, "PCI bus %x device %x", &pci_bus, &pci_devfn) == 2) {
- q = NULL;
- prom_node = prom_pci2node (pci_bus, pci_devfn);
- }
- break;
- }
- if (q == NULL) {
- for (disk = 0; disk < sdlen; disk++)
- if (sd[disk].host == host && sd[disk].type) {
- sd[disk].prom_node = prom_node;
- if (p[1] == 'e') {
- sd[disk].type = SDSK_TYPE_PLN;
- sd[disk].lo = (lun << 28) | id;
- } else if (!strcmp (ent->d_name, "fcal"))
- sd[disk].type = SDSK_TYPE_FC;
- }
- }
- }
- if (!strcmp (ent->d_name, "fcal")) {
- while (fgets (buf, sizeof(buf), f) != NULL) {
- unsigned long long ll;
- if (sscanf (buf, " [AL-PA: %*x, Id: %d, Port WWN: %Lx, Node WWN: ", &id, &ll) == 2) {
- for (disk = 0; disk < sdlen; disk++)
- if (sd[disk].host == host && sd[disk].mid == id) {
- sd[disk].hi = ll >> 32;
- sd[disk].mid = ll;
- }
- }
- }
- }
- fclose(f);
- }
- closedir(dirhba);
- }
- closedir(dir);
- return 0;
-}
-
-static int get_prom_ver(void)
-{
- FILE *f = fopen ("/proc/cpuinfo","r");
- int ver = 0;
- char buffer[1024];
- char *p;
-
- if (f) {
- while (fgets (buffer, 1024, f)) {
- if (!strncmp (buffer, "promlib", 7)) {
- p = strstr (buffer, "Version ");
- if (p) {
- p += 8;
- if (*p == '0' || (*p >= '2' && *p <= '3')) {
- ver = *p - '0';
- }
- }
- break;
- }
- }
- fclose(f);
- }
- if (!ver) {
- int len;
- p = prom_getopt("sd-targets", &len);
- if (p && len > 0 && len <= 8)
- strcpy(sd_targets, p);
- }
- return ver;
-}
-
-static void check_aliases(void) {
- int nextnode, len;
- char *prop;
- hasaliases = 0;
- for (nextnode = prom_getchild(prom_root_node); nextnode; nextnode = prom_getsibling(nextnode)) {
- prop = prom_getproperty("name", &len);
- if (prop && len > 0 && !strcmp (prop, "aliases"))
- hasaliases = 1;
- }
-}
-
-char *prom_root_name = NULL;
-
-static void get_root_name(void) {
- int len;
- char *prop;
-
- prom_getsibling(0);
- prop = prom_getproperty("name", &len);
- if (prop && len > 0)
- prom_root_name = strdup(prop);
-}
-
-int init_sbusdisk(void) {
- if (prom_init(O_RDONLY))
- return -1;
- promvers = get_prom_ver();
- check_aliases();
- get_root_name();
- scan_ide();
- scan_scsi();
- prom_walk_callback = scan_walk_callback;
- prom_walk(prom_path, prom_root_node, prom_getchild (prom_root_node), 0);
- close(promfd);
- return 0;
-}
-
-void set_prom_vars(char *linuxAlias, char *bootDevice) {
- int len;
- int aliasDone = 0;
- if (prom_init(O_RDWR))
- return;
- if (linuxAlias && hasaliases) {
- char *use_nvramrc;
- char nvramrc[2048];
- char *p, *q, *r, *s;
- int enabled = -1;
- int count;
-
- use_nvramrc = prom_getopt ("use-nvramrc?", &len);
- if (len > 0) {
- if (!strcasecmp (use_nvramrc, "false"))
- enabled = 0;
- else if (!strcasecmp (use_nvramrc, "true"))
- enabled = 1;
- }
- if (enabled != -1) {
- p = prom_getopt ("nvramrc", &len);
- if (p) {
- memcpy (nvramrc, p, len);
- nvramrc [len] = 0;
- q = nvramrc;
- for (;;) {
- /* If there is already `devalias linux /some/ugly/prom/path'
- make sure we fully understand that and remove it. */
- if (!strncmp (q, "devalias", 8) && (q[8] == ' ' || q[8] == '\t')) {
- for (r = q + 9; *r == ' ' || *r == '\t'; r++);
- if (!strncmp (r, "linux", 5)) {
- for (s = r + 5; *s && *s != ' ' && *s != '\t'; s++);
- if (!*s) break;
- if (s == r + 5 ||
- (r[5] == '#' && r[6] >= '0' && r[6] <= '9' &&
- (s == r + 7 ||
- (r[7] >= '0' && r[7] <= '9' && s == r + 8)))) {
- for (r = s + 1; *r == ' ' || *r == '\t'; r++);
- for (; *r && *r != ' ' && *r != '\t' && *r != '\n'; r++);
- for (; *r == ' ' || *r == '\t'; r++);
- if (*r == '\n') {
- r++;
- memmove (q, r, strlen(r) + 1);
- continue;
- }
- }
- }
- }
- q = strchr (q, '\n');
- if (!q) break;
- q++;
- }
- len = strlen (nvramrc);
- if (len && nvramrc [len-1] != '\n')
- nvramrc [len++] = '\n';
- p = nvramrc + len;
- p = stpcpy (p, "devalias linux ");
- r = linuxAlias;
- q = strchr (r, ';');
- count = 1;
- while (q) {
- memcpy (p, r, q - r);
- p += q - r;
- sprintf (p, "\ndevalias linux#%d ", count++);
- p = strchr (p, 0);
- r = q + 1;
- q = strchr (r, ';');
- }
- p = stpcpy (p, r);
- *p++ = '\n';
- *p = 0;
- prom_setopt ("nvramrc", nvramrc);
- if (!enabled)
- prom_setopt ("use-nvramrc?", "true");
- aliasDone = 1;
- }
- }
- }
- if (bootDevice) {
- char *p;
- if (aliasDone)
- bootDevice = "linux";
- p = prom_getopt ("boot-device", &len);
- if (p) {
- prom_setopt ("boot-device", bootDevice);
- prom_setopt ("boot-file", "");
- } else {
- p = prom_getopt ("boot-from", &len);
- if (p)
- prom_setopt ("boot-from", bootDevice);
- }
- }
- close(promfd);
-}
-
-#ifdef STANDALONE_SILO
-
-int main(void) {
- int i;
-
- init_sbusdisk();
- set_prom_vars ("/sbus@1f,0/espdma/esp/sd@1,0:c;/sbus@1f,0/espdma/esp/sd@1,0:g;/sbus@1f,0/espdma/esp/sd@1,0:h", "linux");
- printf ("prom root name `%s'\n", prom_root_name);
- for (i = 0; i < hdlen; i++) {
- if (hd[i].type)
- printf ("hd%c %x %d %d %d\n", i + 'a', hd[i].prom_node,
- hd[i].hi, hd[i].mid, hd[i].lo);
- if (hd[i].prom_name) printf ("%s\n", hd[i].prom_name);
- }
- for (i = 0; i < sdlen; i++) {
- if (sd[i].type) {
- if (i < 26)
- printf ("sd%c %x %d %d %d\n", i + 'a', sd[i].prom_node,
- sd[i].hi, sd[i].mid, sd[i].lo);
- else
- printf ("sd%c%c %x %d %d %d\n", (i / 26) + 'a' - 1, (i % 26) + 'a', sd[i].prom_node,
- sd[i].hi, sd[i].mid, sd[i].lo);
- }
- if (sd[i].prom_name) printf ("%s\n", sd[i].prom_name);
- }
- exit(0);
-}
-
-#else
-
-void
-initSilo ()
-{
- return init_sbusdisk();
-}
-
-char *
-disk2PromPath (unsigned char *disk)
-{
- static unsigned char prompath[1024];
- int diskno = -1, part;
-
- if (disk[0] == 'h' && disk[1] == 'd' && disk[2] >= 'a' && disk[2] <= 'z') {
- diskno = disk[2] - 'a';
- disk += 3;
- } else if (disk[0] == 's' && disk[1] == 'd' && disk[2] >= 'a' && disk[2] <= 'z') {
- if (disk[3] >= 'a' && disk[3] <= 'z') {
- diskno = (disk[2] - 'a' + 1) * 26 + (disk[3] - 'a');
- disk += 4;
- } else {
- diskno = disk[2] - 'a';
- disk += 3;
- }
- if (diskno >= 128)
- diskno = -1;
- else
- diskno += hdlen;
- }
- if (diskno == -1)
- part = -1;
- else if (!disk[0])
- part = 3;
- else {
- part = atoi (disk);
- if (part <= 0 || part > 8) part = -1;
- }
- if (diskno < 0 || part == -1 ||
- diskno >= hdlen + sdlen || !hd[diskno].prom_name) {
- return NULL;
- }
- if (!promvers)
- sprintf (prompath, "%s%d)", hd[diskno].prom_name, part ? part - 1 : 2);
- else {
- if (part)
- sprintf (prompath, "%s:%c", hd[diskno].prom_name, part + 'a' - 1);
- else
- strcpy (prompath, hd[diskno].prom_name);
- }
- return prompath;
-}
-
-int
-hasAliases (void)
-{
- return hasaliases;
-}
-
-char *
-promRootName (void)
-{
- return prom_root_name ? prom_root_name : "";
-}
-
-void
-setPromVars (char *linuxAlias, char *bootDevice)
-{
- if (linuxAlias && !*linuxAlias) linuxAlias = NULL;
- if (bootDevice && !*bootDevice) bootDevice = NULL;
- set_prom_vars (linuxAlias, bootDevice);
-}
-
-#endif
-
-#else
-void initSilo() {}
-char *disk2PromPath(unsigned char *disk) { return 0; /* NULL */ }
-int hasAliases(void) { return 0; }
-char *promRootName(void) { return 0; /* NULL */ }
-void setPromVars(char *linuxAlias, char *bootDevice) {}
-#endif /* __sparc__ */
diff --git a/perl-install/c/smp-test.c b/perl-install/c/smp-test.c
deleted file mode 100644
index f644449b8..000000000
--- a/perl-install/c/smp-test.c
+++ /dev/null
@@ -1,6 +0,0 @@
-main() {
- if (detectSMP())
- printf("has smp\n");
- else
- printf("no smp\n");
-}
diff --git a/perl-install/c/smp.c b/perl-install/c/smp.c
deleted file mode 100644
index baf786cc6..000000000
--- a/perl-install/c/smp.c
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
-[_Anarchy_(alan@lightning.swansea.uk.linux.org)] you should do one check
- though - if the board seems to be SMP and the CPU in /proc/cpuinfo is non
- intel dont install an SMP kernel - thats a dual pentium board with a cyrix
- or similar single cpu in it
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <string.h>
-#include <errno.h>
-
-#ifdef __alpha__
-int alphaDetectSMP(void)
-{
- int issmp = 0;
- FILE *f;
-
- f = fopen("/proc/cpuinfo", "r");
- if (f) {
- char buff[1024];
-
- while (fgets (buff, 1024, f) != NULL) {
- if (!strncmp (buff, "cpus detected\t\t: ", 17)) {
- if (strtoul (buff + 17, NULL, 0) > 1)
- issmp = 1;
- break;
- }
- }
- fclose(f);
- } else
- return -1;
-
- return issmp;
-}
-#endif /* __alpha__ */
-
-#ifdef __sparc__
-int sparcDetectSMP(void)
-{
- int issmp = 0;
- FILE *f;
-
- f = fopen("/proc/cpuinfo", "r");
- if (f) {
- char buff[1024];
-
- while (fgets (buff, 1024, f) != NULL) {
- if (!strncmp (buff, "ncpus probed\t: ", 15)) {
- if (strtoul (buff + 15, NULL, 0) > 1)
- issmp = 1;
- break;
- }
- }
- fclose(f);
- } else
- return -1;
-
- return issmp;
-}
-#endif /* __sparc__ */
-
-/* just a placeholder for now - don't have an SMP machine
- need something in place to build - s.benedict */
-
-#ifdef __powerpc__
-int ppcDetectSMP(void)
-{
- int issmp = 0;
- FILE *f;
-
- f = fopen("/proc/cpuinfo", "r");
- if (f) {
- char buff[1024];
-
- while (fgets (buff, 1024, f) != NULL) {
- if (!strncmp (buff, "ncpus active\t: ", 15)) {
- if (strtoul (buff + 15, NULL, 0) > 1)
- issmp = 1;
- break;
- }
- }
- fclose(f);
- } else
- return -1;
-
- return issmp;
-}
-#endif /* __powerpc__ */
-
-#ifdef __i386__
-/*
- * Copyright (c) 1996, by Steve Passe
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. The name of the developer may NOT be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- */
-
-/*
- * mptable.c
- */
-
-#define VMAJOR 2
-#define VMINOR 0
-#define VDELTA 12
-
-/*
- * this will cause the raw mp table to be dumped to /tmp/mpdump
- *
-#define RAW_DUMP
- */
-
-#define MP_SIG 0x5f504d5f /* _MP_ */
-#define EXTENDED_PROCESSING_READY
-#define OEM_PROCESSING_READY_NOT
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#define LINUX 1
-#if LINUX
-typedef unsigned int vm_offset_t;
-#else
-#include <machine/types.h>
-#endif
-
-/* EBDA is @ 40:0e in real-mode terms */
-#define EBDA_POINTER 0x040e /* location of EBDA pointer */
-
-/* CMOS 'top of mem' is @ 40:13 in real-mode terms */
-#define TOPOFMEM_POINTER 0x0413 /* BIOS: base memory size */
-
-#define DEFAULT_TOPOFMEM 0xa0000
-
-#define BIOS_BASE 0xf0000
-#define BIOS_BASE2 0xe0000
-#define BIOS_SIZE 0x10000
-#define ONE_KBYTE 1024
-
-#define GROPE_AREA1 0x80000
-#define GROPE_AREA2 0x90000
-#define GROPE_SIZE 0x10000
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
- char signature[ 4 ];
- void* pap;
- u_char length;
- u_char spec_rev;
- u_char checksum;
- u_char mpfb1;
- u_char mpfb2;
- u_char mpfb3;
- u_char mpfb4;
- u_char mpfb5;
-} mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[ 4 ];
- u_short base_table_length;
- u_char spec_rev;
- u_char checksum;
- u_char oem_id[ 8 ];
- u_char product_id[ 12 ];
- void* oem_table_pointer;
- u_short oem_table_size;
- u_short entry_count;
- void* apic_address;
- u_short extended_table_length;
- u_char extended_table_checksum;
- u_char reserved;
-} mpcth_t;
-
-typedef struct PROCENTRY {
- u_char type;
- u_char apicID;
- u_char apicVersion;
- u_char cpuFlags;
- u_long cpuSignature;
- u_long featureFlags;
- u_long reserved1;
- u_long reserved2;
-} ProcEntry;
-
-#define PROCENTRY_FLAG_EN 0x01
-
-static void seekEntry( vm_offset_t addr );
-static void apic_probe( vm_offset_t* paddr, int* where );
-static void readEntry( void* entry, int size );
-
-/* global data */
-static int pfd; /* physical /dev/mem fd */
-static int verbose = 0;
-static int grope = 0;
-
-static int
-readType()
-{
- u_char type;
-
- if ( read( pfd, &type, sizeof( u_char ) ) != sizeof( u_char ) ) {
- perror( "type read" );
- fprintf( stderr, "\npfd: %d", pfd );
- fflush( stderr );
- exit( 1 );
- }
-
- if ( lseek( pfd, -1, SEEK_CUR ) < 0 ) {
- perror( "type seek" );
- exit( 1 );
- }
-
- return (int)type;
-}
-
-static int intelDetectSMP(void)
-{
- vm_offset_t paddr;
- int where;
- mpfps_t mpfps;
- int rc = 0;
- int ncpus = 0;
-
- /* open physical memory for access to MP structures */
- if ( (pfd = open( "/dev/mem", O_RDONLY )) < 0 ) {
- return 0;
- }
-
- /* probe for MP structures */
- apic_probe( &paddr, &where );
- if ( where <= 0 )
- return 0;
-
- seekEntry( paddr );
- readEntry( &mpfps, sizeof( mpfps_t ) );
-
- if (mpfps.mpfb1)
- /* old style */
- rc = 1;
- else {
- /* go to the config table */
- mpcth_t cth;
- int count, i;
-
- paddr = (vm_offset_t) mpfps.pap;
- seekEntry( paddr );
- readEntry( &cth, sizeof( cth ) );
- /* if we don't have any entries, the kernel sure
- won't be able to set up mp. Needs at least one entry
- for smp kernel */
- if (cth.entry_count <= 1) {
- close (pfd);
- return 0;
- }
- count = cth.entry_count;
- for (i = 0; i < count; i++) {
- if ( readType() == 0 ) {
- ProcEntry entry;
- readEntry( &entry, sizeof( entry ) );
- if (entry.cpuFlags & PROCENTRY_FLAG_EN)
- ncpus++;
- }
- }
- if (ncpus > 1)
- rc = 1;
- }
-
- close (pfd);
- return rc;
-}
-
-/*
- * set PHYSICAL address of MP floating pointer structure
- */
-#define NEXT(X) ((X) += 4)
-static void
-apic_probe( vm_offset_t* paddr, int* where )
-{
- /*
- * c rewrite of apic_probe() by Jack F. Vogel
- */
-
- int x;
- u_short segment;
- vm_offset_t target;
- u_int buffer[ BIOS_SIZE / sizeof( int ) ];
-
- if ( verbose )
- printf( "\n" );
-
- /* search Extended Bios Data Area, if present */
- if ( verbose )
- printf( " looking for EBDA pointer @ 0x%04x, ", EBDA_POINTER );
- seekEntry( (vm_offset_t)EBDA_POINTER );
- readEntry( &segment, 2 );
- if ( segment ) { /* search EBDA */
- target = (vm_offset_t)segment << 4;
- if ( verbose )
- printf( "found, searching EBDA @ 0x%08x\n", target );
- seekEntry( target );
- readEntry( buffer, ONE_KBYTE );
-
- for ( x = 0; x < ONE_KBYTE / sizeof ( unsigned int ); NEXT(x) ) {
- if ( buffer[ x ] == MP_SIG ) {
- *where = 1;
- *paddr = (x * sizeof( unsigned int )) + target;
- return;
- }
- }
- }
- else {
- if ( verbose )
- printf( "NOT found\n" );
- }
-
- /* read CMOS for real top of mem */
- seekEntry( (vm_offset_t)TOPOFMEM_POINTER );
- readEntry( &segment, 2 );
- --segment; /* less ONE_KBYTE */
- target = segment * 1024;
- if ( verbose )
- printf( " searching CMOS 'top of mem' @ 0x%08x (%dK)\n",
- target, segment );
- seekEntry( target );
- readEntry( buffer, ONE_KBYTE );
-
- for ( x = 0; x < ONE_KBYTE / sizeof ( unsigned int ); NEXT(x) ) {
- if ( buffer[ x ] == MP_SIG ) {
- *where = 2;
- *paddr = (x * sizeof( unsigned int )) + target;
- return;
- }
- }
-
- /* we don't necessarily believe CMOS, check base of the last 1K of 640K */
- if ( target != (DEFAULT_TOPOFMEM - 1024)) {
- target = (DEFAULT_TOPOFMEM - 1024);
- if ( verbose )
- printf( " searching default 'top of mem' @ 0x%08x (%dK)\n",
- target, (target / 1024) );
- seekEntry( target );
- readEntry( buffer, ONE_KBYTE );
-
- for ( x = 0; x < ONE_KBYTE / sizeof ( unsigned int ); NEXT(x) ) {
- if ( buffer[ x ] == MP_SIG ) {
- *where = 3;
- *paddr = (x * sizeof( unsigned int )) + target;
- return;
- }
- }
- }
-
- /* search the BIOS */
- if ( verbose )
- printf( " searching BIOS @ 0x%08x\n", BIOS_BASE );
- seekEntry( BIOS_BASE );
- readEntry( buffer, BIOS_SIZE );
-
- for ( x = 0; x < BIOS_SIZE / sizeof( unsigned int ); NEXT(x) ) {
- if ( buffer[ x ] == MP_SIG ) {
- *where = 4;
- *paddr = (x * sizeof( unsigned int )) + BIOS_BASE;
- return;
- }
- }
-
- /* search the extended BIOS */
- if ( verbose )
- printf( " searching extended BIOS @ 0x%08x\n", BIOS_BASE2 );
- seekEntry( BIOS_BASE2 );
- readEntry( buffer, BIOS_SIZE );
-
- for ( x = 0; x < BIOS_SIZE / sizeof( unsigned int ); NEXT(x) ) {
- if ( buffer[ x ] == MP_SIG ) {
- *where = 5;
- *paddr = (x * sizeof( unsigned int )) + BIOS_BASE2;
- return;
- }
- }
-
- if ( grope ) {
- /* search additional memory */
- target = GROPE_AREA1;
- if ( verbose )
- printf( " groping memory @ 0x%08x\n", target );
- seekEntry( target );
- readEntry( buffer, GROPE_SIZE );
-
- for ( x = 0; x < GROPE_SIZE / sizeof( unsigned int ); NEXT(x) ) {
- if ( buffer[ x ] == MP_SIG ) {
- *where = 6;
- *paddr = (x * sizeof( unsigned int )) + GROPE_AREA1;
- return;
- }
- }
-
- target = GROPE_AREA2;
- if ( verbose )
- printf( " groping memory @ 0x%08x\n", target );
- seekEntry( target );
- readEntry( buffer, GROPE_SIZE );
-
- for ( x = 0; x < GROPE_SIZE / sizeof( unsigned int ); NEXT(x) ) {
- if ( buffer[ x ] == MP_SIG ) {
- *where = 7;
- *paddr = (x * sizeof( unsigned int )) + GROPE_AREA2;
- return;
- }
- }
- }
-
- *where = 0;
- *paddr = (vm_offset_t)0;
-}
-
-
-/*
- *
- */
-static void
-seekEntry( vm_offset_t addr )
-{
- if ( lseek( pfd, (off_t)addr, SEEK_SET ) < 0 ) {
- return;
- perror( "/dev/mem seek" );
- exit( 1 );
- }
-}
-
-
-/*
- *
- */
-static void
-readEntry( void* entry, int size )
-{
- if ( read( pfd, entry, size ) != size ) {
- return;
- perror( "readEntry" );
- exit( 1 );
- }
-}
-
-
-#endif /* __i386__ */
-
-int detectSMP(void)
-{
- static int isSMP = -1;
-
- if (isSMP != -1)
- return isSMP;
-
-#ifdef __i386__
- return isSMP = intelDetectSMP();
-#elif __sparc__
- return isSMP = sparcDetectSMP();
-#elif __alpha__
- return isSMP = alphaDetectSMP();
-#elif __powerpc__
- return isSMP = ppcDetectSMP();
-#elif __ia64__
- /* TODO: Update to check against /proc/pal/cpuX */
- return isSMP = 1;
-#elif __x86_64__
- /* TODO: Update when SMP machines are there */
- return isSMP = 0;
-#else
- #error unknown architecture
-#endif
-}
-
-#if TEST
-int main() {
- if (detectSMP())
- printf("has smp\n");
- else
- printf("no smp\n");
-}
-#endif
diff --git a/perl-install/c/smp.h b/perl-install/c/smp.h
deleted file mode 100644
index 3255cc489..000000000
--- a/perl-install/c/smp.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef SMP_H
-#define SMP_H
-
-int detectSMP(void);
-
-#endif /* SMP_H */
diff --git a/perl-install/c/stuff.pm b/perl-install/c/stuff.pm
deleted file mode 100644
index 918abee6c..000000000
--- a/perl-install/c/stuff.pm
+++ /dev/null
@@ -1,34 +0,0 @@
-package c::stuff; # $Id$
-
-use strict;
-use vars qw($VERSION @ISA);
-
-require DynaLoader;
-
-@ISA = qw(DynaLoader);
-$VERSION = '0.01';
-
-bootstrap c::stuff $VERSION;
-
-sub from_utf8 { iconv($_[0], "utf-8", standard_charset()) }
-sub to_utf8 { iconv($_[0], standard_charset(), "utf-8") }
-
-sub headerGetEntry {
- my ($h, $q) = @_;
- $h or log::l("empty header in headerGetEntry"), return;
- $q eq 'name' and return headerGetEntry_string($h, RPMTAG_NAME());
- $q eq 'group' and return from_utf8(headerGetEntry_string($h, RPMTAG_GROUP()));
- $q eq 'version' and return headerGetEntry_string($h, RPMTAG_VERSION());
- $q eq 'release' and return headerGetEntry_string($h, RPMTAG_RELEASE());
- $q eq 'epoch' and return headerGetEntry_int($h, RPMTAG_EPOCH());
- $q eq 'summary' and return from_utf8(headerGetEntry_string($h, RPMTAG_SUMMARY()));
- $q eq 'description' and return from_utf8(headerGetEntry_string($h, RPMTAG_DESCRIPTION()));
- $q eq 'arch' and return headerGetEntry_string($h, RPMTAG_ARCH());
- $q eq 'size' and return headerGetEntry_int($h, RPMTAG_SIZE());
- $q eq 'obsoletes' and return headerGetEntry_string_list($h, RPMTAG_OBSOLETES());
- $q eq 'requires' and return headerGetEntry_string_list($h, RPMTAG_REQUIRENAME());
- $q eq 'fileflags' and return headerGetEntry_int_list($h, RPMTAG_FILEFLAGS());
- $q eq 'filenames' and return headerGetEntry_filenames($h);
-}
-
-1;
diff --git a/perl-install/c/stuff.xs.pm b/perl-install/c/stuff.xs.pm
deleted file mode 100644
index 2253c419e..000000000
--- a/perl-install/c/stuff.xs.pm
+++ /dev/null
@@ -1,579 +0,0 @@
-use Config;
-
-print '
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-/* workaround for glibc and kernel header files not in sync */
-#define dev_t dev_t
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <resolv.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-#include <sys/mount.h>
-#include <linux/keyboard.h>
-#include <linux/kd.h>
-#include <linux/hdreg.h>
-#include <linux/vt.h>
-#include <linux/fd.h>
-#include <linux/cdrom.h>
-#include <linux/loop.h>
-#include <linux/blkpg.h>
-#include <net/if.h>
-#include <net/route.h>
-
-/* for is_ext3 */
-#include <ext2fs/ext2_fs.h>
-#include <ext2fs/ext2fs.h>
-
-#include <libldetect.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/xf86misc.h>
-
-#include <langinfo.h>
-#include <string.h>
-#include <iconv.h>
-
-#include <libintl.h>
-#include <term.h>
-#undef max_colors
-
-#define SECTORSIZE 512
-
-char *prom_getopt();
-void prom_setopt();
-char *prom_getproperty();
-char *disk2PromPath();
-char *promRootName();
-
-';
-
-$ENV{C_DRAKX} && $Config{archname} =~ /i.86/ and print '
-char *pcmcia_probe(void);
-';
-
-$ENV{C_RPM} and print '
-#undef Fflush
-#undef Mkdir
-#undef Stat
-#include <rpm/rpmlib.h>
-#include <rpm/rpmio.h>
-
-void rpmError_callback_empty(void) {}
-
-int rpmError_callback_data;
-void rpmError_callback(void) {
- if (rpmErrorCode() != RPMERR_UNLINK && rpmErrorCode() != RPMERR_RMDIR) {
- write(rpmError_callback_data, rpmErrorString(), strlen(rpmErrorString()));
- }
-}
-
-';
-
-$ENV{C_DRAKX} and print '
-
-#include <gdk/gdkx.h>
-
-void initIMPS2() {
- unsigned char imps2_s1[] = { 243, 200, 243, 100, 243, 80, };
- unsigned char imps2_s2[] = { 246, 230, 244, 243, 100, 232, 3, };
-
- int fd = open("/dev/cdrom", O_WRONLY);
- if (fd < 0) return;
-
- write (fd, imps2_s1, sizeof (imps2_s1));
- usleep (30000);
- write (fd, imps2_s2, sizeof (imps2_s2));
- usleep (30000);
- tcflush (fd, TCIFLUSH);
- tcdrain(fd);
-}
-
-void log_message(const char * s, ...) {}
-
-';
-
-print '
-
-MODULE = c::stuff PACKAGE = c::stuff
-
-';
-
-$ENV{C_DRAKX} && $Config{archname} =~ /i.86/ and print '
-char *
-pcmcia_probe()
-';
-
-$ENV{C_DRAKX} and print '
-
-int
-Xtest(display)
- char *display
- CODE:
- int pid;
- if ((pid = fork()) == 0) {
- Display *d = XOpenDisplay(display);
- if (d) {
- XSetCloseDownMode(d, RetainPermanent);
- XCloseDisplay(d);
- }
- _exit(d != NULL);
- }
- waitpid(pid, &RETVAL, 0);
- OUTPUT:
- RETVAL
-
-void
-setMouseLive(display, type, emulate3buttons)
- char *display
- int type
- int emulate3buttons
- CODE:
- {
- XF86MiscMouseSettings mseinfo;
- Display *d = XOpenDisplay(display);
- if (d) {
- if (XF86MiscGetMouseSettings(d, &mseinfo) == True) {
- mseinfo.type = type;
- mseinfo.flags |= MF_REOPEN;
- mseinfo.emulate3buttons = emulate3buttons;
- XF86MiscSetMouseSettings(d, &mseinfo);
- XFlush(d);
- if (type == MTYPE_IMPS2) initIMPS2();
- }
- }
- }
-';
-
-print '
-
-int
-add_partition(hd, start_sector, size_sector, part_number)
- int hd
- unsigned long start_sector
- unsigned long size_sector
- int part_number
- CODE:
- {
- long long start = start_sector * 512;
- long long size = size_sector * 512;
- struct blkpg_partition p = { start, size, part_number, "", "" };
- struct blkpg_ioctl_arg s = { BLKPG_ADD_PARTITION, 0, sizeof(struct blkpg_partition), (void *) &p };
- RETVAL = ioctl(hd, BLKPG, &s) == 0;
- }
- OUTPUT:
- RETVAL
-
-int
-is_secure_file(filename)
- char * filename
- CODE:
- {
- int fd;
- unlink(filename); /* in case it exists and we manage to remove it */
- RETVAL = (fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) != -1;
- if (RETVAL) close(fd);
- }
- OUTPUT:
- RETVAL
-
-int
-is_ext3(device_name)
- char * device_name
- CODE:
- {
- ext2_filsys fs;
- int retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs);
- if (retval) {
- RETVAL = 0;
- } else {
- RETVAL = fs->super->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL;
- ext2fs_close(fs);
- }
- }
- OUTPUT:
- RETVAL
-
-void
-setlocale()
- CODE:
- setlocale(LC_ALL, "");
- setlocale(LC_NUMERIC, "C"); /* otherwise eval "1.5" returns 1 in fr_FR for example */
-
-char *
-bindtextdomain(domainname, dirname)
- char * domainname
- char * dirname
-
-char *
-dgettext(domainname, msgid)
- char * domainname
- char * msgid
-
-int
-KTYP(x)
- int x
- CODE:
- RETVAL = KTYP(x);
- OUTPUT:
- RETVAL
-
-int
-lseek_sector(fd, sector, offset)
- int fd
- long sector
- long offset
- CODE:
- RETVAL = lseek64(fd, (off64_t) sector * SECTORSIZE + offset, SEEK_SET) >= 0;
- OUTPUT:
- RETVAL
-
-int
-isBurner(fd)
- int fd
- CODE:
- RETVAL = ioctl(fd, CDROM_GET_CAPABILITY) & CDC_CD_RW;
- OUTPUT:
- RETVAL
-
-int
-isDvdDrive(fd)
- int fd
- CODE:
- RETVAL = ioctl(fd, CDROM_GET_CAPABILITY) & CDC_DVD;
- OUTPUT:
- RETVAL
-
-char *
-floppy_info(name)
- char * name
- CODE:
- int fd = open(name, O_RDONLY | O_NONBLOCK);
- RETVAL = NULL;
- if (fd != -1) {
- char drivtyp[17];
- ioctl(fd, FDGETDRVTYP, (void *)drivtyp);
- RETVAL = drivtyp;
- close(fd);
- }
- OUTPUT:
- RETVAL
-
-unsigned int
-total_sectors(fd)
- int fd
- CODE:
- {
- long s;
- RETVAL = ioctl(fd, BLKGETSIZE, &s) == 0 ? s : 0;
- }
- OUTPUT:
- RETVAL
-
-void
-unlimit_core()
- CODE:
- {
- struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY };
- setrlimit(RLIMIT_CORE, &rlim);
- }
-
-int
-getlimit_core()
- CODE:
- {
- struct rlimit rlim;
- getrlimit(RLIMIT_CORE, &rlim);
- RETVAL = rlim.rlim_cur;
- }
- OUTPUT:
- RETVAL
-
-void
-openlog(ident)
- char *ident
- CODE:
- openlog(ident, 0, 0);
-
-void
-closelog()
-
-void
-syslog(priority, mesg)
- int priority
- char *mesg
- CODE:
- syslog(priority, mesg);
-
-void
-setsid()
-
-void
-_exit(status)
- int status
-
-int
-detectSMP()
-
-void
-pci_probe(probe_type)
- int probe_type
- PPCODE:
- struct pciusb_entries entries = pci_probe(probe_type);
- char buf[2048];
- int i;
-
- EXTEND(SP, entries.nb);
- for (i = 0; i < entries.nb; i++) {
- struct pciusb_entry e = entries.entries[i];
- snprintf(buf, sizeof(buf), "%04x\t%04x\t%04x\t%04x\t%d\t%d\t%d\t%s\t%s\t%s",
- e.vendor, e.device, e.subvendor, e.subdevice, e.pci_bus, e.pci_device, e.pci_function,
- pci_class2text(e.class_), e.module ? e.module : "unknown", e.text);
- PUSHs(sv_2mortal(newSVpv(buf, 0)));
- }
- pciusb_free(&entries);
-
-void
-usb_probe()
- PPCODE:
- struct pciusb_entries entries = usb_probe();
- char buf[2048];
- int i;
-
- EXTEND(SP, entries.nb);
- for (i = 0; i < entries.nb; i++) {
- struct pciusb_entry e = entries.entries[i];
- snprintf(buf, sizeof(buf), "%04x\t%04x\t%s\t%s\t%s",
- e.vendor, e.device, usb_class2text(e.class_), e.module ? e.module : "unknown", e.text);
- PUSHs(sv_2mortal(newSVpv(buf, 0)));
- }
- pciusb_free(&entries);
-
-unsigned int
-getpagesize()
-
-int
-hasNetDevice(device)
- char * device
- CODE:
- struct ifreq req;
- int s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s == -1) { RETVAL = 0; return; }
-
- strcpy(req.ifr_name, device);
-
- RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0;
- close(s);
- OUTPUT:
- RETVAL
-
-int
-addDefaultRoute(gateway)
- char *gateway
- CODE:
- struct rtentry route;
- struct sockaddr_in addr;
- int s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s == -1) { RETVAL = 0; return; }
-
- memset(&route, 0, sizeof(route));
-
- addr.sin_family = AF_INET;
- addr.sin_port = 0;
- inet_aton(gateway, &addr.sin_addr);
- memcpy(&route.rt_gateway, &addr, sizeof(addr));
-
- addr.sin_addr.s_addr = INADDR_ANY;
- memcpy(&route.rt_dst, &addr, sizeof(addr));
- memcpy(&route.rt_genmask, &addr, sizeof(addr));
-
- route.rt_flags = RTF_UP | RTF_GATEWAY;
- route.rt_metric = 0;
-
- RETVAL = !ioctl(s, SIOCADDRT, &route);
- OUTPUT:
- RETVAL
-
-char *
-kernel_version()
- CODE:
- struct utsname u;
- if (uname(&u) == 0) RETVAL = u.release; else RETVAL = NULL;
- OUTPUT:
- RETVAL
-
-int
-prom_open()
-
-void
-prom_close()
-
-int
-prom_getsibling(node)
- int node
-
-int
-prom_getchild(node)
- int node
-
-void
-prom_getopt(key)
- char *key
- PPCODE:
- int lenp = 0;
- char *value = NULL;
- value = prom_getopt(key, &lenp);
- EXTEND(sp, 1);
- if (value != NULL) {
- PUSHs(sv_2mortal(newSVpv(value, 0)));
- } else {
- PUSHs(&PL_sv_undef);
- }
-
-void
-prom_setopt(key, value)
- char *key
- char *value
-
-void
-prom_getproperty(key)
- char *key
- PPCODE:
- int lenp = 0;
- char *value = NULL;
- value = prom_getproperty(key, &lenp);
- EXTEND(sp, 1);
- if (value != NULL) {
- PUSHs(sv_2mortal(newSVpv(value, lenp)));
- } else {
- PUSHs(&PL_sv_undef);
- }
-
-void
-prom_getstring(key)
- char *key
- PPCODE:
- int lenp = 0;
- char *value = NULL;
- value = prom_getproperty(key, &lenp);
- EXTEND(sp, 1);
- if (value != NULL) {
- PUSHs(sv_2mortal(newSVpv(value, 0)));
- } else {
- PUSHs(&PL_sv_undef);
- }
-
-int
-prom_getbool(key)
- char *key
-
-void
-initSilo()
-
-char *
-disk2PromPath(disk)
- unsigned char *disk
-
-int
-hasAliases()
-
-char *
-promRootName()
-
-void
-setPromVars(linuxAlias, bootDevice)
- char *linuxAlias
- char *bootDevice
-
-char *
-iconv(s, from_charset, to_charset)
- char *s
- char *from_charset
- char *to_charset
- CODE:
- iconv_t cd = iconv_open(to_charset, from_charset);
- RETVAL = s;
- if (cd != (iconv_t) (-1)) {
- size_t s_len = strlen(RETVAL);
- char *buf = alloca(3 * s_len + 10); /* 10 for safety, it should not be needed */
- {
- char *ptr = buf;
- size_t ptr_len = 3 * s_len + 10;
- if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
- *ptr = 0;
- RETVAL = buf;
- }
- }
- iconv_close(cd);
- }
- OUTPUT:
- RETVAL
-
-char *
-standard_charset()
- CODE:
- RETVAL = nl_langinfo(CODESET);
- OUTPUT:
- RETVAL
-
-';
-
-$ENV{C_RPM} and print '
-char *
-rpmErrorString()
-
-void
-rpmSetVeryVerbose()
- CODE:
- rpmSetVerbosity(RPMMESS_DEBUG);
-
-void
-rpmErrorSetCallback(fd)
- int fd
- CODE:
- rpmError_callback_data = fd;
- rpmErrorSetCallback(rpmError_callback);
-
-int
-rpmvercmp(char *a, char *b);
-';
-
-@macros = (
- [ qw(int S_IFCHR S_IFBLK S_IFIFO KDSKBENT KT_SPEC NR_KEYS MAX_NR_KEYMAPS BLKRRPART TIOCSCTTY
- HDIO_GETGEO BLKGETSIZE LOOP_GET_STATUS
- MS_MGC_VAL MS_RDONLY O_NONBLOCK F_SETFL F_GETFL O_CREAT SECTORSIZE WNOHANG
- VT_ACTIVATE VT_WAITACTIVE VT_GETSTATE CDROM_LOCKDOOR CDROMEJECT
- LOG_WARNING LOG_INFO LOG_LOCAL1
- ) ],
-);
-
-$\= "\n";
-print;
-
-foreach (@macros) {
- my ($type, @l) = @$_;
- foreach (@l) {
- print<< "END"
-$type
-$_()
- CODE:
- RETVAL = $_;
-
- OUTPUT:
- RETVAL
-
-END
-
- }
-}