Changeset 371bd7d in mainline for kernel/arch/arm32


Ignore:
Timestamp:
2010-03-27T09:22:17Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
36a75a2
Parents:
cd82bb1 (diff), eaf22d4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/arch/arm32
Files:
4 added
29 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/Makefile.inc

    rcd82bb1 r371bd7d  
    2727#
    2828
    29 ## Toolchain configuration
    30 #
    31 
    3229BFD_NAME = elf32-littlearm
    3330BFD_ARCH = arm
    3431BFD = binary
    35 TARGET = arm-linux-gnu
    36 TOOLCHAIN_DIR = $(CROSS_PREFIX)/arm32
    3732
    3833ATSIGN = %
    3934
    40 GCC_CFLAGS += -fno-zero-initialized-in-bss
     35GCC_CFLAGS += -fno-zero-initialized-in-bss -mapcs-frame
    4136
    4237BITS = 32
     
    5752        arch/$(KARCH)/src/exception.c \
    5853        arch/$(KARCH)/src/userspace.c \
     54        arch/$(KARCH)/src/debug/stacktrace.c \
     55        arch/$(KARCH)/src/debug/stacktrace_asm.S \
    5956        arch/$(KARCH)/src/mm/as.c \
    6057        arch/$(KARCH)/src/mm/frame.c \
    6158        arch/$(KARCH)/src/mm/page.c \
    6259        arch/$(KARCH)/src/mm/tlb.c \
    63         arch/$(KARCH)/src/mm/page_fault.c
     60        arch/$(KARCH)/src/mm/page_fault.c \
     61        arch/$(KARCH)/src/ras.c
    6462
    6563ifeq ($(MACHINE),testarm)
  • kernel/arch/arm32/_link.ld.in

    rcd82bb1 r371bd7d  
    3434                *(.sdata);
    3535                *(.reginfo);
     36                . = ALIGN(8);
    3637                symbol_table = .;
    3738                *(symtab.*);
  • kernel/arch/arm32/include/asm.h

    rcd82bb1 r371bd7d  
    3838
    3939#include <typedefs.h>
    40 #include <arch/types.h>
    4140#include <arch/stack.h>
    4241#include <config.h>
     
    9695}
    9796
    98 extern void cpu_halt(void);
     97extern void cpu_halt(void) __attribute__((noreturn));
    9998extern void asm_delay_loop(uint32_t t);
    10099extern void userspace_asm(uintptr_t ustack, uintptr_t uspace_uarg,
  • kernel/arch/arm32/include/atomic.h

    rcd82bb1 r371bd7d  
    3737#define KERN_arm32_ATOMIC_H_
    3838
     39#include <arch/asm.h>
     40
    3941/** Atomic addition.
    4042 *
     
    4547 *
    4648 */
    47 static inline long atomic_add(atomic_t *val, int i)
     49static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    4850{
    49         int ret;
    50         volatile long *mem = &(val->count);
    51        
    52         asm volatile (
    53                 "1:\n"
    54                         "ldr r2, [%[mem]]\n"
    55                         "add r3, r2, %[i]\n"
    56                         "str r3, %[ret]\n"
    57                         "swp r3, r3, [%[mem]]\n"
    58                         "cmp r3, r2\n"
    59                         "bne 1b\n"
    60                 : [ret] "=m" (ret)
    61                 : [mem] "r" (mem), [i] "r" (i)
    62                 : "r3", "r2"
    63         );
     51        /*
     52         * This implementation is for UP pre-ARMv6 systems where we do not have
     53         * the LDREX and STREX instructions.
     54         */
     55        ipl_t ipl = interrupts_disable();
     56        val->count += i;
     57        atomic_count_t ret = val->count;
     58        interrupts_restore(ipl);
    6459       
    6560        return ret;
     
    6964 *
    7065 * @param val Variable to be incremented.
     66 *
    7167 */
    7268static inline void atomic_inc(atomic_t *val)
     
    7874 *
    7975 * @param val Variable to be decremented.
     76 *
    8077 */
    8178static inline void atomic_dec(atomic_t *val) {
     
    8784 * @param val Variable to be incremented.
    8885 * @return    Value after incrementation.
     86 *
    8987 */
    90 static inline long atomic_preinc(atomic_t *val)
     88static inline atomic_count_t atomic_preinc(atomic_t *val)
    9189{
    9290        return atomic_add(val, 1);
     
    9795 * @param val Variable to be decremented.
    9896 * @return    Value after decrementation.
     97 *
    9998 */
    100 static inline long atomic_predec(atomic_t *val)
     99static inline atomic_count_t atomic_predec(atomic_t *val)
    101100{
    102101        return atomic_add(val, -1);
     
    107106 * @param val Variable to be incremented.
    108107 * @return    Value before incrementation.
     108 *
    109109 */
    110 static inline long atomic_postinc(atomic_t *val)
     110static inline atomic_count_t atomic_postinc(atomic_t *val)
    111111{
    112112        return atomic_add(val, 1) - 1;
     
    117117 * @param val Variable to be decremented.
    118118 * @return    Value before decrementation.
     119 *
    119120 */
    120 static inline long atomic_postdec(atomic_t *val)
     121static inline atomic_count_t atomic_postdec(atomic_t *val)
    121122{
    122123        return atomic_add(val, -1) + 1;
  • kernel/arch/arm32/include/context.h

    rcd82bb1 r371bd7d  
    4343#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4444
     45#define context_set(c, _pc, stack, size) \
     46        do { \
     47                (c)->pc = (uintptr_t) (_pc); \
     48                (c)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \
     49                (c)->fp = 0; \
     50        } while (0)
     51
    4552#ifndef __ASM__
    4653
    47 #include <arch/types.h>
     54#include <typedefs.h>
    4855
    4956/** Thread context containing registers that must be preserved across function
     
    6269        uint32_t r9;
    6370        uint32_t r10;
    64         uint32_t r11;
     71        uint32_t fp;    /* r11 */
    6572       
    6673        ipl_t ipl;
  • kernel/arch/arm32/include/cpu.h

    rcd82bb1 r371bd7d  
    3737#define KERN_arm32_CPU_H_
    3838
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040#include <arch/asm.h>
    4141
  • kernel/arch/arm32/include/exception.h

    rcd82bb1 r371bd7d  
    3838#define KERN_arm32_EXCEPTION_H_
    3939
    40 #include <arch/types.h>
     40#include <typedefs.h>
    4141#include <arch/regutils.h>
    4242
     
    8686
    8787/** Struct representing CPU state saved when an exception occurs. */
    88 typedef struct {
     88typedef struct istate {
    8989        uint32_t spsr;
    9090        uint32_t sp;
     
    102102        uint32_t r9;
    103103        uint32_t r10;
    104         uint32_t r11;
     104        uint32_t fp;
    105105        uint32_t r12;
    106106
     
    133133}
    134134
     135static inline unative_t istate_get_fp(istate_t *istate)
     136{
     137        return istate->fp;
     138}
     139
    135140
    136141extern void install_exception_handlers(void);
  • kernel/arch/arm32/include/faddr.h

    rcd82bb1 r371bd7d  
    3737#define KERN_arm32_FADDR_H_
    3838
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040
    4141/** Calculate absolute address of function referenced by fptr pointer.
  • kernel/arch/arm32/include/fpu_context.h

    rcd82bb1 r371bd7d  
    3939#define KERN_arm32_FPU_CONTEXT_H_
    4040
    41 #include <arch/types.h>
     41#include <typedefs.h>
    4242
    4343#define FPU_CONTEXT_ALIGN    0
  • kernel/arch/arm32/include/interrupt.h

    rcd82bb1 r371bd7d  
    3737#define KERN_arm32_INTERRUPT_H_
    3838
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040#include <arch/exception.h>
    4141
  • kernel/arch/arm32/include/machine_func.h

    rcd82bb1 r371bd7d  
    4343
    4444#include <console/console.h>
    45 #include <arch/types.h>
     45#include <typedefs.h>
    4646#include <arch/exception.h>
    4747
  • kernel/arch/arm32/include/memstr.h

    rcd82bb1 r371bd7d  
    2727 */
    2828
    29 /** @addtogroup arm32   
     29/** @addtogroup arm32
    3030 * @{
    3131 */
     
    3939#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
    4040
    41 extern void memsetw(void *dst, size_t cnt, uint16_t x);
    42 extern void memsetb(void *dst, size_t cnt, uint8_t x);
    43 
    44 extern int memcmp(const void *a, const void *b, size_t cnt);
     41extern void memsetw(void *, size_t, uint16_t);
     42extern void memsetb(void *, size_t, uint8_t);
    4543
    4644#endif
  • kernel/arch/arm32/include/mm/as.h

    rcd82bb1 r371bd7d  
    5454#define as_destructor_arch(as)                  (as != as)
    5555#define as_create_arch(as, flags)               (as != as)
    56 #define as_install_arch(as)
    5756#define as_deinstall_arch(as)
    5857#define as_invalidate_translation_cache(as, page, cnt)
  • kernel/arch/arm32/include/mm/asid.h

    rcd82bb1 r371bd7d  
    3939#define KERN_arm32_ASID_H_
    4040
    41 #include <arch/types.h>
     41#include <typedefs.h>
    4242
    4343#define ASID_MAX_ARCH           3       /* minimal required number */
  • kernel/arch/arm32/include/mm/frame.h

    rcd82bb1 r371bd7d  
    4343#ifndef __ASM__
    4444
    45 #include <arch/types.h>
     45#include <typedefs.h>
    4646
    4747#define BOOT_PAGE_TABLE_SIZE     0x4000
  • kernel/arch/arm32/include/mm/page_fault.h

    rcd82bb1 r371bd7d  
    3737#define KERN_arm32_PAGE_FAULT_H_
    3838
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040
    4141
  • kernel/arch/arm32/include/types.h

    rcd82bb1 r371bd7d  
    2727 */
    2828
    29 /** @addtogroup arm32   
     29/** @addtogroup arm32
    3030 * @{
    3131 */
     
    3838
    3939#ifndef DOXYGEN
    40 #       define ATTRIBUTE_PACKED __attribute__ ((packed))
     40        #define ATTRIBUTE_PACKED __attribute__((packed))
    4141#else
    42 #       define ATTRIBUTE_PACKED
     42        #define ATTRIBUTE_PACKED
    4343#endif
    44 
    45 typedef signed char int8_t;
    46 typedef signed short int16_t;
    47 typedef signed long int32_t;
    48 typedef signed long long int64_t;
    49 
    50 typedef unsigned char uint8_t;
    51 typedef unsigned short uint16_t;
    52 typedef unsigned long uint32_t;
    53 typedef unsigned long long uint64_t;
    5444
    5545typedef uint32_t size_t;
     
    6252typedef uint32_t unative_t;
    6353typedef int32_t native_t;
     54typedef uint32_t atomic_count_t;
    6455
    6556typedef struct {
    6657} fncptr_t;
    6758
    68 #define PRIp "x"        /**< Format for uintptr_t. */
    69 #define PRIs "u"        /**< Format for size_t. */
     59#define PRIp "x"  /**< Format for uintptr_t. */
     60#define PRIs "u"  /**< Format for size_t. */
    7061
    71 #define PRId8 "d"       /**< Format for int8_t. */
    72 #define PRId16 "d"      /**< Format for int16_t. */
    73 #define PRId32 "d"      /**< Format for int32_t. */
    74 #define PRId64 "lld"    /**< Format for int64_t. */
    75 #define PRIdn "d"       /**< Format for native_t. */
     62#define PRId8 "d"     /**< Format for int8_t. */
     63#define PRId16 "d"    /**< Format for int16_t. */
     64#define PRId32 "d"    /**< Format for int32_t. */
     65#define PRId64 "lld"  /**< Format for int64_t. */
     66#define PRIdn "d"     /**< Format for native_t. */
    7667
    77 #define PRIu8 "u"       /**< Format for uint8_t. */
    78 #define PRIu16 "u"      /**< Format for uint16_t. */
    79 #define PRIu32 "u"      /**< Format for uint32_t. */
    80 #define PRIu64 "llu"    /**< Format for uint64_t. */
    81 #define PRIun "u"       /**< Format for unative_t. */
     68#define PRIu8 "u"     /**< Format for uint8_t. */
     69#define PRIu16 "u"    /**< Format for uint16_t. */
     70#define PRIu32 "u"    /**< Format for uint32_t. */
     71#define PRIu64 "llu"  /**< Format for uint64_t. */
     72#define PRIun "u"     /**< Format for unative_t. */
    8273
    83 #define PRIx8 "x"       /**< Format for hexadecimal (u)int8_t. */
    84 #define PRIx16 "x"      /**< Format for hexadecimal (u)int16_t. */
    85 #define PRIx32 "x"      /**< Format for hexadecimal (u)uint32_t. */
    86 #define PRIx64 "llx"    /**< Format for hexadecimal (u)int64_t. */
    87 #define PRIxn "x"       /**< Format for hexadecimal (u)native_t. */
     74#define PRIx8 "x"     /**< Format for hexadecimal (u)int8_t. */
     75#define PRIx16 "x"    /**< Format for hexadecimal (u)int16_t. */
     76#define PRIx32 "x"    /**< Format for hexadecimal (u)uint32_t. */
     77#define PRIx64 "llx"  /**< Format for hexadecimal (u)int64_t. */
     78#define PRIxn "x"     /**< Format for hexadecimal (u)native_t. */
    8879
    8980#endif
  • kernel/arch/arm32/src/arm32.c

    rcd82bb1 r371bd7d  
    4747#include <userspace.h>
    4848#include <macros.h>
    49 #include <string.h>
     49#include <str.h>
     50#include <arch/ras.h>
    5051
    5152#ifdef MACHINE_testarm
     
    8889        exception_init();
    8990        interrupt_init();
     91
     92        /* Initialize Restartable Atomic Sequences support. */
     93        ras_init();
    9094       
    9195        machine_output_init();
     
    136140        uint8_t *stck;
    137141       
    138         tlb_invalidate_all();
    139142        stck = &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA];
    140143        supervisor_sp = (uintptr_t) stck;
     
    152155void cpu_halt(void)
    153156{
    154         machine_cpu_halt();
     157        while (true)
     158                machine_cpu_halt();
    155159}
    156160
     
    159163{
    160164        /* not implemented */
    161         while (1);
     165        while (true);
    162166}
    163167
     
    176180}
    177181
     182void irq_initialize_arch(irq_t *irq)
     183{
     184        (void) irq;
     185}
     186
    178187/** @}
    179188 */
  • kernel/arch/arm32/src/cpu/cpu.c

    rcd82bb1 r371bd7d  
    4343
    4444/** Implementators (vendor) names */
    45 static char *imp_data[] = {
     45static const char *imp_data[] = {
    4646        "?",                                    /* IMP_DATA_START_OFFSET */
    4747        "ARM Ltd",                              /* 0x41 */
     
    6060
    6161/** Architecture names */
    62 static char *arch_data[] = {
     62static const char *arch_data[] = {
    6363        "?",       /* 0x0 */
    6464        "4",       /* 0x1 */
     
    108108void cpu_print_report(cpu_t *m)
    109109{
    110         char * vendor = imp_data[0];
    111         char * architecture = arch_data[0];
     110        const char *vendor = imp_data[0];
     111        const char *architecture = arch_data[0];
    112112        cpu_arch_t * cpu_arch = &m->arch;
    113113
  • kernel/arch/arm32/src/ddi/ddi.c

    rcd82bb1 r371bd7d  
    3636#include <ddi/ddi.h>
    3737#include <proc/task.h>
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939
    4040/** Enable I/O space range for task.
  • kernel/arch/arm32/src/dummy.S

    rcd82bb1 r371bd7d  
    11#
    2 # Copyright (c) 2007 Michal Kebry, Pavel Jancik, Petr Stepan
     2# Copyright (c) 2007 Michal Kebrt, Pavel Jancik, Petr Stepan
    33# All rights reserved.
    44#
  • kernel/arch/arm32/src/exc_handler.S

    rcd82bb1 r371bd7d  
    123123        stmfd r13!, {r2}
    1241242:
     125        # Stop stack traces here
     126        mov fp, #0
    125127.endm
    126128
     
    148150        mov r0, #0
    149151        mov r1, r13
    150         bl exc_dispatch
     152        bl ras_check
    151153        LOAD_REGS_FROM_STACK
    152154
     
    156158        mov r0, #5
    157159        mov r1, r13
    158         bl exc_dispatch
     160        bl ras_check
    159161        LOAD_REGS_FROM_STACK
    160162
     
    164166        mov r0, #6
    165167        mov r1, r13
    166         bl exc_dispatch
     168        bl ras_check
    167169        LOAD_REGS_FROM_STACK
    168170
     
    171173        mov r0, #1
    172174        mov r1, r13
    173         bl exc_dispatch
     175        bl ras_check
    174176        LOAD_REGS_FROM_STACK
    175177
     
    179181        mov r0, #3
    180182        mov r1, r13
    181         bl exc_dispatch
     183        bl ras_check
    182184        LOAD_REGS_FROM_STACK
    183185
     
    187189        mov r0, #4
    188190        mov r1, r13
    189         bl exc_dispatch
     191        bl ras_check
    190192        LOAD_REGS_FROM_STACK
    191193
     
    195197        mov r0, #2
    196198        mov r1, r13
    197         bl exc_dispatch
    198         LOAD_REGS_FROM_STACK
    199 
     199        bl ras_check
     200        LOAD_REGS_FROM_STACK
     201
  • kernel/arch/arm32/src/exception.c

    rcd82bb1 r371bd7d  
    4242#include <print.h>
    4343#include <syscall/syscall.h>
     44#include <stacktrace.h>
    4445
    4546#ifdef MACHINE_testarm
     
    183184        printf(" r4: %x    r5: %x    r6: %x    r7: %x\n",
    184185            istate->r4, istate->r5, istate->r6, istate->r7);
    185         printf(" r8: %x    r8: %x   r10: %x   r11: %x\n",
    186             istate->r8, istate->r9, istate->r10, istate->r11);
     186        printf(" r8: %x    r8: %x   r10: %x    fp: %x\n",
     187            istate->r8, istate->r9, istate->r10, istate->fp);
    187188        printf(" r12: %x    sp: %x    lr: %x  spsr: %x\n",
    188189            istate->r12, istate->sp, istate->lr, istate->spsr);
    189190       
    190191        printf(" pc: %x\n", istate->pc);
     192
     193        stack_trace_istate(istate);
    191194}
    192195
  • kernel/arch/arm32/src/mm/as.c

    rcd82bb1 r371bd7d  
    3636#include <arch/mm/as.h>
    3737#include <genarch/mm/as_pt.h>
     38#include <genarch/mm/page_pt.h>
    3839#include <genarch/mm/asid_fifo.h>
    3940#include <mm/as.h>
     41#include <mm/tlb.h>
    4042#include <arch.h>
    4143
     
    4951}
    5052
     53void as_install_arch(as_t *as)
     54{
     55        tlb_invalidate_all();
     56}
     57
    5158/** @}
    5259 */
  • kernel/arch/arm32/src/mm/page.c

    rcd82bb1 r371bd7d  
    4141#include <arch/exception.h>
    4242#include <typedefs.h>
    43 #include <arch/types.h>
    4443#include <interrupt.h>
    4544#include <arch/mm/frame.h>
     
    8887            KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) {
    8988                panic("Unable to map physical memory %p (%d bytes).",
    90                     physaddr, size)
     89                    physaddr, size);
    9190        }
    9291       
  • kernel/arch/arm32/src/mm/page_fault.c

    rcd82bb1 r371bd7d  
    181181
    182182        if (ret == AS_PF_FAULT) {
     183                fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr);
    183184                print_istate(istate);
    184185                printf("page fault - pc: %x, va: %x, status: %x(%x), "
     
    186187                    access);
    187188               
    188                 fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr);
    189189                panic("Page fault.");
    190190        }
  • kernel/arch/arm32/src/mm/tlb.c

    rcd82bb1 r371bd7d  
    3737#include <arch/mm/asid.h>
    3838#include <arch/asm.h>
    39 #include <arch/types.h>
     39#include <typedefs.h>
    4040#include <arch/mm/page.h>
    4141
  • kernel/arch/arm32/src/start.S

    rcd82bb1 r371bd7d  
    6969        bl arch_pre_main
    7070       
     71        #
     72        # Create the first stack frame.
     73        #
     74        mov fp, #0
     75        mov ip, sp
     76        push {fp, ip, lr, pc}
     77        sub fp, ip, #4
     78
    7179        bl main_bsp
    7280
  • kernel/arch/arm32/src/userspace.c

    rcd82bb1 r371bd7d  
    3535
    3636#include <userspace.h>
     37#include <arch/ras.h>
    3738
    3839/** Struct for holding all general purpose registers.
     
    7475        ustate.r1 = 0;
    7576
     77        /* pass the RAS page address in %r2 */
     78        ustate.r2 = (uintptr_t) ras_page;
     79
    7680        /* clear other registers */
    77         ustate.r2 = ustate.r3  = ustate.r4  = ustate.r5 =
    78             ustate.r6  = ustate.r7  = ustate.r8  = ustate.r9 = ustate.r10 =
    79             ustate.r11 = ustate.r12 = ustate.lr = 0;
     81        ustate.r3  = ustate.r4  = ustate.r5 = ustate.r6 = ustate.r7 =
     82            ustate.r8 = ustate.r9 = ustate.r10 = ustate.r11 = ustate.r12 =
     83            ustate.lr = 0;
    8084
    8185        /* set user stack */
Note: See TracChangeset for help on using the changeset viewer.