From f9a16861b92bc2f1150ef3968c898fedefa6ea80 Mon Sep 17 00:00:00 2001 From: Kelvin Lawson Date: Tue, 19 Jul 2011 23:19:21 +0100 Subject: [PATCH] Cosmetic changes for consistency with other architecture ports. --- ports/armv7a/arm_irq.h | 5 +-- ports/armv7a/arm_main.c | 52 ++++++++++++++++--------------- ports/armv7a/atomport-private.h | 54 +++++++++++++++++++++++++++++++++ ports/armv7a/atomport.c | 11 +++---- ports/armv7a/atomport.h | 19 +----------- 5 files changed, 90 insertions(+), 51 deletions(-) create mode 100644 ports/armv7a/atomport-private.h diff --git a/ports/armv7a/arm_irq.h b/ports/armv7a/arm_irq.h index 3defb6d..1c6dafb 100644 --- a/ports/armv7a/arm_irq.h +++ b/ports/armv7a/arm_irq.h @@ -30,8 +30,9 @@ #ifndef __ARM_IRQ_H #define __ARM_IRQ_H -#include -#include +#include "atomport.h" +#include "atomport-private.h" +#include "arm_defines.h" typedef int (*arm_irq_handler_t) (uint32_t irq_no, pt_regs_t * regs); diff --git a/ports/armv7a/arm_main.c b/ports/armv7a/arm_main.c index 5546e7d..5384233 100644 --- a/ports/armv7a/arm_main.c +++ b/ports/armv7a/arm_main.c @@ -27,14 +27,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include +#include "atom.h" +#include "atomport.h" +#include "atomtests.h" +#include "atomtimer.h" #include "system.h" -#include -#include -#include +#include "arm_irq.h" +#include "arm_timer.h" +#include "arm_uart.h" /* Constants */ @@ -169,11 +169,11 @@ int main ( void ) IDLE_STACK_SIZE_BYTES, 0); if (status == ATOM_OK) { - arm_irq_init(); + arm_irq_init(); - arm_timer_init(SYSTEM_TICKS_PER_SEC); + arm_timer_init(SYSTEM_TICKS_PER_SEC); - arm_uart_init(); + arm_uart_init(); /* Create an application thread */ status = atomThreadCreate(&main_tcb, @@ -182,23 +182,24 @@ int main ( void ) MAIN_STACK_SIZE_BYTES, 0); if (status == ATOM_OK) { - arm_timer_enable(); + arm_timer_enable(); - /** - * First application thread successfully created. It is - * now possible to start the OS. Execution will not return - * from atomOSStart(), which will restore the context of - * our application thread and start executing it. - * - * Note that interrupts are still disabled at this point. - * They will be enabled as we restore and execute our first - * thread in archFirstThreadRestore(). - */ - atomOSStart(); - } + /** + * First application thread successfully created. It is + * now possible to start the OS. Execution will not return + * from atomOSStart(), which will restore the context of + * our application thread and start executing it. + * + * Note that interrupts are still disabled at this point. + * They will be enabled as we restore and execute our first + * thread in archFirstThreadRestore(). + */ + atomOSStart(); + } } - while (1); + while (1) + ; /* There was an error starting the OS if we reach here */ return (0); @@ -227,5 +228,6 @@ static void main_thread_func (uint32_t data) } printk("Reset your board !!!!!"); /* Test finished so just hang !!! */ - while (1); + while (1) + ; } diff --git a/ports/armv7a/atomport-private.h b/ports/armv7a/atomport-private.h new file mode 100644 index 0000000..695777c --- /dev/null +++ b/ports/armv7a/atomport-private.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2011, Atomthreads Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. No personal names or organizations' names associated with the + * Atomthreads project may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __ATOMPORT_PRIVATE_H_ +#define __ATOMPORT_PRIVATE_H_ + +typedef unsigned int irq_flags_t; +typedef unsigned int virtual_addr_t; +typedef unsigned int virtual_size_t; +typedef unsigned int physical_addr_t; +typedef unsigned int physical_size_t; +typedef unsigned int clock_freq_t; +typedef unsigned long long jiffies_t; + +struct pt_regs { + uint32_t cpsr; // Current Program Status + uint32_t gpr[13]; // R0 - R12 + uint32_t sp; + uint32_t lr; + uint32_t pc; +} __attribute ((packed)) ; +typedef struct pt_regs pt_regs_t; + +/* Function prototypes */ +extern int archSetJump(pt_regs_t *regs, uint32_t *tmp); +extern void archLongJump(pt_regs_t *regs); + +#endif /* __ATOMPORT_PRIVATE_H_ */ diff --git a/ports/armv7a/atomport.c b/ports/armv7a/atomport.c index de52b49..8045a69 100644 --- a/ports/armv7a/atomport.c +++ b/ports/armv7a/atomport.c @@ -28,10 +28,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include +#include "atom.h" +#include "atomport.h" +#include "atomport-private.h" +#include "string.h" +#include "arm_defines.h" /** * This function initialises each thread's stack during creation, before the @@ -68,8 +69,6 @@ void archThreadContextInit (ATOM_TCB *tcb_ptr, void *stack_top, regs->pc = (uint32_t)entry_point; } -extern int archSetJump(pt_regs_t *regs, uint32_t *tmp); -extern void archLongJump(pt_regs_t *regs); /** * archFirstThreadRestore(ATOM_TCB *new_tcb) diff --git a/ports/armv7a/atomport.h b/ports/armv7a/atomport.h index 87a7bca..0730e21 100644 --- a/ports/armv7a/atomport.h +++ b/ports/armv7a/atomport.h @@ -59,24 +59,6 @@ #define POINTER void * #define UINT32 uint32_t -typedef unsigned int irq_flags_t; -typedef unsigned int virtual_addr_t; -typedef unsigned int virtual_size_t; -typedef unsigned int physical_addr_t; -typedef unsigned int physical_size_t; -typedef unsigned int clock_freq_t; -typedef unsigned long long jiffies_t; - -struct pt_regs { - uint32_t cpsr; // Current Program Status - uint32_t gpr[13]; // R0 - R12 - uint32_t sp; - uint32_t lr; - uint32_t pc; -} __attribute ((packed)) ; -typedef struct pt_regs pt_regs_t; - - /** * Critical region protection: this should disable interrupts * to protect OS data structures during modification. It must @@ -84,6 +66,7 @@ typedef struct pt_regs pt_regs_t; * be re-enabled when the outer CRITICAL_END() is reached. */ #include "arm_irq.h" +#include "atomport-private.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);