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