1 /*        $NetBSD: bugsyscalls.h,v 1.2 2008/04/28 20:23:30 martin Exp $         */
2 
3 /*-
4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Steve C. Woodford.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __BUGSYSCALLS_H
33 #define __BUGSYSCALLS_H
34 
35 /*
36  * Basic Console I/O system calls
37  */
38 extern    char      bugsys_inchr(void);
39 extern    void      bugsys_outchr(char);
40 extern    int       bugsys_instat(void);
41 
42 
43 /*
44  * Basic Disk I/O system calls
45  */
46 struct bug_diskio {
47           u_int8_t  dc_clun;  /* Controller LUN for operation */
48           u_int8_t  dc_dlun;  /* Device LUN for operation */
49           u_int16_t dc_status;          /* Completion status written here */
50           void                *dc_buffer;         /* Pointer to dest/src buffer */
51           u_int32_t dc_block; /* Starting block/file-number */
52           u_int16_t dc_nblocks;         /* Number of blocks to transfer */
53           u_int8_t  dc_flag;  /* Flag (see below) */
54           u_int8_t  dc_am;              /* VMEbus address modifier, or zero */
55 };
56 #define   BUG_DISKCMD_FLAG_FILEMARK     (1 << 7)
57 #define   BUG_DISKCMD_FLAG_IFN                    (1 << 1)
58 #define   BUG_DISKCMD_FLAG_EOF                    (1 << 0)
59 
60 extern    int       bugsys_dskrd(struct bug_diskio *);
61 extern    int       bugsys_dskwr(struct bug_diskio *);
62 
63 /*
64  * Basic Nework I/O system calls
65  */
66 struct bug_netio {
67           u_int8_t  nc_clun;  /* Controller LUN for operation */
68           u_int8_t  nc_dlun;  /* Device LUN for operation */
69           u_int16_t nc_status;          /* Completion status written here */
70           u_int32_t nc_command;         /* Command identifier */
71           void                *nc_buffer;         /* Pointer to dest/src data buffer */
72           u_int32_t nc_length;          /* Number of bytes of data */
73           u_int32_t nc_csr;             /* Status/Control flags */
74 };
75 #define   BUG_NETIO_CMD_INIT     0x0    /* Initialise Device/Channel/Node */
76 #define   BUG_NETIO_CMD_GET_MAC            0x1    /* Get ethernet MAC address */
77 #define   BUG_NETIO_CMD_TRANSMIT           0x2    /* Transmit a packet of data */
78 #define BUG_NETIO_CMD_RECEIVE    0x3    /* Receive a packet of data */
79 #define   BUG_NETIO_CMD_FLUSH    0x4    /* Flush receive buffers */
80 #define   BUG_NETIO_CMD_RESET    0x5    /* Reset Device/Channel/Node */
81 
82 #define   BUG_NETIO_CSR_RX_COMPLETE  (1<<16)
83 
84 extern    int       bugsys_netio(struct bug_netio *);
85 
86 /*
87  * Miscellaneous system calls
88  */
89 extern    void      bugsys_delay(int);
90 
91 struct bug_boardid {
92           u_int32_t bi_eyecatcher;      /* Eye catcher pattern */
93           u_int8_t  bi_rev;             /* PPCBug Revision, in BCD */
94           u_int8_t  bi_month; /* PPCBug Month, in BCD */
95           u_int8_t  bi_day;             /* PPCBug Day, in BCD */
96           u_int8_t  bi_year;  /* PPCBug Year, in BCD */
97           u_int16_t bi_size;  /* Size of this structure */
98           u_int16_t bi_resvd;
99           u_int16_t bi_bnumber;         /* Board number, in BCD */
100           u_int16_t bi_bsuffix;         /* Board suffix, in BCD */
101           u_int32_t bi_options;         /* Board options. See below */
102           u_int16_t bi_clun;  /* Boot device CLUN */
103           u_int16_t bi_dlun;  /* Boot device DLUN */
104           u_int16_t bi_devtype;         /* Boot device type. See below */
105           u_int16_t bi_devnumber;       /* Boot device number */
106           u_int32_t bi_resvd2;
107 };
108 #define   BUG_BOARDID_OPT_CPU_MASK      0x0f
109 #define   BUG_BOARDID_OPT_CPU_SHIFT     0
110 #define    BUG_BOARDID_OPT_CPU_MPC620   1
111 #define    BUG_BOARDID_OPT_CPU_MPC601   1
112 #define    BUG_BOARDID_OPT_CPU_MPC602   2
113 #define    BUG_BOARDID_OPT_CPU_MPC603   3
114 #define    BUG_BOARDID_OPT_CPU_MPC604   4
115 #define   BUG_BOARDID_OPT_FAMILY_MASK   0x07
116 #define   BUG_BOARDID_OPT_FAMILY_SHIFT  6
117 #define   BUG_BOARDID_OPT_FAMILY_MPC600 2
118 #define   BUG_BOARDID_OPT_FPC           (1 << 7)
119 #define   BUG_BOARDID_OPT_MMU           (1 << 8)
120 #define   BUG_BOARDID_OPT_MMB           (1 << 9)
121 
122 #define   BUG_BOARDID_DEVTYPE_DIRECT    0  /* Direct Access Device (disk) */
123 #define   BUG_BOARDID_DEVTYPE_SEQ                 1  /* Sequential Access Device (tape) */
124 #define   BUG_BOARDID_DEVTYPE_PRINTER   2  /* Printer device */
125 #define   BUG_BOARDID_DEVTYPE_PROCESSOR 3  /* Processor device */
126 #define   BUG_BOARDID_DEVTYPE_WORM      4  /* WORM device */
127 #define   BUG_BOARDID_DEVTYPE_CDROM     5  /* CD-ROM device */
128 #define   BUG_BOARDID_DEVTYPE_SCANNER   6  /* Scanner device */
129 #define   BUG_BOARDID_DEVTYPE_OPTICAL   7  /* Optical memory device */
130 #define   BUG_BOARDID_DEVTYPE_CHANGER   8  /* Medium Changer device */
131 #define   BUG_BOARDID_DEVTYPE_COMMS     9  /* Communications device */
132 
133 extern    struct bug_boardid  *bugsys_brdid(void);
134 
135 struct bug_ioinquiry {
136           u_int32_t ii_portnum;         /* Port number */
137           char                *ii_boardname;      /* Board name pointer */
138           u_int32_t ii_channel;         /* Channel number */
139           u_int32_t ii_devaddr;         /* Device address */
140           u_int32_t ii_concurmode;      /* Concurrent mode */
141           u_int32_t ii_modemid;         /* Modem ID */
142           struct bug_ioctrl *ii_ioctrl; /* I/O control struction pointer */
143           u_int32_t ii_error; /* Error code */
144           u_int32_t ii_resvd[3];
145 };
146 #define   BUG_IOINQ_PORT_CONSOLE                  0xffffffff
147 
148 struct bug_ioctrl {
149           u_int32_t ic_ctrlbits;
150           u_int32_t ic_baud;
151           u_int32_t ic_protocol;
152           u_int32_t ic_sync1;
153           u_int32_t ic_sync2;
154           u_int32_t ic_xonchar;
155           u_int32_t ic_xoffchar;
156 };
157 #define   IOCTRL_PARITY_ODD   (1 << 0)
158 #define   IOCTRL_PARITY_EVEN  (1 << 1)
159 #define   IOCTRL_BITS_8                 (1 << 2)
160 #define   IOCTRL_BITS_7                 (1 << 3)
161 #define   IOCTRL_BITS_6                 (1 << 4)
162 #define   IOCTRL_BITS_5                 (1 << 5)
163 #define   IOCTRL_STOP_2                 (1 << 6)
164 #define   IOCTRL_STOP_1                 (1 << 7)
165 
166 extern    struct bug_ioinquiry          *bugsys_ioinq(struct bug_ioinquiry *);
167 
168 struct bug_rtc_rd {
169           u_int8_t  rr_year;
170           u_int8_t  rr_month;
171           u_int8_t  rr_dayofmonth;
172           u_int8_t  rr_dayofweek;
173           u_int8_t  rr_hour;
174           u_int8_t  rr_minute;
175           u_int8_t  rr_second;
176           u_int8_t  rr_calibration;
177 };
178 
179 extern    void      bugsys_rtc_rd(struct bug_rtc_rd *);
180 
181 /*
182  * Information passed from bug to the bootstrap program when in PReP mode.
183  *
184  * Note: This is the only option for booting from disk...
185  */
186 struct bug_prepinfo {
187           void      *bpi_residual;                /* PReP mode's "residual data" */
188           void      *bpi_loadaddr;                /* Load address of bootstrap code */
189 };
190 
191 /*
192  * Information passed when in traditional PPCBug mode
193  *
194  * Note: This appears to be the case for netboot only...
195  */
196 struct bug_buginfo {
197           int                 bbi_clun; /* Boot controller LUN */
198           int                 bbi_dlun; /* Boot device LUN */
199           u_int32_t bbi_devaddr;        /* PCI config. addr. of boot device */
200           void                *bbi_loadaddr;      /* Load address of bootstrap code */
201           void                *bbi_ipaddr;        /* Pointer to IP address parameters */
202           const char          *bbi_fnstart;       /* Boot filename string start */
203           const char          *bbi_fnend;         /* Boot filename string end */
204           char                *bbi_argstart;      /* Boot argument string start */
205           char                *bbi_argend;        /* Boot argument string end */
206 };
207 
208 /*
209  * Structure passed into C code from srt0.S
210  */
211 struct bug_bootinfo {
212           int                 bbi_bugmode;        /* Non-zero if traditional bug boot */
213           union {
214                     struct bug_prepinfo bpi;
215                     struct bug_buginfo bbi;
216           } bbi_bi;
217 };
218 
219 #endif    /* __BUGSYSCALLS_H */
220