1 /*        $NetBSD: prom.h,v 1.18 2013/09/23 01:39:27 tsutsui Exp $    */
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  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #define MVMEPROM_INCHR                  0x00
29 #define MVMEPROM_INSTAT                 0x01
30 #define MVMEPROM_INLN                   0x02
31 #define MVMEPROM_READSTR      0x03
32 #define MVMEPROM_READLN                 0x04
33 #define MVMEPROM_OUTCHR                 0x20
34 #define MVMEPROM_OUTSTR                 0x21
35 #define MVMEPROM_DSKRD                  0x10
36 #define MVMEPROM_DSKWR                  0x11
37 #define MVMEPROM_DSKCFIG      0x12
38 #define MVMEPROM_DSKFMT                 0x14
39 #define MVMEPROM_DSKCTRL      0x15
40 #define MVMEPROM_NETCTRL      0x1d
41 #define MVMEPROM_OUTSTRCRLF   0x22
42 #define MVMEPROM_WRITE                  0x23
43 #define MVMEPROM_WRITELN      0x24
44 #define MVMEPROM_DELAY                  0x43
45 #define MVMEPROM_RTC_RD                 0x53
46 #define MVMEPROM_EXIT                   0x63
47 #define MVMEPROM_GETBRDID     0x70
48 #define MVMEPROM_ENVIRON      0x71
49 
50 #define NETCTRLCMD_GETETHER   1
51 
52 #define ENVIRONCMD_WRITE      1
53 #define ENVIRONCMD_READ                 2
54 #define ENVIRONTYPE_EOL                 0
55 #define ENVIRONTYPE_START     1
56 #define ENVIRONTYPE_DISKBOOT  2
57 #define ENVIRONTYPE_ROMBOOT   3
58 #define ENVIRONTYPE_NETBOOT   4
59 #define ENVIRONTYPE_MEMSIZE   5
60 
61 #ifndef _LOCORE
62 struct prom_netctrl {
63           u_char    dev;
64           u_char    ctrl;
65           u_short   status;
66           u_long    cmd;
67           u_long    addr;
68           u_long    len;
69           u_long    flags;
70 };
71 
72 struct prom_environ_hdr {
73           u_char    type;
74           u_char    len;
75 };
76 
77 struct mvmeprom_brdid {
78           u_long    eye_catcher;
79           u_char    rev;
80           u_char    month;
81           u_char    day;
82           u_char    year;
83           u_short   size;
84           u_short   rsv1;
85           u_short   model;
86           u_short   suffix;
87           u_short   options;
88           u_char    family;
89           u_char    cpu;
90           u_short   ctrlun;
91           u_short   devlun;
92           u_short   devtype;
93           u_short   devnum;
94           u_long    bug;
95 
96           /*
97            * XXX: I have seen no documentation for these!
98            *
99            * The following (appears to) exist only on the MVME162 and
100            * upwards. We should figure out what the other fields are.
101            */
102           u_char    xx1[16];
103           u_char    xx2[4];
104           u_char    longname[12];
105           u_char    xx3[16];
106           u_char    speed[4];
107           u_char    xx4[12];
108 };
109 
110 struct mvmeprom_time {
111         u_char      year_BCD;
112         u_char      month_BCD;
113         u_char      day_BCD;
114         u_char      wday_BCD;
115         u_char      hour_BCD;
116         u_char      min_BCD;
117         u_char      sec_BCD;
118         u_char      cal_BCD;
119 };
120 
121 struct mvmeprom_dskio {
122           u_char    ctrl_lun;
123           u_char    dev_lun;
124           u_short   status;
125           void      *pbuffer;
126           u_long    blk_num;
127           u_short   blk_cnt;
128           u_char    flag;
129 #define BUG_FILE_MARK         0x80
130 #define IGNORE_FILENUM        0x02
131 #define END_OF_FILE 0x01
132           u_char    addr_mod;
133 };
134 #define MVMEPROM_BLOCK_SIZE   256
135 
136 struct mvmeprom_args {
137         u_int       dev_lun;
138         u_int       ctrl_lun;
139         u_int       flags;
140         u_int       ctrl_addr;
141         u_int       entry;
142         u_int       conf_blk;
143           char      *nbarg_start;
144           char      *nbarg_end;
145         char        *arg_start;
146         char        *arg_end;
147           u_int     cputyp;
148 };
149 
150 #endif
151 
152 #define MVMEPROM_CALL(x) \
153           __asm volatile ("trap #15; .short " __STRING(x))
154 #define MVMEPROM_NOARG() \
155           __asm volatile ("clrl %sp@-")
156 #define MVMEPROM_ARG1(arg) \
157           __asm volatile ("movel %0, %%sp@-"::"d" (arg))
158 #define MVMEPROM_ARG2(arg0, arg1)                                     \
159           __asm volatile ("movel %0, %%sp@-;"                         \
160                               "movel %1, %%sp@-;"                     \
161                               :: "d" (arg0), "d" (arg1):)
162 #define MVMEPROM_GETRES(ret) \
163           __asm volatile ("movel %%sp@+,%0": "=d" (ret):)
164 #define MVMEPROM_GETSR(ret) \
165           __asm volatile ("movew %%sr,%0": "=d" (ret):)
166 #define MVMEPROM_RETURN(ret) \
167           MVMEPROM_GETRES(ret); \
168           return (ret);                           /* return a value (int) */
169 /* return a byte, ret must be int */
170 #define MVMEPROM_RETURN_BYTE(ret) \
171           MVMEPROM_GETRES(ret); \
172           return(int)((((unsigned int)(ret)) >> 24) & 0xff);
173 #define MVMEPROM_STATRET(ret) \
174           MVMEPROM_GETSR(ret); \
175           return ((ret & 0x4) == 0);    /* return a 'status' in the Z flag */
176 
177 #define MVMEPROM_REG_DEVLUN   %d0
178 #define MVMEPROM_REG_CTRLLUN  %d1
179 #define MVMEPROM_REG_FLAGS    %d4
180 #define MVMEPROM_REG_CTRLADDR %a0
181 #define MVMEPROM_REG_ENTRY    %a1
182 #define MVMEPROM_REG_CONFBLK  %a2
183 #define MVMEPROM_REG_NBARGSTART         %a3
184 #define MVMEPROM_REG_NBARGEND %a4
185 #define MVMEPROM_REG_ARGSTART %a5
186 #define MVMEPROM_REG_ARGEND   %a6
187 
188 #define MVMEPROM_ARGS_DEVLUN  0x00
189 #define MVMEPROM_ARGS_CTRLLUN 0x04
190 #define MVMEPROM_ARGS_FLAGS   0x08
191 #define MVMEPROM_ARGS_CTRLADDR          0x0c
192 #define MVMEPROM_ARGS_ENTRY   0x10
193 #define MVMEPROM_ARGS_CONFBLK 0x14
194 #define MVMEPROM_ARGS_NBARGSTART 0x18
195 #define MVMEPROM_ARGS_NBARGEND          0x1c
196 #define MVMEPROM_ARGS_ARGSTART          0x20
197 #define MVMEPROM_ARGS_ARGEND  0x24
198 #define MVMEPROM_ARGS_CPUTYP  0x28
199 #define MVMEPROM_ARGS_MAX     0x2c
200 
201 
202 #ifndef RB_NOSYM
203 #define RB_NOSYM 0x400
204 #endif
205 #ifndef RB_SBOOT
206 #define RB_SBOOT 0x800
207 #endif
208 
209