mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-07-15 08:32:42 +08:00
feat(wpa_supplicant): Redefine usd heap to DRAM instead of IRAM
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
COMPONENT_ADD_INCLUDEDIRS := include port/include
|
||||
COMPONENT_SRCDIRS := src/crypto
|
||||
COMPONENT_SRCDIRS := src/crypto port
|
||||
|
||||
CFLAGS += -DEMBEDDED_SUPP -D__ets__ -DESPRESSIF_USE
|
@ -21,6 +21,9 @@
|
||||
#include "esp_err.h"
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "esp_libc.h"
|
||||
|
||||
typedef long os_time_t;
|
||||
|
||||
/**
|
||||
@ -188,19 +191,6 @@ char * os_readfile(const char *name, size_t *len);
|
||||
* OS_NO_C_LIB_DEFINES can be defined to skip all defines here in which case
|
||||
* these functions need to be implemented in os_*.c file for the target system.
|
||||
*/
|
||||
|
||||
#ifndef os_malloc
|
||||
#define os_malloc(s) malloc((s))
|
||||
#endif
|
||||
#ifndef os_realloc
|
||||
#define os_realloc(p, s) realloc((p), (s))
|
||||
#endif
|
||||
#ifndef os_zalloc
|
||||
#define os_zalloc(s) calloc(1, (s))
|
||||
#endif
|
||||
#ifndef os_free
|
||||
#define os_free(p) free((p))
|
||||
#endif
|
||||
|
||||
#ifndef os_bzero
|
||||
#define os_bzero(s, n) bzero(s, n)
|
||||
@ -286,6 +276,8 @@ char * ets_strdup(const char *s);
|
||||
*/
|
||||
size_t os_strlcpy(char *dest, const char *src, size_t siz);
|
||||
|
||||
|
||||
void *_xmalloc(size_t n);
|
||||
void _xfree(void *ptr);
|
||||
void *_xrealloc(void *ptr, size_t n);
|
||||
|
||||
#endif /* OS_H */
|
||||
|
@ -21,44 +21,32 @@
|
||||
* this file to work correctly. Note that these implementations are only
|
||||
* examples and are not optimized for speed.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "crypto/common.h"
|
||||
#include "os.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include "esp_system.h"
|
||||
|
||||
int os_get_time(struct os_time *t)
|
||||
void *_xmalloc(size_t n)
|
||||
{
|
||||
return gettimeofday((struct timeval*) t, NULL);
|
||||
void *return_addr = (void *)__builtin_return_address(0);
|
||||
|
||||
return pvPortMalloc_trace(n, return_addr, (unsigned)-1, false);
|
||||
}
|
||||
|
||||
unsigned long os_random(void)
|
||||
void _xfree(void *ptr)
|
||||
{
|
||||
return esp_random();
|
||||
void *return_addr = (void *)__builtin_return_address(0);
|
||||
|
||||
vPortFree_trace(ptr, return_addr, (unsigned)-1);
|
||||
}
|
||||
|
||||
unsigned long r_rand(void) __attribute__((alias("os_random")));
|
||||
|
||||
|
||||
int os_get_random(unsigned char *buf, size_t len)
|
||||
void *_xrealloc(void *ptr, size_t n)
|
||||
{
|
||||
int i, j;
|
||||
unsigned long tmp;
|
||||
|
||||
for (i = 0; i < ((len + 3) & ~3) / 4; i++) {
|
||||
tmp = r_rand();
|
||||
|
||||
for (j = 0; j < 4; j++) {
|
||||
if ((i * 4 + j) < len) {
|
||||
buf[i * 4 + j] = (uint8_t)(tmp >> (j * 8));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
void *return_addr = (void *)__builtin_return_address(0);
|
||||
void *p = pvPortMalloc_trace(n, return_addr, (unsigned)-1, false);
|
||||
if (p && ptr) {
|
||||
// n ?
|
||||
memcpy(p, ptr, n);
|
||||
vPortFree_trace(ptr, return_addr, (unsigned)-1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,9 @@ typedef u64 mp_word;
|
||||
#define MP_28BIT
|
||||
|
||||
|
||||
#define XMALLOC os_malloc
|
||||
#define XFREE os_free
|
||||
#define XREALLOC os_realloc
|
||||
#define XMALLOC _xmalloc
|
||||
#define XFREE _xfree
|
||||
#define XREALLOC _xrealloc
|
||||
|
||||
|
||||
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
|
||||
|
Reference in New Issue
Block a user