freebsd-dev/release/sysinstall/uc_main.c

324 lines
7.9 KiB
C
Raw Normal View History

/***************************************************
* file: userconfig/uc_main.c
*
* Copyright (c) 1996 Eric L. Hernes (erich@rrnet.com)
* 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 author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
* library functions for userconfig library
*
1997-02-22 14:13:04 +00:00
* $Id$
*/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <paths.h>
#include <sys/mman.h>
#include <nlist.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "uc_main.h"
#include "sysinstall.h"
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
static struct nlist _nl[] = {
1996-10-05 05:51:12 +00:00
{"_isa_devtab_bio"},
{"_isa_devtab_tty"},
{"_isa_devtab_net"},
{"_isa_devtab_null"},
{"_isa_biotab_wdc"},
{"_isa_biotab_fdc"},
{"_eisadriver_set"},
{"_eisa_dev_list"},
{"_pcidevice_set"},
{"_device_list"},
{"_scbusses"},
{"_scsi_cinit"},
{"_scsi_dinit"},
{"_scsi_tinit"},
{""},
};
struct kernel *
uc_open(char *name){
1996-10-05 05:51:12 +00:00
int kd, flags, incore;
struct kernel *kern;
struct stat sb;
char kname[80];
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
int size, i = 0;
struct nlist *nl = _nl;
1996-10-05 05:51:12 +00:00
if (strcmp(name, "-incore") == 0)
incore = 1;
else
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
incore = 0;
1996-10-05 05:51:12 +00:00
if (incore || (strcmp(name,"-bootfile") == 0))
SAFE_STRCPY(kname, getbootfile());
1996-10-05 05:51:12 +00:00
else
SAFE_STRCPY(kname, name);
1996-10-05 05:51:12 +00:00
if (isDebug())
msgDebug("uc_open: kernel name is %s, incore = %d\n", kname, incore);
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
kern = (struct kernel *)malloc(sizeof(struct kernel));
#ifdef KERN_NO_SYMBOLS
1996-10-05 05:51:12 +00:00
if (incore) {
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
FILE *fp;
fp = fopen("/stand/symbols", "r");
if (!fp) {
msgDebug("Couldn't open /stand/symbols file! Punting.\n");
free(kern);
return NULL;
}
if (fscanf(fp, "%d\n", &size) != 1) {
msgDebug("Unable to get # of name list entries from symbol file.\n");
free(kern);
return NULL;
}
else if (isDebug())
msgDebug("uc_open: opened /stand/symbols file, reading %d entries.\n", size);
kern->nl = nl = (struct nlist *)malloc((size + 1) * sizeof(struct nlist));
bzero(nl, (size + 1) * sizeof(struct nlist));
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
for (i = 0; i < size; i++) {
char *cp, name[255];
int c1;
unsigned int uc1;
short d1;
unsigned long v1;
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
if (fgets(name, 255, fp) == NULL) {
msgDebug("Can't get name field for entry %d\n", i);
free(kern);
return NULL;
}
if ((cp = index(name, '\n')) != NULL)
*cp = '\0';
nl[i].n_name = strdup(name);
if (fscanf(fp, "%u %d %hd %ld\n", &uc1, &c1, &d1, &v1) == 4) {
nl[i].n_type = (unsigned char)uc1;
nl[i].n_other = (char)c1;
nl[i].n_desc = d1;
nl[i].n_value = v1;
if (isDebug())
msgDebug("uc_open: for entry %d, decoded: \"%s\", %u %d %hd %ld\n", i, nl[i].n_name, nl[i].n_type, nl[i].n_other, nl[i].n_desc, nl[i].n_value);
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
}
}
nl[i].n_name = "";
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
fclose(fp);
1996-10-05 05:51:12 +00:00
i = 0;
}
else
#endif
1996-10-05 05:51:12 +00:00
i = nlist(kname, nl);
if (i == -1) {
msgDebug("uc_open: kernel %s does not contain symbols.\n", kname);
Multiple changes stacked as one commit since they all depend on one another. First, change sysinstall and the Makefile rules to not build the kernel nlist directly into sysinstall now. Instead, spit it out as an ascii file in /stand and parse it from sysinstall later. This solves the chicken-n- egg problem of building sysinstall into the fsimage before BOOTMFS is built and can have its symbols extracted. Now we generate the symbol file in release.8. Second, add Poul-Henning's USERCONFIG_BOOT changes. These have two effects: 1. Userconfig is always entered, rather than only after a -c (don't scream yet, it's not as bad as it sounds). 2. Userconfig reads a message string which can optionally be written just past the boot blocks. This string "preloads" the userconfig input buffer and is parsed as user input. If the first command is not "USERCONFIG", userconfig will treat this as an implied "quit" (which is why you don't need to scream - you never even know you went through userconfig and back out again if you don't specifically ask for it), otherwise it will read and execute the following commands until a "quit" is seen or the end is reached, in which case the normal userconfig command prompt will then be presented. How to create your own startup sequences, using any boot.flp image from the next snap forward (not yet, but soon): % dd of=/dev/rfd0 seek=1 bs=512 count=1 conv=sync <<WAKKA_WAKKA_DOO USERCONFIG irq ed0 10 iomem ed0 0xcc000 disable ed1 quit WAKKA_WAKKA_DOO Third, add an intro screen to UserConfig so that users aren't just thrown into this strange screen if userconfig is auto-launched. The default boot.flp startup sequence is now, in fact, this: USERCONFIG intro visual (Since visual never returns, we don't need a following "quit"). Submitted-By: phk & jkh
1996-10-05 10:44:07 +00:00
free(kern);
return NULL;
1996-10-05 05:51:12 +00:00
}
1996-10-04 14:25:23 +00:00
#ifdef KERN_NO_SYMBOLS
1996-10-05 05:51:12 +00:00
if (!incore) {
1996-10-04 14:25:23 +00:00
#else
1996-10-05 05:51:12 +00:00
{
1996-10-04 14:25:23 +00:00
#endif
kern->nl=(struct nlist *)malloc(sizeof(_nl));
bcopy(_nl, kern->nl, sizeof(_nl));
}
1996-10-05 05:51:12 +00:00
if (incore) {
if (isDebug())
msgDebug("uc_open: attempting to open /dev/kmem for incore.\n");
if ((kd = open("/dev/kmem", O_RDONLY)) < 0) {
1996-10-05 05:51:12 +00:00
free(kern);
msgDebug("uc_open: Unable to open /dev/kmem.\n");
return NULL;
1996-10-05 05:51:12 +00:00
}
kern->core = (caddr_t)NULL;
kern->incore = 1;
kern->size = 0;
}
1996-10-05 05:51:12 +00:00
else {
if (stat(kname, &sb) < 0) {
free(kern);
msgDebug("uc_open: Unable to stat %s.\n", kname);
return NULL;
1996-10-05 05:51:12 +00:00
}
kern->size = sb.st_size;
flags = sb.st_flags;
1996-10-05 05:51:12 +00:00
if (chflags(kname, 0) < 0) {
free(kern);
msgDebug("uc_open: Unable to chflags %s.\n", kname);
return NULL;
1996-10-05 05:51:12 +00:00
}
if (isDebug())
msgDebug("uc_open: attempting to open %s\n", kname);
if ((kd = open(kname, O_RDWR, 0644)) < 0) {
1996-10-05 05:51:12 +00:00
free(kern);
msgDebug("uc_open: Unable to open %s.\n", kname);
return NULL;
1996-10-05 05:51:12 +00:00
}
fchflags(kd, flags);
1996-10-05 05:51:12 +00:00
if (isDebug())
msgDebug("uc_open: attempting to mmap %d bytes\n", sb.st_size);
kern->core = mmap((caddr_t)0, sb.st_size, PROT_READ | PROT_WRITE,
MAP_SHARED, kd, 0);
kern->incore = 0;
if (kern->core == MAP_FAILED) {
1996-10-05 05:51:12 +00:00
free(kern);
msgDebug("uc_open: Unable to mmap from %s.\n", kname);
return NULL;
1996-10-05 05:51:12 +00:00
}
}
1996-10-05 05:51:12 +00:00
kern->fd = kd;
get_isa_info(kern);
if (isDebug())
msgDebug("uc_open: got isa information\n");
1996-10-05 05:51:12 +00:00
get_pci_info(kern);
if (isDebug())
msgDebug("uc_open: got pci information\n");
1996-10-05 05:51:12 +00:00
get_eisa_info(kern);
if (isDebug())
msgDebug("uc_open: got eisa information\n");
#ifdef USE_SCSI
1996-10-05 05:51:12 +00:00
get_scsi_info(kern);
if (isDebug())
msgDebug("uc_open: got scsi information\n");
#else
kern->scsi_devp=(struct uc_scsi*)NULL;
kern->scsibus_devp=(struct uc_scsibus*)NULL;
#endif
1996-10-05 05:51:12 +00:00
return kern;
}
int
1996-10-05 05:51:12 +00:00
uc_close(struct kernel *kern, int writeback)
{
if (kern->isa_devp)
isa_free(kern, writeback);
if (kern->eisa_devp)
eisa_free(kern, writeback); /* `writeback' isn't really useful here */
if (kern->pci_devp)
pci_free(kern, writeback); /* or here */
if (kern->scsi_devp)
scsi_free(kern, writeback);
if (!kern->incore)
munmap(kern->core, kern->size);
close(kern->fd);
free(kern->nl);
free(kern);
return 0;
}
struct list *
1996-10-05 05:51:12 +00:00
uc_getdev(struct kernel *kern, char *dev)
{
struct list *list = (struct list *)0;
if (*dev == '-') { /* asked for -isa, -eisa, -pci, -scsi, -all */
if (strcmp(dev, "-all") == 0) {
list = list_new();
if (kern->isa_devp)
list_append(list, "isa");
if (kern->eisa_devp)
list_append(list, "eisa");
if (kern->pci_devp)
list_append(list, "pci");
if (kern->scsi_devp)
list_append(list, "scsi");
}
1996-10-05 05:51:12 +00:00
else if (strcmp(dev, "-isa") == 0)
list = get_isa_devlist(kern);
else if (strcmp(dev, "-eisa") == 0)
list = get_eisa_devlist(kern);
else if (strcmp(dev, "-pci") == 0)
list = get_pci_devlist(kern);
else if (strcmp(dev, "-scsi") == 0)
list = get_scsi_devlist(kern);
}
1996-10-05 05:51:12 +00:00
else {
/* we gotta figure out which real device to report */
struct uc_isa *ip;
struct uc_scsi *sp;
struct uc_pci *pp;
struct uc_eisa *ep;
if (kern->isa_devp) {
for (ip = kern->isa_devp; ip->device; ip++) {
if (strcmp(dev, ip->device) == 0) {
list = get_isa_device(ip);
goto end;
}
}
}
1996-10-05 05:51:12 +00:00
if (kern->scsi_devp) {
for (sp = kern->scsi_devp; sp->device; sp++) {
if (strcmp(dev, sp->device) == 0) {
list = get_scsi_device(sp);
goto end;
}
}
}
1996-10-05 05:51:12 +00:00
if (kern->pci_devp) {
for(pp = kern->pci_devp; pp->device; pp++) {
if (strcmp(dev, pp->device) == 0) {
list = get_pci_device(pp);
goto end;
}
}
}
if (kern->eisa_devp) {
for (ep = kern->eisa_devp; ep->device; ep++) {
if (strcmp(dev, ep->device) == 0) {
list = get_eisa_device(ep);
goto end;
}
}
}
}
end:
1996-10-05 05:51:12 +00:00
return(list);
}