#endif
uint8_t ao_aes_mutex;
-static uint8_t key[16];
+static word32 key[16/4];
static roundkey rkk;
-static uint8_t iv[16];
+static word32 iv[16/4];
void
ao_aes_set_mode(enum ao_aes_mode mode)
__xdata uint8_t *out)
{
uint8_t i;
+ uint8_t *_iv = (uint8_t *) iv;
for (i = 0; i < 16; i++)
- iv[i] ^= in[i];
- xrijndaelEncrypt((word32 *) iv, &rkk);
+ _iv[i] ^= in[i];
+ xrijndaelEncrypt(iv, &rkk);
if (out)
memcpy(out, iv, 16);
}
static void ublox_u16(uint8_t offset)
{
- uint16_t __xdata *ptr = (uint16_t __xdata *) (ublox_target + offset);
+ uint16_t __xdata *ptr = (uint16_t __xdata *) (void __xdata *) (ublox_target + offset);
uint16_t val;
val = data_byte();
static void ublox_u32(uint8_t offset) __reentrant
{
- uint32_t __xdata *ptr = (uint32_t __xdata *) (ublox_target + offset);
+ uint32_t __xdata *ptr = (uint32_t __xdata *) (void __xdata *) (ublox_target + offset);
uint32_t val;
val = ((uint32_t) data_byte ());
{
uint16_t i;
uint16_t t;
- uint32_t *rnd = (uint32_t *) ao_adc_ring;
+ uint32_t *rnd = (uint32_t *) (void *) ao_adc_ring;
uint8_t mismatch = 0;
t = ao_adc_get(AO_USB_IN_SIZE) >> 1; /* one 16-bit value per output byte */
* @return A pointer to the data struct containing the list head.
*/
#define ao_container_of(ptr, type, member) \
- ((type *)((char *)(ptr) - offsetof(type, member)))
+ ((type *)((void *) ((char *)(ptr) - offsetof(type, member))))
/**
* Alias of ao_container_of
if (ao_pyro_values[v].flag & AO_PYRO_8_BIT_VALUE)
value = *((uint8_t *) ((char *) pyro + ao_pyro_values[v].offset));
else
- value = *((int16_t *) ((char *) pyro + ao_pyro_values[v].offset));
+ value = *((int16_t *) (void *) ((char *) pyro + ao_pyro_values[v].offset));
printf ("%6d ", value);
} else {
printf (" ");
} else {
if (negative)
ao_cmd_lex_i = -ao_cmd_lex_i;
- *((int16_t *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i;
+ *((int16_t *) (void *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i;
}
}
}
#define HAS_TASK_INFO 1
#endif
+/* arm stacks must be 32-bit aligned */
+#ifdef __arm__
+#define AO_STACK_ALIGNMENT __attribute__ ((aligned(4)))
+#endif
+#ifdef SDCC
+#define AO_STACK_ALIGNMENT
+#endif
+#ifdef __AVR__
+#define AO_STACK_ALIGNMENT
+#endif
+
/* An AltOS task */
struct ao_task {
__xdata void *wchan; /* current wait channel (NULL if running) */
struct ao_list queue;
struct ao_list alarm_queue;
#endif
- uint8_t stack[AO_STACK_SIZE]; /* saved stack */
+ uint8_t stack[AO_STACK_SIZE] AO_STACK_ALIGNMENT; /* saved stack */
#if HAS_SAMPLE_PROFILE
uint32_t ticks;
uint32_t yields;
WARN_FLAGS=-Wall -Wextra -Werror
AO_CFLAGS=-I. -I../stm -I../kernel -I../drivers -I../math -I.. $(PDCLIB_INCLUDES)
-STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb \
+STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -Wcast-align \
-ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS)
LDFLAGS=-L../stm -Wl,-Taltos.ld
static inline void
ao_arch_init_stack(struct ao_task *task, void *start)
{
- uint32_t *sp = (uint32_t *) (task->stack + AO_STACK_SIZE);
+ uint32_t *sp = (uint32_t *) ((void*) task->stack + AO_STACK_SIZE);
uint32_t a = (uint32_t) start;
int i;
uint32_t *sp;
asm("mov %0,sp" : "=&r" (sp) );
ao_cur_task->sp = (sp);
- if ((uint8_t *) sp < &ao_cur_task->stack[0])
- ao_panic (AO_PANIC_STACK);
}
static inline void ao_arch_restore_stack(void) {
- uint32_t sp;
- sp = (uint32_t) ao_cur_task->sp;
-
/* Switch stacks */
- asm("mov sp, %0" : : "r" (sp) );
+ asm("mov sp, %0" : : "r" (ao_cur_task->sp) );
/* Restore PRIMASK */
asm("pop {r0}");
{
volatile uint32_t *addr;
- addr = (uint32_t *) (stm_eeprom + pos);
+ addr = (uint32_t *) (void *) (stm_eeprom + pos);
/* Write a word to a valid address in the data EEPROM */
*addr = w;
uint32_t w, *addr, mask;
uint8_t shift;
- addr = (uint32_t *) (stm_eeprom + (pos & ~3));
+ addr = (uint32_t *) (void *) (stm_eeprom + (pos & ~3));
/* Compute word to be written */
shift = (pos & 3) << 3;
static inline uint32_t *ao_usb_packet_buffer_addr(uint16_t sram_addr)
{
- return (uint32_t *) (stm_usb_sram + 2 * sram_addr);
+ return (uint32_t *) (((void *) ((uint8_t *) stm_usb_sram + 2 * sram_addr)));
}
static inline uint32_t ao_usb_epr_stat_rx(uint32_t epr) {
#define STM_USB_BDT_SIZE 8
-extern uint8_t stm_usb_sram[];
+extern uint8_t stm_usb_sram[] __attribute__ ((aligned(4)));
struct stm_exti {
vuint32_t imr;
ELFTOHEX=$(TOPDIR)/../ao-tools/ao-elftohex/ao-elftohex
CC=$(ARM_CC)
-WARN_FLAGS=-Wall -Wextra -Werror
+WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align
AO_CFLAGS=-I. -I$(TOPDIR)/stmf0 -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) -I$(TOPDIR)/math $(PDCLIB_INCLUDES)
STMF0_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb\
/* Total ring size in samples */
#define AO_ADC_RING_SIZE 256
-extern uint16_t ao_adc_ring[AO_ADC_RING_SIZE];
+extern uint16_t ao_adc_ring[AO_ADC_RING_SIZE] __attribute__((aligned(4)));
#define ao_adc_ring_step(pos,inc) (((pos) + (inc)) & (AO_ADC_RING_SIZE - 1))
static inline void
ao_arch_init_stack(struct ao_task *task, void *start)
{
- uint32_t *sp = (uint32_t *) (task->stack + AO_STACK_SIZE);
+ uint32_t *sp = (uint32_t *) ((void *) task->stack + AO_STACK_SIZE);
uint32_t a = (uint32_t) start;
int i;
static inline uint16_t *ao_usb_packet_buffer_addr(uint16_t sram_addr)
{
- return (uint16_t *) (stm_usb_sram + sram_addr);
+ return (uint16_t *) (void *) (stm_usb_sram + sram_addr);
}
static inline uint16_t ao_usb_packet_buffer_offset(uint16_t *addr)
#define STM_USB_BDT_SIZE 8
-extern uint8_t stm_usb_sram[];
+extern uint8_t stm_usb_sram[] __attribute__((aligned(4)));
struct stm_exti {
vuint32_t imr;