misc: Switched to using C11
This commit is contained in:
parent
52e5357e99
commit
c530bd077b
|
@ -1 +1 @@
|
||||||
Subproject commit 8435287300e5ca9af9f889c529e7b1fa019c42fb
|
Subproject commit 44e142d4f97863e669737707a1a22bf40ed49bbc
|
|
@ -9,7 +9,7 @@ Q := @
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts \
|
CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts \
|
||||||
-std=gnu99 -g3 -MD -I./target \
|
-std=c11 -g3 -MD -I./target \
|
||||||
-I. -Iinclude -I$(PLATFORM_DIR)
|
-I. -Iinclude -I$(PLATFORM_DIR)
|
||||||
|
|
||||||
ifeq ($(ENABLE_DEBUG), 1)
|
ifeq ($(ENABLE_DEBUG), 1)
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
# include "traceswo.h"
|
# include "traceswo.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
static bool cmd_version(target *t, int argc, char **argv);
|
static bool cmd_version(target *t, int argc, char **argv);
|
||||||
static bool cmd_help(target *t, int argc, char **argv);
|
static bool cmd_help(target *t, int argc, char **argv);
|
||||||
|
|
||||||
|
@ -117,6 +119,9 @@ int command_process(target *t, char *cmd)
|
||||||
for(char *s = cmd; *s; s++)
|
for(char *s = cmd; *s; s++)
|
||||||
if((*s == ' ') || (*s == '\t')) argc++;
|
if((*s == ' ') || (*s == '\t')) argc++;
|
||||||
|
|
||||||
|
/* This needs replacing with something more sensible.
|
||||||
|
* It should be pinging -Wvla among other things, and it failing is straight-up UB
|
||||||
|
*/
|
||||||
argv = alloca(sizeof(const char *) * argc);
|
argv = alloca(sizeof(const char *) * argc);
|
||||||
|
|
||||||
/* Tokenize cmd to find argv */
|
/* Tokenize cmd to find argv */
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
#include "rtt.h"
|
#include "rtt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
enum gdb_signal {
|
enum gdb_signal {
|
||||||
GDB_SIGINT = 2,
|
GDB_SIGINT = 2,
|
||||||
GDB_SIGTRAP = 5,
|
GDB_SIGTRAP = 5,
|
||||||
|
@ -361,6 +363,8 @@ static void exec_q_rcmd(const char *packet,int len)
|
||||||
|
|
||||||
/* calculate size and allocate buffer for command */
|
/* calculate size and allocate buffer for command */
|
||||||
datalen = len / 2;
|
datalen = len / 2;
|
||||||
|
// This needs replacing with something more sensible.
|
||||||
|
// It should be pinging -Wvla among other things, and it failing is straight-up UB
|
||||||
data = alloca(datalen + 1);
|
data = alloca(datalen + 1);
|
||||||
/* dehexify command */
|
/* dehexify command */
|
||||||
unhexify(data, packet, datalen);
|
unhexify(data, packet, datalen);
|
||||||
|
|
|
@ -21,9 +21,8 @@
|
||||||
#ifndef __GENERAL_H
|
#ifndef __GENERAL_H
|
||||||
#define __GENERAL_H
|
#define __GENERAL_H
|
||||||
|
|
||||||
#if !defined(_GNU_SOURCE)
|
#define _GNU_SOURCE
|
||||||
# define _GNU_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#endif
|
|
||||||
#if !defined(__USE_MINGW_ANSI_STDIO)
|
#if !defined(__USE_MINGW_ANSI_STDIO)
|
||||||
# define __USE_MINGW_ANSI_STDIO 1
|
# define __USE_MINGW_ANSI_STDIO 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void jtagtap_reset(void)
|
||||||
if (platform_hwversion() == 0) {
|
if (platform_hwversion() == 0) {
|
||||||
gpio_clear(TRST_PORT, TRST_PIN);
|
gpio_clear(TRST_PORT, TRST_PIN);
|
||||||
for (volatile size_t i = 0; i < 10000; i++)
|
for (volatile size_t i = 0; i < 10000; i++)
|
||||||
asm("nop");
|
__asm__("nop");
|
||||||
gpio_set(TRST_PORT, TRST_PIN);
|
gpio_set(TRST_PORT, TRST_PIN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -92,7 +92,7 @@ void platform_nrst_set_val(bool assert)
|
||||||
volatile int i;
|
volatile int i;
|
||||||
if (assert) {
|
if (assert) {
|
||||||
gpio_clear(NRST_PORT, NRST_PIN);
|
gpio_clear(NRST_PORT, NRST_PIN);
|
||||||
for(i = 0; i < 10000; i++) asm("nop");
|
for(i = 0; i < 10000; i++) __asm__("nop");
|
||||||
} else {
|
} else {
|
||||||
gpio_set(NRST_PORT, NRST_PIN);
|
gpio_set(NRST_PORT, NRST_PIN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ int platform_hwversion(void)
|
||||||
gpio_set(GPIOB, hwversion_pins);
|
gpio_set(GPIOB, hwversion_pins);
|
||||||
|
|
||||||
/* Wait a little to make sure the pull up is in effect... */
|
/* Wait a little to make sure the pull up is in effect... */
|
||||||
for(int i = 0; i < 100; i++) asm("nop");
|
for(int i = 0; i < 100; i++) __asm__("nop");
|
||||||
|
|
||||||
/* Get all pins that are pulled low in hardware.
|
/* Get all pins that are pulled low in hardware.
|
||||||
* This also sets all the "unused" pins to 1.
|
* This also sets all the "unused" pins to 1.
|
||||||
|
@ -119,7 +119,7 @@ int platform_hwversion(void)
|
||||||
gpio_clear(GPIOB, hwversion_pins);
|
gpio_clear(GPIOB, hwversion_pins);
|
||||||
|
|
||||||
/* Wait a little to make sure the pull down is in effect... */
|
/* Wait a little to make sure the pull down is in effect... */
|
||||||
for(int i = 0; i < 100; i++) asm("nop");
|
for(int i = 0; i < 100; i++) __asm__("nop");
|
||||||
|
|
||||||
/* Get all the pins that are pulled high in hardware. */
|
/* Get all the pins that are pulled high in hardware. */
|
||||||
uint16_t pins_positive = gpio_get(GPIOB, hwversion_pins);
|
uint16_t pins_positive = gpio_get(GPIOB, hwversion_pins);
|
||||||
|
@ -243,7 +243,7 @@ void platform_nrst_set_val(bool assert)
|
||||||
gpio_set_val(NRST_PORT, NRST_PIN, !assert);
|
gpio_set_val(NRST_PORT, NRST_PIN, !assert);
|
||||||
}
|
}
|
||||||
if (assert) {
|
if (assert) {
|
||||||
for(int i = 0; i < 10000; i++) asm("nop");
|
for(int i = 0; i < 10000; i++) __asm__("nop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,10 +105,9 @@ void dfu_jump_app_if_valid(void)
|
||||||
/* Set vector table base address */
|
/* Set vector table base address */
|
||||||
SCB_VTOR = app_address & 0x1FFFFF; /* Max 2 MByte Flash*/
|
SCB_VTOR = app_address & 0x1FFFFF; /* Max 2 MByte Flash*/
|
||||||
/* Initialise master stack pointer */
|
/* Initialise master stack pointer */
|
||||||
asm volatile ("msr msp, %0"::"g"
|
__asm__ volatile("msr msp, %0"::"g"
|
||||||
(*(volatile uint32_t*)app_address));
|
(*(volatile uint32_t*)app_address));
|
||||||
/* Jump to application */
|
/* Jump to application */
|
||||||
(*(void(**)())(app_address + 4))();
|
(*(void(**)())(app_address + 4))();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,10 +101,9 @@ void dfu_jump_app_if_valid(void)
|
||||||
SCB_VTOR = app_address & 0x1FFFFF; /* Max 2 MByte Flash*/
|
SCB_VTOR = app_address & 0x1FFFFF; /* Max 2 MByte Flash*/
|
||||||
#endif
|
#endif
|
||||||
/* Initialise master stack pointer */
|
/* Initialise master stack pointer */
|
||||||
asm volatile ("msr msp, %0"::"g"
|
__asm__ volatile("msr msp, %0"::"g"
|
||||||
(*(volatile uint32_t*)app_address));
|
(*(volatile uint32_t*)app_address));
|
||||||
/* Jump to application */
|
/* Jump to application */
|
||||||
(*(void(**)())(app_address + 4))();
|
(*(void(**)())(app_address + 4))();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ static void gdb_if_update_buf(void)
|
||||||
{
|
{
|
||||||
while (cdcacm_get_config() != 1);
|
while (cdcacm_get_config() != 1);
|
||||||
#ifdef STM32F4
|
#ifdef STM32F4
|
||||||
asm volatile ("cpsid i; isb");
|
__asm__ volatile("cpsid i; isb");
|
||||||
if (count_new) {
|
if (count_new) {
|
||||||
memcpy(buffer_out, double_buffer_out, count_new);
|
memcpy(buffer_out, double_buffer_out, count_new);
|
||||||
count_out = count_new;
|
count_out = count_new;
|
||||||
|
@ -89,7 +89,7 @@ static void gdb_if_update_buf(void)
|
||||||
out_ptr = 0;
|
out_ptr = 0;
|
||||||
usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
|
usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0);
|
||||||
}
|
}
|
||||||
asm volatile ("cpsie i; isb");
|
__asm__ volatile("cpsie i; isb");
|
||||||
#else
|
#else
|
||||||
count_out = usbd_ep_read_packet(usbdev, CDCACM_GDB_ENDPOINT,
|
count_out = usbd_ep_read_packet(usbdev, CDCACM_GDB_ENDPOINT,
|
||||||
buffer_out, CDCACM_PACKET_SIZE);
|
buffer_out, CDCACM_PACKET_SIZE);
|
||||||
|
@ -129,4 +129,3 @@ unsigned char gdb_if_getchar_to(int timeout)
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -629,7 +629,7 @@ void debug_monitor_handler_c(struct ex_frame *sp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asm(".globl debug_monitor_handler\n"
|
__asm__(".globl debug_monitor_handler\n"
|
||||||
".thumb_func\n"
|
".thumb_func\n"
|
||||||
"debug_monitor_handler: \n"
|
"debug_monitor_handler: \n"
|
||||||
" mov r0, sp\n"
|
" mov r0, sp\n"
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
static inline void __attribute__((always_inline))
|
static inline void __attribute__((always_inline))
|
||||||
stub_exit(const int code)
|
stub_exit(const int code)
|
||||||
{
|
{
|
||||||
asm("bkpt %0"::"i"(code));
|
__asm__("bkpt %0"::"i"(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -466,10 +466,10 @@ static bool rp_attach(target *t)
|
||||||
if (!cortexm_attach(t))
|
if (!cortexm_attach(t))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct rp_priv_s *ps = (struct rp_priv_s *)t->target_storage;
|
struct rp_priv_s *ps = (struct rp_priv_s*)t->target_storage;
|
||||||
uint16_t *table = alloca(RP_MAX_TABLE_SIZE);
|
uint16_t table[RP_MAX_TABLE_SIZE];
|
||||||
uint16_t table_offset = target_mem_read32(t, BOOTROM_MAGIC_ADDR + 4);
|
uint16_t table_offset = target_mem_read32( t, BOOTROM_MAGIC_ADDR + 4);
|
||||||
if (!table || target_mem_read(t, table, table_offset, RP_MAX_TABLE_SIZE))
|
if (target_mem_read(t, table, table_offset, RP_MAX_TABLE_SIZE))
|
||||||
return false;
|
return false;
|
||||||
if (rp2040_fill_table(ps, table, RP_MAX_TABLE_SIZE))
|
if (rp2040_fill_table(ps, table, RP_MAX_TABLE_SIZE))
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue