Replacement system_set_os_print() function.

This commit is contained in:
Johny Mattsson 2016-06-02 15:49:56 +10:00
parent c378298000
commit 860aa47dc1
3 changed files with 23 additions and 9 deletions

View File

@ -44,7 +44,13 @@
.align 4
.literal_position
__wrap_printf:
addi a1, a1, -48 /* get some stack space */
movi a9, os_printf_enabled /* a9 is caller saved */
l8ui a9, a9, 0 /* load os_printf_enabled flag */
bnez a9, 1f /* if it's enabled, we print everything */
movi a9, _irom0_sdktext_end /* else we check if it's SDK called */
bgeu a0, a9, 1f /* ...and only print from user code */
ret
1:addi a1, a1, -48 /* get some stack space */
s32i a0, a1, 0 /* store a0 at the bottom */
s32i a2, a1, 16 /* copy the formatting string and first few arguments */
s32i a3, a1, 20 /* ...onto the stack in a way that we get a struct */
@ -61,3 +67,9 @@ __wrap_printf:
l32i a0, a1, 0 /* restore return address into a0 */
addi a1, a1, 48 /* release the stack */
ret /* all done */
/* Flag for controlling whether SDK printf()s are suppressed or not.
* This is to provide an RTOS-safe reimplementation of system_set_os_print(). */
.section ".data"
.globl os_printf_enabled
os_printf_enabled: .byte 1

View File

@ -91,6 +91,12 @@ SECTIONS
.irom0.text : ALIGN(0x1000)
{
_irom0_text_start = ABSOLUTE(.);
/* To be able to suppress SDK printfs, we place all SDK code first, with
* a marker at the end that we can easily compare against. */
*/rtos-sdk/lib/lib*.a:*.o(.irom*)
_irom0_sdktext_end = ABSOLUTE(.);
*(.servercert.flash)
*(.clientcert.flash)
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
@ -108,10 +114,6 @@ SECTIONS
KEEP(*(.lua_rotable))
LONG(0) LONG(0) /* Null-terminate the array */
/* SDK doesn't use libc functions, and are therefore safe to put in flash */
*/libc.a:*.o(.text* .literal*)
/* end libc functions */
_irom0_text_end = ABSOLUTE(.);
_flash_used_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr =0xffffffff

View File

@ -3,7 +3,6 @@
#define ets_timer_arm_new(tmr, ms, rpt, isms) os_timer_arm(tmr,ms,rpt)
//#include_next "user_interface.h"
#include "espressif/esp_system.h"
#include "espressif/esp_misc.h"
#include "espressif/esp_wifi.h"
@ -11,9 +10,10 @@
#include "espressif/esp_softap.h"
#include "espressif/esp_timer.h"
// FIXME
static inline void system_set_os_print(uint8 onoff) { (void)onoff; }
static inline void system_set_os_print(uint8_t onoff) {
extern uint8_t os_printf_enabled;
os_printf_enabled = onoff;
}
bool wifi_softap_deauth(uint8 mac[6]);