2 BootMii - a Free Software replacement for the Nintendo/BroadOn bootloader.
5 Copyright (C) 2008, 2009 Haxx Enterprises <bushing@gmail.com>
6 Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
7 Copyright (C) 2009 Andre Heider "dhewg" <dhewg@wiibrew.org>
8 Copyright (C) 2009 John Kelley <wiidev@kelley.ca>
9 Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com>
11 # This code is licensed to you under the terms of the GNU GPL, version 2;
12 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
18 /* TODO: It would be nice to somehow link this header file with mini/ipc.h.
19 Until then, if you do make any changes here, you MUST make them here
20 (or vice-versa). See warnings in mini/ipc.h. --bushing */
22 #define IPC_SYS_PING 0x01000000
23 #define IPC_SYS_SLWPING 0x00000000
24 #define IPC_SYS_JUMP 0x00000001
25 #define IPC_SYS_GETVERS 0x00000002
26 #define IPC_SYS_GETGITS 0x00000003
28 #define IPC_SYS_WRITE32 0x01000100
29 #define IPC_SYS_WRITE16 0x01000101
30 #define IPC_SYS_WRITE8 0x01000102
31 #define IPC_SYS_READ32 0x01000103
32 #define IPC_SYS_READ16 0x01000104
33 #define IPC_SYS_READ8 0x01000105
34 #define IPC_SYS_SET32 0x01000106
35 #define IPC_SYS_SET16 0x01000107
36 #define IPC_SYS_SET8 0x01000108
37 #define IPC_SYS_CLEAR32 0x01000109
38 #define IPC_SYS_CLEAR16 0x0100010a
39 #define IPC_SYS_CLEAR8 0x0100010b
40 #define IPC_SYS_MASK32 0x0100010c
41 #define IPC_SYS_MASK16 0x0100010d
42 #define IPC_SYS_MASK8 0x0100010e
44 #define IPC_NAND_RESET 0x00010000
45 #define IPC_NAND_GETID 0x00010001
46 #define IPC_NAND_READ 0x00010002
47 #define IPC_NAND_WRITE 0x00010003
48 #define IPC_NAND_ERASE 0x00010004
49 #define IPC_NAND_STATUS 0x00010005
50 //#define IPC_NAND_USER0 0x00018000
51 //#define IPC_NAND_USER1 0x00018001
54 #define IPC_SDMMC_ACK 0x00070000
55 #define IPC_SDMMC_READ 0x00070001
56 #define IPC_SDMMC_WRITE 0x00070002
57 #define IPC_SDMMC_STATE 0x00070003
58 #define IPC_SDMMC_SIZE 0x00070004
60 #define IPC_SDHC_DISCOVER 0x00020000
62 #define IPC_KEYS_GETOTP 0x00030000
63 #define IPC_KEYS_GETEEP 0x00030001
65 #define IPC_AES_RESET 0x00040000
66 #define IPC_AES_SETIV 0x00040001
67 #define IPC_AES_SETKEY 0x00040002
68 #define IPC_AES_DECRYPT 0x00040003
70 #define IPC_BOOT2_RUN 0x00050000
71 #define IPC_BOOT2_TMD 0x00050001
73 #define IPC_PPC_BOOT 0x00060000
88 extern void *mem2_boundary;
90 int ipc_initialize(void);
91 void ipc_shutdown(void);
93 void ipc_post(u32 code, u32 tag, u32 num_args, ...);
97 ipc_request *ipc_receive(void);
98 ipc_request *ipc_receive_tagged(u32 code, u32 tag);
100 ipc_request *ipc_exchange(u32 code, u32 num_args, ...);
102 static inline void ipc_sys_write32(u32 addr, u32 x)
104 ipc_post(IPC_SYS_WRITE32, 0, 2, addr, x);
106 static inline void ipc_sys_write16(u32 addr, u16 x)
108 ipc_post(IPC_SYS_WRITE16, 0, 2, addr, x);
110 static inline void ipc_sys_write8(u32 addr, u8 x)
112 ipc_post(IPC_SYS_WRITE8, 0, 2, addr, x);
115 static inline u32 ipc_sys_read32(u32 addr)
117 return ipc_exchange(IPC_SYS_READ32, 1, addr)->args[0];
119 static inline u16 ipc_sys_read16(u32 addr)
121 return ipc_exchange(IPC_SYS_READ16, 1, addr)->args[0];
123 static inline u8 ipc_sys_read8(u32 addr)
125 return ipc_exchange(IPC_SYS_READ8, 1, addr)->args[0];
128 static inline void ipc_sys_set32(u32 addr, u32 set)
130 ipc_post(IPC_SYS_SET32, 0, 2, addr, set);
132 static inline void ipc_sys_set16(u32 addr, u16 set)
134 ipc_post(IPC_SYS_SET16, 0, 2, addr, set);
136 static inline void ipc_sys_set8(u32 addr, u8 set)
138 ipc_post(IPC_SYS_SET8, 0, 2, addr, set);
141 static inline void ipc_sys_clear32(u32 addr, u32 clear)
143 ipc_post(IPC_SYS_CLEAR32, 0, 2, addr, clear);
145 static inline void ipc_sys_clear16(u32 addr, u16 clear)
147 ipc_post(IPC_SYS_CLEAR16, 0, 2, addr, clear);
149 static inline void ipc_sys_clear8(u32 addr, u8 clear)
151 ipc_post(IPC_SYS_CLEAR8, 0, 2, addr, clear);
154 static inline void ipc_sys_mask32(u32 addr, u32 clear, u32 set)
156 ipc_post(IPC_SYS_MASK32, 0, 3, addr, clear, set);
158 static inline void ipc_sys_mask16(u32 addr, u16 clear, u32 set)
160 ipc_post(IPC_SYS_MASK16, 0, 3, addr, clear, set);
162 static inline void ipc_sys_mask8(u32 addr, u8 clear, u32 set)
164 ipc_post(IPC_SYS_MASK8, 0, 3, addr, clear, set);
167 static inline void ipc_ping(void)
169 ipc_exchange(IPC_SYS_PING, 0);
172 static inline void ipc_slowping(void)
174 ipc_exchange(IPC_SYS_SLWPING, 0);
177 static inline u32 ipc_getvers(void)
179 return ipc_exchange(IPC_SYS_GETVERS, 0)->args[0];