Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / mac68k / include / iopreg.h
blobae2d3fc926755b1a3430b1c1214ab05beaa35f29
1 /* $NetBSD: iopreg.h,v 1.4.24.2 2005/11/10 13:57:13 skrll Exp $ */
3 /*
4 * Copyright (c) 2000 Allen Briggs.
5 * All rights reserved.
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. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #define IOP1_BASE 0x00004000
32 #define SCC_IOP 0
33 #define ISM_IOP 1
35 #define IOP_CS_BYPASS 0x01
36 #define IOP_CS_AUTOINC 0x02
37 #define IOP_CS_RUN 0x04
38 #define IOP_CS_IRQ 0x08
39 #define IOP_CS_INT0 0x10
40 #define IOP_CS_INT1 0x20
41 #define IOP_CS_HWINT 0x40
42 #define IOP_CS_DMAINACT 0x80
44 #define IOP_RESET (IOP_CS_DMAINACT | IOP_CS_AUTOINC)
45 #define IOP_BYPASS \
46 (IOP_CS_BYPASS | IOP_CS_AUTOINC | IOP_CS_RUN | IOP_CS_DMAINACT)
47 #define IOP_INTERRUPT (IOP_CS_INT0 | IOP_CS_INT1)
49 #define OSS_INTLEVEL_OFFSET 0x0001A006
51 typedef struct {
52 volatile u_char ram_hi;
53 u_char pad0;
54 volatile u_char ram_lo;
55 u_char pad1;
56 volatile u_char control_status;
57 u_char pad2[3];
58 volatile u_char data;
59 u_char pad3[23];
60 union {
61 struct {
62 volatile u_char sccb_cmd;
63 u_char pad0;
64 volatile u_char scca_cmd;
65 u_char pad1;
66 volatile u_char sccb_data;
67 u_char pad2;
68 volatile u_char scca_data;
69 u_char pad3;
70 } scc;
71 struct {
72 volatile u_char wdata;
73 u_char pad0;
74 /* etc... */
75 } iwm;
76 } bypass;
77 } IOPHW;
79 #define IOP_MAXCHAN 7
80 #define IOP_MAXMSG 8
81 #define IOP_MSGLEN 32
82 #define IOP_MSGBUFLEN (IOP_MSGLEN * IOP_MAXCHAN)
84 #define IOP_MSG_IDLE 0 /* idle */
85 #define IOP_MSG_NEW 1 /* new message sent */
86 #define IOP_MSG_RECEIVED 2 /* message received; processing */
87 #define IOP_MSG_COMPLETE 3 /* message processing complete */
89 #define IOP_ADDR_MAX_SEND_CHAN 0x200
90 #define IOP_ADDR_SEND_STATE 0x201
91 #define IOP_ADDR_PATCH_CTRL 0x21F
92 #define IOP_ADDR_SEND_MSG 0x220
93 #define IOP_ADDR_MAX_RECV_CHAN 0x300
94 #define IOP_ADDR_RECV_STATE 0x301
95 #define IOP_ADDR_ALIVE 0x31F
96 #define IOP_ADDR_RECV_MSG 0x320
98 typedef struct {
99 u_char pad1[0x200];
100 u_char max_send_chan; /* maximum send channel # */
101 u_char send_state[IOP_MAXCHAN]; /* send channel states */
102 u_char pad2[23];
103 u_char patch_ctrl; /* patch control flag */
104 u_char send_msg[IOP_MSGBUFLEN]; /* send channel message data */
105 u_char max_recv_chan; /* max. receive channel # */
106 u_char recv_state[IOP_MAXCHAN]; /* receive channel states */
107 u_char pad3[23];
108 u_char alive; /* IOP alive flag */
109 u_char recv_msg[IOP_MSGBUFLEN]; /* receive channel msg data */
110 } IOPK;
112 struct iop_msg;
113 struct _s_IOP;
115 typedef void (*iop_msg_handler)(struct _s_IOP *iop, struct iop_msg *);
117 struct iop_msg {
118 SIMPLEQ_ENTRY(iop_msg) iopm;
119 int channel;
120 int status;
121 u_char msg[IOP_MSGLEN];
123 /* The routine that will handle the message */
124 iop_msg_handler handler;
125 void *user_data;
128 #define IOP_MSGSTAT_IDLE 0 /* Message unused (invalid) */
129 #define IOP_MSGSTAT_QUEUED 1 /* Message queued for send */
130 #define IOP_MSGSTAT_SENDING 2 /* Message on IOP */
131 #define IOP_MSGSTAT_SENT 3 /* Message complete */
132 #define IOP_MSGSTAT_RECEIVING 4 /* Top of receive queue */
133 #define IOP_MSGSTAT_RECEIVED 5 /* Msg received */
134 #define IOP_MSGSTAT_UNEXPECTED 6 /* Unexpected msg received */
136 typedef struct _s_IOP {
137 IOPHW *iop;
138 struct pool pool;
139 SIMPLEQ_HEAD(, iop_msg) sendq[IOP_MAXCHAN];
140 SIMPLEQ_HEAD(, iop_msg) recvq[IOP_MAXCHAN];
141 iop_msg_handler listeners[IOP_MAXCHAN];
142 void *listener_data[IOP_MAXCHAN];
143 struct iop_msg unsolicited_msg;
144 } IOP;
146 #define IOP_LOADADDR(ioph,addr) (ioph->ram_lo = addr & 0xff, \
147 ioph->ram_hi = (addr >> 8) & 0xff)
149 void iop_init(int);
150 void iop_upload(int, u_char *, u_long, u_long);
151 void iop_download(int, u_char *, u_long, u_long);
152 int iop_send_msg(int, int, u_char *, int, iop_msg_handler, void *);
153 int iop_queue_receipt(int, int, iop_msg_handler, void *);
154 int iop_register_listener(int, int, iop_msg_handler, void *);
156 /* SWIM support */
157 #define IOP_CHAN_SWIM 1
159 #define IOP_SWIM_INITIALIZE 0x01
160 #define IOP_SWIM_SHUTDOWN 0x02
161 #define IOP_SWIM_START_POLLING 0x03
162 #define IOP_SWIM_STOP_POLLING 0x04
163 #define IOP_SWIM_SET_HFS_TAG_ADDR 0x05
164 #define IOP_SWIM_DRIVE_STATUS 0x06
165 #define IOP_SWIM_EJECT 0x07
166 #define IOP_SWIM_FORMAT 0x08
167 #define IOP_SWIM_FORMAT_VERIFY 0x09
168 #define IOP_SWIM_WRITE 0x0a
169 #define IOP_SWIM_READ 0x0b
170 #define IOP_SWIM_READ_VERIFY 0x0c
171 #define IOP_SWIM_CACHE_CONTROL 0x0d
172 #define IOP_SWIM_TAG_BUFFER_CONTROL 0x0e
173 #define IOP_SWIM_GET_ICON 0x0f
174 #define IOP_SWIM_DISK_DUP_INFO 0x10
175 #define IOP_SWIM_GET_RAW_DATA 0x11
178 * The structure of a SWIM packet to/from the IOP is:
179 * Request kind
180 * Drive Number (if needed)
181 * Error Code
182 * Data (optional)
185 /* ADB support */
186 #define IOP_CHAN_ADB 2
188 #define IOP_ADB_FL_EXPLICIT 0x80 /* Non-zero if explicit command */
189 #define IOP_ADB_FL_AUTOPOLL 0x40 /* Auto/SRQ polling enabled */
190 #define IOP_ADB_FL_POLL_UPDATE 0x20 /* Update polling bit mask */
191 #define IOP_ADB_FL_SRQ 0x04 /* SRQ detected */
192 #define IOP_ADB_FL_TIMEOUT 0x02 /* Non-zero if timeout */
195 * The structure of an ADB packet to/from the IOP is:
196 * Flag byte (values above)
197 * Count of bytes in data
198 * Command byte
199 * Data (optional)