/*---------------------------------------------------------------------------* Project: Horizon File: peth.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: 12449 $ *---------------------------------------------------------------------------*/ #ifndef NN_NETWORK_PETH_H #define NN_NETWORK_PETH_H #include #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------------------------* * Definitions *---------------------------------------------------------------------------*/ #define PETH_DEVICE_1 0 /* このドライバで扱えるI/Fは1つだけ */ #define PETH_VENDOR_NINTENDO 0x0000 #define PETH_COMMON_CONF_VERSION 0x1100 #define PETH_INS_CONF_VERSION 0x2100 /** * エラーコード */ #define PETH_ERROR_BASE 0xffff9000 #define PETH_ERROR_CODE(code) ((s32)(PETH_ERROR_BASE|(code))) enum { PETH_ERR_PARAM = PETH_ERROR_CODE(1), /* パラメータエラー */ PETH_ERR_INIT = PETH_ERROR_CODE(2), /* 初期状態のため実行不可 */ PETH_ERR_FINISH = PETH_ERROR_CODE(3), /* 終了状態のため実行不可 */ PETH_ERR_CONFVER = PETH_ERROR_CODE(4), /* 設定のバージョンエラー */ PETH_ERR_STATE = PETH_ERROR_CODE(5), /* ステートエラー */ PETH_ERR_EXIST = PETH_ERROR_CODE(6), /* 既に作成済み */ PETH_ERR_NOMEM = PETH_ERROR_CODE(7), /* メモリ不足 */ PETH_ERR_TIMEOUT = PETH_ERROR_CODE(8), /* タイムアウト */ PETH_ERR_NONE = 0 /* 正常終了 */ }; /** * メモリ */ #define PETH_MEM_BASE 0x00050000 #define PETH_MEM_NAME(name) ((s32)(PETH_MEM_BASE|(name))) enum { PETH_MEM_INSTANCE = PETH_MEM_NAME(1) }; /** * ステート */ enum { PETH_STATE_INIT = 0, /* 初期状態 */ PETH_STATE_ACTIVE, /* 接続完了状態 */ PETH_STATE_ABORT /* 接続完了状態 */ }; /*---------------------------------------------------------------------------* * Types/Declarations *---------------------------------------------------------------------------*/ #define PETH_MAC_LEN 6 /** * 無線ドライバが保持するプロトコル情報 */ typedef struct PETHProtocolList { u16 protocol; /* IP、ARPなど */ NNETInstance *upper_ins; /* 上位インスタンス */ NOSMessageQueueId mq_receive; /* 上記プロトコルを受信したときにパケットを入れるキュー */ } PETHProtocolList; /** * インスタンス */ #define PETH_PROTOCOL_NUM 8 /* ARP, RARP, IP, PPPoE Discovery, PPPoE Session */ #define PETH_UPPER_NUM 2 /* 上位のレイヤ数 */ #define PETH_MQ_NUM 16 /* 上位へ渡すキューのサイズ */ #define PETH_MAX_SEND_LEN 1600 typedef struct PETHMessage { NOSMessageQueue mq; /* 上位用の受信キュー */ NOSMessage mqarray[PETH_MQ_NUM]; /* 上位用の受信キュー実体 */ } PETHMessage; typedef struct PETHInstance { NNETInstance ins; /* 全レイヤ共通に持っているインスタンス情報 */ PETHProtocolList upper_protocol[PETH_PROTOCOL_NUM]; /* 上位のプロトコルと送信するメッセージキュー */ s32 upper_protocol_count; PETHMessage upper_mq[PETH_UPPER_NUM]; /* 上位用の受信キュー */ s32 upper_ins_count; s32 state; u8 macaddr[PETH_MAC_LEN]; /* 自MACアドレス */ u16 pad; u8 sendBuf[PETH_MAX_SEND_LEN]; /* 送信バッファ */ } PETHInstance; /* WCMのインスタンスからNNETInstanceを取得する */ static inline NNETInstance *PETH_GetNNETInstance(PETHInstance *peth_ins) { return &peth_ins->ins; } /* NNETInstanceからWCMのインスタンスを取得する */ static inline PETHInstance *PETH_GetPETHInstance(NNETInstance *ins) { return (PETHInstance *)ins; } /*---------------------------------------------------------------------------* * Function Prototypes *---------------------------------------------------------------------------*/ /* PETH_main.c */ extern s32 PETH_Init(const NNETAllocator *allocator); extern s32 PETH_Finish(void); extern s32 PETH_StartupIns(NNETInstance *ins, s32 timeout); extern s32 PETH_CleanupIns(NNETInstance *ins, s32 timeout); extern s32 PETH_AbortIns(NNETInstance *ins); extern s32 PETH_CreateIns(PETHInstance **peth_ins); extern s32 PETH_DestroyIns(PETHInstance *peth_ins); extern s32 PETH_GetStateIns(PETHInstance *peth_ins); extern s32 PETH_GetUpperAPI(NNETEthernetAPI *wcm_api, PETHInstance *peth_ins); extern s32 PETH_SetUpper(NNETInstance *ins, NNETInstance *upper_ins, u32 *receive_id, u16 entry[]); extern s32 PETH_ClearUpper(NNETInstance *ins, NNETInstance *upper_ins); extern s32 PETH_GetMacAddr(NNETInstance *ins, u8 *macaddr); extern s32 PETH_SetMulticastAddr(NNETInstance *ins, u8 *macaddr); extern s32 PETH_ClearMulticastAddr(NNETInstance *ins, u8 *macaddr); extern s32 PETH_Send(NNETInstance *ins, u8 *dstMAC, NOSMessageBuf *mbuf); extern s32 PETH_Receive(NNETInstance *ins, u32 receive_id, NOSMessageBuf **mbuf); extern s32 PETH_CancelReceive(NNETInstance *ins, u32 receive_id); #ifdef __cplusplus } #endif /* NN_NETWORK_PETH_H */ #endif