Update of arch/amiga tree, includes

- realtime clock support for a2k and a3k
- scsi drivers for a2091 and gvp-II controllers in a2k
- working ethernet driver for a2065/ameristar lance-controllers
This commit is contained in:
mw 1993-09-02 16:52:13 +00:00
parent 3ecb88ccbc
commit 7dac6517f1
10 changed files with 976 additions and 25 deletions

View File

@ -1,13 +1,18 @@
Current list as of 93-7-5:
There are probably dozens of bugs, keep in mind this is the first release :-)
Those I'm aware of:
- the console has some scrolling bug. This shows in the ircII client, where
incoming message lines just `scroll' in the last displayed line, instead
of scrolling the entire display.
- the dma code is currently broken. I'd really like to get this going again,
it's scribbling over innocent memory at the moment, and I think there might
be some bugs in the A3000 Service Manual describing some registers, we'll
see...
- nfsd and mountd crash regularly when going to multiuser mode...
- the console seems to have some problems displaying text when parity is
enabled. This shows in a distorted login-prompt (multiuser mode).
- the vt200 emulator is really far from perfect, and needs a lot more work
to be honestly called a vt200 (or vt320 even) emulator.
- the console chops the rightmost character, I guess this is a problem of
the display-window, not of the bitmap drawing itself.
- 8bit characters are all displayed as ^@. Problems could lie in wrong tty
settings or the ite driver.
- although autoconfig information is passed into the kernel and the hardware
@ -18,6 +23,8 @@ Those I'm aware of:
- disklabels can't be written back to disk. You'll have to configure your
drives under amigados (with hdtoolbox), and just format the partitions
under BSD. I think this is a tolerable limitation.
- the clock runs much too fast. I have an idea the kernel might think in
60Hz units, when the clock really runs at 100Hz, I'll look into this.
- there's currently no provision for reading the realtime-clock, so time
is always set using the last modification date of the mounted root
filesystem.

View File

@ -12,15 +12,17 @@ options NFS,NFSSERVER,NFSCLIENT
options MFS
options ISOFS
options FIFO
options PCFS,KERNFS
options MSDOSFS
options KERNFS
options FDESC
options ISO
options TPIP
#options ISO
#options TPIP
options "COMPAT_43"
options "TCP_COMPAT_42"
options "COMPAT_NOMID"
options "HAVE_USL_UFS"
options "PANICWAIT"
# Options for all HP machines
#options SYSVSHM
@ -35,12 +37,15 @@ options "NKMEMCLUSTERS=256"
options GENERIC
#options PROFTIMER,"PRF_INTERVAL=500"
#options KGDB,"KGDBDEV=15*256+2","KGDBRATE=19200"
options "PPP_OUTQ_SIZE=4096"
#config vmunix root on sd6a swap on sd6b
config vmunix swap generic
# manufacturer 1 is a pseudo and stands for `builtin'
master scsi0 at manufacturer 1 product 1
master a3000scsi0 at manufacturer 1 product 1
master a2091scsi0 at manufacturer 514 product 3
master gvp11scsi0 at manufacturer 2017 product 11
#master floppy0 at manufacturer 1 product 2
# further builtin devices
@ -50,21 +55,52 @@ device ser0 at manufacturer 1 product 3
#device par at manufacturer 1 product 6
#device mouse at manufacturer 1 product 8
disk sd0 at scsi0 slave 0
disk sd1 at scsi0 slave 1
disk sd2 at scsi0 slave 2
disk sd3 at scsi0 slave 3
disk sd4 at scsi0 slave 4
disk sd5 at scsi0 slave 5
disk sd6 at scsi0 slave 6
disk sd0 at a3000scsi0 slave 0
disk sd0 at a2091scsi0 slave 0
disk sd0 at gvp11scsi0 slave 0
tape st0 at scsi0 slave 4
tape st1 at scsi0 slave 5
disk sd1 at a3000scsi0 slave 1
disk sd1 at a2091scsi0 slave 1
disk sd1 at gvp11scsi0 slave 1
disk sd2 at a3000scsi0 slave 2
disk sd2 at a2091scsi0 slave 2
disk sd2 at gvp11scsi0 slave 2
disk sd3 at a3000scsi0 slave 3
disk sd3 at a2091scsi0 slave 3
disk sd3 at gvp11scsi0 slave 3
disk sd4 at a3000scsi0 slave 4
disk sd4 at a2091scsi0 slave 4
disk sd4 at gvp11scsi0 slave 4
disk sd5 at a3000scsi0 slave 5
disk sd5 at a2091scsi0 slave 5
disk sd5 at gvp11scsi0 slave 5
disk sd6 at a3000scsi0 slave 6
disk sd6 at a2091scsi0 slave 6
disk sd6 at gvp11scsi0 slave 6
tape st0 at a3000scsi0 slave ?
tape st0 at a2091scsi0 slave ?
tape st0 at gvp11scsi0 slave ?
tape st1 at a3000scsi0 slave ?
tape st1 at a2091scsi0 slave ?
tape st1 at gvp11scsi0 slave ?
device grf0 at manufacturer 1 product 7
device grf1 at manufacturer 18260 product 6
# builtin clock (should all identify as "rtclock")
device rtclocka0 at manufacturer 1 product 4
device rtclockb0 at manufacturer 1 product 9
# ethernet board
#device le0 at manufacturer ? product ?
device le0 at manufacturer ? product ?
# my dear A2410
#device tiga0 at manufacturer 1030 product 0
@ -72,7 +108,7 @@ device grf0 at manufacturer 1 product 7
pseudo-device sl 4
pseudo-device ppp 4
pseudo-device bpfilter 16
pseudo-device ite 1
pseudo-device ite 2
pseudo-device pty
pseudo-device loop
pseudo-device ether

