diff --git a/platforms/qemu_integratorcp/Makefile b/platforms/qemu_integratorcp/Makefile index e88e47d..cc54f51 100644 --- a/platforms/qemu_integratorcp/Makefile +++ b/platforms/qemu_integratorcp/Makefile @@ -44,7 +44,7 @@ include ../rules.mk run_test: clean all echo "START TEST $(TEST_NAME)" - qemu-system-arm -M integratorcp -kernel boot.elf -semihosting | tee atomthreads_test.out + qemu-system-arm -M integratorcp -kernel boot.elf -semihosting >> atomthreads_test.out all_tests: echo "Starting atomthreads test suite" > atomthreads_test.out @@ -87,5 +87,5 @@ all_tests: make run_test "TEST_NAME=sem9" run_last: - qemu-system-arm -M integratorcp -kernel boot.elf -monitor stdio -semihosting + qemu-system-arm -M integratorcp -kernel boot.elf -semihosting diff --git a/platforms/qemu_integratorcp/main.c b/platforms/qemu_integratorcp/main.c index 3222170..aebdd3d 100644 --- a/platforms/qemu_integratorcp/main.c +++ b/platforms/qemu_integratorcp/main.c @@ -77,8 +77,8 @@ main (void) printf ("atomthreads starting %s... ", ATOMTHREADS_TEST) ; - atomOSInit(&idle_stack[IDLE_STACK_BYTE_SIZE - sizeof(unsigned int)], IDLE_STACK_BYTE_SIZE - sizeof(unsigned int)) ; - atomThreadCreate ((ATOM_TCB *)&test_tcb, TEST_THREAD_PRIO, test_thread, 0, &test_stack[(TEST_STACK_BYTE_SIZE) - sizeof(unsigned int)], TEST_STACK_BYTE_SIZE - sizeof(unsigned int)); + atomOSInit(&idle_stack[0], IDLE_STACK_BYTE_SIZE, TRUE) ; + atomThreadCreate ((ATOM_TCB *)&test_tcb, TEST_THREAD_PRIO, test_thread, 0, &test_stack[0], TEST_STACK_BYTE_SIZE, TRUE); atomOSStart() ; return 0 ; diff --git a/platforms/qemu_lm3s/Makefile b/platforms/qemu_lm3s/Makefile index c8568ad..dc9c117 100644 --- a/platforms/qemu_lm3s/Makefile +++ b/platforms/qemu_lm3s/Makefile @@ -85,11 +85,11 @@ all_tests: make run_test "TEST_NAME=sem8" make run_test "TEST_NAME=sem9" -all_fail: +fail_tests: make run_test "TEST_NAME=mutex4" make run_test "TEST_NAME=sem4" run_last: - qemu-system-arm -M lm3s6965evb -kernel boot.elf -monitor stdio -semihosting + qemu-system-arm -M lm3s6965evb -kernel boot.elf -semihosting diff --git a/platforms/qemu_lm3s/main.c b/platforms/qemu_lm3s/main.c index 9aa5bdc..725a642 100644 --- a/platforms/qemu_lm3s/main.c +++ b/platforms/qemu_lm3s/main.c @@ -79,8 +79,8 @@ main (void) uint32_t failures ; printf ("Atomthreads starting %s... \r\n", ATOMTHREADS_TEST) ; - atomOSInit(&idle_stack[IDLE_STACK_BYTE_SIZE - sizeof(unsigned int)], IDLE_STACK_BYTE_SIZE - sizeof(unsigned int)) ; - atomThreadCreate ((ATOM_TCB *)&test_tcb, TEST_THREAD_PRIO, test_thread, 0, &test_stack[(TEST_STACK_BYTE_SIZE) - sizeof(unsigned int)], TEST_STACK_BYTE_SIZE - sizeof(unsigned int)); + atomOSInit(&idle_stack[0], IDLE_STACK_BYTE_SIZE, TRUE) ; + atomThreadCreate ((ATOM_TCB *)&test_tcb, TEST_THREAD_PRIO, test_thread, 0, &test_stack[0], TEST_STACK_BYTE_SIZE, TRUE); atomOSStart() ; return 0 ; diff --git a/ports/arm/atomport.h b/ports/arm/atomport.h index f7ac10d..f07e75a 100644 --- a/ports/arm/atomport.h +++ b/ports/arm/atomport.h @@ -32,8 +32,17 @@ #include "types.h" -#define SYSTEM_TICKS_PER_SEC 100 +#define SYSTEM_TICKS_PER_SEC 100 +/** + * Definition of NULL. + * If stddef.h is available on the platform it is simplest to include it + * from this header, otherwise define below. + */ +#define NULL ((void *)(0)) + +/* Size of each stack entry / stack alignment size (e.g. 32 bits) */ +#define STACK_ALIGN_SIZE sizeof(unsigned int) /** * Architecture-specific types. @@ -47,12 +56,17 @@ * Functions defined in atomport_arm.asm * */ -extern void contextInit (void) ; -extern uint32_t contextEnterCritical (void) ; -extern void contextExitCritical (uint32_t posture) ; +extern void contextInit (void) ; +extern uint32_t contextEnterCritical (void) ; +extern void contextExitCritical (uint32_t posture) ; -/* 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. + */ #define CRITICAL_STORE uint32_t __atom_critical #define CRITICAL_START() __atom_critical = contextEnterCritical() #define CRITICAL_END() contextExitCritical(__atom_critical) diff --git a/ports/cortex_m/atomport.h b/ports/cortex_m/atomport.h index f7ac10d..1a4cfd9 100644 --- a/ports/cortex_m/atomport.h +++ b/ports/cortex_m/atomport.h @@ -32,7 +32,23 @@ #include "types.h" -#define SYSTEM_TICKS_PER_SEC 100 +#define SYSTEM_TICKS_PER_SEC 100 + +/** + * Definition of NULL. + * If stddef.h is available on the platform it is simplest to include it + * from this header, otherwise define below. + */ +#define NULL ((void *)(0)) + +/* Size of each stack entry / stack alignment size (e.g. 32 bits) */ +#define STACK_ALIGN_SIZE sizeof(unsigned int) + +/** + * Architecture-specific types. + * Most of these are available from types.h on this platform, which is + * included above. + */ /** @@ -47,9 +63,9 @@ * Functions defined in atomport_arm.asm * */ -extern void contextInit (void) ; -extern uint32_t contextEnterCritical (void) ; -extern void contextExitCritical (uint32_t posture) ; +extern void contextInit (void) ; +extern uint32_t contextEnterCritical (void) ; +extern void contextExitCritical (uint32_t posture) ; /* Critical region protection */ @@ -58,3 +74,4 @@ extern void contextExitCritical (uint32_t posture) ; #define CRITICAL_END() contextExitCritical(__atom_critical) #endif /* __ATOM_PORT_H__ */ +