ipc.h

Go to the documentation of this file.
00001 /*
00002         libbroadway - A general purpose library to control the Wii.
00003         Inter-processor communication
00004 
00005 Copyright (C) 2008, 2009        Haxx Enterprises <bushing@gmail.com>
00006 Copyright (C) 2008, 2009        Hector Martin "marcan" <marcan@marcansoft.com>
00007 Copyright (C) 2009              Andre Heider "dhewg" <dhewg@wiibrew.org>
00008 Copyright (C) 2009              John Kelley <wiidev@kelley.ca>
00009 Copyright (C) 2008, 2009        Sven Peter <svenpeter@gmail.com>
00010 
00011 # This code is licensed to you under the terms of the GNU GPL, version 2;
00012 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
00013 */
00014 
00019 #ifndef __IPC_H__
00020 #define __IPC_H__
00021 
00022 #include <ipc_common.h>
00023 
00024 /* Nothing over here used this, so in order to make the doxygen look nicer
00025  * I've removed the union/struct deal.
00026  */
00027 #if 0
00028 typedef struct {
00029         union {
00030                 struct {
00031                         u8 flags;
00032                         u8 device;
00033                         u16 req;
00034                 };
00035                 u32 code;
00036         };
00037         u32 tag;
00038         u32 args[6];
00039 } ipc_request;
00040 #endif
00041 
00044 typedef struct {
00045         u32 code;       
00046         u32 tag;        
00047         u32 args[6];    
00048 } ipc_request_t;
00049 
00050 extern void *mem2_boundary;
00051 
00057 int ipc_initialize(void);
00062 void ipc_shutdown(void);
00063 
00072 void ipc_post(u32 code, u32 tag, u32 num_args, ...);
00073 
00076 void ipc_flush(void);
00077 
00082 ipc_request_t *ipc_receive(void);
00089 ipc_request_t *ipc_receive_tagged(u32 code, u32 tag);
00090 
00098 ipc_request_t *ipc_exchange(u32 code, u32 num_args, ...);
00099 
00100 static inline void ipc_sys_write32(u32 addr, u32 x)
00101 {
00102         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_WRITE32), 0, 2, addr, x);
00103 }
00104 static inline void ipc_sys_write16(u32 addr, u16 x)
00105 {
00106         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_WRITE16), 0, 2, addr, x);
00107 }
00108 static inline void ipc_sys_write8(u32 addr, u8 x)
00109 {
00110         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_WRITE8), 0, 2, addr, x);
00111 }
00112 
00113 static inline u32 ipc_sys_read32(u32 addr)
00114 {
00115         return ipc_exchange(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_READ32), 1, addr)->args[0];
00116 }
00117 static inline u16 ipc_sys_read16(u32 addr)
00118 {
00119         return ipc_exchange(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_READ16), 1, addr)->args[0];
00120 }
00121 static inline u8 ipc_sys_read8(u32 addr)
00122 {
00123         return ipc_exchange(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_READ8), 1, addr)->args[0];
00124 }
00125 
00126 static inline void ipc_sys_set32(u32 addr, u32 set)
00127 {
00128         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_SET32), 0, 2, addr, set);
00129 }
00130 static inline void ipc_sys_set16(u32 addr, u16 set)
00131 {
00132         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_SET16), 0, 2, addr, set);
00133 }
00134 static inline void ipc_sys_set8(u32 addr, u8 set)
00135 {
00136         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_SET8), 0, 2, addr, set);
00137 }
00138 
00139 static inline void ipc_sys_clear32(u32 addr, u32 clear)
00140 {
00141         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_CLEAR32), 0, 2, addr, clear);
00142 }
00143 static inline void ipc_sys_clear16(u32 addr, u16 clear)
00144 {
00145         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_CLEAR16), 0, 2, addr, clear);
00146 }
00147 static inline void ipc_sys_clear8(u32 addr, u8 clear)
00148 {
00149         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_CLEAR8), 0, 2, addr, clear);
00150 }
00151 
00152 static inline void ipc_sys_mask32(u32 addr, u32 clear, u32 set)
00153 {
00154         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_MASK32), 0, 3, addr, clear, set);
00155 }
00156 static inline void ipc_sys_mask16(u32 addr, u16 clear, u32 set)
00157 {
00158         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_MASK16), 0, 3, addr, clear, set);
00159 }
00160 static inline void ipc_sys_mask8(u32 addr, u8 clear, u32 set)
00161 {
00162         ipc_post(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_MASK8), 0, 3, addr, clear, set);
00163 }
00164 
00165 static inline void ipc_ping(void)
00166 {
00167         ipc_exchange(IPC_CODE(IPC_FAST, IPC_DEV_SYS, IPC_SYS_PING), 0);
00168 }
00169 
00170 static inline void ipc_slowping(void)
00171 {
00172         ipc_exchange(IPC_CODE(IPC_SLOW, IPC_DEV_SYS, IPC_SYS_PING), 0);
00173 }
00174 
00175 static inline u32 ipc_getvers(void)
00176 {
00177         return ipc_exchange(IPC_CODE(IPC_SLOW, IPC_DEV_SYS, IPC_SYS_GETVERS), 0)->args[0];
00178 }
00179 
00180 #endif
00181 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated by  doxygen 1.6.3