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/Makefile17
-rw-r--r--perl-install/c/Makefile.PL25
-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-dmi.c302
-rw-r--r--perl-install/c/smp-test.c6
-rw-r--r--perl-install/c/smp.c516
-rw-r--r--perl-install/c/smp.h6
-rw-r--r--perl-install/c/stuff.pm17
-rw-r--r--perl-install/c/stuff.xs.pl778
12 files changed, 0 insertions, 2652 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 0d09a8919..000000000
--- a/perl-install/c/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-.PHONY: clean
-
-MAKEIT = $(MAKE) -f Makefile_c LD_RUN_PATH=
-
-stuff: %: %.xs
- test -e Makefile_c || perl Makefile.PL
- $(MAKEIT) || $(MAKEIT)
- 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 probe.c
-
-stuff.xs: %: %.pl
- rm -f $@
- perl $< > $@
- chmod a-w $@
diff --git a/perl-install/c/Makefile.PL b/perl-install/c/Makefile.PL
deleted file mode 100644
index 46960e36d..000000000
--- a/perl-install/c/Makefile.PL
+++ /dev/null
@@ -1,25 +0,0 @@
-use MDK::Common;
-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 $lib = arch() =~ /x86_64/ ? 'lib64' : 'lib';
-
-my $libs = '-lldetect -lext2fs';
-$libs .= ' -lrpm -lrpmdb -lrpmio -lpopt -lz';
-
-my $pcmcia_dir = $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 smp-dmi.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 " . ($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-dmi.c b/perl-install/c/smp-dmi.c
deleted file mode 100644
index 241d8f464..000000000
--- a/perl-install/c/smp-dmi.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * CPU detetion based on DMI decode rev 1.2
- *
- * (C) 2003 Nicolas Planel <nplanel@mandrakesoft.com>
- *
- * Licensed under the GNU Public license. If you want to use it in with
- * another license just ask.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned int u32;
-
-static void
-dump_raw_data(void *data, unsigned int length)
-{
- unsigned char buffer1[80], buffer2[80], *b1, *b2, c;
- unsigned char *p = data;
- unsigned long column=0;
- unsigned int length_printed = 0;
- const unsigned char maxcolumn = 16;
- while (length_printed < length) {
- b1 = buffer1;
- b2 = buffer2;
- for (column = 0;
- column < maxcolumn && length_printed < length;
- column ++) {
- b1 += sprintf(b1, "%02x ",(unsigned int) *p);
- if (*p < 32 || *p > 126) c = '.';
- else c = *p;
- b2 += sprintf(b2, "%c", c);
- p++;
- length_printed++;
- }
- /* pad out the line */
- for (; column < maxcolumn; column++)
- {
- b1 += sprintf(b1, " ");
- b2 += sprintf(b2, " ");
- }
-
- printf("%s\t%s\n", buffer1, buffer2);
- }
-}
-
-
-
-struct dmi_header
-{
- u8 type;
- u8 length;
- u16 handle;
-};
-
-static char *dmi_string(struct dmi_header *dm, u8 s)
-{
- u8 *bp=(u8 *)dm;
- if (!s) return "";
-
- bp+=dm->length;
- while(s>1)
- {
- bp+=strlen(bp);
- bp++;
- s--;
- }
- return bp;
-}
-
-static char *dmi_processor_type(u8 code)
-{
- static char *processor_type[]={
- "",
- "Other",
- "Unknown",
- "Central Processor",
- "Math Processor",
- "DSP Processor",
- "Video Processor"
- };
-
- if(code == 0xFF)
- return "Other";
-
- if (code > 0xA1)
- return "";
- return processor_type[code];
-}
-
-static char *dmi_processor_family(u8 code)
-{
- static char *processor_family[]={
- "",
- "Other",
- "Unknown",
- "8086",
- "80286",
- "Intel386 processor",
- "Intel486 processor",
- "8087",
- "80287",
- "80387",
- "80487",
- "Pentium processor Family",
- "Pentium Pro processor",
- "Pentium II processor",
- "Pentium processor with MMX technology",
- "Celeron processor",
- "Pentium II Xeon processor",
- "Pentium III processor",
- "M1 Family",
- "M1","M1","M1","M1","M1","M1", /* 13h - 18h */
- "K5 Family",
- "K5","K5","K5","K5","K5","K5", /* 1Ah - 1Fh */
- "Power PC Family",
- "Power PC 601",
- "Power PC 603",
- "Power PC 603+",
- "Power PC 604",
- };
-
- if(code == 0xFF)
- return "Other";
-
- if (code > 0x24)
- return "";
- return processor_family[code];
-}
-
-typedef int (*dmi_decode)(u8 * data);
-
-static int decode_handle(int fd, u32 base, int len, int num, dmi_decode decode)
-{
- u8 *buf = malloc(len);
- struct dmi_header *dm;
- u8 *data;
- int i = 0;
- int ret = 0;
-
- if (lseek(fd, (long)base, 0) == -1) {
- perror("dmi: lseek");
- return;
- }
- if (read(fd, buf, len)!=len) {
- perror("dmi: read");
- return;
- }
- data = buf;
- while(i<num && data+sizeof(struct dmi_header)<=buf+len)
- {
- u8 *next;
- struct dmi_header *dm = (struct dmi_header *)data;
-
- /* look for the next handle */
- next=data+dm->length;
- while(next-buf+1<len && (next[0]!=0 || next[1]!=0))
- next++;
- next+=2;
- if(next-buf<=len)
- ret += decode(data);
- else {
- ret = 0; /* TRUNCATED */
- break;
- }
- data=next;
- i++;
- }
- free(buf);
- return ret;
-}
-
-static int dmi_detect(dmi_decode decode) {
- unsigned char buf[20];
- int fd = open("/dev/mem", O_RDONLY);
- long fp = 0xE0000L;
- int ret = 0;
-
- if (fd == -1) {
- perror("/dev/mem");
- exit(1);
- }
- if (lseek(fd, fp, 0) == -1) {
- perror("seek");
- exit(1);
- }
-
- while (fp < 0xFFFFF)
- {
- if (read(fd, buf, 16) != 16)
- perror("read");
-
- if (memcmp(buf, "_DMI_", 5) == 0) {
- u16 num = buf[13]<<8|buf[12];
- u16 len = buf[7]<<8|buf[6];
- u32 base = buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8];
-
- ret = decode_handle(fd, base, len, num, decode);
- break;
- }
- fp += 16;
- }
- close(fd);
- return ret;
-}
-
-static int processor(u8 *data) {
- struct dmi_header *dm = (struct dmi_header *)data;
-
- if((dm->type == 4) && /*"Central Processor"*/(data[5] == 3)) {
- if(/*Processor Manufacturer*/data[7] != 0)
- return 1;
- }
- return 0;
-}
-
-static int memory_in_MB_type6(u8 *data)
-{
- struct dmi_header *dm;
-
- int dmi_memory_module_size(u8 code) {
- /* 3.3.7.2 */
- switch(code&0x7F) {
- case 0x7D: /* Not Determinable */
- case 0x7E: /* Disabled */
- case 0x7F: /* Not Installed */
- break;
- default:
- return 1<<(code&0x7F);
- }
- return 0;
- }
-
- dm = (struct dmi_header *)data;
-
- if ((dm->type == 6) && (dm->length >= 0xC))
- return dmi_memory_module_size(data[0x0A]); /* Enabled Size */
-
- return 0;
-}
-
-static int memory_in_MB_type17(u8 *data)
-{
- struct dmi_header *dm;
-
- int form_factor_check(u8 code) {
- /* 3.3.18.1 */
- static const char form_factor[]={
- 0, /* "Other", */ /* 0x01 */
- 0, /* "Unknown", */
- 1, /* "SIMM", */
- 1, /* "SIP", */
- 0, /* "Chip", */
- 1, /* "DIP", */
- 0, /* "ZIP", */
- 0, /* "Proprietary Card", */
- 1, /* "DIMM", */
- 0, /* "TSOP", */
- 0, /* "Row Of Chips", */
- 1, /* "RIMM", */
- 1, /* "SODIMM", */
- 1, /* "SRIMM" *//* 0x0E */
- };
-
- if(code>=0x01 && code<=0x0E)
- return form_factor[code-0x01];
- return 0; /* out of spec */
- }
- int dmi_memory_device_size(u16 code) {
- int mult = 1;
-
- if (code == 0 || code == 0xFFFF)
- return 0;
- if (code & 0x8000) /* code is in KB */
- mult = 1024;
- return (code & 0x7FFF) * mult;
- }
-
- dm = (struct dmi_header *)data;
-
- if ((dm->type == 17) && (dm->length >= 0x15)) {
- if (form_factor_check(data[0x0E]))
- return dmi_memory_device_size((data[0x0D] << 8) + data[0x0C]);
- }
-
- return 0;
-}
-
-int intelDetectSMP(void) {
- return dmi_detect(processor) > 1;
-}
-
-int dmiDetectMemory(void) {
- int s1 = dmi_detect(memory_in_MB_type6);
- int s2 = dmi_detect(memory_in_MB_type17);
- return s1 > s2 ? s1 : s2;
-}
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 886321e06..000000000
--- a/perl-install/c/smp.c
+++ /dev/null
@@ -1,516 +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__ */
-
-#if defined(__i386__) || defined(__x86_64__)
-/*
- * 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
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned int u32;
-typedef vm_offset_t addr_t;
-
-/* 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 ];
- addr_t pap;
- u8 length;
- u8 spec_rev;
- u8 checksum;
- u8 mpfb1;
- u8 mpfb2;
- u8 mpfb3;
- u8 mpfb4;
- u8 mpfb5;
-} mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[ 4 ];
- u16 base_table_length;
- u8 spec_rev;
- u8 checksum;
- u8 oem_id[ 8 ];
- u8 product_id[ 12 ];
- addr_t oem_table_pointer;
- u16 oem_table_size;
- u16 entry_count;
- addr_t apic_address;
- u16 extended_table_length;
- u8 extended_table_checksum;
- u8 reserved;
-} mpcth_t;
-
-typedef struct PROCENTRY {
- u8 type;
- u8 apicID;
- u8 apicVersion;
- u8 cpuFlags;
- u32 cpuSignature;
- u32 featureFlags;
- u32 reserved1;
- u32 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;
-}
-
-extern int intelDetectSMP(void);
-
-// old detection
-static int intelDetectSMP_mptable(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 = 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() || intelDetectSMP_mptable();
-#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__
- return isSMP = intelDetectSMP() || intelDetectSMP_mptable();
-#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 405f896cd..000000000
--- a/perl-install/c/stuff.pm
+++ /dev/null
@@ -1,17 +0,0 @@
-package c::stuff; # $Id$
-
-use strict;
-use vars qw($VERSION @ISA);
-
-require DynaLoader;
-
-@ISA = qw(DynaLoader);
-$VERSION = '0.01';
-# perl_checker: EXPORT-ALL
-
-c::stuff->bootstrap($VERSION);
-
-sub from_utf8 { iconv($_[0], "utf-8", standard_charset()) }
-sub to_utf8 { iconv($_[0], standard_charset(), "utf-8") }
-
-1;
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
deleted file mode 100644
index 889b29428..000000000
--- a/perl-install/c/stuff.xs.pl
+++ /dev/null
@@ -1,778 +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 <stdio.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>
-#undef __USE_MISC
-#include <linux/wireless.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 <linux/iso_fs.h>
-#include <net/if.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <linux/sockios.h>
-
-// for ethtool structs:
-typedef unsigned long long u64;
-typedef __uint32_t u32;
-typedef __uint16_t u16;
-typedef __uint8_t u8;
-
-#include <linux/ethtool.h>
-
-/* for is_ext3 */
-#include <ext2fs/ext2_fs.h>
-#include <ext2fs/ext2fs.h>
-
-// for UPS on USB:
-# define HID_MAX_USAGES 1024
-#include <linux/hiddev.h>
-
-#include <libldetect.h>
-
-#include <langinfo.h>
-#include <string.h>
-#include <iconv.h>
-
-#include <libintl.h>
-
-#define SECTORSIZE 512
-
-char *prom_getopt();
-void prom_setopt();
-char *prom_getproperty();
-char *disk2PromPath();
-char *promRootName();
-
-';
-
-$Config{archname} =~ /i.86/ and print '
-char *pcmcia_probe(void);
-';
-
-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()));
- }
-}
-
-';
-
-print '
-
-void log_message(const char * s, ...) {
- va_list args;
- va_list args_copy;
- FILE * logtty = fopen("/dev/tty3", "w");
- if (!logtty)
- return;
- fprintf(logtty, "* ");
- va_start(args, s);
- vfprintf(logtty, s, args);
- fprintf(logtty, "\n");
- fclose(logtty);
- va_end(args);
-
- logtty = fopen("/tmp/ddebug.log", "a");
- if (!logtty)
- return;
- fprintf(logtty, "* ");
- va_copy(args_copy, args);
- va_start(args_copy, s);
- vfprintf(logtty, s, args_copy);
- fprintf(logtty, "\n");
- fclose(logtty);
- va_end(args_copy);
-}
-
-';
-
-print '
-
-SV * iconv_(char* s, char* from_charset, char* to_charset) {
- iconv_t cd = iconv_open(to_charset, from_charset);
- char* retval = s;
- if (cd != (iconv_t) (-1)) {
- size_t s_len = strlen(retval);
- /* the maximum expansion when converting happens when converting
- tscii to utf-8; each tscii char can become up to 4 unicode chars
- and each one of those unicode chars can be 3 bytes long */
- char *buf = alloca(4 * 3 * s_len);
- {
- char *ptr = buf;
- size_t ptr_len = 4 * 3 * s_len;
- if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
- *ptr = 0;
- retval = buf;
- }
- }
- iconv_close(cd);
- }
- return newSVpv(retval, 0);
-}
-
-int length_of_space_padded(char *str, int len) {
- while (len >= 0 && str[len-1] == \' \')
- --len;
- return len;
-}
-
-MODULE = c::stuff PACKAGE = c::stuff
-
-';
-
-$Config{archname} =~ /i.86/ and print '
-char *
-pcmcia_probe()
-';
-
-print '
-char *
-dgettext(domainname, msgid)
- char * domainname
- char * msgid
-
-int
-del_partition(hd, part_number)
- int hd
- int part_number
- CODE:
- {
- struct blkpg_partition p = { 0, 0, part_number, "", "" };
- struct blkpg_ioctl_arg s = { BLKPG_DEL_PARTITION, 0, sizeof(struct blkpg_partition), (void *) &p };
- RETVAL = ioctl(hd, BLKPG, &s) == 0;
- }
- OUTPUT:
- RETVAL
-
-int
-add_partition(hd, part_number, start_sector, size_sector)
- int hd
- int part_number
- unsigned long start_sector
- unsigned long size_sector
- CODE:
- {
- long long start = (long long) start_sector * 512;
- long long size = (long long) 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
-
-char *
-get_ext2_label(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_volume_name;
- 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 *
-bind_textdomain_codeset(domainname, codeset)
- char * domainname
- char * codeset
-
-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];
- if (ioctl(fd, FDGETDRVTYP, (void *)drivtyp) == 0) {
- struct floppy_drive_struct ds;
- if (ioctl(fd, FDPOLLDRVSTAT, &ds) == 0 && ds.track >= 0)
- 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
-
-void
-usleep(microseconds)
- unsigned long microseconds
-
-int
-detectSMP()
-
-int
-dmiDetectMemory()
-
-void
-pci_probe()
- PPCODE:
- struct pciusb_entries entries = pci_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%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];
- struct usb_class_text class_text = usb_class2text(e->class_);
- snprintf(buf, sizeof(buf), "%04x\t%04x\t%s|%s|%s\t%s\t%s\t%d\t%d",
- e->vendor, e->device, class_text.usb_class_text, class_text.usb_sub_text, class_text.usb_prot_text, e->module ? e->module : "unknown", e->text, e->pci_bus, e->pci_device);
- PUSHs(sv_2mortal(newSVpv(buf, 0)));
- }
- pciusb_free(&entries);
-
-unsigned int
-getpagesize()
-
-
-char*
-get_usb_ups_name(int fd)
- CODE:
- /* from nut/drivers/hidups.c::upsdrv_initups() : */
- char name[256];
- ioctl(fd, HIDIOCGNAME(sizeof(name)), name);
- RETVAL=name;
- ioctl(fd, HIDIOCINITREPORT, 0);
- OUTPUT:
- RETVAL
-
-
-
-int
-hasNetDevice(device)
- char * device
- CODE:
- struct ifreq req;
- int s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s == -1) { RETVAL = 0; return; }
-
- strncpy(req.ifr_name, device, IFNAMSIZ);
-
- RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0;
- close(s);
- OUTPUT:
- RETVAL
-
-
-int
-isNetDeviceWirelessAware(device)
- char * device
- CODE:
- struct iwreq ifr;
-
- int s = socket(AF_INET, SOCK_DGRAM, 0);
-
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, device, IFNAMSIZ);
- RETVAL = ioctl(s, SIOCGIWNAME, &ifr) != -1;
- close(s);
- OUTPUT:
- RETVAL
-
-
-void
-get_netdevices()
- PPCODE:
- struct ifconf ifc;
- struct ifreq *ifr;
- int i;
- int numreqs = 10;
-
- int s = socket(AF_INET, SOCK_DGRAM, 0);
-
- ifc.ifc_buf = NULL;
- for (;;) {
- ifc.ifc_len = sizeof(struct ifreq) * numreqs;
- ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
-
- if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
- perror("SIOCGIFCONF");
- return;
- }
- if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) {
- /* assume it overflowed and try again */
- numreqs += 10;
- continue;
- }
- break;
- }
- if (ifc.ifc_len) {
- ifr = ifc.ifc_req;
- EXTEND(sp, ifc.ifc_len);
- for (i=0; i < ifc.ifc_len; i+= sizeof(struct ifreq)) {
- PUSHs(sv_2mortal(newSVpv(ifr->ifr_name, 0)));
- ifr++;
- }
- }
-
- close(s);
-
-
-char*
-getNetDriver(char* device)
- ALIAS:
- getHwIDs = 1
- CODE:
- struct ifreq ifr;
- struct ethtool_drvinfo drvinfo;
- int s = socket(AF_INET, SOCK_DGRAM, 0);
-
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, device, IFNAMSIZ);
-
- drvinfo.cmd = ETHTOOL_GDRVINFO;
- ifr.ifr_data = (caddr_t) &drvinfo;
-
- if (ioctl(s, SIOCETHTOOL, &ifr) != -1) {
- switch (ix) {
- case 0:
- RETVAL = strdup(drvinfo.driver);
- break;
- case 1:
- RETVAL = strdup(drvinfo.bus_info);
- break;
- }
- } else { perror("SIOCETHTOOL"); RETVAL = strdup(""); }
- 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*
-get_hw_address(const char* ifname)
- CODE:
- int s;
- struct ifreq ifr;
- unsigned char *a;
- char *res;
- s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
- if (s < 0) {
- perror("socket");
- RETVAL = NULL;
- return;
- }
- strncpy((char*) &ifr.ifr_name, ifname, IFNAMSIZ);
- if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) {
- perror("ioctl(SIOCGIFHWADDR)");
- RETVAL = NULL;
- return;
- }
- a = ifr.ifr_hwaddr.sa_data;
- asprintf(&res, "%02x:%02x:%02x:%02x:%02x:%02x", a[0],a[1],a[2],a[3],a[4],a[5]);
- RETVAL= res;
- 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
-
-SV *
-iconv(s, from_charset, to_charset)
- char *s
- char *from_charset
- char *to_charset
- CODE:
- RETVAL = iconv_(s, from_charset, to_charset);
- OUTPUT:
- RETVAL
-
-int
-is_tagged_utf8(s)
- SV *s
- CODE:
- RETVAL = SvUTF8(s);
- OUTPUT:
- RETVAL
-
-void
-set_tagged_utf8(s)
- SV *s
- CODE:
- SvUTF8_on(s);
-
-void
-upgrade_utf8(s)
- SV *s
- CODE:
- sv_utf8_upgrade(s);
-
-void
-unset_tagged_utf8(s)
- SV *s
- CODE:
- SvUTF8_off(s);
-
-char *
-standard_charset()
- CODE:
- RETVAL = nl_langinfo(CODESET);
- OUTPUT:
- RETVAL
-
-void
-get_iso_volume_ids(int fd)
- INIT:
- struct iso_primary_descriptor voldesc;
- PPCODE:
- lseek(fd, 16 * ISOFS_BLOCK_SIZE, SEEK_SET);
- if (read(fd, &voldesc, sizeof(struct iso_primary_descriptor)) == sizeof(struct iso_primary_descriptor)) {
- if (voldesc.type[0] == ISO_VD_PRIMARY && !strncmp(voldesc.id, ISO_STANDARD_ID, sizeof(voldesc.id))) {
- XPUSHs(sv_2mortal(newSVpv(voldesc.volume_id, length_of_space_padded(voldesc.volume_id, sizeof(voldesc.volume_id)))));
- XPUSHs(sv_2mortal(newSVpv(voldesc.application_id, length_of_space_padded(voldesc.application_id, sizeof(voldesc.application_id)))));
- }
- }
-
-';
-
-print '
-const 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 K_NOSUCHMAP NR_KEYS MAX_NR_KEYMAPS BLKRRPART TIOCSCTTY
- HDIO_GETGEO BLKGETSIZE LOOP_GET_STATUS HIDIOCAPPLICATION
- MS_MGC_VAL MS_RDONLY O_NONBLOCK F_SETFL F_GETFL O_CREAT SECTORSIZE WNOHANG
- VT_ACTIVATE VT_WAITACTIVE VT_GETSTATE CDROM_LOCKDOOR CDROMEJECT CDROM_DRIVE_STATUS CDS_DISC_OK
- LOG_WARNING LOG_INFO LOG_LOCAL1
- ) ],
-);
-
-$\= "\n";
-print;
-
-foreach (@macros) {
- my ($type, @l) = @$_;
- foreach (@l) {
- print<< "END"
-$type
-$_()
- CODE:
- RETVAL = $_;
-
- OUTPUT:
- RETVAL
-
-END
-
- }
-}
-print '
-
-PROTOTYPES: DISABLE
-';
-