diff options
author | Jeremy Katz <katzj@redhat.com> | 2002-12-09 18:11:18 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2002-12-09 18:11:18 +0000 |
commit | b6272454deb5e5479cf586eb043e3041f6f82ee1 (patch) | |
tree | 8973cac51aa4a274c1dd88c1441cdcec0801d249 /loader2 | |
parent | c96e4da0c0ff9cc4514c24324f1cf1abc4aa3df9 (diff) | |
download | anaconda-b6272454deb5e5479cf586eb043e3041f6f82ee1.tar.gz anaconda-b6272454deb5e5479cf586eb043e3041f6f82ee1.tar.xz anaconda-b6272454deb5e5479cf586eb043e3041f6f82ee1.zip |
move hardware functions into their own file
Diffstat (limited to 'loader2')
-rw-r--r-- | loader2/Makefile | 2 | ||||
-rw-r--r-- | loader2/driverdisk.c | 5 | ||||
-rw-r--r-- | loader2/hardware.c | 189 | ||||
-rw-r--r-- | loader2/hardware.h | 22 | ||||
-rw-r--r-- | loader2/loader.c | 180 | ||||
-rw-r--r-- | loader2/loader.h | 8 | ||||
-rw-r--r-- | loader2/md5.h | 1 |
7 files changed, 227 insertions, 180 deletions
diff --git a/loader2/Makefile b/loader2/Makefile index 7d34110cd..05c9bcf98 100644 --- a/loader2/Makefile +++ b/loader2/Makefile @@ -25,7 +25,7 @@ MODULELINKAGE :=-lmodutils -lmodutilutil -lmodutilobj BINS = init -HWOBJS = pcmcia.o usb.o firewire.o +HWOBJS = pcmcia.o usb.o firewire.o hardware.o METHOBJS = method.o cdinstall.o hdinstall.o nfsinstall.o urlinstall.o OBJS = log.o moduleinfo.o loadermisc.o modules.o moduledeps.o windows.o \ lang.o kbd.o modules.o modstubs.o driverdisk.o \ diff --git a/loader2/driverdisk.c b/loader2/driverdisk.c index 5a314d049..22c009f9d 100644 --- a/loader2/driverdisk.c +++ b/loader2/driverdisk.c @@ -30,15 +30,12 @@ #include "moduledeps.h" #include "moduleinfo.h" #include "windows.h" +#include "hardware.h" #include "../isys/isys.h" #include "../isys/imount.h" #include "../isys/probe.h" -/* JKFIXME: busProbe et al need to go into a hardware file */ -int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, - int justProbe, struct knownDevices * kd, int flags); - static char * driverDiskFiles[] = { "modinfo", "modules.dep", "pcitable", "modules.cgz", "rhdd-6.1", NULL }; diff --git a/loader2/hardware.c b/loader2/hardware.c new file mode 100644 index 000000000..ec694d1dd --- /dev/null +++ b/loader2/hardware.c @@ -0,0 +1,189 @@ +/* + * hardware.c - various hardware probing functionality + * + * Erik Troan <ewt@redhat.com> + * Matt Wilson <msw@redhat.com> + * Michael Fulbright <msf@redhat.com> + * Jeremy Katz <katzj@redhat.com> + * + * Copyright 1997 - 2002 Red Hat, Inc. + * + * This software may be freely redistributed under the terms of the GNU + * General 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. + */ + +#include <fcntl.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> + +#include "loader.h" +#include "hardware.h" +#include "log.h" + +/* JKFIXME: this is the same hack as in loader.c for second stage modules */ +extern struct moduleBallLocation * secondStageModuleLocation; + +static int detectHardware(moduleInfoSet modInfo, + char *** modules, int flags) { + struct device ** devices, ** device; + char ** modList; + int numMods; + char *driver; + + logMessage("probing buses"); + + devices = probeDevices(CLASS_UNSPEC, + BUS_PCI | BUS_SBUS, + PROBE_ALL); + + logMessage("finished bus probing"); + + if (devices == NULL) { + *modules = NULL; + return LOADER_OK; + } + + numMods = 0; + for (device = devices; *device; device++) numMods++; + + if (!numMods) { + *modules = NULL; + return LOADER_OK; + } + + modList = malloc(sizeof(*modList) * (numMods + 1)); + numMods = 0; + + for (device = devices; *device; device++) { + driver = (*device)->driver; + if (strcmp (driver, "ignore") && strcmp (driver, "unknown") + && strcmp (driver, "disabled")) { + modList[numMods++] = strdup(driver); + } + + freeDevice (*device); + } + + modList[numMods] = NULL; + *modules = modList; + + free(devices); + + return LOADER_OK; +} + +int agpgartInitialize(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags) { + struct device ** devices, *p; + int i; + + if (FL_TESTING(flags)) return 0; + + logMessage("looking for video cards requiring agpgart module"); + + devices = probeDevices(CLASS_VIDEO, BUS_UNSPEC, PROBE_ALL); + + if (!devices) { + logMessage("no video cards found"); + return 0; + } + + /* loop thru cards, see if we need agpgart */ + for (i=0; devices[i]; i++) { + p = devices[i]; + logMessage("found video card controller %s", p->driver); + + /* HACK - need to have list of cards which match!! */ + /* JKFIXME: verify this is really still needed */ + if (!strcmp(p->driver, "Card:Intel 810") || + !strcmp(p->driver, "Card:Intel 815")) { + logMessage("found %s card requiring agpgart, loading module", + p->driver+5); + + if (mlLoadModuleSetLocation("agpgart", modLoaded, modDeps, + modInfo, flags, + secondStageModuleLocation)) { + logMessage("failed to insert agpgart module"); + return 1; + } else { + /* only load it once! */ + return 0; + } + } + } + + return 0; +} + +/* This loads the necessary parallel port drivers for printers so that + kudzu can autodetect and setup printers in post install*/ +void initializeParallelPort(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags) { + /* JKFIXME: this can be used on other arches too... */ +#if !defined (__i386__) + return; +#endif + if (FL_NOPARPORT(flags)) return; + + logMessage("loading parallel port drivers..."); + if (mlLoadModuleSetLocation("parport_pc", modLoaded, modDeps, + modInfo, flags, + secondStageModuleLocation)) { + logMessage("failed to load parport_pc module"); + return; + } +} + +int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, + int justProbe, struct knownDevices * kd, int flags) { + int i; + char ** modList; + char modules[1024]; + + if (FL_NOPROBE(flags)) return 0; + + if (!access("/proc/bus/pci/devices", R_OK) || + !access("/proc/openprom", R_OK)) { + /* autodetect whatever we can */ + if (detectHardware(modInfo, &modList, flags)) { + logMessage("failed to scan pci bus!"); + return 0; + } else if (modList && justProbe) { + for (i = 0; modList[i]; i++) + printf("%s\n", modList[i]); + } else if (modList) { + *modules = '\0'; + + for (i = 0; modList[i]; i++) { + if (i) strcat(modules, ":"); + strcat(modules, modList[i]); + } + + mlLoadModuleSet(modules, modLoaded, modDeps, modInfo, flags); + + kdFindScsiList(kd, 0); + kdFindNetList(kd, 0); + } else + logMessage("found nothing"); + } + + return 0; +} + + +void scsiSetup(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags, + struct knownDevices * kd) { + mlLoadModuleSet("sd_mod:sr_mod", modLoaded, modDeps, modInfo, flags); +} + +void ideSetup(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags, + struct knownDevices * kd) { + mlLoadModuleSet("ide-cd", modLoaded, modDeps, modInfo, flags); +} diff --git a/loader2/hardware.h b/loader2/hardware.h new file mode 100644 index 000000000..d4f1da772 --- /dev/null +++ b/loader2/hardware.h @@ -0,0 +1,22 @@ +#ifndef LOADERHW_H +#define LOADERHW_H + +#include "modules.h" +#include "../isys/probe.h" + +int agpgartInitialize(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags); +void initializeParallelPort(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags); + +int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, + int justProbe, struct knownDevices * kd, int flags); + +void scsiSetup(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags, + struct knownDevices * kd); +void ideSetup(moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags, + struct knownDevices * kd); + +#endif diff --git a/loader2/loader.c b/loader2/loader.c index 5f1db0386..954a69ebf 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -57,6 +57,7 @@ #include "driverdisk.h" /* hardware stuff */ +#include "hardware.h" #include "firewire.h" #include "pcmcia.h" #include "usb.h" @@ -64,11 +65,15 @@ /* install method stuff */ #include "method.h" #include "cdinstall.h" +#include "nfsinstall.h" +#include "hdinstall.h" +#include "urlinstall.h" #include "../isys/imount.h" #include "../isys/isys.h" #include "../isys/probe.h" #include "../isys/stubs.h" +#include "../isys/lang.h" /* maximum number of extra arguments that can be passed to the second stage */ #define MAX_EXTRA_ARGS 128 @@ -102,6 +107,14 @@ static int numMethods = sizeof(installMethods) / sizeof(struct installMethod); struct moduleBallLocation * secondStageModuleLocation; +#if 0 +#if !defined(__s390__) && !defined(__s390x__) +#define RAMDISK_DEVICE "/dev/ram" +#else +#define RAMDISK_DEVICE "/dev/ram2" +#endif + + int setupRamdisk(void) { gzFile f; static int done = 0; @@ -133,6 +146,7 @@ int setupRamdisk(void) { return 0; } +#endif void setupRamfs(void) { mkdirChain("/tmp/ramfs"); @@ -277,172 +291,6 @@ static void checkForHardDrives(struct knownDevices * kd, int flags) { return; } -static int detectHardware(moduleInfoSet modInfo, - char *** modules, int flags) { - struct device ** devices, ** device; - char ** modList; - int numMods; - char *driver; - - logMessage("probing buses"); - - devices = probeDevices(CLASS_UNSPEC, - BUS_PCI | BUS_SBUS, - PROBE_ALL); - - logMessage("finished bus probing"); - - if (devices == NULL) { - *modules = NULL; - return LOADER_OK; - } - - numMods = 0; - for (device = devices; *device; device++) numMods++; - - if (!numMods) { - *modules = NULL; - return LOADER_OK; - } - - modList = malloc(sizeof(*modList) * (numMods + 1)); - numMods = 0; - - for (device = devices; *device; device++) { - driver = (*device)->driver; - if (strcmp (driver, "ignore") && strcmp (driver, "unknown") - && strcmp (driver, "disabled")) { - modList[numMods++] = strdup(driver); - } - - freeDevice (*device); - } - - modList[numMods] = NULL; - *modules = modList; - - free(devices); - - return LOADER_OK; -} - -static int agpgartInitialize(moduleList modLoaded, moduleDeps modDeps, - moduleInfoSet modInfo, int flags) { - struct device ** devices, *p; - int i; - - if (FL_TESTING(flags)) return 0; - - logMessage("looking for video cards requiring agpgart module"); - - devices = probeDevices(CLASS_VIDEO, BUS_UNSPEC, PROBE_ALL); - - if (!devices) { - logMessage("no video cards found"); - return 0; - } - - /* loop thru cards, see if we need agpgart */ - for (i=0; devices[i]; i++) { - p = devices[i]; - logMessage("found video card controller %s", p->driver); - - /* HACK - need to have list of cards which match!! */ - if (!strcmp(p->driver, "Card:Intel 810") || - !strcmp(p->driver, "Card:Intel 815")) { - logMessage("found %s card requiring agpgart, loading module", - p->driver+5); - - if (mlLoadModuleSetLocation("agpgart", modLoaded, modDeps, - modInfo, flags, - secondStageModuleLocation)) { - logMessage("failed to insert agpgart module"); - return 1; - } else { - /* only load it once! */ - return 0; - } - } - } - - return 0; -} - -/* This loads the necessary parallel port drivers for printers so that - kudzu can autodetect and setup printers in post install*/ -static void initializeParallelPort(moduleList modLoaded, moduleDeps modDeps, - moduleInfoSet modInfo, int flags) { - /* JKFIXME: this can be used on other arches too... */ -#if !defined (__i386__) - return; -#endif - if (FL_NOPARPORT(flags)) return; - - logMessage("loading parallel port drivers..."); - if (mlLoadModuleSetLocation("parport_pc", modLoaded, modDeps, - modInfo, flags, - secondStageModuleLocation)) { - logMessage("failed to load parport_pc module"); - return; - } -} - -int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, - int justProbe, struct knownDevices * kd, int flags) { - int i; - char ** modList; - char modules[1024]; - - if (FL_NOPROBE(flags)) return 0; - - if (!access("/proc/bus/pci/devices", R_OK) || - !access("/proc/openprom", R_OK)) { - /* autodetect whatever we can */ - if (detectHardware(modInfo, &modList, flags)) { - logMessage("failed to scan pci bus!"); - return 0; - } else if (modList && justProbe) { - for (i = 0; modList[i]; i++) - printf("%s\n", modList[i]); - } else if (modList) { - *modules = '\0'; - - for (i = 0; modList[i]; i++) { - if (i) strcat(modules, ":"); - strcat(modules, modList[i]); - } - - mlLoadModuleSet(modules, modLoaded, modDeps, modInfo, flags); - - kdFindScsiList(kd, 0); - kdFindNetList(kd, 0); - } else - logMessage("found nothing"); - } - - return 0; -} - - - -/* JKFIXME: move all of this hardware setup stuff to a new file */ -static void scsiSetup(moduleList modLoaded, moduleDeps modDeps, - moduleInfoSet modInfo, int flags, - struct knownDevices * kd) { - mlLoadModuleSet("sd_mod:sr_mod", modLoaded, modDeps, modInfo, flags); -} - -static void ideSetup(moduleList modLoaded, moduleDeps modDeps, - moduleInfoSet modInfo, int flags, - struct knownDevices * kd) { - - /* This is fast enough that we don't need a screen to pop up */ - mlLoadModuleSet("ide-cd", modLoaded, modDeps, modInfo, flags); - - /* JKFIXME: I removed a kdFindIde() call here... it seems bogus */ -} - - /* parses /proc/cmdline for any arguments which are important to us. * NOTE: in test mode, can specify a cmdline with --cmdline diff --git a/loader2/loader.h b/loader2/loader.h index a282f637b..8a800561a 100644 --- a/loader2/loader.h +++ b/loader2/loader.h @@ -70,14 +70,6 @@ void startNewt(int flags); void stopNewt(); -int setupRamdisk(void); - - -#if !defined(__s390__) && !defined(__s390x__) -#define RAMDISK_DEVICE "/dev/ram" -#else -#define RAMDISK_DEVICE "/dev/ram2" -#endif /* JKFIXME: I don't like all of the _set attribs, but without them, diff --git a/loader2/md5.h b/loader2/md5.h index bacfb534a..705692ab6 100644 --- a/loader2/md5.h +++ b/loader2/md5.h @@ -1,4 +1,3 @@ - #ifndef MD5_H #define MD5_H |