View File

@ -0,0 +1,55 @@
#
# GENERIC AMIGA
#
machine "amiga"
cpu "A3000"
ident GENERIC
timezone -1 dst
# Standard 4.3-Reno options
maxusers 48
options INET
#options NS
#options KADB
options QUOTA
options FIFO
#options NFS
options MFS
options DIAGNOSTIC
options "TCP_COMPAT_42"
options "COMPAT_43"
#options "COMPAT_42"
options KTRACE
#options GATEWAY # slip needs this for packet forwarding
# OSI stuff:
#options ISO
#options TPIP
#options EON
# More standard options for the HPs
options MAPMEM
#options SYSVSHM
#options HPUXCOMPAT
config vmunix swap generic
#master scsi0 at builtin
#disk sd0 at scsi? slave ?
#disk sd1 at scsi? slave ?
#disk sd2 at scsi? slave ?
#disk sd3 at scsi? slave ?
#device le0 at product? manufacturer?
device ser at builtin
#device gcon at builtin
#device tiga0 at product 0 manufacturer 1030
pseudo-device pty
pseudo-device loop
#pseudo-device ether

View File

@ -0,0 +1,118 @@
machine "amiga"
cpu "A3000"
ident GODZILLA
timezone -1 dst
maxusers 16
# Standard options
#options QUOTA
options INET
options NFS,NFSSERVER,NFSCLIENT
options MFS
options ISOFS
options FIFO
options MSDOSFS
options KERNFS
options FDESC
#options ISO
#options TPIP
options "COMPAT_43"
options "TCP_COMPAT_42"
options "COMPAT_NOMID"
options "HAVE_USL_UFS"
options "PANICWAIT"
# Options for all HP machines
#options SYSVSHM
#options HPUXCOMPAT
# Options specific to this host.
options DEBUG,DIAGNOSTIC,FPCOPROC
# options PANICBUTTON
options KTRACE
#options "BUFPAGES=900"
options "NKMEMCLUSTERS=256"
#options PROFTIMER,"PRF_INTERVAL=500"
#options KGDB,"KGDBDEV=15*256+2","KGDBRATE=19200"
options "PPP_OUTQ_SIZE=4096"
config vmunix root on sd1a swap on sd1b and sd6b
#config vmunix swap generic
# manufacturer 1 is a pseudo and stands for `builtin'
master a3000scsi0 at manufacturer 1 product 1
master a2091scsi0 at manufacturer 514 product 3
master gvp11scsi0 at manufacturer 2017 product 11
#master floppy0 at manufacturer 1 product 2
# further builtin devices
device ser0 at manufacturer 1 product 3
#device clock at manufacturer 1 product 4
#device kbd at manufacturer 1 product 5
#device par at manufacturer 1 product 6
#device mouse at manufacturer 1 product 8
disk sd0 at a3000scsi0 slave 0
disk sd0 at a2091scsi0 slave 0
disk sd0 at gvp11scsi0 slave 0
disk sd1 at a3000scsi0 slave 1
disk sd1 at a2091scsi0 slave 1
disk sd1 at gvp11scsi0 slave 1
disk sd2 at a3000scsi0 slave 2
disk sd2 at a2091scsi0 slave 2
disk sd2 at gvp11scsi0 slave 2
disk sd3 at a3000scsi0 slave 3
disk sd3 at a2091scsi0 slave 3
disk sd3 at gvp11scsi0 slave 3
disk sd4 at a3000scsi0 slave 4
disk sd4 at a2091scsi0 slave 4
disk sd4 at gvp11scsi0 slave 4
disk sd5 at a3000scsi0 slave 5
disk sd5 at a2091scsi0 slave 5
disk sd5 at gvp11scsi0 slave 5
disk sd6 at a3000scsi0 slave 6
disk sd6 at a2091scsi0 slave 6
disk sd6 at gvp11scsi0 slave 6
tape st0 at a3000scsi0 slave ?
tape st0 at a2091scsi0 slave ?
tape st0 at gvp11scsi0 slave ?
tape st1 at a3000scsi0 slave ?
tape st1 at a2091scsi0 slave ?
tape st1 at gvp11scsi0 slave ?
device grf0 at manufacturer 1 product 7
device grf1 at manufacturer 18260 product 6
# builtin clock (should all identify as "rtclock")
device rtclocka0 at manufacturer 1 product 4
device rtclockb0 at manufacturer 1 product 9
# ethernet board
device le0 at manufacturer ? product ?
# my dear A2410
#device tiga0 at manufacturer 1030 product 0
pseudo-device sl 4
pseudo-device ppp 4
pseudo-device bpfilter 16
pseudo-device ite 2
pseudo-device pty
pseudo-device loop
pseudo-device ether
pseudo-device vn 10
pseudo-device devpager
pseudo-device swappager
pseudo-device vnodepager

