/*---------------------------------------------------------------------------* Project: HostIO File: hio_interface.h Description: This file defines the public HostIO interface. Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef __HIO_INTERFACE_H__ #define __HIO_INTERFACE_H__ #include #include #include #ifdef __cplusplus extern "C" { #endif // __cplusplus /* HostIO Channel Option Values */ #define HIO_CHANNEL_OPTION_READ 1 #define HIO_CHANNEL_OPTION_WRITE 2 #define HIO_CHANNEL_OPTION_READ_WRITE (HIO_CHANNEL_OPTION_READ | \ HIO_CHANNEL_OPTION_WRITE) /* HostIO Handle Values */ #define HIO_HANDLE_INVALID -1 typedef s32 HIOStatus; typedef s32 HIOHandle; typedef u32 HIOChannelOptions; typedef u32 HIOChannelFlags; typedef void (*HIOAsyncParam)(HIOStatus status, void* context); typedef void (*HIOConnectionCallback)(HIOStatus status, void* context); typedef void (*HIOCallback)(HIOStatus status, void* context); typedef struct { OSMessageQueue* queue; void* userData; HIOCallback callback; } HIOAsyncStruct; typedef struct { void* userData; HIOCallback callback; HIOStatus status; OSFunctionType type; } HIOMessage; HIOStatus HIOInit(void); HIOStatus HIOShutdown(void); HIOHandle HIOOpenEx(const char * hioName, HIOAsyncStruct* asyncStruct, HIOChannelOptions options, HIOChannelFlags flags); HIOStatus HIOClose(HIOHandle handle); HIOStatus HIORead(HIOHandle handle, u32 sizeInBytes, void *pData); HIOStatus HIOReadAsyncEx(HIOHandle handle, u32 sizeInBytes, void *pData, HIOAsyncStruct* asyncStruct); HIOStatus HIOWrite(HIOHandle handle, u32 sizeInBytes, const void *pData); HIOStatus HIOWriteAsyncEx(HIOHandle handle, u32 sizeInBytes, const void *pData, HIOAsyncStruct* asyncStruct); HIOStatus HIOQueryHeadlessMode(void); #define HIO_STATUS_NEW_CONNECTION 1 #define HIO_STATUS_OK 0 #define HIO_STATUS_INVALID_CHANNEL_NAME (-1) #define HIO_STATUS_NO_CONNECTIONS (-2) #define HIO_STATUS_NO_CHANNELS (-3) #define HIO_STATUS_INVALID_HANDLE (-4) #define HIO_STATUS_NO_CLIENT_TXN_BUF_AVAILABLE (-5) #define HIO_STATUS_OUT_OF_MEMORY (-6) #define HIO_STATUS_INVALID_PARAM (-7) #define HIO_STATUS_NOT_INITIALIZED (-8) #define HIO_STATUS_INVALID_OPERATION (-9) #define HIO_STATUS_HEADLESS_MODE (-10) #define HIO_STATUS_ALREADY_OPEN (-100) #define HIO_STATUS_ALREADY_CLOSED (-101) // DefaultAppIOQueue is provided for compatibility with the original // HIOOpen, HIOReadAsync, and HIOWriteAsync methods. Applications should // prefer using the "Ex" versions of these APIs and provide their own // OSMessageQueue. inline HIOHandle HIOOpen(const char * hioName, HIOConnectionCallback connection, void * context, HIOChannelOptions options, HIOChannelFlags flags) { HIOAsyncStruct asyncStruct; // asyncStruct will be copied in HIOOpenEx. asyncStruct.queue = OSGetDefaultAppIOQueue(); asyncStruct.userData = context; asyncStruct.callback = (HIOCallback) connection; return HIOOpenEx(hioName, &asyncStruct, options, flags); } inline HIOStatus HIOReadAsync(HIOHandle handle, u32 sizeInBytes, void *pData, HIOAsyncParam asyncParam, void* context) { HIOAsyncStruct asyncStruct; // asyncStruct will be copied in HIOReadAsyncEx. asyncStruct.queue = OSGetDefaultAppIOQueue(); asyncStruct.userData = context; asyncStruct.callback = (HIOCallback) asyncParam; return HIOReadAsyncEx(handle, sizeInBytes, pData, &asyncStruct); } inline HIOStatus HIOWriteAsync(HIOHandle handle, u32 sizeInBytes, const void *pData, HIOAsyncParam asyncParam, void* context) { HIOAsyncStruct asyncStruct; // asyncStruct will be copied in HIOWriteAsyncEx. asyncStruct.queue = OSGetDefaultAppIOQueue(); asyncStruct.userData = context; asyncStruct.callback = (HIOCallback) asyncParam; return HIOWriteAsyncEx(handle, sizeInBytes, pData, &asyncStruct); } #ifdef __cplusplus } #endif // __cplusplus #endif // __HIO_INTERFACE_H__