diff --git a/ports/armv7a/atomport-tests.h b/ports/armv7a/atomport-tests.h index d76e27d..cf3465a 100644 --- a/ports/armv7a/atomport-tests.h +++ b/ports/armv7a/atomport-tests.h @@ -33,8 +33,10 @@ /* Include Atomthreads kernel API */ #include "atom.h" +/* Prerequisite include for ATOMLOG() macro (via printf) */ +#include "printk.h" + /* Logger macro for viewing test results */ -/* FIXME: Add uart out routine once uart is supported */ #define ATOMLOG printk #define _STR diff --git a/ports/armv7a/atomport.h b/ports/armv7a/atomport.h index 487df12..87a7bca 100644 --- a/ports/armv7a/atomport.h +++ b/ports/armv7a/atomport.h @@ -31,17 +31,33 @@ #ifndef __ATOM_PORT_H #define __ATOM_PORT_H + /* Required number of system ticks per second (normally 100 for 10ms tick) */ #define SYSTEM_TICKS_PER_SEC 1000 -typedef signed int int32_t; -typedef signed short int16_t; -typedef signed char int8_t; -typedef unsigned int uint32_t; -typedef unsigned short uint16_t; -typedef unsigned char uint8_t; -typedef long long int64_t; -typedef unsigned long size_t; +/** + * Definition of NULL. stddef.h not available on this platform. + */ +#define NULL ((void *)(0)) + +/* Size of each stack entry / stack alignment size (32 bits on ARMv7A) */ +#define STACK_ALIGN_SIZE sizeof(uint32_t) + +/** + * Architecture-specific types. + * Provide stdint.h style types. + */ +#define uint8_t unsigned char +#define uint16_t unsigned short +#define uint32_t unsigned int +#define uint64_t unsigned long long +#define int8_t signed char +#define int16_t signed short +#define int32_t signed int +#define int64_t long long +#define size_t unsigned long +#define POINTER void * +#define UINT32 uint32_t typedef unsigned int irq_flags_t; typedef unsigned int virtual_addr_t; @@ -51,17 +67,6 @@ typedef unsigned int physical_size_t; typedef unsigned int clock_freq_t; typedef unsigned long long jiffies_t; -#define UINT32 uint32_t -#define STACK_ALIGN_SIZE sizeof(uint32_t) -#define NULL ((void *)(0)) - -/** - * Architecture-specific types. - * Most of these are available from stdint.h on this platform, which is - * included above. - */ -#define POINTER void * - struct pt_regs { uint32_t cpsr; // Current Program Status uint32_t gpr[13]; // R0 - R12 @@ -71,10 +76,14 @@ struct pt_regs { } __attribute ((packed)) ; typedef struct pt_regs pt_regs_t; -#include -#include -/* Critical region protection */ +/** + * Critical region protection: this should disable interrupts + * to protect OS data structures during modification. It must + * allow nested calls, which means that interrupts should only + * be re-enabled when the outer CRITICAL_END() is reached. + */ +#include "arm_irq.h" #define CRITICAL_STORE irq_flags_t status_flags #define CRITICAL_START() status_flags = arm_irq_save(); #define CRITICAL_END() arm_irq_restore(status_flags); @@ -82,4 +91,5 @@ typedef struct pt_regs pt_regs_t; /* Uncomment to enable stack-checking */ /* #define ATOM_STACK_CHECKING */ + #endif /* __ATOM_PORT_H */ diff --git a/ports/armv7a/printk.c b/ports/armv7a/printk.c index 99d137f..ea52ef3 100644 --- a/ports/armv7a/printk.c +++ b/ports/armv7a/printk.c @@ -28,10 +28,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include #include -#include +#include "system.h" +#include "atomport.h" +#include "printk.h" +#include "arm_uart.h" static int8_t buf[2048]; diff --git a/ports/armv7a/vsprintf.c b/ports/armv7a/vsprintf.c index c8819fd..0a89344 100644 --- a/ports/armv7a/vsprintf.c +++ b/ports/armv7a/vsprintf.c @@ -5,8 +5,8 @@ */ #include -#include -#include +#include "system.h" +#include "atomport.h" /* we use this so that we can do without the ctype library */ #define is_digit(c) ((c) >= '0' && (c) <= '9')