1 /* $NetBSD: iopreg.h,v 1.4.24.2 2005/11/10 13:57:13 skrll Exp $ */
4 * Copyright (c) 2000 Allen Briggs.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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)
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
52 volatile u_char ram_hi
;
54 volatile u_char ram_lo
;
56 volatile u_char control_status
;
62 volatile u_char sccb_cmd
;
64 volatile u_char scca_cmd
;
66 volatile u_char sccb_data
;
68 volatile u_char scca_data
;
72 volatile u_char wdata
;
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
100 u_char max_send_chan
; /* maximum send channel # */
101 u_char send_state
[IOP_MAXCHAN
]; /* send channel states */
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 */
108 u_char alive
; /* IOP alive flag */
109 u_char recv_msg
[IOP_MSGBUFLEN
]; /* receive channel msg data */
115 typedef void (*iop_msg_handler
)(struct _s_IOP
*iop
, struct iop_msg
*);
118 SIMPLEQ_ENTRY(iop_msg
) iopm
;
121 u_char msg
[IOP_MSGLEN
];
123 /* The routine that will handle the message */
124 iop_msg_handler handler
;
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
{
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
;
146 #define IOP_LOADADDR(ioph,addr) (ioph->ram_lo = addr & 0xff, \
147 ioph->ram_hi = (addr >> 8) & 0xff)
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 *);
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:
180 * Drive Number (if needed)
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