/*---------------------------------------------------------------------------* Project: Horizon File: nwmeth.h Copyright (C)2009 Nintendo Co., Ltd. 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. $Rev: 21218 $ *---------------------------------------------------------------------------*/ #ifndef NN_NETWORK_NWMETH_H #define NN_NETWORK_NWMETH_H #include #include #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------------------------* * Definitions *---------------------------------------------------------------------------*/ #define NWMETH_DEVICE_1 0 /* このドライバで扱えるI/Fは1つだけ */ #define NWMETH_USE_MBUF 1 #define NWMETH_VENDOR_NINTENDO 0x0000 #define NWMETH_COMMON_CONF_VERSION 0x1100 #define NWMETH_INS_CONF_VERSION 0x2100 /** * エラーコード */ #define NWMETH_ERROR_BASE 0xffff9000 #define NWMETH_ERROR_CODE(code) ((s32)(NWMETH_ERROR_BASE | (code))) enum { NWMETH_ERR_PARAM = NWMETH_ERROR_CODE(1), /* パラメータエラー */ NWMETH_ERR_INIT = NWMETH_ERROR_CODE(2), /* 初期状態のため実行不可 */ NWMETH_ERR_FINISH = NWMETH_ERROR_CODE(3), /* 終了状態のため実行不可 */ NWMETH_ERR_CONFVER = NWMETH_ERROR_CODE(4), /* 設定のバージョンエラー */ NWMETH_ERR_STATE = NWMETH_ERROR_CODE(5), /* ステートエラー */ NWMETH_ERR_EXIST = NWMETH_ERROR_CODE(6), /* 既に作成済み */ NWMETH_ERR_NOMEM = NWMETH_ERROR_CODE(7), /* メモリ不足 */ NWMETH_ERR_TIMEOUT = NWMETH_ERROR_CODE(8), /* タイムアウト */ NWMETH_ERR_IO = NWMETH_ERROR_CODE(9), NWMETH_ERR_NONE = 0 /* 正常終了 */ }; /** * メモリ */ #define NWMETH_MEM_BASE 0x00050000 #define NWMETH_MEM_NAME(name) ((s32)(NWMETH_MEM_BASE | (name))) enum { NWMETH_MEM_INSTANCE = NWMETH_MEM_NAME(1) }; /** * ステート */ enum { NWMETH_STATE_INIT = 0, /* 初期状態 */ NWMETH_STATE_ACTIVE, /* 接続完了状態 */ NWMETH_STATE_DESTROY, NWMETH_STATE_ABORT /* 接続完了状態 */ }; /*---------------------------------------------------------------------------* * Types/Declarations *---------------------------------------------------------------------------*/ /** * インスタンス */ #define NWMETH_UPPER_NUM 2 /* 上位のレイヤ数 */ #define NWMETH_RXFRAME_BUFFUR_COUNT 16 /* 上位へ渡すキューのサイズ */ #define NWMETH_STACK_SIZE 4096 #define NWMETH_PROTOCOL_ENTRY_MAX 16 typedef struct NWMETHQueuePair { NOSMessageQueue mq; /* 上位用の受信キュー */ NOSMessage msg[NWMETH_RXFRAME_BUFFUR_COUNT]; /* 上位用の受信キュー実体 */ } NWMETHQueuePair; typedef struct NWMETHInstance { NNETInstance netIns; /* 全レイヤ共通に持っているインスタンス情報 */ NNETProtocolList protocolList; NWMETHQueuePair upper_mq[NWMETH_UPPER_NUM]; /* 上位用の受信キュー */ s32 upper_ins_count; s32 state; u8 macaddr[NNET_ETH_ALEN]; /* 自MACアドレス */ u16 pad; u8 sendBuf[NNET_MAX_SEND_LEN]; /* 送信バッファ */ u8 recvBuf[NNET_MAX_RECV_LEN]; NOSThread thread; NOSThreadId threadId; u8 stack[NWMETH_STACK_SIZE]; } NWMETHInstance; /* WCMのインスタンスからNNETInstanceを取得する */ static inline NNETInstance* NWMETH_GetNNETInstance(NWMETHInstance* pNwmIns) { return &pNwmIns->netIns; } /* NNETInstanceからWCMのインスタンスを取得する */ static inline NWMETHInstance* NWMETH_GetNWMETHInstance(NNETInstance* pNetIns) { return (NWMETHInstance*)pNetIns; } /*---------------------------------------------------------------------------* * Function Prototypes *---------------------------------------------------------------------------*/ /* nwmeth_Main.cpp */ void* NWMETHi_Alloc(u32 name, u32 size, u32 align); void NWMETHi_Free(u32 name, void* ptr); s32 NWMETH_Init(const NNETAllocator* allocator); s32 NWMETH_Finish(void); s32 NWMETH_GetMacAddr(NNETInstance* ins, u8* macaddr); void NWMETHi_HandleFrame(NWMETHInstance* pNwmIns, NOSMessageBuf* mbuf); void NWMETHi_HandleFrameRaw(NWMETHInstance* pNwmIns, const u8* pFrame, int len); /* nwmeth_Direct.cpp */ s32 NWMETH_CreateInsDirect(NWMETHInstance** pNwmEth); s32 NWMETH_DestroyInsDirect(NWMETHInstance* pNwmEth); s32 NWMETH_GetUpperDirectAPI(NNETEthernetAPI* pEtherAPI, NWMETHInstance* pNwmEth); /* nwmeth_Ipc.cpp */ s32 NWMETH_CreateIns(NWMETHInstance** pNwmEth); s32 NWMETH_DestroyIns(NWMETHInstance* pNwmEth); s32 NWMETH_GetUpperAPI(NNETEthernetAPI* pEtherAPI, NWMETHInstance* pNwmEth); #ifdef __cplusplus } #endif /* NN_NETWORK_NWMETH_H */ #endif