View File

@ -1,5 +1,6 @@
arch/amiga/amiga/amiga_init.c standard
arch/amiga/amiga/autoconf.c standard
arch/amiga/amiga/cia.c standard
arch/amiga/amiga/clock.c standard
arch/amiga/amiga/conf.c standard
arch/amiga/amiga/cons.c standard
@ -14,18 +15,27 @@ arch/amiga/amiga/pmap.c standard
arch/amiga/amiga/sys_machdep.c standard
arch/amiga/amiga/trap.c standard
arch/amiga/amiga/vm_machdep.c standard
arch/amiga/dev/dma.c optional scsi
arch/amiga/dev/vn.c optional vn
arch/amiga/dev/scsi.c optional scsi device-driver
arch/amiga/dev/sd.c optional sd
arch/amiga/dev/st.c optional st
arch/amiga/dev/a3000dma.c optional a3000scsi device-driver
arch/amiga/dev/a2091dma.c optional a2091scsi device-driver
arch/amiga/dev/gvp11dma.c optional gvp11scsi device-driver
arch/amiga/dev/vn.c optional vn device-driver
arch/amiga/dev/scsi.c optional a3000scsi
arch/amiga/dev/sd.c optional sd device-driver
arch/amiga/dev/st.c optional st device-driver
arch/amiga/dev/ser.c optional ser device-driver
arch/amiga/dev/kbd.c optional ite
arch/amiga/dev/ite.c optional ite
arch/amiga/dev/ite.c optional ite device-driver
arch/amiga/dev/ite_cc.c optional ite
arch/amiga/dev/ite_tg.c optional ite
arch/amiga/dev/ite_rt.c optional ite
arch/amiga/dev/kernel_font.c optional ite
arch/amiga/dev/kbdmap.c optional ite
arch/amiga/dev/grf.c optional grf
arch/amiga/dev/grf.c optional grf device-driver
arch/amiga/dev/grf_cc.c optional grf
arch/amiga/dev/grf_tg.c optional grf
arch/amiga/dev/grf_rt.c optional grf
arch/amiga/dev/par.c optional par device-driver
arch/amiga/dev/if_le.c optional le device-driver
arch/amiga/dev/rtclocka.c optional rtclocka device-driver
arch/amiga/dev/rtclockb.c optional rtclockb device-driver
kern/syscalls.c standard

