]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/lwIP_MCF5235_GCC/lwip/contrib/port/FreeRTOS/MCF5235/netif/nbuf.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / lwIP_MCF5235_GCC / lwip / contrib / port / FreeRTOS / MCF5235 / netif / nbuf.h
1 /*\r
2  * Network buffer code based on the MCF523x examples from Freescale.\r
3  *\r
4  * Freescale explicitly grants the redistribution and modification\r
5  * of these source files. The complete licensing information is\r
6  * available in the file LICENSE_FREESCALE.TXT.\r
7  *\r
8  * Modifications Copyright (c) 2006 Christian Walter <wolti@sil.at>\r
9  *\r
10  * File: $Id: nbuf.h,v 1.3 2006/09/24 22:50:23 wolti Exp $\r
11  */\r
12 \r
13 #ifndef _NBUF_H\r
14 #define _NBUF_H\r
15 \r
16 /* ------------------------ Defines --------------------------------------- */\r
17 \r
18 #ifdef __GNUC__\r
19 #define ATTR_FECMEM             \\r
20     __attribute__((section(".nbuf"),aligned(16)))\r
21 #endif\r
22 \r
23 #define NBUF_RX                 ( 1 )\r
24 #define NBUF_TX                 ( 0 )\r
25 \r
26 /* We set the receiver buffers to the maximum size the FEC supports ( See\r
27  * MCF5235 reference manual 19.2.5.1.2 - Driver/DMA Operation with Receive\r
28  * BDs). This gives us the benefit that any frame fits into one buffer. A\r
29  * maximum size of 2047 is guaranteed by the FEC and 2048 is therefore a\r
30  * safe value.\r
31  * Note: The value MUST be dividable by 16!\r
32  */\r
33 #define RX_BUFFER_SIZE          ( 2048 )\r
34 \r
35 /* Size of the transmit buffers. If you set this value to small all frames\r
36  * greater than this size will be dropped. The value 1520 was choosen because\r
37  * it is bigger than the FEC MTU (1518) and is dividable by 16.\r
38  * Note: The value MUST be dividable by 16! */\r
39 #define TX_BUFFER_SIZE          ( 1520 )\r
40 \r
41 /* Number of Receive and Transmit Buffers and Buffer Descriptors */\r
42 #define NUM_RXBDS               ( 2 )\r
43 #define NUM_TXBDS               ( 2 )\r
44 \r
45 /* ------------------------ Defines ( Buffer Descriptor Flags )------------ */\r
46 \r
47 #define TX_BD_R                 ( 0x8000 )\r
48 #define TX_BD_INUSE             ( 0x4000 )\r
49 #define TX_BD_TO1               ( 0x4000 )\r
50 #define TX_BD_W                 ( 0x2000 )\r
51 #define TX_BD_TO2               ( 0x1000 )\r
52 #define TX_BD_L                 ( 0x0800 )\r
53 #define TX_BD_TC                ( 0x0400 )\r
54 #define TX_BD_DEF               ( 0x0200 )\r
55 #define TX_BD_HB                ( 0x0100 )\r
56 #define TX_BD_LC                ( 0x0080 )\r
57 #define TX_BD_RL                ( 0x0040 )\r
58 #define TX_BD_UN                ( 0x0002 )\r
59 #define TX_BD_CSL               ( 0x0001 )\r
60 \r
61 #define RX_BD_E                 ( 0x8000 )\r
62 #define RX_BD_INUSE             ( 0x4000 )\r
63 #define RX_BD_R01               ( 0x4000 )\r
64 #define RX_BD_W                 ( 0x2000 )\r
65 #define RX_BD_R02               ( 0x1000 )\r
66 #define RX_BD_L                 ( 0x0800 )\r
67 #define RX_BD_M                 ( 0x0100 )\r
68 #define RX_BD_BC                ( 0x0080 )\r
69 #define RX_BD_MC                ( 0x0040 )\r
70 #define RX_BD_LG                ( 0x0020 )\r
71 #define RX_BD_NO                ( 0x0010 )\r
72 #define RX_BD_SH                ( 0x0008 )\r
73 #define RX_BD_CR                ( 0x0004 )\r
74 #define RX_BD_OV                ( 0x0002 )\r
75 #define RX_BD_TR                ( 0x0001 )\r
76 \r
77 /* ------------------------ Type definitions ------------------------------ */\r
78 typedef struct\r
79 {\r
80     uint16          status;     /* control and status */\r
81     uint16          length;     /* transfer length */\r
82     uint8          *data;       /* buffer address */\r
83 } nbuf_t;\r
84 \r
85 /* ------------------------ Prototypes ------------------------------------ */\r
86 \r
87 void            nbuf_init( void );\r
88 uint32          nbuf_get_start( uint8 );\r
89 nbuf_t         *nbuf_rx_allocate( void );\r
90 nbuf_t         *nbuf_tx_allocate( void );\r
91 void            nbuf_rx_release( nbuf_t * );\r
92 void            nbuf_tx_release( nbuf_t * );\r
93 int             nbuf_rx_next_ready( void );\r
94 \r
95 #endif\r