This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
NyLPC_cEthernetMM.h
00001 /********************************************************************************* 00002 * PROJECT: MiMic 00003 * -------------------------------------------------------------------------------- 00004 * 00005 * This file is part of MiMic 00006 * Copyright (C)2011 Ryo Iizuka 00007 * 00008 * MiMic is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published 00010 * by the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * 00021 * For further information please contact. 00022 * http://nyatla.jp/ 00023 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp> 00024 * 00025 *********************************************************************************/ 00026 /** 00027 * @file 00028 * このファイルは、イーサネットメモリマネージャクラスを定義します。 00029 */ 00030 #ifndef NyLPC_cEthernetMM_protected_h 00031 #define NyLPC_cEthernetMM_protected_h 00032 00033 #include "NyLPC_stdlib.h" 00034 #include "NyLPC_IEthernetDevice.h" 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif /* __cplusplus */ 00039 00040 #ifndef PACK_STRUCT_END 00041 #define PACK_STRUCT_END __attribute((packed)) 00042 #endif 00043 00044 /** 00045 * 構造体のアライメントサイズ(4 or 16) 00046 */ 00047 #ifndef NyLPC_TTxBufferHeader_ALIGNMENT 00048 # define NyLPC_TTxBufferHeader_ALIGNMENT 4 00049 #endif 00050 00051 /** 00052 *バッファメモリのパディングサイズ 00053 */ 00054 #ifndef NyLPC_TcEthernetMM_BUF_PADDING 00055 # define NyLPC_TcEthernetMM_BUF_PADDING 0 00056 #endif 00057 00058 /** 00059 * 送信バッフメモリのヘッダ。 00060 * この構造体は、TXバッファメモリブロックのヘッダーです。 00061 * TXバッファメモリブロックは、この構造体の後ろに、sizeに一致したメモリを連結したもので表現します。 00062 * <pre> 00063 * buffer=[struct NyLPC_TTxBufferHeader][n] 00064 * </pre> 00065 */ 00066 struct NyLPC_TTxBufferHeader 00067 { 00068 //メモリブロックの参照カウンタ。 00069 NyLPC_TInt8 ref; 00070 //送信用にロックしたかを示すフラグ 00071 NyLPC_TUInt8 is_lock; 00072 //Nビット境界に合わせるためのパディング。 00073 NyLPC_TUInt8 padding[NyLPC_TTxBufferHeader_ALIGNMENT-2]; 00074 }PACK_STRUCT_END; 00075 00076 /** 00077 * バッファメモリアドレスからメモリヘッダアドレスを復元します。 00078 */ 00079 #define NyLPC_TTxBufferHeader_getBufferHeaderAddr(a) ((struct NyLPC_TTxBufferHeader*)(((NyLPC_TUInt8*)a)-sizeof(struct NyLPC_TTxBufferHeader))) 00080 00081 00082 /** 00083 * NyLPC_cEthernetMM_allocのヒント値。 00084 * コントロールパケット用のサイズ要求をするときに使用します。 00085 */ 00086 #define NyLPC_TcEthernetMM_HINT_CTRL_PACKET 0 00087 00088 00089 /** 00090 * メモリブロック構造体の定数値 00091 */ 00092 #define NyLPC_TcEthernetMM_NUM_OF_MAX_BUF 3 00093 #define NyLPC_TcEthernetMM_NUM_OF_512_BUF 3 00094 #define NyLPC_TcEthernetMM_NUM_OF_256_BUF 4 00095 #define NyLPC_TcEthernetMM_NUM_OF_128_BUF 16 00096 #define NyLPC_TcEthernetMM_NUM_OF_64_BUF 4 00097 00098 /** 00099 * FULLサイズのEthernetFrame送信メモリのサイズ。 00100 * ここで最大送信サイズを制限します。 00101 * 通常は1460+20+20+14=1514バイト 00102 * パディングと合計で128bit(16byte)アライメントにしておかないと不幸になる。 00103 */ 00104 #define NyLPC_TcEthernetMM_MAX_TX_ETHERNET_FRAME_SIZE 1514 00105 /** 00106 * Alignment padding(128bit) 00107 */ 00108 #define NyLPC_TcEthernetMM_MAX_TX_ETHERNET_PADDING 22 00109 00110 00111 /** 00112 * TXメモリブロックの定義配列 00113 */ 00114 struct NyLPC_TcEthernetMM_TxMemoryBlock 00115 { 00116 struct{ 00117 struct NyLPC_TTxBufferHeader h; 00118 NyLPC_TUInt8 b[NyLPC_TcEthernetMM_MAX_TX_ETHERNET_FRAME_SIZE]; 00119 NyLPC_TUInt8 _padding[NyLPC_TcEthernetMM_MAX_TX_ETHERNET_PADDING+NyLPC_TcEthernetMM_BUF_PADDING]; 00120 }buf_max[NyLPC_TcEthernetMM_NUM_OF_MAX_BUF];//(4+MAX_TX_ETHERNET_FRAME_SIZE(1514))*3=? default=4554 00121 struct{ 00122 struct NyLPC_TTxBufferHeader h; 00123 NyLPC_TUInt8 b[512+NyLPC_TcEthernetMM_BUF_PADDING]; 00124 }buf_512[NyLPC_TcEthernetMM_NUM_OF_512_BUF];//(4+512)*3=1548 00125 struct{ 00126 struct NyLPC_TTxBufferHeader h; 00127 NyLPC_TUInt8 b[256+NyLPC_TcEthernetMM_BUF_PADDING]; 00128 }buf_256[NyLPC_TcEthernetMM_NUM_OF_256_BUF];//(4+256)*4=1560 00129 struct{ 00130 struct NyLPC_TTxBufferHeader h; 00131 NyLPC_TUInt8 b[128+NyLPC_TcEthernetMM_BUF_PADDING]; 00132 }buf_128[NyLPC_TcEthernetMM_NUM_OF_128_BUF];//(4+128)*16=1584 00133 struct{ 00134 struct NyLPC_TTxBufferHeader h; 00135 NyLPC_TUInt8 b[64+NyLPC_TcEthernetMM_BUF_PADDING]; 00136 }buf_64[NyLPC_TcEthernetMM_NUM_OF_64_BUF];//(4+64)*4=272 00137 }PACK_STRUCT_END; 00138 00139 00140 00141 int NyLPC_cEthernetMM_dbg_getNumofUsedTx(void); 00142 00143 /** 00144 * メモリブロックを初期化してメモリマネージャを構築します。 00145 * メモリサイズはsizeof(struct TTxMemoryBlock)以上である必要があります。 00146 */ 00147 void NyLPC_cEthernetMM_initialize(void* i_memblock_addr); 00148 #define NyLPC_cEthernetMM_finalize(i) 00149 /** 00150 * メモリを割り当てます。 00151 * @param i_hint 00152 * 割り当てるメモリサイズのヒント。 00153 * 数値の場合、128バイト以上のもっともhintに近いメモリを割り当てます。 00154 * 以下の定義値の場合、特別な領域を優先して返します。たぶん。 00155 * <ul> 00156 * <li>NyLPC_TcEthernetMM_HINT_CTRL_PACKET - 64 00157 * </ul> 00158 * @return 00159 * 割り当て不能な場合はNULLが帰ります。 00160 * @bug 00161 * パケットバッファの先頭アドレス 00162 */ 00163 void* NyLPC_cEthernetMM_alloc(NyLPC_TUInt16 i_hint,NyLPC_TUInt16* o_size); 00164 /** 00165 * NyLPC_EthernetMM_allocで得たメモリを解放します。 00166 */ 00167 void NyLPC_cEthernetMM_release(void* i_buf); 00168 00169 #ifdef __cplusplus 00170 } 00171 #endif /* __cplusplus */ 00172 00173 #endif
Generated on Tue Jul 12 2022 15:46:15 by 1.7.2