View File

@ -0,0 +1,147 @@
/*-
* Copyright (c) 1991 The Regents of the University of California.
* 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. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)a.out.h 5.6 (Berkeley) 4/30/91
*/
#ifndef _AOUT_H_
#define _AOUT_H_
#include <sys/exec.h>
#if defined(amiga)
#define __LDPGSZ 8192
#endif
#if defined(hp300) || defined(i386)
#define __LDPGSZ 4096
#endif
#if defined(tahoe) || defined(vax)
#define __LDPGSZ 1024
#endif
#define N_GETMAGIC(ex) \
( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : ((ex).a_midmag))
#define N_GETMAGIC2(ex) \
( (((ex).a_midmag)&0xffff0000) ? (ntohl(((ex).a_midmag))&0xffff) : \
(((ex).a_midmag) | 0x10000) )
#define N_GETMID(ex) \
( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>16)&0x03ff) : MID_ZERO )
#define N_GETFLAG(ex) \
( (((ex).a_midmag)&0xffff0000) ? ((ntohl(((ex).a_midmag))>>26)&0x3f) : 0 )
#define N_SETMAGIC(ex,mag,mid,flag) \
( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
(((mag)&0xffff)) ) )
#define N_ALIGN(ex,x) \
(/*N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC ?*/ \
((x) + __LDPGSZ - 1) & ~(__LDPGSZ - 1) /*: (x)*/)
/* Valid magic number check. */
#define N_BADMAG(ex) \
(N_GETMAGIC(ex) != NMAGIC && N_GETMAGIC(ex) != OMAGIC && \
N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC)
/* Address of the bottom of the text segment. */
#define N_TXTADDR(ex) (((N_GETMAGIC2(ex) == (ZMAGIC|0x10000)) \
|| (N_GETMAGIC(ex) == NMAGIC) \
|| (N_GETMAGIC(ex) == OMAGIC)) ? 0 : __LDPGSZ)
/* Address of the bottom of the data segment. */
#define N_DATADDR(ex) \
N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
/* Text segment offset. */
#define N_TXTOFF(ex) \
( N_GETMAGIC2(ex)==ZMAGIC || N_GETMAGIC2(ex)==(QMAGIC|0x10000) ? \
0 : (N_GETMAGIC2(ex)==(ZMAGIC|0x10000) ? __LDPGSZ : sizeof(struct exec)) )
/* Data segment offset. */
#define N_DATOFF(ex) \
N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
/* Relocation table offset. */
#define N_RELOFF(ex) \
N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
/* Symbol table offset. */
#define N_SYMOFF(ex) \
(N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
/* String table offset. */
#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
/* Relocation format. */
struct relocation_info {
int r_address; /* offset in text or data segment */
unsigned int r_symbolnum : 24, /* ordinal number of add symbol */
r_pcrel : 1, /* 1 if value should be pc-relative */
r_length : 2, /* log base 2 of value's width */
r_extern : 1, /* 1 if need to add symbol to value */
: 4; /* reserved */
};
/* the system macros are plain wrong.. sigh.. */
#undef N_TXTOFF
#undef N_DATOFF
#define N_TXTOFF(x) /* text segment */ \
(N_GETMAGIC(x)==ZMAGIC ? 0 : sizeof (struct exec))
#define N_DATOFF(x) /* data segment */ \
(N_TXTOFF(x) + (x).a_text)
#undef N_TRELOFF
#undef N_DRELOFF
#undef N_SYMOFF
#undef N_STROFF
#define N_TRELOFF(x) /* text reloc'n */ \
(N_DATOFF(x) + (x).a_data)
#define N_DRELOFF(x) /* data relocation*/ \
(N_TRELOFF(x) + (x).a_trsize)
#define N_SYMOFF(x) \
/* symbol table */ \
(N_TXTOFF(x)+(x).a_text+(x).a_data+(x).a_trsize+(x).a_drsize)
#define N_STROFF(x) \
/* string table */ \
(N_SYMOFF(x) + (x).a_syms)
#undef N_TXTADDR
#undef N_DATADDR
#define N_TXTADDR(x) (N_GETMAGIC(x)==ZMAGIC?__LDPGSZ:0)
#define N_DATADDR(x) \
((N_GETMAGIC(x)==OMAGIC)? (N_TXTADDR(x)+(x).a_text) \
: (__LDPGSZ+((N_TXTADDR(x)+(x).a_text-1) & ~(__LDPGSZ-1))))
#define _AOUT_INCLUDE_
#include <nlist.h>
#endif /* !_AOUT_H_ */

View File

@ -0,0 +1,199 @@
#include <sys/types.h>
#include <a.out.h>
#include <stdio.h>
extern char *optarg;
extern int optind;
volatile void error ();
int test = 1;
int testbss;
char foo = 23;
int
main(argc, argv)
int argc;
char *argv[];
{
struct exec e;
int c;
u_long addr = 0;
u_long replace = 0, do_replace = 0;
char *symbol = 0;
char size = 4; /* default to long */
char *fname;
int fd;
int type, off;
u_long lval;
u_short sval;
u_char cval;
while ((c = getopt (argc, argv, "a:bwlr:s:")) != EOF)
switch (c)
{
case 'a':
if (addr || symbol)
error ("only one address/symbol allowed");
if (! strncmp (optarg, "0x", 2))
sscanf (optarg, "%x", &addr);
else
addr = atoi (optarg);
if (! addr)
error ("invalid address");
break;
case 'b':
size = 1;
break;
case 'w':
size = 2;
break;
case 'l':
size = 4;
break;
case 'r':
do_replace = 1;
if (! strncmp (optarg, "0x", 2))
sscanf (optarg, "%x", &replace);
else
replace = atoi (optarg);
break;
case 's':
if (addr || symbol)
error ("only one address/symbol allowed");
symbol = optarg;
break;
}
argv += optind;
argc -= optind;
if (argc < 1)
error ("No file to patch.");
fname = argv[0];
if ((fd = open (fname, 0)) < 0)
error ("Can't open file");
if (read (fd, &e, sizeof (e)) != sizeof (e)
|| N_BADMAG (e))
error ("Not a valid executable.");
/* fake mid, so the N_ macros work on the amiga.. */
e.a_midmag |= 127 << 16;
if (symbol)
{
struct nlist nl[2];
nl[0].n_un.n_name = symbol;
nl[1].n_un.n_name = 0;
if (nlist (fname, nl) != 0)
error ("Symbol not found.");
addr = nl[0].n_value;
type = nl[0].n_type & N_TYPE;
}
else
{
type = N_UNDF;
if (addr >= N_TXTADDR(e) && addr < N_DATADDR(e))
type = N_TEXT;
else if (addr >= N_DATADDR(e) && addr < N_DATADDR(e) + e.a_data)
type = N_DATA;
}
/* if replace-mode, have to reopen the file for writing.
Can't do that from the beginning, or nlist() will not
work (at least not under AmigaDOS) */
if (do_replace)
{
close (fd);
if ((fd = open (fname, 2)) == -1)
error ("Can't reopen file for writing.");
}
if (type != N_TEXT && type != N_DATA)
error ("address/symbol is not in text or data section.");
if (type == N_TEXT)
off = addr - N_TXTADDR(e) + N_TXTOFF(e);
else
off = addr - N_DATADDR(e) + N_DATOFF(e);
if (lseek (fd, off, 0) == -1)
error ("lseek");
/* not beautiful, but works on big and little endian machines */
switch (size)
{
case 1:
if (read (fd, &cval, 1) != 1)
error ("cread");
lval = cval;
break;
case 2:
if (read (fd, &sval, 2) != 2)
error ("sread");
lval = sval;
break;
case 4:
if (read (fd, &lval, 4) != 4)
error ("lread");
break;
}
if (symbol)
printf ("%s(0x%x): %d (0x%x)\n", symbol, addr, lval, lval);
else
printf ("0x%x: %d (0x%x)\n", addr, lval, lval);
if (do_replace)
{
if (lseek (fd, off, 0) == -1)
error ("write-lseek");
switch (size)
{
case 1:
cval = replace;
if (cval != replace)
error ("byte-value overflow.");
if (write (fd, &cval, 1) != 1)
error ("cwrite");
break;
case 2:
sval = replace;
if (sval != replace)
error ("word-value overflow.");
if (write (fd, &sval, 2) != 2)
error ("swrite");
break;
case 4:
if (write (fd, &replace, 4) != 4)
error ("lwrite");
break;
}
}
close (fd);
}
volatile void error (str)
char *str;
{
fprintf (stderr, "%s\n", str);
exit (1);
}

View File

@ -0,0 +1,122 @@
/*
* Copyright (c) 1989 The Regents of the University of California.
* 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. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)nlist.c 5.8 (Berkeley) 2/23/91";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <sys/file.h>
#include <a.out.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
typedef struct nlist NLIST;
#define _strx n_un.n_strx
#define _name n_un.n_name
#define ISVALID(p) (p->_name && p->_name[0])
int
nlist(name, list)
const char *name;
NLIST *list;
{
register NLIST *p, *s;
struct exec ebuf;
FILE *fstr, *fsym;
NLIST nbuf;
off_t strings_offset, symbol_offset, symbol_size, lseek();
int entries, len, maxlen;
char sbuf[256];
entries = -1;
if (!(fsym = fopen(name, "r")))
return(-1);
if (fread((char *)&ebuf, sizeof(struct exec), 1, fsym) != 1 ||
N_BADMAG(ebuf))
goto done1;
symbol_offset = N_SYMOFF(ebuf);
symbol_size = ebuf.a_syms;
strings_offset = symbol_offset + symbol_size;
if (fseek(fsym, symbol_offset, SEEK_SET))
goto done1;
if (!(fstr = fopen(name, "r")))
goto done1;
/*
* clean out any left-over information for all valid entries.
* Type and value defined to be 0 if not found; historical
* versions cleared other and desc as well. Also figure out
* the largest string length so don't read any more of the
* string table than we have to.
*/
for (p = list, entries = maxlen = 0; ISVALID(p); ++p, ++entries) {
p->n_type = 0;
p->n_other = 0;
p->n_desc = 0;
p->n_value = 0;
if ((len = strlen(p->_name)) > maxlen)
maxlen = len;
}
if (++maxlen > sizeof(sbuf)) { /* for the NULL */
(void)fprintf(stderr, "nlist: symbol too large.\n");
entries = -1;
goto done2;
}
for (s = &nbuf; symbol_size; symbol_size -= sizeof(NLIST)) {
if (fread((char *)s, sizeof(NLIST), 1, fsym) != 1)
goto done2;
if (!s->_strx || s->n_type&N_STAB)
continue;
if (fseek(fstr, strings_offset + s->_strx, SEEK_SET))
goto done2;
(void)fread(sbuf, sizeof(sbuf[0]), maxlen, fstr);
for (p = list; ISVALID(p); p++)
if (!strcmp(p->_name, sbuf)) {
p->n_value = s->n_value;
p->n_type = s->n_type;
p->n_desc = s->n_desc;
p->n_other = s->n_other;
if (!--entries)
goto done2;
}
}
done2: (void)fclose(fstr);
done1: (void)fclose(fsym);
return(entries);
}

