prom.h revision 1.2 1 /* $OpenBSD$ */
2
3 /*
4 * Copyright (c) 1995 Theo de Raadt
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed under OpenBSD by
18 * Theo de Raadt for Willowglen Singapore.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #define MVMEPROM_INCHR 0x00
35 #define MVMEPROM_INSTAT 0x01
36 #define MVMEPROM_INLN 0x02
37 #define MVMEPROM_READSTR 0x03
38 #define MVMEPROM_READLN 0x04
39 #define MVMEPROM_OUTCHR 0x20
40 #define MVMEPROM_OUTSTR 0x21
41 #define MVMEPROM_DSKRD 0x10
42 #define MVMEPROM_DSKWR 0x11
43 #define MVMEPROM_DSKCFIG 0x12
44 #define MVMEPROM_DSKFMT 0x14
45 #define MVMEPROM_DSKCTRL 0x15
46 #define MVMEPROM_NETCTRL 0x1d
47 #define MVMEPROM_OUTSTRCRLF 0x22
48 #define MVMEPROM_WRITE 0x23
49 #define MVMEPROM_WRITELN 0x24
50 #define MVMEPROM_DELAY 0x43
51 #define MVMEPROM_RTC_RD 0x53
52 #define MVMEPROM_EXIT 0x63
53 #define MVMEPROM_GETBRDID 0x70
54 #define MVMEPROM_ENVIRON 0x71
55
56 #define NETCTRLCMD_GETETHER 1
57
58 #define ENVIRONCMD_WRITE 1
59 #define ENVIRONCMD_READ 2
60 #define ENVIRONTYPE_EOL 0
61 #define ENVIRONTYPE_START 1
62 #define ENVIRONTYPE_DISKBOOT 2
63 #define ENVIRONTYPE_ROMBOOT 3
64 #define ENVIRONTYPE_NETBOOT 4
65 #define ENVIRONTYPE_MEMSIZE 5
66
67 #ifndef _LOCORE
68 struct prom_netctrl {
69 u_char dev;
70 u_char ctrl;
71 u_short status;
72 u_long cmd;
73 u_long addr;
74 u_long len;
75 u_long flags;
76 };
77
78 struct prom_environ_hdr {
79 u_char type;
80 u_char len;
81 };
82
83 struct mvmeprom_brdid {
84 u_long eye_catcher;
85 u_char rev;
86 u_char month;
87 u_char day;
88 u_char year;
89 u_short size;
90 u_short rsv1;
91 u_short model;
92 u_short suffix;
93 u_short options;
94 u_char family;
95 u_char cpu;
96 u_short ctrlun;
97 u_short devlun;
98 u_short devtype;
99 u_short devnum;
100 u_long bug;
101
102 /*
103 * XXX: I have seen no documentation for these!
104 *
105 * The following (appears to) exist only on the MVME162 and
106 * upwards. We should figure out what the other fields are.
107 */
108 u_char xx1[16];
109 u_char xx2[4];
110 u_char longname[12];
111 u_char xx3[16];
112 u_char speed[4];
113 u_char xx4[12];
114 };
115
116 struct mvmeprom_time {
117 u_char year_BCD;
118 u_char month_BCD;
119 u_char day_BCD;
120 u_char wday_BCD;
121 u_char hour_BCD;
122 u_char min_BCD;
123 u_char sec_BCD;
124 u_char cal_BCD;
125 };
126
127 struct mvmeprom_dskio {
128 u_char ctrl_lun;
129 u_char dev_lun;
130 u_short status;
131 void *pbuffer;
132 u_long blk_num;
133 u_short blk_cnt;
134 u_char flag;
135 #define BUG_FILE_MARK 0x80
136 #define IGNORE_FILENUM 0x02
137 #define END_OF_FILE 0x01
138 u_char addr_mod;
139 };
140 #define MVMEPROM_BLOCK_SIZE 256
141
142 struct mvmeprom_args {
143 u_int dev_lun;
144 u_int ctrl_lun;
145 u_int flags;
146 u_int ctrl_addr;
147 u_int entry;
148 u_int conf_blk;
149 char *arg_start;
150 char *arg_end;
151 char *nbarg_start;
152 char *nbarg_end;
153 u_int cputyp;
154 };
155
156 #endif
157
158 #define MVMEPROM_CALL(x) \
159 asm volatile (__CONCAT("trap #15; .short ", __STRING(x)) )
160 #define MVMEPROM_NOARG() \
161 asm volatile ("clrl sp@-")
162 #define MVMEPROM_ARG1(arg) \
163 asm volatile ("movel %0, sp@-"::"d" (arg))
164 #define MVMEPROM_ARG2(arg) \
165 asm volatile ("movel %0, sp@-"::"d" (arg))
166 #define MVMEPROM_GETRES(ret) \
167 asm volatile ("movel sp@+,%0": "=d" (ret):)
168 #define MVMEPROM_RETURN(ret) \
169 MVMEPROM_GETRES(ret); \
170 return (ret); /* return a value (int) */
171 #define MVMEPROM_RETURN_BYTE(ret) \
172 MVMEPROM_GETRES(ret); \
173 return((ret >> 24) & 0xff); /* return a byte, ret must be int */
174 #define MVMEPROM_STATRET(ret) \
175 MVMEPROM_GETRES(ret); \
176 return (!(ret & 0x4)); /* return a 'status' */
177
178 #define MVMEPROM_REG_DEVLUN "d0"
179 #define MVMEPROM_REG_CTRLLUN "d1"
180 #define MVMEPROM_REG_FLAGS "d4"
181 #define MVMEPROM_REG_CTRLADDR "a0"
182 #define MVMEPROM_REG_ENTRY "a1"
183 #define MVMEPROM_REG_CONFBLK "a2"
184 #define MVMEPROM_REG_NBARGSTART "a3"
185 #define MVMEPROM_REG_NBARGEND "a4"
186 #define MVMEPROM_REG_ARGSTART "a5"
187 #define MVMEPROM_REG_ARGEND "a6"
188
189 #ifndef RB_NOSYM
190 #define RB_NOSYM 0x400
191 #endif
192 #ifndef RB_SBOOT
193 #define RB_SBOOT 0x800
194 #endif
195
196