date and time created 92/07/13 00:42:59 by torek
authorChris Torek <torek@ucbvax.Berkeley.EDU>
Mon, 13 Jul 1992 15:42:59 +0000 (07:42 -0800)
committerChris Torek <torek@ucbvax.Berkeley.EDU>
Mon, 13 Jul 1992 15:42:59 +0000 (07:42 -0800)
SCCS-vsn: sys/sparc/include/bsd_audioio.h 7.1
SCCS-vsn: sys/sparc/include/bsd_openprom.h 7.1
SCCS-vsn: sys/sparc/include/cpu.h 7.1

usr/src/sys/sparc/include/bsd_audioio.h [new file with mode: 0644]
usr/src/sys/sparc/include/bsd_openprom.h [new file with mode: 0644]
usr/src/sys/sparc/include/cpu.h [new file with mode: 0644]

diff --git a/usr/src/sys/sparc/include/bsd_audioio.h b/usr/src/sys/sparc/include/bsd_audioio.h
new file mode 100644 (file)
index 0000000..89bc00e
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 1991, 1992 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)bsd_audioio.h       7.1 (Berkeley) %G%
+ *
+ * from: $Header: bsd_audioio.h,v 1.4 92/07/13 00:31:22 torek Exp $ (LBL)
+ */
+
+#ifndef _BSD_AUDIOIO_H_
+#define _BSD_AUDIOIO_H_
+
+/*
+ * /dev/audio ioctls.  needs comments!
+ */
+#define AUDIO_MIN_GAIN 0
+#define AUDIO_MAX_GAIN 255
+
+#define AUDIO_ENCODING_ULAW 1
+#define AUDIO_ENCODING_ALAW 2
+
+struct audio_prinfo {
+       u_int   sample_rate;
+       u_int   channels;
+       u_int   precision;
+       u_int   encoding;
+       u_int   gain;
+       u_int   port;
+       u_int   samples;
+
+       u_char  pause;
+       u_char  error;
+       u_char  waiting;
+       u_char  open;
+
+       /* BSD extensions */
+       u_long  seek;
+};
+
+struct audio_info {
+       struct  audio_prinfo play;
+       struct  audio_prinfo record;
+       u_int   monitor_gain;
+       /* BSD extensions */
+       u_int   blocksize;      /* input blocking threshold */
+       u_int   hiwat;          /* output high water mark */
+       u_int   lowat;          /* output low water mark */
+};
+typedef struct audio_info audio_info_t;
+
+#define AUDIO_INITINFO(p)\
+       (void)memset((void *)(p), 0xff, sizeof(struct audio_info))
+
+#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__)
+#define AUDIO_GETINFO  _IOR(A, 1, struct audio_info)
+#define AUDIO_SETINFO  _IOWR(A, 2, struct audio_info)
+#define AUDIO_DRAIN    _IO(A, 3)
+#define AUDIO_FLUSH    _IO(A, 4)
+#define AUDIO_WSEEK    _IOR(A, 5, u_long)
+#define AUDIO_RERROR   _IOR(A, 6, int)
+#define AUDIO_GETMAP   _IOR(A, 20, struct mapreg)
+#define        AUDIO_SETMAP    _IOW(A, 21, struct mapreg)
+#else
+#define AUDIO_GETINFO  _IOR('A', 1, struct audio_info)
+#define AUDIO_SETINFO  _IOWR('A', 2, struct audio_info)
+#define AUDIO_DRAIN    _IO('A', 3)
+#define AUDIO_FLUSH    _IO('A', 4)
+#define AUDIO_WSEEK    _IOR('A', 5, u_long)
+#define AUDIO_RERROR   _IOR('A', 6, int)
+#define AUDIO_GETMAP   _IOR('A', 20, struct mapreg)
+#define        AUDIO_SETMAP    _IOW('A', 21, struct mapreg)
+#endif
+
+#define AUDIO_SPEAKER          1
+#define AUDIO_HEADPHONE                2
+
+/*
+ * Low level interface.
+ */
+struct mapreg {
+       u_short mr_x[8];
+       u_short mr_r[8];
+       u_short mr_gx;
+       u_short mr_gr;
+       u_short mr_ger;
+       u_short mr_stgr;
+       u_short mr_ftgr;
+       u_short mr_atgr;
+       u_char  mr_mmr1;
+       u_char  mr_mmr2;
+};
+
+#endif /* _BSD_AUDIOIO_H_ */
diff --git a/usr/src/sys/sparc/include/bsd_openprom.h b/usr/src/sys/sparc/include/bsd_openprom.h
new file mode 100644 (file)
index 0000000..30c297d
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 1992 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)bsd_openprom.h      7.1 (Berkeley) %G%
+ *
+ * from: $Header: bsd_openprom.h,v 1.2 92/07/10 06:26:12 torek Exp $
+ */
+
+/*
+ * This file defines the interface between the kernel and the Openboot PROM.
+ * N.B.: this has been tested only on interface versions 0 and 2 (we have
+ * never seen interface version 1).
+ */
+
+/*
+ * The v0 interface tells us what virtual memory to scan to avoid PMEG
+ * conflicts, but the v2 interface fails to do so, and we must `magically'
+ * know where the OPENPROM lives in virtual space.
+ */
+#define        OPENPROM_STARTVADDR     0xffd00000
+#define        OPENPROM_ENDVADDR       0xfff00000
+
+#define        OPENPROM_MAGIC 0x10010407
+
+/*
+ * Version 0 PROM vector device operations (collected here to emphasise that
+ * they are deprecated).  Open and close are obvious.  Read and write are
+ * segregated according to the device type (block, network, or character);
+ * this is unnecessary and was eliminated from the v2 device operations, but
+ * we are stuck with it.
+ *
+ * Seek is probably only useful on tape devices, since the only character
+ * devices are the serial ports.
+ *
+ * Note that a v0 device name is always exactly two characters ("sd", "le",
+ * and so forth).
+ */
+struct v0devops {
+       int     (*v0_open)(char *dev);
+       int     (*v0_close)(int d);
+       int     (*v0_rbdev)(int d, int nblks, int blkno, caddr_t addr); 
+       int     (*v0_wbdev)(int d, int nblks, int blkno, caddr_t addr); 
+       int     (*v0_wnet)(int d, int nbytes, caddr_t addr);
+       int     (*v0_rnet)(int d, int nbytes, caddr_t addr);
+       int     (*v0_rcdev)(int d, int nbytes, int, caddr_t addr);
+       int     (*v0_wcdev)(int d, int nbytes, int, caddr_t addr);
+       int     (*v0_seek)(int d, long offset, int whence);
+};
+
+/*
+ * Version 2 device operations.  Open takes a device `path' such as
+ * /sbus/le@0,c00000,0 or /sbus/esp@.../sd@0,0, which means it can open
+ * anything anywhere, without any magic translation.
+ *
+ * The memory allocator and map functions are included here even though
+ * they relate only indirectly to devices (e.g., mmap is good for mapping
+ * device memory, and drivers need to allocate space in which to record
+ * the device state).
+ */
+struct v2devops {
+       int     (*v2_xxx1)(int d);      /* ??? convert fd to something */
+
+       /* Memory allocation and release. */
+       caddr_t (*v2_malloc)(caddr_t va, u_int sz);
+       void    (*v2_free)(caddr_t va, u_int sz);
+
+       /* Device memory mapper. */
+       caddr_t (*v2_mmap)(caddr_t va, int asi, u_int pa, u_int sz);
+       void    (*v2_munmap)(caddr_t va, u_int sz);
+
+       /* Device open, close, etc. */
+       int     (*v2_open)(char *devpath);
+       void    (*v2_close)(int d);
+       int     (*v2_read)(int d, caddr_t buf, int nbytes);
+       int     (*v2_write)(int d, caddr_t buf, int nbytes);
+       void    (*v2_seek)(int d, int hi, int lo);
+
+       void    (*v2_xxx2)();           /* ??? */
+       void    (*v2_xxx3)();           /* ??? */
+};
+
+/*
+ * The v0 interface describes memory regions with these linked lists.
+ * (The !$&@#+ v2 interface reformats these as properties, so that we
+ * have to extract them into local temporary memory and reinterpret them.)
+ */
+struct v0mlist {
+       struct  v0mlist *next;
+       caddr_t addr;
+       u_int   nbytes;
+};
+
+/*
+ * V0 gives us three memory lists:  Total physical memory, VM reserved to
+ * the PROM, and available physical memory (which, presumably, is just the
+ * total minus any pages mapped in the PROM's VM region).  We can find the
+ * reserved PMEGs by scanning the taken VM.  Unfortunately, the V2 prom
+ * forgot to provide taken VM, and we are stuck with scanning ``magic''
+ * addresses.
+ */
+struct v0mem {
+       struct  v0mlist **v0_phystot;   /* physical memory */
+       struct  v0mlist **v0_vmprom;    /* VM used by PROM */
+       struct  v0mlist **v0_physavail; /* available physical memory */
+};
+
+/*
+ * The version 0 PROM breaks up the string given to the boot command and
+ * leaves the decoded version behind.
+ */
+struct v0bootargs {
+       char    *ba_argv[8];            /* argv format for boot string */
+       char    ba_args[100];           /* string space */
+       char    ba_bootdev[2];          /* e.g., "sd" for `b sd(...' */
+       int     ba_ctlr;                /* controller # */
+       int     ba_unit;                /* unit # */
+       int     ba_part;                /* partition # */
+       char    *ba_kernel;             /* kernel to boot, e.g., "vmunix" */
+       void    *ba_spare0;             /* not decoded here     XXX */
+};
+
+/*
+ * The version 2 PROM interface uses the more general, if less convenient,
+ * approach of passing the boot strings unchanged.  We also get open file
+ * numbers for stdin and stdout (keyboard and screen, or whatever), for use
+ * with the v2 device ops.
+ */
+struct v2bootargs {
+       char    **v2_bootpath;          /* V2: Path to boot device */
+       char    **v2_bootargs;          /* V2: Boot args */
+       int     *v2_fd0;                /* V2: Stdin descriptor */
+       int     *v2_fd1;                /* V2: Stdout descriptor */
+};
+
+/*
+ * The following structure defines the primary PROM vector interface.
+ * The Boot PROM hands the kernel a pointer to this structure in %o0.
+ * There are numerous substructures defined below.
+ */
+struct promvec {
+       /* Version numbers. */
+       u_int   pv_magic;               /* Magic number */
+       u_int   pv_romvec_vers;         /* interface version (0, 2) */
+       u_int   pv_plugin_vers;         /* ??? */
+       u_int   pv_printrev;            /* PROM rev # (* 10, e.g 1.9 = 19) */
+
+       /* Version 0 memory descriptors (see below). */
+       struct  v0mem pv_v0mem;         /* V0: Memory description lists. */
+
+       /* Node operations (see below). */
+       struct  nodeops *pv_nodeops;    /* node functions */
+
+       char    **pv_bootstr;           /* Boot command, eg sd(0,0,0)vmunix */
+
+       struct  v0devops pv_v0devops;   /* V0: device ops */
+
+       /*
+        * PROMDEV_* cookies.  I fear these may vanish in lieu of fd0/fd1
+        * (see below) in future PROMs, but for now they work fine.
+        */
+       char    *pv_stdin;              /* stdin cookie */
+       char    *pv_stdout;             /* stdout cookie */
+#define        PROMDEV_KBD     0               /* input from keyboard */
+#define        PROMDEV_SCREEN  0               /* output to screen */
+#define        PROMDEV_TTYA    1               /* in/out to ttya */
+#define        PROMDEV_TTYB    2               /* in/out to ttyb */
+
+       /* Blocking getchar/putchar.  NOT REENTRANT! (grr) */
+       int     (*pv_getchar)(void);
+       void    (*pv_putchar)(int ch);
+
+       /* Non-blocking variants that return -1 on error. */
+       int     (*pv_nbgetchar)(void);
+       int     (*pv_nbputchar)(int ch);
+
+       /* Put counted string (can be very slow). */
+       void    (*pv_putstr)(char *str, int len);
+
+       /* Miscellany. */
+       void    (*pv_reboot)(char *bootstr);
+       void    (*pv_printf)(char *fmt, ...);
+       void    (*pv_abort)(void);      /* L1-A abort */
+       int     *pv_ticks;              /* Ticks since last reset */
+       void    (*pv_halt)(void);       /* Halt! */
+       void    (**pv_synchook)(void);  /* "sync" command hook */
+
+       /*
+        * This eval's a FORTH string.  Unfortunately, its interface
+        * changed between V0 and V2, which gave us much pain.
+        */
+       union {
+               void    (*v0_eval)(int len, char *str);
+               void    (*v2_eval)(char *str);
+       } pv_fortheval;
+
+       struct  v0bootargs **pv_v0bootargs;     /* V0: Boot args */
+
+       /* Extract Ethernet address from network device. */
+       u_int   (*pv_enaddr)(int d, char *enaddr);
+
+       struct  v2bootargs pv_v2bootargs;       /* V2: Boot args + std in/out */
+       struct  v2devops pv_v2devops;   /* V2: device operations */
+
+       int     pv_spare[15];
+
+       /*
+        * The following is machine-dependent.
+        *
+        * The sun4c needs a PROM function to set a PMEG for another
+        * context, so that the kernel can map itself in all contexts.
+        * It is not possible simply to set the context register, because
+        * contexts 1 through N may have invalid translations for the
+        * current program counter.  The hardware has a mode in which
+        * all memory references go to the PROM, so the PROM can do it
+        * easily.
+        */
+       void    (*pv_setctxt)(int ctxt, caddr_t va, int pmeg);
+};
+
+/*
+ * In addition to the global stuff defined in the PROM vectors above,
+ * the PROM has quite a collection of `nodes'.  A node is described by
+ * an integer---these seem to be internal pointers, actually---and the
+ * nodes are arranged into an N-ary tree.  Each node implements a fixed
+ * set of functions, as described below.  The first two deal with the tree
+ * structure, allowing traversals in either breadth- or depth-first fashion.
+ * The rest deal with `properties'.
+ *
+ * A node property is simply a name/value pair.  The names are C strings
+ * (NUL-terminated); the values are arbitrary byte strings (counted strings).
+ * Many values are really just C strings.  Sometimes these are NUL-terminated,
+ * sometimes not, depending on the the interface version; v0 seems to
+ * terminate and v2 not.  Many others are simply integers stored as four
+ * bytes in machine order: you just get them and go.  The third popular
+ * format is an `address', which is made up of one or more sets of three
+ * integers as defined below.
+ *
+ * N.B.: for the `next' functions, next(0) = first, and next(last) = 0.
+ * Whoever designed this part had good taste.  On the other hand, these
+ * operation vectors are global, rather than per-node, yet the pointers
+ * are not in the openprom vectors but rather found by indirection from
+ * there.  So the taste balances out.
+ */
+struct openprom_addr {
+       int     oa_space;               /* address space (may be relative) */
+       u_int   oa_base;                /* address within space */
+       u_int   oa_size;                /* extent (number of bytes) */
+};
+
+struct nodeops {
+       /*
+        * Tree traversal.
+        */
+       int     (*no_nextnode)(int node);       /* next(node) */
+       int     (*no_child)(int node);  /* first child */
+
+       /*
+        * Property functions.  Proper use of getprop requires calling
+        * proplen first to make sure it fits.  Kind of a pain, but no
+        * doubt more convenient for the PROM coder.
+        */
+       int     (*no_proplen)(int node, caddr_t name);
+       int     (*no_getprop)(int node, caddr_t name, caddr_t val);
+       int     (*no_setprop)(int node, caddr_t name, caddr_t val, int len);
+       caddr_t (*no_nextprop)(int node, caddr_t name);
+};
diff --git a/usr/src/sys/sparc/include/cpu.h b/usr/src/sys/sparc/include/cpu.h
new file mode 100644 (file)
index 0000000..3afd7e6
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 1992 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)cpu.h       7.1 (Berkeley) %G%
+ *
+ * from: $Header: cpu.h,v 1.10 92/07/09 03:10:54 torek Exp $ (LBL)
+ */
+
+#ifndef _CPU_H_
+#define _CPU_H_
+
+#include "machine/psl.h"
+#include "../sparc/intreg.h"
+
+/*
+ * Exported definitions unique to SPARC cpu support.
+ */
+
+/*
+ * definitions of cpu-dependent requirements
+ * referenced in generic code
+ */
+#define        COPY_SIGCODE            /* copy sigcode above user stack in exec */
+
+/*
+ * function vs. inline configuration;
+ * these are defined to get generic functions
+ * rather than inline or machine-dependent implementations
+ */
+#define        NEED_MINMAX             /* need {,i,l,ul}{min,max} functions */
+#undef NEED_FFS                /* don't need ffs function */
+#define        NEED_BCMP               /* need bcmp function */
+#define        NEED_STRLEN             /* need strlen function */
+
+#define        cpu_exec(p)     /* nothing */
+#define        cpu_wait(p)     /* nothing */
+#define        cpu_setstack(p, ap)     ((p)->p_md.md_tf->tf_out[6] = (ap) - 64)
+
+/*
+ * Arguments to hardclock, softclock and gatherstats encapsulate the
+ * previous machine state in an opaque clockframe.  The ipl is here
+ * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
+ * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
+ */
+struct clockframe {
+       u_int   psr;            /* psr before interrupt, excluding PSR_ET */
+       u_int   pc;             /* pc at interrupt */
+       u_int   npc;            /* npc at interrupt */
+       u_int   ipl;            /* actual interrupt priority level */
+       u_int   fp;             /* %fp at interrupt */
+};
+
+extern int eintstack[];
+
+#define        CLKF_USERMODE(framep)   (((framep)->psr & PSR_PS) == 0)
+#define        CLKF_BASEPRI(framep)    (((framep)->psr & PSR_PIL) == 0)
+#define        CLKF_PC(framep)         ((framep)->pc)
+#define        CLKF_INTR(framep)       ((framep)->fp < (u_int)eintstack)
+
+/*
+ * Software interrupt request `register'.
+ */
+union sir {
+       int     sir_any;
+       char    sir_which[4];
+} sir;
+
+#define SIR_NET                0
+#define SIR_CLOCK      1
+
+#define        setsoftint()    ienab_bis(IE_L1)
+#define setsoftnet()   (sir.sir_which[SIR_NET] = 1, setsoftint())
+#define setsoftclock() (sir.sir_which[SIR_CLOCK] = 1, setsoftint())
+
+int    want_ast;
+
+/*
+ * Preempt the current process if in interrupt from user mode,
+ * or after the current trap/syscall if in system mode.
+ */
+int    want_resched;           /* resched() was called */
+#define        need_resched()          (want_resched = 1, want_ast = 1)
+
+/*
+ * Give a profiling tick to the current process when the user profiling
+ * buffer pages are invalid.  On the sparc, request an ast to send us 
+ * through trap(), marking the proc as needing a profiling tick.
+ */
+#define        need_proftick(p)        ((p)->p_flag |= SOWEUPC, want_ast = 1)
+
+/*
+ * Notify the current process (p) that it has a signal pending,
+ * process as soon as possible.
+ */
+#define        signotify(p)            (want_ast = 1)
+
+/*
+ * Only one process may own the FPU state.
+ *
+ * XXX this must be per-cpu (eventually)
+ */
+struct proc *fpproc;           /* FPU owner */
+int    foundfpu;               /* true => we have an FPU */
+
+/*
+ * Interrupt handler chains.  Interrupt handlers should return 0 for
+ * ``not me'' or 1 (``I took care of it'').  intr_establish() inserts a
+ * handler into the list.  The handler is called with its (single)
+ * argument, or with a pointer to a clockframe if ih_arg is NULL.
+ */
+struct intrhand {
+       int     (*ih_fun) __P((void *));
+       void    *ih_arg;
+       struct  intrhand *ih_next;
+} *intrhand[15];
+
+void   intr_establish __P((int level, struct intrhand *));
+
+/*
+ * intr_fasttrap() is a lot like intr_establish, but is used for ``fast''
+ * interrupt vectors (vectors that are not shared and are handled in the
+ * trap window).  Such functions must be written in assembly.
+ */
+void   intr_fasttrap __P((int level, void (*vec)(void)));
+
+#endif _CPU_H_