View File

@ -0,0 +1,80 @@
/*-
* Copyright (c) 1991 The Regents of the University of California.
* 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. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nlist.h 5.6 (Berkeley) 4/4/91
*/
#ifndef _NLIST_H_
#define _NLIST_H_
/*
* Symbol table entry format. The #ifdef's are so that programs including
* nlist.h can initialize nlist structures statically.
*/
struct nlist {
#ifdef _AOUT_INCLUDE_
union {
char *n_name; /* symbol name (in memory) */
long n_strx; /* file string table offset (on disk) */
} n_un;
#else
char *n_name; /* symbol name (in memory) */
#endif
#define N_UNDF 0x00 /* undefined */
#define N_ABS 0x02 /* absolute address */
#define N_TEXT 0x04 /* text segment */
#define N_DATA 0x06 /* data segment */
#define N_BSS 0x08 /* bss segment */
#define N_COMM 0x12 /* common reference */
#define N_FN 0x1e /* file name */
#define N_EXT 0x01 /* external (global) bit, OR'ed in */
#define N_TYPE 0x1e /* mask for all the type bits */
unsigned char n_type; /* type defines */
char n_other; /* spare */
#define n_hash n_desc /* used internally by ld(1); XXX */
short n_desc; /* used by stab entries */
unsigned long n_value; /* address/value of the symbol */
};
#define N_FORMAT "%08x" /* namelist value format; XXX */
#define N_STAB 0x0e0 /* mask for debugger symbols -- stab(5) */
#include <sys/cdefs.h>
__BEGIN_DECLS
int nlist __P((const char *, struct nlist *));
__END_DECLS
#endif /* !_NLIST_H_ */

