Home | History | Annotate | Line # | Download | only in include
prom.h revision 1.13
      1  1.13    rmind /* $NetBSD: prom.h,v 1.13 2011/05/24 20:26:35 rmind Exp $ */
      2   1.1      cgd 
      3   1.1      cgd /*
      4   1.6      cgd  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
      5   1.1      cgd  * All rights reserved.
      6   1.1      cgd  *
      7   1.1      cgd  * Author: Keith Bostic, Chris G. Demetriou
      8   1.1      cgd  *
      9   1.1      cgd  * Permission to use, copy, modify and distribute this software and
     10   1.1      cgd  * its documentation is hereby granted, provided that both the copyright
     11   1.1      cgd  * notice and this permission notice appear in all copies of the
     12   1.1      cgd  * software, derivative works or modified versions, and any portions
     13   1.1      cgd  * thereof, and that both notices appear in supporting documentation.
     14   1.1      cgd  *
     15   1.1      cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16   1.1      cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17   1.1      cgd  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18   1.1      cgd  *
     19   1.1      cgd  * Carnegie Mellon requests users of this software to return to
     20   1.1      cgd  *
     21   1.1      cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22   1.1      cgd  *  School of Computer Science
     23   1.1      cgd  *  Carnegie Mellon University
     24   1.1      cgd  *  Pittsburgh PA 15213-3890
     25   1.1      cgd  *
     26   1.1      cgd  * any improvements or extensions that they make and grant Carnegie the
     27   1.1      cgd  * rights to redistribute these changes.
     28   1.1      cgd  */
     29   1.1      cgd 
     30   1.1      cgd #ifndef	ASSEMBLER
     31   1.1      cgd struct prom_vec {
     32   1.5      cgd 	u_int64_t	routine;
     33   1.5      cgd 	void		*routine_arg;
     34   1.1      cgd };
     35   1.1      cgd 
     36   1.1      cgd /* The return value from a prom call. */
     37   1.1      cgd typedef union {
     38   1.1      cgd 	struct {
     39   1.1      cgd 		u_int64_t
     40   1.1      cgd 			retval	: 32,		/* return value. */
     41   1.1      cgd 			unit	: 8,
     42   1.1      cgd 			mbz	: 8,
     43   1.1      cgd 			error	: 13,
     44   1.1      cgd 			status	: 3;
     45   1.1      cgd 	} u;
     46   1.1      cgd 	u_int64_t bits;
     47   1.1      cgd } prom_return_t;
     48   1.1      cgd 
     49  1.11     ross #ifdef _STANDALONE
     50  1.12  thorpej int	getchar(void);
     51  1.12  thorpej void	putchar(int);
     52   1.1      cgd #endif
     53   1.1      cgd 
     54  1.12  thorpej void	prom_halt(int) __attribute__((__noreturn__));
     55  1.12  thorpej int	prom_getenv(int, char *, int);
     56   1.4      cgd 
     57  1.12  thorpej void	hwrpb_primary_init(void);
     58  1.12  thorpej void	hwrpb_restart_setup(void);
     59   1.1      cgd #endif
     60   1.1      cgd 
     61   1.1      cgd /* Prom operation values. */
     62   1.1      cgd #define	PROM_R_CLOSE		0x11
     63   1.1      cgd #define	PROM_R_GETC		0x01
     64   1.1      cgd #define	PROM_R_GETENV		0x22
     65   1.1      cgd #define	PROM_R_OPEN		0x10
     66   1.1      cgd #define	PROM_R_PUTS		0x02
     67   1.1      cgd #define	PROM_R_READ		0x13
     68   1.3      cgd #define	PROM_R_WRITE		0x14
     69  1.11     ross #define	PROM_R_IOCTL		0x12
     70  1.11     ross 
     71  1.11     ross /* Prom IOCTL operation subcodes */
     72  1.11     ross #define	PROM_I_SKIP2IRG		1
     73  1.11     ross #define	PROM_I_SKIP2MARK	2
     74  1.11     ross #define	PROM_I_REWIND		3
     75  1.11     ross #define	PROM_I_WRITEMARK	4
     76   1.1      cgd 
     77   1.1      cgd /* Environment variable values. */
     78   1.1      cgd #define	PROM_E_BOOTED_DEV	0x4
     79   1.1      cgd #define	PROM_E_BOOTED_FILE	0x6
     80   1.1      cgd #define	PROM_E_BOOTED_OSFLAGS	0x8
     81   1.1      cgd #define	PROM_E_TTY_DEV		0xf
     82   1.8  thorpej #define	PROM_E_SCSIID		0x42
     83   1.8  thorpej #define	PROM_E_SCSIFAST		0x43
     84   1.1      cgd 
     85  1.11     ross #if defined(_STANDALONE) || defined(ENABLEPROM)
     86   1.1      cgd /*
     87  1.11     ross  * These can't be called from the kernel without great care.
     88  1.11     ross  *
     89   1.1      cgd  * There have to be stub routines to do the copying that ensures that the
     90   1.1      cgd  * PROM doesn't get called with an address larger than 32 bits.  Calls that
     91   1.1      cgd  * either don't need to copy anything, or don't need the copy because it's
     92   1.1      cgd  * already being done elsewhere, are defined here.
     93   1.1      cgd  */
     94  1.11     ross #define	prom_open(dev, len)						\
     95  1.11     ross 	prom_dispatch(PROM_R_OPEN, (dev), (len), 0, 0)
     96   1.5      cgd #define	prom_close(chan)						\
     97   1.5      cgd 	prom_dispatch(PROM_R_CLOSE, chan, 0, 0, 0)
     98   1.5      cgd #define	prom_read(chan, len, buf, blkno)				\
     99   1.5      cgd 	prom_dispatch(PROM_R_READ, chan, len, (u_int64_t)buf, blkno)
    100   1.5      cgd #define	prom_write(chan, len, buf, blkno)				\
    101   1.5      cgd 	prom_dispatch(PROM_R_WRITE, chan, len, (u_int64_t)buf, blkno)
    102  1.11     ross #define	prom_ioctl(chan, op, count)					\
    103  1.11     ross 	prom_dispatch(PROM_R_IOCTL, chan, op, (int64_t)count, 0, 0)
    104   1.5      cgd #define	prom_putstr(chan, str, len)					\
    105   1.5      cgd 	prom_dispatch(PROM_R_PUTS, chan, (u_int64_t)str, len, 0)
    106   1.5      cgd #define	prom_getc(chan)							\
    107   1.5      cgd 	prom_dispatch(PROM_R_GETC, chan, 0, 0, 0)
    108   1.5      cgd #define prom_getenv_disp(id, buf, len)					\
    109   1.5      cgd 	prom_dispatch(PROM_R_GETENV, id, (u_int64_t)buf, len, 0)
    110  1.11     ross #endif
    111   1.5      cgd 
    112   1.5      cgd #ifndef ASSEMBLER
    113   1.5      cgd #ifdef _KERNEL
    114  1.13    rmind void	prom_enter(void);
    115  1.13    rmind void	prom_leave(void);
    116   1.9  thorpej 
    117  1.12  thorpej void	promcnputc(dev_t, int);
    118  1.12  thorpej int	promcngetc(dev_t);
    119  1.12  thorpej int	promcnlookc(dev_t, char *);
    120   1.5      cgd 
    121  1.12  thorpej u_int64_t	prom_dispatch(u_int64_t, u_int64_t, u_int64_t, u_int64_t,
    122  1.12  thorpej 		    u_int64_t);
    123   1.5      cgd #endif /* _KERNEL */
    124   1.5      cgd #endif /* ASSEMBLER */
    125