Files
Dong Heng 74e013e493 feat(LWIP): Fix IRAM pbuf never send
WIFI only can send DRAM data, so if upper layer pbuf payload is
IRAM data, here it must be copy to DRAM.

We add "pbuf_alloc_ll" to reduce this happen.
2018-07-25 19:18:12 +08:00

56 lines
1.4 KiB
C

// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stddef.h>
#include "lwip/opt.h"
#include "lwip/memp.h"
#include "FreeRTOS.h"
#include "esp8266/eagle_soc.h"
#ifdef ESP_LWIP
/*
* @brief allocate an only DRAM memory block for LWIP pbuf
*
* @param s memory size
*
* @return memory block pointer
*/
void *mem_malloc_ll(size_t s)
{
void *p;
void *return_addr = (void *)__builtin_return_address(0);
p = pvPortMalloc_trace(s, return_addr, (unsigned)-1, false);
if (IS_IRAM(p)) {
vPortFree_trace(p, return_addr, (unsigned)-1);
p = NULL;
}
return p;
}
void *memp_malloc_ll(size_t type)
{
extern const struct memp_desc* const memp_pools[MEMP_MAX];
uint8_t *p;
const struct memp_desc *desc = memp_pools[type];
p = (uint8_t *)mem_malloc_ll(MEMP_SIZE + MEMP_ALIGN_SIZE(desc->size));
return p + MEMP_SIZE;
}
#endif