View File

@ -0,0 +1,177 @@
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* 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. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)exec.h 7.5 (Berkeley) 2/15/91
* $Id: exec.h,v 1.1.1.1 1993/09/02 16:52:31 mw Exp $
*/
#ifndef _SYS_EXEC_H_
#define _SYS_EXEC_H_
#include <sys/param.h>
#include <sys/cdefs.h>
/*
* Header prepended to each a.out file.
* only manipulate the a_midmag field via the
* N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
*/
struct exec {
unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
unsigned long a_text; /* text segment size */
unsigned long a_data; /* initialized data size */
unsigned long a_bss; /* uninitialized data size */
unsigned long a_syms; /* symbol table size */
unsigned long a_entry; /* entry point */
unsigned long a_trsize; /* text relocation size */
unsigned long a_drsize; /* data relocation size */
};
/* a_magic */
#define OMAGIC 0407 /* old impure format */
#define NMAGIC 0410 /* read-only text */
#define ZMAGIC 0413 /* demand load format */
#define QMAGIC 0314 /* "compact" demand load format -- DEPRICATE */
/*
* a_mid - keep sorted in numerical order for sanity's sake
* ensure that: 0 < mid < 0x3ff
*/
#define MID_ZERO 0 /* unknown - implementation dependent */
#define MID_SUN010 1 /* sun 68010/68020 binary */
#define MID_SUN020 2 /* sun 68020-only binary */
#define MID_AMIGA030 64 /* amiga (68020/68030) 6888[12] fpu */
#define MID_AMIGA040 65 /* amiga 68040 (w/ 68040 fpu only) */
#define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */
#define MID_HP200 200 /* hp200 (68010) BSD binary */
#define MID_I386 134 /* i386 BSD binary */
#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
/*
* Magic number/exec function table... (execution class loader)
*/
struct execsw {
int magic; /* magic number this loader sees*/
int m_size; /* size of magic number (significant bytes)*/
int (*load)(); /* loader function*/
};
extern struct execsw execsw[];
extern int nexecs;
/*
* i (cgd) give up; it's damned impossible to find out where a process's
* args are. 4.4 actually puts pointers in the process address space,
* above the stack. this is reasonable, and also allows the process to
* set its ps-visible arguments.
*
* PS_STRINGS defines the location of a process's ps_strings structure.
*/
struct ps_strings {
char *ps_argvstr; /* the argv strings */
int ps_nargvstr; /* number of argv strings */
char *ps_envstr; /* the environment strings */
int ps_nenvstr; /* number of environment strings */
};
#define PS_STRINGS \
((struct ps_strings *)(USRSTACK - sizeof(struct ps_strings)))
/*
* the following structures allow exec to put together processes
* in a more extensible and cleaner way.
*
* the exec_package struct defines an executable being execve()'d.
* it contains the header, the vmspace-building commands, the vnode
* information, and the arguments associated with the newly-execve'd
* process.
*
* the exec_vmcmd struct defines a command description to be used
* in creating the new process's vmspace.
*/
struct exec_package {
struct exec *ep_execp; /* file's exec header */
struct exec_vmcmd *ep_vcp; /* exec_vmcmds used to build the vmspace */
struct vnode *ep_vp; /* executable's vnode */
struct vattr *ep_vap; /* executable's attributes */
unsigned long ep_taddr; /* process's text address */
unsigned long ep_tsize; /* size of process's text */
unsigned long ep_daddr; /* process's data(+bss) address */
unsigned long ep_dsize; /* size of process's data(+bss) */
unsigned long ep_maxsaddr; /* process's max stack address ("top") */
unsigned long ep_minsaddr; /* process's min stack address ("bottom") */
unsigned long ep_ssize; /* size of process's stack */
unsigned long ep_entry; /* process's entry point */
#ifdef notdef
char *ep_argbuf; /* argument buffer. generally same as argv */
int ep_argc; /* count of process arguments */
char *ep_argv; /* process arguments, null seperated */
int ep_envc; /* count of process environment strings */
char *ep_env; /* process enviornment strings, null seperated */
#endif
};
struct proc;
struct exec_vmcmd {
struct exec_vmcmd *ev_next; /* next command on the chain */
/* procedure to run */
int (*ev_proc) __P((struct proc *p, struct exec_vmcmd *cmd));
unsigned long ev_len; /* length of the segment to map */
unsigned long ev_addr; /* address in the vmspace to place it at */
struct vnode *ev_vp; /* vnode pointer for the file w/the data */
unsigned long ev_offset; /* offset in the file for the data */
unsigned ev_prot; /* protections for segment */
};
#ifdef KERNEL
struct exec_vmcmd *new_vmcmd __P(( \
int (*proc) __P((struct proc *p, struct exec_vmcmd *)), \
unsigned long len, \
unsigned long addr, \
struct vnode *vp, \
unsigned long offset, \
unsigned long prot));
void kill_vmcmd __P((struct exec_vmcmd **));
int exec_makecmds __P((struct proc *, struct exec_package *));
int exec_runcmds __P((struct proc *, struct exec_package *));
int exec_prep_qmagic __P((struct proc *, struct exec_package *));
int exec_prep_zmagic __P((struct proc *, struct exec_package *));
int vmcmd_map_pagedvn __P((struct proc *, struct exec_vmcmd *));
int vmcmd_map_zero __P((struct proc *, struct exec_vmcmd *));
#endif
#endif /* !_SYS_EXEC_H_ */