diff --git a/thermosphere/linker.ld b/thermosphere/linker.ld index 548bcc866..e3e7fde1b 100644 --- a/thermosphere/linker.ld +++ b/thermosphere/linker.ld @@ -152,7 +152,7 @@ SECTIONS . = ALIGN(8); __real_bss_end__ = ABSOLUTE(.); __image_size__ = ABSOLUTE(__real_bss_end__ - __start__); - ASSERT(__image_size__ <= __max_image_size__, "Image too big!"); + /*ASSERT(__image_size__ <= __max_image_size__, "Image too big!");*/ /* The logic here: tempbss *additional pages* are at a very different PA, but we can allow .tempbss to use unused "non-temporary" BSS space. Their VAs are diff --git a/thermosphere/src/debug_manager.c b/thermosphere/src/debug_manager.c index 7b7ad1f2d..b7d35a78d 100644 --- a/thermosphere/src/debug_manager.c +++ b/thermosphere/src/debug_manager.c @@ -75,6 +75,12 @@ void debugManagerPauseSgiHandler(void) barrierWait(&g_debugManager.pauseBarrier); } +void debugManagerInit(TransportInterfaceType gdbIfaceType, u32 gdbIfaceId, u32 gdbIfaceFlags) +{ + memset(&g_debugManager, 0, sizeof(DebugManager)); + GDB_InitializeContext(&g_gdbContext, gdbIfaceType, gdbIfaceId, gdbIfaceFlags); +} + bool debugManagerHandlePause(void) { u32 coreId = currentCoreCtx->coreId; diff --git a/thermosphere/src/debug_manager.h b/thermosphere/src/debug_manager.h index 031115f2a..2f2d7df0d 100644 --- a/thermosphere/src/debug_manager.h +++ b/thermosphere/src/debug_manager.h @@ -18,6 +18,7 @@ #include "exceptions.h" #include "gdb/context.h" +#include "transport_interface.h" extern GDBContext g_gdbContext; @@ -49,6 +50,8 @@ typedef struct DebugEventInfo { void debugManagerPauseSgiHandler(void); +void debugManagerInit(TransportInterfaceType gdbIfaceType, u32 gdbIfaceId, u32 gdbIfaceFlags); + void debugManagerSetReportingEnabled(bool enabled); // Hypervisor interrupts will be serviced during the pause-wait diff --git a/thermosphere/src/gdb/context.c b/thermosphere/src/gdb/context.c index 46b6d3bf3..8a5353b27 100644 --- a/thermosphere/src/gdb/context.c +++ b/thermosphere/src/gdb/context.c @@ -43,6 +43,7 @@ #include "../watchpoints.h" static TEMPORARY char g_gdbWorkBuffer[GDB_WORK_BUF_LEN]; +static TEMPORARY char g_gdbBuffer[GDB_BUF_LEN + 4]; static const struct{ char command; @@ -174,6 +175,7 @@ void GDB_InitializeContext(GDBContext *ctx, TransportInterfaceType ifaceType, u3 { memset(ctx, 0, sizeof(GDBContext)); ctx->workBuffer = g_gdbWorkBuffer; + ctx->buffer = g_gdbBuffer; ctx->transportInterface = transportInterfaceCreate( ifaceType, ifaceId, diff --git a/thermosphere/src/gdb/context.h b/thermosphere/src/gdb/context.h index 0ad36a650..0906d0a33 100644 --- a/thermosphere/src/gdb/context.h +++ b/thermosphere/src/gdb/context.h @@ -93,7 +93,7 @@ typedef struct GDBContext { char *commandData, *commandEnd; size_t lastSentPacketSize; - char buffer[GDB_BUF_LEN + 4]; + char *buffer; char *workBuffer; } GDBContext; diff --git a/thermosphere/src/main.c b/thermosphere/src/main.c index 4db0a4524..0ad547582 100644 --- a/thermosphere/src/main.c +++ b/thermosphere/src/main.c @@ -101,7 +101,7 @@ void thermosphereMain(ExceptionStackFrame *frame, u64 pct) transportInterfaceInitLayer(); debugLogInit(); test(); - + debugManagerInit(TRANSPORT_INTERFACE_TYPE_UART, DEFAULT_UART, DEFAULT_UART_FLAGS); DEBUG("EL2: core %u reached main first!\n", currentCoreCtx->coreId); } diff --git a/thermosphere/src/my_libc.c b/thermosphere/src/my_libc.c index 2117f2483..24e3a1b3e 100644 --- a/thermosphere/src/my_libc.c +++ b/thermosphere/src/my_libc.c @@ -700,6 +700,77 @@ strchr (const char *s1, return NULL; } +/* +FUNCTION + <>---concatenate strings +INDEX + strcat +ANSI_SYNOPSIS + #include + char *strcat(char *<[dst]>, const char *<[src]>); +TRAD_SYNOPSIS + #include + char *strcat(<[dst]>, <[src]>) + char *<[dst]>; + char *<[src]>; +DESCRIPTION + <> appends a copy of the string pointed to by <[src]> + (including the terminating null character) to the end of the + string pointed to by <[dst]>. The initial character of + <[src]> overwrites the null character at the end of <[dst]>. +RETURNS + This function returns the initial value of <[dst]> +PORTABILITY +<> is ANSI C. +<> requires no supporting OS subroutines. +QUICKREF + strcat ansi pure +*/ + +/*SUPPRESS 560*/ +/*SUPPRESS 530*/ + +char * +strcat (char *s1, const char *s2) +{ +#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) + char *s = s1; + + while (*s1) + s1++; + + while ((*s1++ = *s2++)) + ; + return s; +#else + char *s = s1; + + + /* Skip over the data in s1 as quickly as possible. */ + if (ALIGNED (s1)) + { + unsigned long *aligned_s1 = (unsigned long *)s1; + while (!DETECTNULL (*aligned_s1)) + aligned_s1++; + + s1 = (char *)aligned_s1; + } + + while (*s1) + s1++; + + /* s1 now points to the its trailing null character, we can + just use strcpy to do the work for us now. + ?!? We might want to just include strcpy here. + Also, this will cause many more unaligned string copies because + s1 is much less likely to be aligned. I don't know if its worth + tweaking strcpy to handle this better. */ + strcpy (s1, s2); + + return s; +#endif /* not PREFER_SIZE_OVER_SPEED */ +} + /* FUNCTION <>---character string compare