Remove obsolete dset code. It's an ELF/3-stage boot world now and there
are cleaner ways of doing this that don't involve stomping on kernel binaries directly.
This commit is contained in:
parent
8910306462
commit
7eaf680c7a
@ -15,15 +15,11 @@ SRCS= anonFTP.c cdrom.c command.c config.c devices.c \
|
||||
label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \
|
||||
msg.c network.c nfs.c options.c package.c register.c system.c \
|
||||
tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \
|
||||
uc_eisa.c uc_isa.c uc_kmem.c uc_list.c uc_main.c uc_pci.c \
|
||||
keymap.h
|
||||
|
||||
CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR}
|
||||
CFLAGS+= -I${.CURDIR}/../../sys
|
||||
CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS # -DSAVE_USERCONFIG -DDO_SCSI
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
CFLAGS+= -DSAVE_USERCONFIG
|
||||
.endif
|
||||
CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS
|
||||
|
||||
DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
|
||||
LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.220 1998/12/06 10:13:57 jkh Exp $
|
||||
* $Id: install.c,v 1.221 1999/01/08 00:14:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -35,7 +35,6 @@
|
||||
*/
|
||||
|
||||
#include "sysinstall.h"
|
||||
#include "uc_main.h"
|
||||
#include <ctype.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/errno.h>
|
||||
@ -54,9 +53,6 @@
|
||||
|
||||
static void create_termcap(void);
|
||||
static void fixit_common(void);
|
||||
#ifdef SAVE_USERCONFIG
|
||||
static void save_userconfig_to_kernel(char *);
|
||||
#endif
|
||||
|
||||
#define TERMCAP_FILE "/usr/share/misc/termcap"
|
||||
|
||||
@ -762,10 +758,6 @@ installFixupBin(dialogMenuItem *self)
|
||||
msgConfirm("Unable to copy /kernel into place!");
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
#ifdef SAVE_USERCONFIG
|
||||
/* Snapshot any boot -c changes back to the new kernel */
|
||||
save_userconfig_to_kernel("/kernel");
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
msgConfirm("Can't find a kernel image to link to on the root file system!\n"
|
||||
@ -1120,62 +1112,3 @@ create_termcap(void)
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SAVE_USERCONFIG
|
||||
static void
|
||||
save_userconfig_to_kernel(char *kern)
|
||||
{
|
||||
struct kernel *core, *boot;
|
||||
struct list *c_isa, *b_isa, *c_dev, *b_dev;
|
||||
int i, d;
|
||||
|
||||
if ((core = uc_open("-incore")) == NULL) {
|
||||
msgDebug("save_userconf: Can't read in-core information for kernel.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((boot = uc_open(kern)) == NULL) {
|
||||
msgDebug("save_userconf: Can't read device information for kernel image %s\n", kern);
|
||||
return;
|
||||
}
|
||||
|
||||
msgNotify("Saving any boot -c changes to new kernel...");
|
||||
c_isa = uc_getdev(core, "-isa");
|
||||
b_isa = uc_getdev(boot, "-isa");
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: got %d ISA device entries from core, %d from boot.\n", c_isa->ac, b_isa->ac);
|
||||
for (d = 0; d < c_isa->ac; d++) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: ISA device loop, c_isa->av[%d] = %s\n", d, c_isa->av[d]);
|
||||
if (strcmp(c_isa->av[d], "npx0")) { /* special case npx0, which mucks with its id_irq member */
|
||||
c_dev = uc_getdev(core, c_isa->av[d]);
|
||||
b_dev = uc_getdev(boot, b_isa->av[d]);
|
||||
if (!c_dev || !b_dev) {
|
||||
msgDebug("save_userconf: c_dev: %x b_dev: %x\n", c_dev, b_dev);
|
||||
continue;
|
||||
}
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: ISA device %s: %d config parameters (core), %d (boot)\n",
|
||||
c_isa->av[d], c_dev->ac, b_dev->ac);
|
||||
for (i = 0; i < c_dev->ac; i++) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: c_dev->av[%d] = %s, b_dev->av[%d] = %s\n", i, c_dev->av[i], i, b_dev->av[i]);
|
||||
if (strcmp(c_dev->av[i], b_dev->av[i])) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: %s (boot) -> %s (core)\n",
|
||||
c_dev->av[i], b_dev->av[i]);
|
||||
isa_setdev(boot, c_dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isDebug())
|
||||
msgDebug("skipping npx0\n");
|
||||
}
|
||||
}
|
||||
if (isDebug())
|
||||
msgDebug("Closing kernels\n");
|
||||
uc_close(core, 0);
|
||||
uc_close(boot, 1);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,166 +0,0 @@
|
||||
/***************************************************
|
||||
* file: userconfig/uc_eisa.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.
|
||||
*
|
||||
* $Id: uc_eisa.c,v 1.4 1997/02/22 14:12:26 peter Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <nlist.h>
|
||||
#include <i386/eisa/eisaconf.h>
|
||||
|
||||
#include "uc_main.h"
|
||||
|
||||
struct eisa_device_node {
|
||||
struct eisa_device dev;
|
||||
struct eisa_device_node *next;
|
||||
};
|
||||
|
||||
/* module prototypes */
|
||||
static void eisa_fill_in(struct kernel *, struct uc_eisa *, struct eisa_device_node *);
|
||||
|
||||
void
|
||||
get_eisa_info(struct kernel *kp){
|
||||
int i, total;
|
||||
u_int *ls;
|
||||
struct eisa_driver *ed;
|
||||
struct uc_eisa *ep, *epc;
|
||||
char *name;
|
||||
|
||||
if(kp->nl[EISA_SET].n_value || kp->nl[EISA_LIST].n_value) {
|
||||
ep=epc=(struct uc_eisa *)malloc(sizeof(struct uc_eisa));
|
||||
if(!kp->incore) {
|
||||
if(kp->nl[EISA_SET].n_value) {
|
||||
u_int ndev;
|
||||
ls=(u_int *)kv_to_u(kp, kp->nl[EISA_SET].n_value, sizeof(u_int)*10); /* XXX, size? */
|
||||
ndev=ls[0];
|
||||
for(i=1;i<(ndev+1);i++){
|
||||
ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*i);
|
||||
epc = ep+(i-1);
|
||||
ed=(struct eisa_driver *)kv_to_u(kp, ls[i], sizeof(struct eisa_driver));
|
||||
name=(char *)kv_to_u(kp, (u_int)ed->name, 10); /* XXX, size? */
|
||||
asprintf(&epc->device, "%s", name);
|
||||
asprintf(&epc->full_name, "?");
|
||||
}
|
||||
ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*i);
|
||||
epc = ep+(i-1);
|
||||
bzero(epc, sizeof(struct uc_eisa));
|
||||
kp->eisa_devp=ep;
|
||||
} else { /* not incore and no symbol, we have no EISA devs... */
|
||||
kp->eisa_devp=(struct uc_eisa *)0;
|
||||
}
|
||||
} else {
|
||||
/* if we're incore, we can get data from _eisa_dev_list, */
|
||||
/* which should be much more useful, but I'll need a machine */
|
||||
/* to test :( */
|
||||
if(kp->nl[EISA_LIST].n_value) {
|
||||
u_int t;
|
||||
struct eisa_device_node *edn;
|
||||
|
||||
t=kv_dref_p(kp, kp->nl[EISA_LIST].n_value);
|
||||
total=0;
|
||||
while(t) {
|
||||
edn=(struct eisa_device_node *)
|
||||
kv_to_u(kp, t,sizeof(struct eisa_device_node));
|
||||
ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*(total+1));
|
||||
epc=ep+total;
|
||||
eisa_fill_in(kp, epc, edn);
|
||||
t=(u_int)edn->next;
|
||||
free(edn);
|
||||
total++;
|
||||
}
|
||||
|
||||
ep=(struct uc_eisa *)realloc(ep, sizeof(struct uc_eisa)*(total+1));
|
||||
epc=ep+total;
|
||||
bzero(epc, sizeof(struct uc_eisa));
|
||||
kp->eisa_devp=ep;
|
||||
} else {
|
||||
kp->eisa_devp=(struct uc_eisa *)0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
kp->eisa_devp=(struct uc_eisa *)0;
|
||||
}
|
||||
}
|
||||
|
||||
struct list *
|
||||
get_eisa_devlist(struct kernel *kp){
|
||||
struct list *dl;
|
||||
struct uc_eisa *kdp;
|
||||
|
||||
dl=list_new();
|
||||
|
||||
for(kdp=kp->eisa_devp; kdp->device; kdp++){
|
||||
list_append(dl, kdp->device);
|
||||
}
|
||||
return(dl);
|
||||
}
|
||||
|
||||
|
||||
struct list *
|
||||
get_eisa_device(struct uc_eisa *ep){
|
||||
struct list *list;
|
||||
list=list_new();
|
||||
|
||||
list_append(list, ep->device);
|
||||
list_append(list, ep->full_name);
|
||||
|
||||
return(list);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
eisa_fill_in(struct kernel *kp, struct uc_eisa *epc, struct eisa_device_node *edn){
|
||||
struct eisa_driver *edrv;
|
||||
char *n;
|
||||
|
||||
edrv=(struct eisa_driver *)kv_to_u(kp, (u_int)edn->dev.driver,
|
||||
sizeof(struct eisa_driver));
|
||||
|
||||
n=(char *)kv_to_u(kp, (u_int)edrv->name, 20);
|
||||
asprintf(&epc->device, "%s%lu", n, edn->dev.unit);
|
||||
free(n);
|
||||
|
||||
n=(char *)kv_to_u(kp, (u_int)edn->dev.full_name, 40); /*XXX*/
|
||||
asprintf(&epc->full_name, "%s", n);
|
||||
free(n);
|
||||
free(edrv);
|
||||
}
|
||||
|
||||
void
|
||||
eisa_free(struct kernel *kp, int writeback){
|
||||
struct uc_eisa *ep;
|
||||
|
||||
for(ep=kp->eisa_devp;ep->device;ep++){
|
||||
free(ep->device);
|
||||
free(ep->full_name);
|
||||
}
|
||||
free(kp->eisa_devp);
|
||||
kp->eisa_devp=0;
|
||||
}
|
||||
|
||||
/* end of userconfig/uc_eisa.c */
|
@ -1,211 +0,0 @@
|
||||
/***************************************************
|
||||
* file: userconfig/uc_isa.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.
|
||||
*
|
||||
* $Id: uc_isa.c,v 1.4 1997/02/22 14:12:27 peter Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <nlist.h>
|
||||
#include <i386/isa/isa_device.h>
|
||||
|
||||
#include "uc_main.h"
|
||||
|
||||
void
|
||||
get_isa_info(struct kernel *kp){
|
||||
int total, i, j;
|
||||
struct uc_isa *idp;
|
||||
struct isa_device *p, *isa_dp;
|
||||
struct isa_driver *drv;
|
||||
char *name;
|
||||
|
||||
if(kp->nl[ISA_BIOTAB].n_value || kp->nl[ISA_TTYTAB].n_value || kp->nl[ISA_NETTAB].n_value ||
|
||||
kp->nl[ISA_CAMTAB].n_value || kp->nl[ISA_NULLTAB].n_value ||
|
||||
kp->nl[ISA_WDCTAB].n_value || kp->nl[ISA_FDCTAB].n_value) {
|
||||
|
||||
idp = kp->isa_devp = (struct uc_isa *)malloc(sizeof(struct uc_isa));
|
||||
total=0; /* a running total of the number of isa devices */
|
||||
|
||||
for (i=0; i<6; i++) { /* the isa devices */
|
||||
if(kp->nl[i].n_value) {
|
||||
p = isa_dp = (struct isa_device *)kv_to_u(kp, kp->nl[i].n_value, /* XXX size? */
|
||||
sizeof(struct isa_device)*30);
|
||||
/* build the device list */
|
||||
/* `total' keeps a running total of all the devices found */
|
||||
for (j=0; p->id_id; j++, p++, total++) {
|
||||
kp->isa_devp = (struct uc_isa *)realloc(kp->isa_devp,
|
||||
sizeof(struct uc_isa)*(total+1));
|
||||
idp=kp->isa_devp+total;
|
||||
|
||||
drv=(struct isa_driver *)kv_to_u(kp, (u_int)p->id_driver, sizeof(struct isa_driver));
|
||||
name=(char *)kv_to_u(kp, (u_int)drv->name, 64);
|
||||
|
||||
if (i==ISA_WDCTAB || i==ISA_FDCTAB) { /* special case the disk devices */
|
||||
char n[10];
|
||||
strncpy(n, name, 10);
|
||||
n[strlen(n)-1]=0; /* chop off the trailing 'c' */
|
||||
asprintf(&idp->device, "%s%d", n, j);
|
||||
} else {
|
||||
asprintf(&idp->device, "%s%d", name, p->id_unit);
|
||||
}
|
||||
idp->port=p->id_iobase;
|
||||
idp->irq=p->id_irq;
|
||||
idp->drq=p->id_drq;
|
||||
idp->iomem=(u_int)p->id_maddr & 0xFFFFFF; /* kludge to get pa from kva */
|
||||
idp->iosize=p->id_msize;
|
||||
idp->flags=p->id_flags;
|
||||
idp->alive=p->id_alive;
|
||||
idp->enabled=p->id_enabled;
|
||||
idp->modified=0;
|
||||
if(!kp->incore){
|
||||
idp->idp=p;
|
||||
} else {
|
||||
free(name);
|
||||
free(drv);
|
||||
}
|
||||
}
|
||||
if(kp->incore){
|
||||
free(isa_dp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
idp=kp->isa_devp+total;
|
||||
bzero(idp, sizeof(struct uc_isa));
|
||||
} else {
|
||||
kp->isa_devp=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct list *
|
||||
get_isa_devlist(struct kernel *kp){
|
||||
struct list *dl;
|
||||
struct uc_isa *kdp;
|
||||
|
||||
dl=list_new();
|
||||
|
||||
for(kdp=kp->isa_devp; kdp->device; kdp++){
|
||||
list_append(dl, kdp->device);
|
||||
}
|
||||
return(dl);
|
||||
}
|
||||
|
||||
|
||||
struct list *
|
||||
get_isa_device(struct uc_isa *ip){
|
||||
struct list *list;
|
||||
char *tmp;
|
||||
|
||||
list=list_new();
|
||||
|
||||
asprintf(&tmp, "%s", ip->device );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "0x%04x", ip->port );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "%d", ip->irq>0 ? ffs(ip->irq)-1 : ip->irq);
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "%d", ip->drq );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "0x%08x", ip->iomem );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "0x%x", ip->iosize );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "0x%x", ip->flags );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "%d", ip->alive );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "%d", ip->enabled );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
return(list);
|
||||
}
|
||||
|
||||
int
|
||||
isa_setdev(struct kernel *kp, struct list *list){
|
||||
int r=1, irq;
|
||||
struct uc_isa *ip;
|
||||
|
||||
if(kp->isa_devp)
|
||||
for(ip=kp->isa_devp;ip->device;ip++){
|
||||
if(strcmp(list->av[0], ip->device)==0){
|
||||
ip->modified=1;
|
||||
ip->port = strtol(list->av[1], (char **)NULL, 0);
|
||||
irq=strtol(list->av[2], (char **)NULL, 0);
|
||||
ip->irq= irq > 0 ? 1 << (irq) : irq;
|
||||
ip->drq = strtol(list->av[3], (char **)NULL, 0);
|
||||
ip->iomem = strtol(list->av[4], (char **)NULL, 0);
|
||||
ip->iosize = strtol(list->av[5], (char **)NULL, 0);
|
||||
ip->flags = strtol(list->av[6], (char **)NULL, 0);
|
||||
ip->enabled = strtol(list->av[8], (char **)NULL, 0);
|
||||
r=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
|
||||
void
|
||||
isa_free(struct kernel *kp, int writeback){
|
||||
struct uc_isa *ip;
|
||||
for(ip=kp->isa_devp; ip->device; ip++){
|
||||
if((!kp->incore) && ip->modified && writeback) {
|
||||
/* save any changes */
|
||||
ip->idp->id_iobase=ip->port;
|
||||
ip->idp->id_irq = ip->irq;
|
||||
ip->idp->id_drq = ip->drq;
|
||||
ip->idp->id_maddr = (caddr_t)ip->iomem;
|
||||
ip->idp->id_msize = ip->iosize;
|
||||
ip->idp->id_flags = ip->flags;
|
||||
ip->idp->id_enabled = ip->enabled;
|
||||
}
|
||||
/* and, be free... */
|
||||
free(ip->device);
|
||||
}
|
||||
/* and free the whole ball of wax */
|
||||
free(kp->isa_devp);
|
||||
kp->isa_devp=0;
|
||||
}
|
||||
|
||||
/* end of userconfig/uc_isa.c */
|
@ -1,87 +0,0 @@
|
||||
/***************************************************
|
||||
* file: userconfig/uc_kmem.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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <a.out.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "uc_main.h"
|
||||
|
||||
/* translate a kv pointer to user space */
|
||||
/* malloc()-ing if we aren't mmaped */
|
||||
u_int
|
||||
kv_to_u(struct kernel *kp, u_int adr, u_int size){
|
||||
u_int tadr;
|
||||
if(!kp->incore){
|
||||
struct exec *ep;
|
||||
ep=(struct exec *)kp->core;
|
||||
tadr=(u_int)((adr - ep->a_entry + (N_DATOFF(*ep) - ep->a_text))+kp->core);
|
||||
} else {
|
||||
caddr_t ptr;
|
||||
ptr = malloc(size);
|
||||
lseek(kp->fd, adr, SEEK_SET);
|
||||
read(kp->fd, ptr, size);
|
||||
tadr=(u_int)ptr;
|
||||
}
|
||||
return(tadr);
|
||||
}
|
||||
|
||||
/* dereference a pointer to kernel space */
|
||||
u_int
|
||||
kv_dref_p(struct kernel *kp, u_int adr){
|
||||
u_int tadr;
|
||||
if(!kp->incore){
|
||||
struct exec *ep;
|
||||
ep=(struct exec *)kp->core;
|
||||
tadr=*(u_int*)((adr - ep->a_entry + (N_DATOFF(*ep) - ep->a_text))+kp->core);
|
||||
} else {
|
||||
lseek(kp->fd, adr, SEEK_SET);
|
||||
read(kp->fd, &tadr, sizeof(tadr));
|
||||
}
|
||||
return(tadr);
|
||||
}
|
||||
|
||||
/* deref a pointer to kernel text */
|
||||
u_int
|
||||
kv_dref_t(struct kernel *kp, u_int adr){
|
||||
u_int tadr;
|
||||
if(!kp->incore){
|
||||
struct exec *ep;
|
||||
ep=(struct exec *)kp->core;
|
||||
tadr=*(u_int*)((adr - ep->a_entry) + N_TXTOFF(*ep) + (u_int)kp->core);
|
||||
} else {
|
||||
lseek(kp->fd, adr, SEEK_SET);
|
||||
read(kp->fd, &tadr, sizeof(tadr));
|
||||
}
|
||||
return(tadr);
|
||||
}
|
||||
|
||||
/* end of userconfig/uc_kmem.c */
|
@ -1,76 +0,0 @@
|
||||
/***************************************************
|
||||
* file: userconfig/uc_isa.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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <nlist.h>
|
||||
#include "uc_main.h"
|
||||
|
||||
struct list *
|
||||
list_new(void){
|
||||
struct list *rv;
|
||||
rv=(struct list *)malloc(sizeof(struct list));
|
||||
rv->ac=0;
|
||||
rv->av=(char **)0;
|
||||
return(rv);
|
||||
}
|
||||
|
||||
void
|
||||
list_append(struct list *list , char *item){
|
||||
|
||||
if(list->ac==0) {
|
||||
list->av=(char **)malloc(sizeof(char *)*(list->ac+1));
|
||||
} else {
|
||||
list->av=(char **)realloc(list->av, sizeof(char *)*(list->ac+1));
|
||||
}
|
||||
asprintf(list->av+list->ac, "%s", item);
|
||||
list->ac++;
|
||||
}
|
||||
|
||||
void
|
||||
list_print(struct list *list, char *separator){
|
||||
int i;
|
||||
for(i=0; i<list->ac; i++)
|
||||
printf("%s%s", list->av[i], separator);
|
||||
}
|
||||
|
||||
void
|
||||
list_destroy(struct list *list){
|
||||
int i;
|
||||
for(i=0;i<list->ac;i++){
|
||||
free(list->av[i]);
|
||||
list->av[i]=0;
|
||||
}
|
||||
free(list->av);
|
||||
list->av=0;
|
||||
free(list);
|
||||
}
|
||||
|
||||
/* end of userconfig/uc_list.c */
|
@ -1,334 +0,0 @@
|
||||
/***************************************************
|
||||
* 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
|
||||
*
|
||||
* $Id: uc_main.c,v 1.24 1998/10/07 19:42:46 jkh Exp $
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
||||
static struct nlist _nl[] = {
|
||||
{"_isa_devtab_bio"},
|
||||
{"_isa_devtab_tty"},
|
||||
{"_isa_devtab_net"},
|
||||
{"_isa_devtab_cam"},
|
||||
{"_isa_devtab_null"},
|
||||
{"_isa_biotab_wdc"},
|
||||
{"_isa_biotab_fdc"},
|
||||
{"_eisadriver_set"},
|
||||
{"_eisa_dev_list"},
|
||||
{"_pcidevice_set"},
|
||||
{"_device_list"},
|
||||
#ifdef DO_SCSI
|
||||
{"_scbusses"},
|
||||
{"_scsi_cinit"},
|
||||
{"_scsi_dinit"},
|
||||
{"_scsi_tinit"},
|
||||
#endif
|
||||
{""},
|
||||
};
|
||||
|
||||
struct kernel *
|
||||
uc_open(char *name){
|
||||
int kd, flags, incore;
|
||||
struct kernel *kern;
|
||||
struct stat sb;
|
||||
char kname[80];
|
||||
int size, i = 0;
|
||||
struct nlist *nl = _nl;
|
||||
|
||||
if (strcmp(name, "-incore") == 0)
|
||||
incore = 1;
|
||||
else
|
||||
incore = 0;
|
||||
|
||||
if (incore || (strcmp(name,"-bootfile") == 0))
|
||||
SAFE_STRCPY(kname, getbootfile());
|
||||
else
|
||||
SAFE_STRCPY(kname, name);
|
||||
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: kernel name is %s, incore = %d\n", kname, incore);
|
||||
kern = (struct kernel *)malloc(sizeof(struct kernel));
|
||||
|
||||
#ifdef KERN_NO_SYMBOLS
|
||||
if (incore) {
|
||||
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));
|
||||
for (i = 0; i < size; i++) {
|
||||
char *cp, name[255];
|
||||
int c1;
|
||||
unsigned int uc1;
|
||||
short d1;
|
||||
unsigned long v1;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
nl[i].n_name = "";
|
||||
fclose(fp);
|
||||
i = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
i = nlist(kname, nl);
|
||||
if (i == -1) {
|
||||
msgDebug("uc_open: kernel %s does not contain symbols.\n", kname);
|
||||
free(kern);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef KERN_NO_SYMBOLS
|
||||
if (!incore) {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
kern->nl=(struct nlist *)malloc(sizeof(_nl));
|
||||
bcopy(_nl, kern->nl, sizeof(_nl));
|
||||
}
|
||||
|
||||
if (incore) {
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: attempting to open /dev/kmem for incore.\n");
|
||||
if ((kd = open("/dev/kmem", O_RDONLY)) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to open /dev/kmem.\n");
|
||||
return NULL;
|
||||
}
|
||||
kern->core = (caddr_t)NULL;
|
||||
kern->incore = 1;
|
||||
kern->size = 0;
|
||||
}
|
||||
else {
|
||||
if (stat(kname, &sb) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to stat %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
kern->size = sb.st_size;
|
||||
flags = sb.st_flags;
|
||||
|
||||
if (chflags(kname, 0) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to chflags %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: attempting to open %s\n", kname);
|
||||
if ((kd = open(kname, O_RDWR, 0644)) < 0) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to open %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fchflags(kd, flags);
|
||||
|
||||
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) {
|
||||
free(kern);
|
||||
msgDebug("uc_open: Unable to mmap from %s.\n", kname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
kern->fd = kd;
|
||||
get_isa_info(kern);
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: got isa information\n");
|
||||
|
||||
get_pci_info(kern);
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: got pci information\n");
|
||||
|
||||
get_eisa_info(kern);
|
||||
if (isDebug())
|
||||
msgDebug("uc_open: got eisa information\n");
|
||||
#ifdef DO_SCSI
|
||||
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
|
||||
return kern;
|
||||
}
|
||||
|
||||
int
|
||||
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 */
|
||||
|
||||
#ifdef DO_SCSI
|
||||
if (kern->scsi_devp)
|
||||
scsi_free(kern, writeback);
|
||||
#endif
|
||||
if (!kern->incore)
|
||||
munmap(kern->core, kern->size);
|
||||
|
||||
close(kern->fd);
|
||||
free(kern->nl);
|
||||
free(kern);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct list *
|
||||
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");
|
||||
|
||||
#ifdef DO_SCSI
|
||||
if (kern->scsi_devp)
|
||||
list_append(list, "scsi");
|
||||
#endif
|
||||
|
||||
}
|
||||
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);
|
||||
#ifdef DO_SCSI
|
||||
else if (strcmp(dev, "-scsi") == 0)
|
||||
list = get_scsi_devlist(kern);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* we gotta figure out which real device to report */
|
||||
struct uc_isa *ip;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DO_SCSI
|
||||
if (kern->scsi_devp) {
|
||||
struct uc_scsi *sp;
|
||||
|
||||
for (sp = kern->scsi_devp; sp->device; sp++) {
|
||||
if (strcmp(dev, sp->device) == 0) {
|
||||
list = get_scsi_device(sp);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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:
|
||||
return(list);
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
/***************************************************
|
||||
* file: userconfig/uc_main.h
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $Id: uc_main.h,v 1.4 1997/02/22 14:12:32 peter Exp $
|
||||
*/
|
||||
|
||||
#define ISA_BIOTAB 0
|
||||
#define ISA_TTYTAB 1
|
||||
#define ISA_NETTAB 2
|
||||
#define ISA_CAMTAB 3
|
||||
#define ISA_NULLTAB 4
|
||||
#define ISA_WDCTAB 5
|
||||
#define ISA_FDCTAB 6
|
||||
#define EISA_SET 7
|
||||
#define EISA_LIST 8
|
||||
#define PCI_SET 9
|
||||
#define SCSI_LIST 10
|
||||
#define SCSI_BUSSES 11
|
||||
#define SCSI_CINIT 12
|
||||
#define SCSI_DINIT 13
|
||||
#define SCSI_TINIT 14
|
||||
/* symbols + the null terminator */
|
||||
#define NSYMBOLS 16
|
||||
|
||||
struct kernel {
|
||||
int fd; /* file descriptor for the kernel image, either a binary or /dev/kmem */
|
||||
caddr_t core; /* either the mmap()ed kernel image, or a scratch area */
|
||||
u_int size; /* size of the object at ->core */
|
||||
int incore; /* true if the kernel is running */
|
||||
#ifdef UC_PRIVATE
|
||||
struct nlist *nl; /* the symbol table */
|
||||
#else
|
||||
void *nl;
|
||||
#endif
|
||||
struct uc_isa *isa_devp; /* pointer to the isa devices (if any) */
|
||||
struct uc_eisa *eisa_devp; /* pointer to the eisa devices (if any) */
|
||||
struct uc_pci *pci_devp; /* pointer to the pci devices (if any) */
|
||||
struct uc_scsi *scsi_devp; /* pointer to the scsi devices (if any) */
|
||||
struct uc_scsibus *scsibus_devp; /* internal pointer to scsibus wirings */
|
||||
};
|
||||
|
||||
struct uc_isa {
|
||||
char *device;
|
||||
u_short port;
|
||||
u_short irq;
|
||||
short drq;
|
||||
u_int iomem;
|
||||
int iosize;
|
||||
int flags;
|
||||
int alive;
|
||||
int enabled;
|
||||
#ifdef UC_PRIVATE
|
||||
struct isa_device *idp;
|
||||
#else
|
||||
void *idp;
|
||||
#endif
|
||||
int modified;
|
||||
};
|
||||
|
||||
struct uc_pci {
|
||||
char *device;
|
||||
};
|
||||
|
||||
struct uc_eisa {
|
||||
char *device;
|
||||
char *full_name;
|
||||
};
|
||||
|
||||
struct uc_scsibus {
|
||||
int bus_no;
|
||||
int unit;
|
||||
char *driver;
|
||||
#ifdef UC_PRIVATE
|
||||
struct scsi_ctlr_config *config;
|
||||
#else
|
||||
void *config;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct uc_scsi {
|
||||
char *device;
|
||||
char *adapter;
|
||||
u_short target;
|
||||
u_short lun;
|
||||
char *desc;
|
||||
#ifdef UC_PRIVATE
|
||||
struct scsi_device_config *config;
|
||||
#else
|
||||
void *config;
|
||||
#endif
|
||||
int modified;
|
||||
};
|
||||
|
||||
/* nearly everything useful returns a list */
|
||||
|
||||
struct list {
|
||||
int ac;
|
||||
char **av;
|
||||
};
|
||||
|
||||
/* prototypes */
|
||||
|
||||
/* uc_main.c */
|
||||
/* these are really the only public ones */
|
||||
struct kernel *uc_open(char *name);
|
||||
int uc_close(struct kernel *kern, int writeback);
|
||||
struct list *uc_getdev(struct kernel *kern, char *dev);
|
||||
|
||||
/* uc_isa.c */
|
||||
void get_isa_info(struct kernel *kp);
|
||||
struct list *get_isa_devlist(struct kernel *kp);
|
||||
struct list *get_isa_device(struct uc_isa *ip);
|
||||
int isa_setdev(struct kernel *kp, struct list *list);
|
||||
void isa_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_eisa.c */
|
||||
void get_eisa_info(struct kernel *kp);
|
||||
struct list *get_eisa_devlist(struct kernel *kp);
|
||||
struct list *get_eisa_device(struct uc_eisa *ep);
|
||||
void eisa_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_pci.c */
|
||||
void get_pci_info(struct kernel *kp);
|
||||
struct list *get_pci_devlist(struct kernel *kp);
|
||||
struct list *get_pci_device(struct uc_pci *pp);
|
||||
void pci_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_scsi.c */
|
||||
void get_scsi_info(struct kernel *kp);
|
||||
struct list *get_scsi_devlist(struct kernel *kp);
|
||||
struct list *get_scsi_device(struct uc_scsi *sp);
|
||||
int scsi_setdev(struct kernel *kp, struct list *list);
|
||||
void scsi_free(struct kernel *kp, int writeback);
|
||||
|
||||
/* uc_kmem.c */
|
||||
u_int kv_to_u(struct kernel *kp, u_int adr, u_int size);
|
||||
u_int kv_dref_p(struct kernel *kp, u_int adr);
|
||||
u_int kv_dref_t(struct kernel *kp, u_int adr);
|
||||
|
||||
/* uc_list.c */
|
||||
struct list *list_new(void);
|
||||
void list_append(struct list *list, char *item);
|
||||
void list_print(struct list *list, char *separator);
|
||||
void list_destroy(struct list *list);
|
||||
|
||||
/* end of userconfig/uc_main.h */
|
@ -1,122 +0,0 @@
|
||||
/***************************************************
|
||||
* file: userconfig/uc_pci.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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <nlist.h>
|
||||
#include <pci/pcivar.h>
|
||||
|
||||
#include "uc_main.h"
|
||||
|
||||
void
|
||||
get_pci_info(struct kernel *kp){
|
||||
int i, total;
|
||||
u_int *ls, ndev;
|
||||
struct pci_device *pd;
|
||||
struct uc_pci *pp,*ppc;
|
||||
char *name;
|
||||
|
||||
if(kp->nl[PCI_SET].n_value){
|
||||
pp = ppc = (struct uc_pci *)malloc(sizeof(struct uc_pci));
|
||||
ls=(u_int *)kv_to_u(kp, kp->nl[PCI_SET].n_value, sizeof(u_int)*30); /* XXX, size? */
|
||||
ndev=ls[0];
|
||||
total=0;
|
||||
for(i=1;i<(ndev+1);i++){
|
||||
pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1));
|
||||
ppc = pp+(total);
|
||||
pd=(struct pci_device *)kv_to_u(kp, ls[i], sizeof(struct pci_device));
|
||||
/* don't try to dereference a null pointer */
|
||||
name=pd->pd_name ? (char *)kv_to_u(kp, (u_int)pd->pd_name, 10) :
|
||||
pd->pd_name; /* XXX, size? */
|
||||
if(kp->incore){
|
||||
int u, k;
|
||||
/* incore, we can get unit numbers */
|
||||
|
||||
u=kv_dref_p(kp, (u_int)pd->pd_count);
|
||||
for(k=0;k<u;k++,total++){
|
||||
pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1));
|
||||
ppc = pp+(total);
|
||||
asprintf(&ppc->device, "%s%d", name, k);
|
||||
}
|
||||
free(pd);
|
||||
if(name)
|
||||
free(name);
|
||||
} else {
|
||||
asprintf(&ppc->device, "%s?", name);
|
||||
total++;
|
||||
}
|
||||
}
|
||||
pp=(struct uc_pci *)realloc(pp, sizeof(struct uc_pci)*(total+1));
|
||||
ppc = pp+(total);
|
||||
bzero(ppc, sizeof(struct uc_pci));
|
||||
kp->pci_devp=pp;
|
||||
} else {
|
||||
kp->pci_devp=(struct uc_pci *)0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct list *
|
||||
get_pci_devlist(struct kernel *kp){
|
||||
struct list *dl;
|
||||
struct uc_pci *kdp;
|
||||
|
||||
dl=list_new();
|
||||
|
||||
for(kdp=kp->pci_devp; kdp->device; kdp++){
|
||||
list_append(dl, kdp->device);
|
||||
}
|
||||
return(dl);
|
||||
}
|
||||
|
||||
|
||||
struct list *
|
||||
get_pci_device(struct uc_pci *pp){
|
||||
struct list *list;
|
||||
list=list_new();
|
||||
|
||||
list_append(list, pp->device);
|
||||
|
||||
return(list);
|
||||
}
|
||||
|
||||
void
|
||||
pci_free(struct kernel *kp, int writeback){
|
||||
struct uc_pci *pp;
|
||||
|
||||
for(pp=kp->pci_devp;pp->device;pp++){
|
||||
free(pp->device);
|
||||
}
|
||||
free(kp->pci_devp);
|
||||
kp->pci_devp=0;
|
||||
|
||||
}
|
||||
|
||||
/* end of userconfig/uc_pci.c */
|
@ -1,477 +0,0 @@
|
||||
/***************************************************
|
||||
* file: userconfig/uc_scsi.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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <nlist.h>
|
||||
#include <scsi/scsiconf.h>
|
||||
|
||||
#include "uc_main.h"
|
||||
|
||||
/* this stuff is hidden under an #ifdef KERNEL in scsiconf.h */
|
||||
#define SCCONF_UNSPEC 255
|
||||
#define SCCONF_ANY 254
|
||||
|
||||
struct scsi_ctlr_config {
|
||||
int scbus;
|
||||
char *driver;
|
||||
int unit;
|
||||
int bus;
|
||||
};
|
||||
|
||||
struct scsi_device_config {
|
||||
char *name; /* SCSI device name (sd, st, etc) */
|
||||
int unit; /* desired device unit */
|
||||
int cunit; /* Controller unit */
|
||||
int target; /* SCSI ID (target) */
|
||||
int lun; /* SCSI lun */
|
||||
int flags; /* Flags from config */
|
||||
};
|
||||
|
||||
/* module prototypes */
|
||||
static void get_sl_info(struct kernel *kp, struct uc_scsi *spc,
|
||||
struct scsi_link *sl);
|
||||
|
||||
void
|
||||
get_scsi_info(struct kernel *kp){
|
||||
int i, j, k;
|
||||
|
||||
if(kp->incore){
|
||||
if (kp->nl[SCSI_BUSSES].n_value) {
|
||||
u_int *es, *sba;
|
||||
struct scsibus_data *sbd;
|
||||
int nsbd, nscsibus, total;
|
||||
struct uc_scsi *sp, *spc;
|
||||
struct uc_scsibus *sbp, *sbpc;
|
||||
struct scsi_link *s_l;
|
||||
u_int *slp;
|
||||
char *temp;
|
||||
struct scsi_device *sdev;
|
||||
u_int t;
|
||||
char name[10];
|
||||
|
||||
sp=(struct uc_scsi*)malloc(sizeof(struct uc_scsi));
|
||||
total=0;
|
||||
sbp=(struct uc_scsibus*)malloc(sizeof(struct uc_scsibus));
|
||||
nscsibus=0;
|
||||
|
||||
es=(u_int *)kv_to_u(kp, kv_dref_p(kp,kp->nl[SCSI_BUSSES].n_value),
|
||||
sizeof(u_int)*2);
|
||||
nsbd=es[0];
|
||||
sba=(u_int *)kv_to_u(kp, es[1], sizeof(u_int)*nsbd);
|
||||
free(es);
|
||||
|
||||
for(i=0;i<nsbd;i++){
|
||||
if(sba[i]){
|
||||
/* first grab the adapter info */
|
||||
sbd=(struct scsibus_data *)kv_to_u(kp, sba[i],
|
||||
sizeof(struct scsibus_data));
|
||||
sbp=(struct uc_scsibus *)realloc(sbp, sizeof(struct uc_scsibus)*
|
||||
(nscsibus+1));
|
||||
|
||||
sp=(struct uc_scsi*)realloc(sp, (sizeof(struct uc_scsi)*(total+1)));
|
||||
spc=sp+total;
|
||||
s_l=(struct scsi_link*)kv_to_u(kp, (u_int)sbd->adapter_link,
|
||||
sizeof(struct scsi_link));
|
||||
get_sl_info(kp, spc, s_l);
|
||||
free(s_l);
|
||||
|
||||
sbpc=sbp+nscsibus;
|
||||
sbpc->bus_no=nscsibus;
|
||||
nscsibus++;
|
||||
sscanf(spc->device, "%[a-z]%d", name, &sbpc->unit);
|
||||
asprintf(&sbpc->driver, "%s", name);
|
||||
|
||||
total++;
|
||||
t=kv_dref_p(kp, (u_int)sbd->sc_link);
|
||||
t=(u_int)sbd->sc_link;
|
||||
for(j=0;j<8;j++) {
|
||||
slp=(u_int *)kv_to_u(kp, t+(j*8*sizeof(u_int)), /* XXX */
|
||||
(sizeof(u_int)*sbd->maxlun));
|
||||
for(k=0;k<sbd->maxlun && slp[k]; k++){
|
||||
struct scsi_link *slt;
|
||||
sp=(struct uc_scsi*)realloc(sp,
|
||||
(sizeof(struct uc_scsi)*(total+1)));
|
||||
spc=sp+total;
|
||||
slt=(struct scsi_link*)kv_to_u(kp, slp[k],
|
||||
sizeof(struct scsi_link));
|
||||
get_sl_info(kp, spc, slt);
|
||||
free(slt);
|
||||
spc->config=(struct scsi_device_config *)0;
|
||||
total++;
|
||||
}
|
||||
free(slp);
|
||||
}
|
||||
free(sbd);
|
||||
}
|
||||
}
|
||||
/* now stuff in the list of drivers configured in the system */
|
||||
t=kv_dref_p(kp, kp->nl[SCSI_LIST].n_value);
|
||||
while(t) {
|
||||
sdev=(struct scsi_device*)kv_to_u(kp, t, sizeof(struct scsi_device));
|
||||
sp=(struct uc_scsi*)realloc(sp, (sizeof(struct uc_scsi)*(total+1)));
|
||||
spc=sp+total;
|
||||
total++;
|
||||
temp=(char *)kv_to_u(kp, (u_int)sdev->name, 10);
|
||||
asprintf(&spc->device, "%s*", temp);
|
||||
free(temp);
|
||||
asprintf(&spc->adapter, "any");
|
||||
|
||||
spc->target=SCCONF_ANY;
|
||||
spc->lun=SCCONF_ANY;
|
||||
|
||||
temp=(char *)kv_to_u(kp, (u_int)sdev->desc, 20);
|
||||
asprintf(&spc->desc, "%s", temp);
|
||||
free(temp);
|
||||
|
||||
spc->config=(struct scsi_device_config *)0;
|
||||
|
||||
t=(u_int)sdev->next;
|
||||
free(sdev);
|
||||
}
|
||||
/* slap on the terminators */
|
||||
sp=(struct uc_scsi*)realloc(sp, (sizeof(struct uc_scsi)*(total+1)));
|
||||
spc=sp+total;
|
||||
bzero(spc, sizeof(struct uc_scsi));
|
||||
|
||||
sbp=(struct uc_scsibus *)realloc(sbp, sizeof(struct uc_scsibus)*
|
||||
(nscsibus+1));
|
||||
sbpc=sbp+nscsibus;
|
||||
bzero(sbpc, sizeof(struct uc_scsibus));
|
||||
|
||||
kp->scsi_devp=sp;
|
||||
kp->scsibus_devp=sbp;
|
||||
} else { /* no symbol, and incore, no scsi */
|
||||
kp->scsi_devp=(struct uc_scsi *)0;
|
||||
kp->scsibus_devp=(struct uc_scsibus *)0;
|
||||
}
|
||||
} else { /* on disk */
|
||||
|
||||
if (kp->nl[SCSI_CINIT].n_value || kp->nl[SCSI_DINIT].n_value ||
|
||||
kp->nl[SCSI_TINIT].n_value) {
|
||||
int total=0;
|
||||
struct uc_scsi *sp, *spc;
|
||||
struct scsi_ctlr_config *sctl_c;
|
||||
struct scsi_device_config *sdev_c;
|
||||
struct scsi_device *sdev;
|
||||
|
||||
struct uc_scsibus *uc_scbus, *uc_scbusc;
|
||||
|
||||
u_int t, ctrl_total;
|
||||
char *temp;
|
||||
u_int initp;
|
||||
|
||||
spc=sp=(struct uc_scsi*)malloc(sizeof(struct uc_scsi));
|
||||
total=0;
|
||||
ctrl_total=0;
|
||||
uc_scbus = NULL; /* Just prevent unused warning */
|
||||
|
||||
/* static kernel, we'll first get the wired controllers/devices */
|
||||
if((t=kp->nl[SCSI_CINIT].n_value)){
|
||||
/* get controller info*/
|
||||
sctl_c=(struct scsi_ctlr_config*)kv_to_u(kp, t, sizeof(struct scsi_ctlr_config));
|
||||
uc_scbus=(struct uc_scsibus*)malloc(sizeof(struct uc_scsibus));
|
||||
|
||||
while(sctl_c->driver){
|
||||
|
||||
/* remember the bus info, for later */
|
||||
uc_scbus=(struct uc_scsibus*)realloc(uc_scbus, sizeof(struct uc_scsibus)*(ctrl_total+1));
|
||||
uc_scbusc=uc_scbus+ctrl_total;
|
||||
uc_scbusc->bus_no=sctl_c->scbus;
|
||||
temp=(char *)kv_to_u(kp, (u_int)sctl_c->driver, 20);
|
||||
uc_scbusc->driver=temp;
|
||||
uc_scbusc->unit=sctl_c->unit;
|
||||
uc_scbusc->config=sctl_c;
|
||||
|
||||
sp=(struct uc_scsi*)realloc(sp,sizeof(struct uc_scsi)*(total+1));
|
||||
spc=sp+total;
|
||||
asprintf(&spc->device, "%s%d", temp, sctl_c->unit);
|
||||
asprintf(&spc->adapter, "%s%d", temp, sctl_c->unit);
|
||||
spc->target=0;
|
||||
spc->lun=0;
|
||||
spc->modified=0;
|
||||
asprintf(&spc->desc, "%s", temp);
|
||||
total++;
|
||||
ctrl_total++;
|
||||
sctl_c++;
|
||||
}
|
||||
}
|
||||
|
||||
if((t=kp->nl[SCSI_DINIT].n_value)){
|
||||
/* get wired device info */
|
||||
sdev_c=(struct scsi_device_config*)kv_to_u(kp, t, sizeof(struct scsi_device_config));
|
||||
while(sdev_c->name){
|
||||
sp=(struct uc_scsi*)realloc(sp, sizeof(struct uc_scsi)*(total+1));
|
||||
spc=sp+total;
|
||||
temp=(char*)kv_to_u(kp, (u_int)sdev_c->name, 10);
|
||||
asprintf(&spc->device, "%s%d", temp, sdev_c->unit);
|
||||
/* figure out controller */
|
||||
if(sdev_c->cunit == SCCONF_ANY){
|
||||
asprintf(&spc->adapter, "any");
|
||||
} else {
|
||||
if(ctrl_total){
|
||||
for(i=0;i<ctrl_total;i++){
|
||||
if(sdev_c->cunit==uc_scbus[i].bus_no){
|
||||
asprintf(&spc->adapter, "%s%d",
|
||||
uc_scbus[i].driver, uc_scbus[i].unit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i==ctrl_total) { /* made it through the whole list */
|
||||
asprintf(&spc->adapter, "any?");
|
||||
}
|
||||
} else {
|
||||
asprintf(&spc->adapter, "any?");
|
||||
}
|
||||
}
|
||||
spc->target= sdev_c->target;
|
||||
spc->lun= sdev_c->lun;
|
||||
spc->desc=(char *)0; /* filled in later */
|
||||
spc->config=sdev_c;
|
||||
spc->modified=0;
|
||||
sdev_c++;
|
||||
total++;
|
||||
}
|
||||
}
|
||||
kp->scsibus_devp=uc_scbus;
|
||||
|
||||
if((t=kp->nl[SCSI_TINIT].n_value)) {
|
||||
/* WARNING: This is teetering on the brink of stupid.
|
||||
|
||||
this ugly little hack only works because the
|
||||
<scsi driver>init routines are macro-generated,
|
||||
so the offset of the device pointers will be
|
||||
the same (hopefully).
|
||||
*/
|
||||
|
||||
while((initp=kv_dref_p(kp,t))) {
|
||||
u_int tadr;
|
||||
u_int sl;
|
||||
|
||||
t+=4;
|
||||
tadr=kv_dref_t(kp, initp+4); /* offset in *.text* */
|
||||
sdev=(struct scsi_device*)kv_to_u(kp, tadr, sizeof(struct scsi_device));
|
||||
sp=(struct uc_scsi*)realloc(sp, (sizeof(struct uc_scsi)*(total+1)));
|
||||
spc=sp+total;
|
||||
total++;
|
||||
temp=(char *)kv_to_u(kp, (u_int)sdev->name, 10);
|
||||
asprintf(&spc->device, "%s*", temp);
|
||||
|
||||
asprintf(&spc->adapter, "any");
|
||||
|
||||
spc->target=SCCONF_ANY;
|
||||
spc->lun=SCCONF_ANY;
|
||||
spc->modified=0;
|
||||
temp=(char *)kv_to_u(kp, (u_int)sdev->desc, 20);
|
||||
asprintf(&spc->desc, "%s", temp);
|
||||
/* now try to fill in any device descriptions from above */
|
||||
sl=strlen(spc->device)-1;
|
||||
for(i=0;i<(total-1);i++){ /* don't look at this device */
|
||||
struct uc_scsi *usp;
|
||||
|
||||
usp=sp+i;
|
||||
if(strncmp(usp->device, spc->device, sl)==0 && usp->desc==0) {
|
||||
asprintf(&usp->desc, "%s", spc->desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(total){
|
||||
sp=(struct uc_scsi*)realloc(sp, (sizeof(struct uc_scsi)*(total+1)));
|
||||
spc=sp+total;
|
||||
bzero(spc, sizeof(struct uc_scsi));
|
||||
kp->scsi_devp=sp;
|
||||
} else {
|
||||
free(sp);
|
||||
kp->scsi_devp=(struct uc_scsi *)0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
kp->scsi_devp=(struct uc_scsi *)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct list *
|
||||
get_scsi_devlist(struct kernel *kp){
|
||||
struct list *dl;
|
||||
struct uc_scsi *kdp;
|
||||
|
||||
dl=list_new();
|
||||
|
||||
for(kdp=kp->scsi_devp; kdp->device; kdp++){
|
||||
list_append(dl, kdp->device);
|
||||
}
|
||||
|
||||
return(dl);
|
||||
}
|
||||
|
||||
struct list *
|
||||
get_scsi_device(struct uc_scsi *sp){
|
||||
struct list *list;
|
||||
char *tmp;
|
||||
|
||||
list=list_new();
|
||||
|
||||
list_append(list, sp->device);
|
||||
list_append(list, sp->adapter);
|
||||
|
||||
asprintf(&tmp, "%d", sp->target );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
asprintf(&tmp, "%d", sp->lun );
|
||||
list_append(list, tmp);
|
||||
free(tmp);
|
||||
|
||||
list_append(list, sp->desc);
|
||||
|
||||
return(list);
|
||||
}
|
||||
|
||||
/* given a scsi_link and a uc_scsi pointer, fill it in */
|
||||
static void
|
||||
get_sl_info(struct kernel *kp, struct uc_scsi *spc, struct scsi_link *sl){
|
||||
|
||||
struct scsi_adapter *sadp;
|
||||
struct scsi_device *sdev;
|
||||
char *temp;
|
||||
|
||||
sadp=(struct scsi_adapter*)kv_to_u(kp, (u_int)sl->adapter,
|
||||
sizeof(struct scsi_adapter));
|
||||
|
||||
sdev=(struct scsi_device*)kv_to_u(kp, (u_int)sl->device,
|
||||
sizeof(struct scsi_device));
|
||||
|
||||
temp=(char *)kv_to_u(kp, (u_int)sdev->name, 20);
|
||||
asprintf(&spc->device, "%s%d", temp, sl->dev_unit);
|
||||
free(temp);
|
||||
temp=(char *)kv_to_u(kp, (u_int)sadp->name, 20);
|
||||
asprintf(&spc->adapter, "%s%d", temp, sl->adapter_unit);
|
||||
free(temp);
|
||||
spc->target = sl->target;
|
||||
spc->lun = sl->lun;
|
||||
|
||||
temp=(char *)kv_to_u(kp, (u_int)sdev->desc, 30);
|
||||
asprintf(&spc->desc, "%s", temp);
|
||||
free(temp);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
scsi_setdev(struct kernel *kp, struct list *list){
|
||||
int r=1, bus_valid=0;
|
||||
struct uc_scsi *sp;
|
||||
struct uc_scsibus *sbp;
|
||||
char *t;
|
||||
|
||||
if(kp->scsi_devp)
|
||||
for(sp=kp->scsi_devp;sp->device;sp++){
|
||||
if(strcmp(list->av[0], sp->device)==0){
|
||||
for(sbp=kp->scsibus_devp;sbp->driver; sbp++){
|
||||
asprintf(&t, "%s%d", sbp->driver, sbp->unit);
|
||||
if(strcmp(list->av[1], t)==0) {
|
||||
bus_valid=1;
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
if(bus_valid){
|
||||
sp->modified=1;
|
||||
free(sp->adapter);
|
||||
asprintf(&sp->adapter, "%s", list->av[1]);
|
||||
sp->target = strtol(list->av[2], (char **)NULL, 0);
|
||||
sp->lun = strtol(list->av[3], (char **)NULL, 0);
|
||||
r=0;
|
||||
goto done;
|
||||
} else {
|
||||
r=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
return(r);
|
||||
}
|
||||
|
||||
void
|
||||
scsi_free(struct kernel *kp, int writeback){
|
||||
struct uc_scsi *sp;
|
||||
struct uc_scsibus *sbp;
|
||||
char *t;
|
||||
int scbus, i;
|
||||
|
||||
for(sp=kp->scsi_devp; sp->device; sp++){
|
||||
if((!kp->incore) && sp->modified && writeback) {
|
||||
/* save info */
|
||||
|
||||
/* I'm not sure this is necessary */
|
||||
#if 0
|
||||
sscanf(sp->device, "%[a-z]%d", name, &unit);
|
||||
sp->config->unit= unit;
|
||||
#endif
|
||||
|
||||
/* figger out the controller, which may have changed */
|
||||
scbus=-1;
|
||||
for(sbp=kp->scsibus_devp, i=0;sbp->driver; sbp++,i++){
|
||||
asprintf(&t, "%s%d", sbp->driver, sbp->unit);
|
||||
if(strcmp(sp->adapter, t)==0) {
|
||||
scbus=i;
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
|
||||
/* if we fell through, don't change anything */
|
||||
if(scbus!=-1){
|
||||
sp->config->cunit= scbus;
|
||||
}
|
||||
|
||||
sp->config->target= sp->target;
|
||||
sp->config->lun= sp->lun;
|
||||
/* sp->config->flags= ; XXX this should be here*/
|
||||
|
||||
}
|
||||
free(sp->device);
|
||||
free(sp->adapter);
|
||||
free(sp->desc);
|
||||
}
|
||||
free(kp->scsi_devp);
|
||||
kp->scsi_devp=(struct uc_scsi *)0;
|
||||
/* now free the bus info */
|
||||
if(kp->incore){
|
||||
for(sbp=kp->scsibus_devp;sbp->driver; sbp++){
|
||||
/* fprintf(stderr, "sbp: 0x%x free(0x%x)\n", sbp, sbp->driver);*/
|
||||
free(sbp->driver);
|
||||
}
|
||||
}
|
||||
|
||||
if (kp->scsibus_devp)
|
||||
free(kp->scsibus_devp);
|
||||
kp->scsibus_devp=(struct uc_scsibus *)0;
|
||||
}
|
||||
|
||||
/* end of userconfig/uc_scsi.c */
|
@ -15,15 +15,11 @@ SRCS= anonFTP.c cdrom.c command.c config.c devices.c \
|
||||
label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \
|
||||
msg.c network.c nfs.c options.c package.c register.c system.c \
|
||||
tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \
|
||||
uc_eisa.c uc_isa.c uc_kmem.c uc_list.c uc_main.c uc_pci.c \
|
||||
keymap.h
|
||||
|
||||
CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR}
|
||||
CFLAGS+= -I${.CURDIR}/../../sys
|
||||
CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS # -DSAVE_USERCONFIG -DDO_SCSI
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
CFLAGS+= -DSAVE_USERCONFIG
|
||||
.endif
|
||||
CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS
|
||||
|
||||
DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
|
||||
LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.220 1998/12/06 10:13:57 jkh Exp $
|
||||
* $Id: install.c,v 1.221 1999/01/08 00:14:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -35,7 +35,6 @@
|
||||
*/
|
||||
|
||||
#include "sysinstall.h"
|
||||
#include "uc_main.h"
|
||||
#include <ctype.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/errno.h>
|
||||
@ -54,9 +53,6 @@
|
||||
|
||||
static void create_termcap(void);
|
||||
static void fixit_common(void);
|
||||
#ifdef SAVE_USERCONFIG
|
||||
static void save_userconfig_to_kernel(char *);
|
||||
#endif
|
||||
|
||||
#define TERMCAP_FILE "/usr/share/misc/termcap"
|
||||
|
||||
@ -762,10 +758,6 @@ installFixupBin(dialogMenuItem *self)
|
||||
msgConfirm("Unable to copy /kernel into place!");
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
#ifdef SAVE_USERCONFIG
|
||||
/* Snapshot any boot -c changes back to the new kernel */
|
||||
save_userconfig_to_kernel("/kernel");
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
msgConfirm("Can't find a kernel image to link to on the root file system!\n"
|
||||
@ -1120,62 +1112,3 @@ create_termcap(void)
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SAVE_USERCONFIG
|
||||
static void
|
||||
save_userconfig_to_kernel(char *kern)
|
||||
{
|
||||
struct kernel *core, *boot;
|
||||
struct list *c_isa, *b_isa, *c_dev, *b_dev;
|
||||
int i, d;
|
||||
|
||||
if ((core = uc_open("-incore")) == NULL) {
|
||||
msgDebug("save_userconf: Can't read in-core information for kernel.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((boot = uc_open(kern)) == NULL) {
|
||||
msgDebug("save_userconf: Can't read device information for kernel image %s\n", kern);
|
||||
return;
|
||||
}
|
||||
|
||||
msgNotify("Saving any boot -c changes to new kernel...");
|
||||
c_isa = uc_getdev(core, "-isa");
|
||||
b_isa = uc_getdev(boot, "-isa");
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: got %d ISA device entries from core, %d from boot.\n", c_isa->ac, b_isa->ac);
|
||||
for (d = 0; d < c_isa->ac; d++) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: ISA device loop, c_isa->av[%d] = %s\n", d, c_isa->av[d]);
|
||||
if (strcmp(c_isa->av[d], "npx0")) { /* special case npx0, which mucks with its id_irq member */
|
||||
c_dev = uc_getdev(core, c_isa->av[d]);
|
||||
b_dev = uc_getdev(boot, b_isa->av[d]);
|
||||
if (!c_dev || !b_dev) {
|
||||
msgDebug("save_userconf: c_dev: %x b_dev: %x\n", c_dev, b_dev);
|
||||
continue;
|
||||
}
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: ISA device %s: %d config parameters (core), %d (boot)\n",
|
||||
c_isa->av[d], c_dev->ac, b_dev->ac);
|
||||
for (i = 0; i < c_dev->ac; i++) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: c_dev->av[%d] = %s, b_dev->av[%d] = %s\n", i, c_dev->av[i], i, b_dev->av[i]);
|
||||
if (strcmp(c_dev->av[i], b_dev->av[i])) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: %s (boot) -> %s (core)\n",
|
||||
c_dev->av[i], b_dev->av[i]);
|
||||
isa_setdev(boot, c_dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isDebug())
|
||||
msgDebug("skipping npx0\n");
|
||||
}
|
||||
}
|
||||
if (isDebug())
|
||||
msgDebug("Closing kernels\n");
|
||||
uc_close(core, 0);
|
||||
uc_close(boot, 1);
|
||||
}
|
||||
#endif
|
||||
|
@ -15,15 +15,11 @@ SRCS= anonFTP.c cdrom.c command.c config.c devices.c \
|
||||
label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \
|
||||
msg.c network.c nfs.c options.c package.c register.c system.c \
|
||||
tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \
|
||||
uc_eisa.c uc_isa.c uc_kmem.c uc_list.c uc_main.c uc_pci.c \
|
||||
keymap.h
|
||||
|
||||
CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR}
|
||||
CFLAGS+= -I${.CURDIR}/../../sys
|
||||
CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS # -DSAVE_USERCONFIG -DDO_SCSI
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
CFLAGS+= -DSAVE_USERCONFIG
|
||||
.endif
|
||||
CFLAGS+= -DUC_PRIVATE -DKERN_NO_SYMBOLS
|
||||
|
||||
DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
|
||||
LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio
|
||||
|
@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.220 1998/12/06 10:13:57 jkh Exp $
|
||||
* $Id: install.c,v 1.221 1999/01/08 00:14:21 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@ -35,7 +35,6 @@
|
||||
*/
|
||||
|
||||
#include "sysinstall.h"
|
||||
#include "uc_main.h"
|
||||
#include <ctype.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/errno.h>
|
||||
@ -54,9 +53,6 @@
|
||||
|
||||
static void create_termcap(void);
|
||||
static void fixit_common(void);
|
||||
#ifdef SAVE_USERCONFIG
|
||||
static void save_userconfig_to_kernel(char *);
|
||||
#endif
|
||||
|
||||
#define TERMCAP_FILE "/usr/share/misc/termcap"
|
||||
|
||||
@ -762,10 +758,6 @@ installFixupBin(dialogMenuItem *self)
|
||||
msgConfirm("Unable to copy /kernel into place!");
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
#ifdef SAVE_USERCONFIG
|
||||
/* Snapshot any boot -c changes back to the new kernel */
|
||||
save_userconfig_to_kernel("/kernel");
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
msgConfirm("Can't find a kernel image to link to on the root file system!\n"
|
||||
@ -1120,62 +1112,3 @@ create_termcap(void)
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SAVE_USERCONFIG
|
||||
static void
|
||||
save_userconfig_to_kernel(char *kern)
|
||||
{
|
||||
struct kernel *core, *boot;
|
||||
struct list *c_isa, *b_isa, *c_dev, *b_dev;
|
||||
int i, d;
|
||||
|
||||
if ((core = uc_open("-incore")) == NULL) {
|
||||
msgDebug("save_userconf: Can't read in-core information for kernel.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((boot = uc_open(kern)) == NULL) {
|
||||
msgDebug("save_userconf: Can't read device information for kernel image %s\n", kern);
|
||||
return;
|
||||
}
|
||||
|
||||
msgNotify("Saving any boot -c changes to new kernel...");
|
||||
c_isa = uc_getdev(core, "-isa");
|
||||
b_isa = uc_getdev(boot, "-isa");
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: got %d ISA device entries from core, %d from boot.\n", c_isa->ac, b_isa->ac);
|
||||
for (d = 0; d < c_isa->ac; d++) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: ISA device loop, c_isa->av[%d] = %s\n", d, c_isa->av[d]);
|
||||
if (strcmp(c_isa->av[d], "npx0")) { /* special case npx0, which mucks with its id_irq member */
|
||||
c_dev = uc_getdev(core, c_isa->av[d]);
|
||||
b_dev = uc_getdev(boot, b_isa->av[d]);
|
||||
if (!c_dev || !b_dev) {
|
||||
msgDebug("save_userconf: c_dev: %x b_dev: %x\n", c_dev, b_dev);
|
||||
continue;
|
||||
}
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: ISA device %s: %d config parameters (core), %d (boot)\n",
|
||||
c_isa->av[d], c_dev->ac, b_dev->ac);
|
||||
for (i = 0; i < c_dev->ac; i++) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: c_dev->av[%d] = %s, b_dev->av[%d] = %s\n", i, c_dev->av[i], i, b_dev->av[i]);
|
||||
if (strcmp(c_dev->av[i], b_dev->av[i])) {
|
||||
if (isDebug())
|
||||
msgDebug("save_userconf: %s (boot) -> %s (core)\n",
|
||||
c_dev->av[i], b_dev->av[i]);
|
||||
isa_setdev(boot, c_dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isDebug())
|
||||
msgDebug("skipping npx0\n");
|
||||
}
|
||||
}
|
||||
if (isDebug())
|
||||
msgDebug("Closing kernels\n");
|
||||
uc_close(core, 0);
|
||||
uc_close(boot, 1);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user