MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_gmacmem_create

Function rt_gmacmem_create

bsp/ft2004/drivers/drv_eth.c:88–123  ·  view source on GitHub ↗

* @name: rt_gmacmem_create * @msg: Initialize the Gmac TX/Rx Describe Memory 。 * @param {*} * @return {*} */

Source from the content-addressed store, hash-verified

86 * @return {*}
87 */
88static void rt_gmacmem_create(struct drv_gmac *pOsGmac)
89{
90 pOsGmac->rx_buffer = rt_calloc(1, RX_DESCNUM * GMAC_MAX_PACKET_SIZE);
91 if (pOsGmac->rx_buffer == NULL)
92 {
93 LOG_E("rx_buffer Malloc is error ");
94 RT_ASSERT(0)
95 }
96
97 pOsGmac->tx_buffer = rt_calloc(1, TX_DESCNUM * GMAC_MAX_PACKET_SIZE);
98 if (pOsGmac->tx_buffer == NULL)
99 {
100 LOG_E("tx_buffer Malloc is error ");
101 RT_ASSERT(0)
102 }
103
104 pOsGmac->Gmac.TxDesc = rt_calloc(1, TX_DESCNUM * sizeof(FGmac_DmaDesc_t));
105 if (pOsGmac->Gmac.TxDesc == NULL)
106 {
107 LOG_E("TxDesc Malloc is error ");
108 RT_ASSERT(0)
109 }
110
111 pOsGmac->Gmac.RxDesc = rt_calloc(1, RX_DESCNUM * sizeof(FGmac_DmaDesc_t) + 128);
112 if (pOsGmac->Gmac.RxDesc == NULL)
113 {
114 LOG_E("RxDesc Malloc is error ");
115 RT_ASSERT(0)
116 }
117
118#define ROUND_UP(x, align) (((long)(x) + ((long)align - 1)) & \
119 ~((long)align - 1))
120
121 pOsGmac->Gmac.RxDesc = (FGmac_DmaDesc_t *)ROUND_UP(pOsGmac->Gmac.RxDesc, 128);
122 LOG_D("RxDesc fit after addr %x ", pOsGmac->Gmac.RxDesc);
123}
124
125static void rt_gmacmem_free(struct drv_gmac *pOsGmac)
126{

Callers 1

rt_hw_gmac_initFunction · 0.85

Calls 1

rt_callocFunction · 0.85

Tested by

no test coverage detected