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