1239478Sadrian/*-
2239478Sadrian * Copyright (C) 2012 Margarida Gouveia
3239478Sadrian * All rights reserved.
4239478Sadrian *
5239478Sadrian * Redistribution and use in source and binary forms, with or without
6239478Sadrian * modification, are permitted provided that the following conditions
7239478Sadrian * are met:
8239478Sadrian * 1. Redistributions of source code must retain the above copyright
9239478Sadrian *    notice, this list of conditions and the following disclaimer.
10239478Sadrian * 2. Redistributions in binary form must reproduce the above copyright
11239478Sadrian *    notice, this list of conditions and the following disclaimer in the
12239478Sadrian *    documentation and/or other materials provided with the distribution.
13239478Sadrian *
14239478Sadrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15239478Sadrian * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16239478Sadrian * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17239478Sadrian * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18239478Sadrian * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19239478Sadrian * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20239478Sadrian * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21239478Sadrian * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22239478Sadrian * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23239478Sadrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24239478Sadrian * SUCH DAMAGE.
25239478Sadrian *
26239478Sadrian * $FreeBSD$
27239478Sadrian */
28239478Sadrian
29239478Sadrian#ifndef	_POWERPC_WII_WII_IPCREG_H
30239478Sadrian#define	_POWERPC_WII_WII_IPCREG_H
31239478Sadrian
32239478Sadrian#define	WIIIPC_REG_ADDR		0x0d000000
33239478Sadrian#define	WIIIPC_REG_LEN		0x40
34239478Sadrian#define	WIIIPC_IOH_ADDR		0x133e0000
35241860Srpaulo#define	WIIIPC_IOH_LEN		0xc20000
36239478Sadrian
37252499Srpaulo#define	WIIIPC_TXBUF		0x00
38252499Srpaulo#define	WIIIPC_CSR		0x04
39252499Srpaulo#define	WIIIPC_CSR_TXSTART	0x01
40252499Srpaulo#define	WIIIPC_CSR_TBEI		0x02
41252499Srpaulo#define	WIIIPC_CSR_RBFI		0x04
42252499Srpaulo#define	WIIIPC_CSR_RXREADY	0x08
43252499Srpaulo#define	WIIIPC_CSR_RBFIMASK	0x10
44252499Srpaulo#define	WIIIPC_CSR_TBEIMASK	0x20
45252499Srpaulo#define	WIIIPC_RXBUF		0x08
46252499Srpaulo#define	WIIIPC_ISR		0x30
47252499Srpaulo#define	WIIIPC_ISR_MAGIC 	0x40000000
48252499Srpaulo
49252499Srpauloenum wiiipc_cmd {
50252499Srpaulo	WIIIPC_CMD_OPEN		= 1,
51252499Srpaulo	WIIIPC_CMD_CLOSE	= 2,
52252499Srpaulo	WIIIPC_CMD_READ		= 3,
53252499Srpaulo	WIIIPC_CMD_WRITE	= 4,
54252499Srpaulo	WIIIPC_CMD_SEEK		= 5,
55252499Srpaulo	WIIIPC_CMD_IOCTL	= 6,
56252499Srpaulo	WIIIPC_CMD_IOCTLV	= 7,
57252499Srpaulo	WIIIPC_CMD_ASYNCRESP	= 8
58252499Srpaulo};
59252499Srpaulo
60252499Srpaulostruct wiiipc_ipc_msg {
61252499Srpaulo	uint32_t	ipc_cmd;
62252499Srpaulo	int32_t		ipc_result;
63252499Srpaulo	int32_t	 	ipc_fd;	/* WIIIPC_CMD_ASYNCRESP - the original cmd */
64252499Srpaulo	union {
65252499Srpaulo		struct {
66252499Srpaulo			intptr_t  pathname;
67252499Srpaulo			uint32_t  mode;
68252499Srpaulo		} _ipc_open;
69252499Srpaulo		struct {
70252499Srpaulo			intptr_t  data;
71252499Srpaulo			uint32_t  len;
72252499Srpaulo		} _ipc_read, _ipc_write;
73252499Srpaulo		struct {
74252499Srpaulo			int32_t   offset;
75252499Srpaulo			int32_t   whence;
76252499Srpaulo		} _ipc_seek;
77252499Srpaulo		struct {
78252499Srpaulo			uint32_t  request;
79252499Srpaulo			intptr_t  ibuf;
80252499Srpaulo			uint32_t  ilen;
81252499Srpaulo			intptr_t  obuf;
82252499Srpaulo			uint32_t  olen;
83252499Srpaulo		} _ipc_ioctl;
84252499Srpaulo		struct {
85252499Srpaulo			uint32_t  request;
86252499Srpaulo			uint32_t  argin;
87252499Srpaulo			uint32_t  argout;
88252499Srpaulo			intptr_t  iovec;
89252499Srpaulo		} _ipc_ioctlv;
90252499Srpaulo		uint32_t _ipc_argv[5];
91252499Srpaulo	} args;
92252499Srpaulo} __attribute__((packed));
93252499Srpaulo
94252499SrpauloCTASSERT(sizeof(struct wiiipc_ipc_msg) == 32);
95252499Srpaulo
96252500Srpaulo#define	ipc_open 	args._ipc_open
97252499Srpaulo#define	ipc_read	args._ipc_read
98252499Srpaulo#define	ipc_write	args._ipc_write
99252500Srpaulo#define	ipc_ioctl 	args._ipc_ioctl
100252500Srpaulo#define	ipc_ioctlv	args._ipc_ioctlv
101252499Srpaulo
102239478Sadrian#endif	/* _POWERPC_WII_WII_IPCREG_H */
103