mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-06 15:15:15 +08:00
Merge branch 'feature/using_dram_calculating_pmk' into 'master'
Redefine usd heap to DRAM instead of IRAM See merge request sdk/ESP8266_RTOS_SDK!474
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
COMPONENT_ADD_INCLUDEDIRS := include port/include
|
COMPONENT_ADD_INCLUDEDIRS := include port/include
|
||||||
COMPONENT_SRCDIRS := src/crypto
|
COMPONENT_SRCDIRS := src/crypto port
|
||||||
|
|
||||||
CFLAGS += -DEMBEDDED_SUPP -D__ets__ -DESPRESSIF_USE
|
CFLAGS += -DEMBEDDED_SUPP -D__ets__ -DESPRESSIF_USE
|
@ -21,6 +21,9 @@
|
|||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "rom/ets_sys.h"
|
#include "rom/ets_sys.h"
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "esp_libc.h"
|
||||||
|
|
||||||
typedef long os_time_t;
|
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
|
* 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.
|
* 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
|
#ifndef os_bzero
|
||||||
#define os_bzero(s, n) bzero(s, n)
|
#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);
|
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 */
|
#endif /* OS_H */
|
||||||
|
@ -21,44 +21,32 @@
|
|||||||
* this file to work correctly. Note that these implementations are only
|
* this file to work correctly. Note that these implementations are only
|
||||||
* examples and are not optimized for speed.
|
* examples and are not optimized for speed.
|
||||||
*/
|
*/
|
||||||
|
#include <string.h>
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
|
||||||
#include "crypto/common.h"
|
void *_xmalloc(size_t n)
|
||||||
#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)
|
|
||||||
{
|
{
|
||||||
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")));
|
void *_xrealloc(void *ptr, size_t n)
|
||||||
|
|
||||||
|
|
||||||
int os_get_random(unsigned char *buf, size_t len)
|
|
||||||
{
|
{
|
||||||
int i, j;
|
void *return_addr = (void *)__builtin_return_address(0);
|
||||||
unsigned long tmp;
|
void *p = pvPortMalloc_trace(n, return_addr, (unsigned)-1, false);
|
||||||
|
if (p && ptr) {
|
||||||
for (i = 0; i < ((len + 3) & ~3) / 4; i++) {
|
// n ?
|
||||||
tmp = r_rand();
|
memcpy(p, ptr, n);
|
||||||
|
vPortFree_trace(ptr, return_addr, (unsigned)-1);
|
||||||
for (j = 0; j < 4; j++) {
|
|
||||||
if ((i * 4 + j) < len) {
|
|
||||||
buf[i * 4 + j] = (uint8_t)(tmp >> (j * 8));
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ typedef u64 mp_word;
|
|||||||
#define MP_28BIT
|
#define MP_28BIT
|
||||||
|
|
||||||
|
|
||||||
#define XMALLOC os_malloc
|
#define XMALLOC _xmalloc
|
||||||
#define XFREE os_free
|
#define XFREE _xfree
|
||||||
#define XREALLOC os_realloc
|
#define XREALLOC _xrealloc
|
||||||
|
|
||||||
|
|
||||||
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
|
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
|
||||||
|
Reference in New Issue
Block a user