From df76e77598bd4311a2dab96195f96e94f5015c74 Mon Sep 17 00:00:00 2001 From: Our Air Quality Date: Thu, 24 Nov 2016 02:56:34 +1100 Subject: [PATCH] open_esplibs libwpa: source code for os_xtensa.c (#283) --- lib/allsymbols.rename | 2 ++ lib/libwpa.remove | 2 ++ open_esplibs/include/esplibs/libwpa.h | 3 +++ open_esplibs/include/open_esplibs.h | 4 +++ open_esplibs/libwpa/os_xtensa.c | 38 +++++++++++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 open_esplibs/libwpa/os_xtensa.c diff --git a/lib/allsymbols.rename b/lib/allsymbols.rename index 7f56f1f..2d609bc 100644 --- a/lib/allsymbols.rename +++ b/lib/allsymbols.rename @@ -279,9 +279,11 @@ NoiseTimerInterval sdk_NoiseTimerInterval operation_test sdk_operation_test os_delay_us sdk_os_delay_us os_get_cpu_frequency sdk_os_get_cpu_frequency +os_get_random sdk_os_get_random os_get_time sdk_os_get_time os_install_putc1 sdk_os_install_putc1 os_putc sdk_os_putc +os_random sdk_os_random os_timer_arm sdk_os_timer_arm os_timer_disarm sdk_os_timer_disarm os_timer_setfn sdk_os_timer_setfn diff --git a/lib/libwpa.remove b/lib/libwpa.remove index e69de29..2b3ad84 100644 --- a/lib/libwpa.remove +++ b/lib/libwpa.remove @@ -0,0 +1,2 @@ +# Object files to be removed from libwpa +os_xtensa.o diff --git a/open_esplibs/include/esplibs/libwpa.h b/open_esplibs/include/esplibs/libwpa.h index 0d75ff8..36a2fc2 100644 --- a/open_esplibs/include/esplibs/libwpa.h +++ b/open_esplibs/include/esplibs/libwpa.h @@ -35,6 +35,9 @@ int sdk_hostapd_setup_wpa_psk(struct _unknown_softap2 *); // md5.o // os_xtensa.o +int sdk_os_get_time(uint32_t time[]); +uint32_t sdk_os_random(); +int sdk_os_get_random(uint8_t *dst, uint32_t size); // rc4.o diff --git a/open_esplibs/include/open_esplibs.h b/open_esplibs/include/open_esplibs.h index fce49a1..da59d3c 100644 --- a/open_esplibs/include/open_esplibs.h +++ b/open_esplibs/include/open_esplibs.h @@ -111,6 +111,10 @@ #define OPEN_LIBWPA (OPEN_ESPLIBS) #endif +#ifndef OPEN_LIBWPA_OS_XTENSA +#define OPEN_LIBWPA_OS_XTENSA (OPEN_LIBWPA) +#endif + #ifndef OPEN_LIBWPA_WPA_MAIN #define OPEN_LIBWPA_WPA_MAIN (OPEN_LIBWPA) #endif diff --git a/open_esplibs/libwpa/os_xtensa.c b/open_esplibs/libwpa/os_xtensa.c new file mode 100644 index 0000000..a5beba6 --- /dev/null +++ b/open_esplibs/libwpa/os_xtensa.c @@ -0,0 +1,38 @@ +/* Recreated Espressif libwpa is_xtensa.s contents. + + Copyright (C) 2015 Espressif Systems. Derived from MIT Licensed SDK libraries. + BSD Licensed as described in the file LICENSE +*/ +#include "open_esplibs.h" +#if OPEN_LIBWPA_OS_XTENSA +// The contents of this file are only built if OPEN_LIBWPA_WPA_MAIN is set to true + +#include +#include +#include +#include + +// Used by wpa_get_ntp_timestamp. +int IRAM sdk_os_get_time(uint32_t time[]) { + return 0; +} + +uint32_t IRAM sdk_os_random() { + return rand(); +} + +int IRAM sdk_os_get_random(uint8_t *dst, uint32_t size) { + uint32_t end = size >> 2; + if (end > 0) { + uint32_t i = 0; + do { + uint32_t n = rand(); + memcpy(dst, &n, sizeof(n)); + dst += 4; + i++; + } while (i < end); + } + return 0; +} + +#endif /* OPEN_LIBWPA_OS_XTENSA */