Changeset c621f4aa in mainline for kernel/arch/arm32
- Timestamp:
- 2010-07-25T10:11:13Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 377cce8
- Parents:
- 24a2517 (diff), a2da43c (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. - Location:
- kernel/arch/arm32
- Files:
-
- 2 added
- 41 edited
-
Makefile.inc (modified) (3 diffs)
-
_link.ld.in (modified) (1 diff)
-
include/arch.h (modified) (1 diff)
-
include/asm.h (modified) (3 diffs)
-
include/atomic.h (modified) (9 diffs)
-
include/context.h (modified) (1 diff)
-
include/cpu.h (modified) (1 diff)
-
include/cycle.h (modified) (1 diff)
-
include/exception.h (modified) (8 diffs)
-
include/faddr.h (modified) (2 diffs)
-
include/fpu_context.h (modified) (1 diff)
-
include/interrupt.h (modified) (2 diffs)
-
include/mach/gta02/gta02.h (added)
-
include/mach/integratorcp/integratorcp.h (modified) (2 diffs)
-
include/mach/testarm/testarm.h (modified) (2 diffs)
-
include/machine_func.h (modified) (4 diffs)
-
include/memstr.h (modified) (2 diffs)
-
include/mm/asid.h (modified) (1 diff)
-
include/mm/frame.h (modified) (1 diff)
-
include/mm/page.h (modified) (9 diffs)
-
include/mm/page_fault.h (modified) (2 diffs)
-
include/mm/tlb.h (modified) (1 diff)
-
include/ras.h (modified) (2 diffs)
-
include/types.h (modified) (3 diffs)
-
src/arm32.c (modified) (1 diff)
-
src/asm.S (modified) (3 diffs)
-
src/cpu/cpu.c (modified) (3 diffs)
-
src/ddi/ddi.c (modified) (1 diff)
-
src/debug/stacktrace.c (modified) (4 diffs)
-
src/dummy.S (modified) (1 diff)
-
src/exc_handler.S (modified) (9 diffs)
-
src/exception.c (modified) (6 diffs)
-
src/interrupt.c (modified) (3 diffs)
-
src/mach/gta02/gta02.c (added)
-
src/mach/integratorcp/integratorcp.c (modified) (3 diffs)
-
src/mach/testarm/testarm.c (modified) (3 diffs)
-
src/machine_func.c (modified) (7 diffs)
-
src/mm/frame.c (modified) (2 diffs)
-
src/mm/page.c (modified) (6 diffs)
-
src/mm/page_fault.c (modified) (3 diffs)
-
src/mm/tlb.c (modified) (1 diff)
-
src/ras.c (modified) (3 diffs)
-
src/userspace.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/Makefile.inc
r24a2517 rc621f4aa 27 27 # 28 28 29 ## Toolchain configuration30 #31 32 29 BFD_NAME = elf32-littlearm 33 30 BFD_ARCH = arm 34 31 BFD = binary 35 TARGET = arm-linux-gnu36 TOOLCHAIN_DIR = $(CROSS_PREFIX)/arm3237 32 38 33 ATSIGN = % … … 51 46 arch/$(KARCH)/src/context.S \ 52 47 arch/$(KARCH)/src/dummy.S \ 53 arch/$(KARCH)/src/panic.S \54 48 arch/$(KARCH)/src/cpu/cpu.c \ 55 49 arch/$(KARCH)/src/ddi/ddi.c \ … … 66 60 arch/$(KARCH)/src/ras.c 67 61 62 ifeq ($(MACHINE),gta02) 63 ARCH_SOURCES += arch/$(KARCH)/src/mach/gta02/gta02.c 64 endif 65 68 66 ifeq ($(MACHINE),testarm) 69 67 ARCH_SOURCES += arch/$(KARCH)/src/mach/testarm/testarm.c -
kernel/arch/arm32/_link.ld.in
r24a2517 rc621f4aa 7 7 */ 8 8 9 #define KERNEL_LOAD_ADDRESS 0x80200000 9 #ifdef MACHINE_gta02 10 #define KERNEL_LOAD_ADDRESS 0xb0a08000 11 #else 12 #define KERNEL_LOAD_ADDRESS 0x80a00000 13 #endif 10 14 11 15 OUTPUT_ARCH(arm) -
kernel/arch/arm32/include/arch.h
r24a2517 rc621f4aa 45 45 46 46 typedef struct { 47 uintptr_taddr;48 uint32_t size;47 void *addr; 48 size_t size; 49 49 char name[BOOTINFO_TASK_NAME_BUFLEN]; 50 50 } utask_t; 51 51 52 52 typedef struct { 53 uint32_t cnt;53 size_t cnt; 54 54 utask_t tasks[TASKMAP_MAX_RECORDS]; 55 55 } bootinfo_t; -
kernel/arch/arm32/include/asm.h
r24a2517 rc621f4aa 38 38 39 39 #include <typedefs.h> 40 #include <arch/types.h>41 40 #include <arch/stack.h> 42 41 #include <config.h> 43 42 #include <arch/interrupt.h> 43 #include <trace.h> 44 44 45 45 /** No such instruction on ARM to sleep CPU. */ 46 static inline void cpu_sleep(void)46 NO_TRACE static inline void cpu_sleep(void) 47 47 { 48 48 } 49 49 50 static inline void pio_write_8(ioport8_t *port, uint8_t v)50 NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v) 51 51 { 52 52 *port = v; 53 53 } 54 54 55 static inline void pio_write_16(ioport16_t *port, uint16_t v)55 NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v) 56 56 { 57 57 *port = v; 58 58 } 59 59 60 static inline void pio_write_32(ioport32_t *port, uint32_t v)60 NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v) 61 61 { 62 62 *port = v; 63 63 } 64 64 65 static inline uint8_t pio_read_8(ioport8_t *port)65 NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port) 66 66 { 67 67 return *port; 68 68 } 69 69 70 static inline uint16_t pio_read_16(ioport16_t *port)70 NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port) 71 71 { 72 72 return *port; 73 73 } 74 74 75 static inline uint32_t pio_read_32(ioport32_t *port)75 NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port) 76 76 { 77 77 return *port; … … 85 85 * 86 86 */ 87 static inline uintptr_t get_stack_base(void)87 NO_TRACE static inline uintptr_t get_stack_base(void) 88 88 { 89 89 uintptr_t v; 90 90 91 asm volatile ( 91 92 "and %[v], sp, %[size]\n" … … 93 94 : [size] "r" (~(STACK_SIZE - 1)) 94 95 ); 96 95 97 return v; 96 98 } -
kernel/arch/arm32/include/atomic.h
r24a2517 rc621f4aa 38 38 39 39 #include <arch/asm.h> 40 #include <trace.h> 40 41 41 42 /** Atomic addition. … … 47 48 * 48 49 */ 49 static inline long atomic_add(atomic_t *val, int i) 50 NO_TRACE static inline atomic_count_t atomic_add(atomic_t *val, 51 atomic_count_t i) 50 52 { 51 long ret;52 53 53 /* 54 54 * This implementation is for UP pre-ARMv6 systems where we do not have … … 57 57 ipl_t ipl = interrupts_disable(); 58 58 val->count += i; 59 ret = val->count;59 atomic_count_t ret = val->count; 60 60 interrupts_restore(ipl); 61 61 … … 66 66 * 67 67 * @param val Variable to be incremented. 68 * 68 69 */ 69 static inline void atomic_inc(atomic_t *val)70 NO_TRACE static inline void atomic_inc(atomic_t *val) 70 71 { 71 72 atomic_add(val, 1); … … 75 76 * 76 77 * @param val Variable to be decremented. 78 * 77 79 */ 78 static inline void atomic_dec(atomic_t *val) {80 NO_TRACE static inline void atomic_dec(atomic_t *val) { 79 81 atomic_add(val, -1); 80 82 } … … 84 86 * @param val Variable to be incremented. 85 87 * @return Value after incrementation. 88 * 86 89 */ 87 static inline longatomic_preinc(atomic_t *val)90 NO_TRACE static inline atomic_count_t atomic_preinc(atomic_t *val) 88 91 { 89 92 return atomic_add(val, 1); … … 94 97 * @param val Variable to be decremented. 95 98 * @return Value after decrementation. 99 * 96 100 */ 97 static inline longatomic_predec(atomic_t *val)101 NO_TRACE static inline atomic_count_t atomic_predec(atomic_t *val) 98 102 { 99 103 return atomic_add(val, -1); … … 104 108 * @param val Variable to be incremented. 105 109 * @return Value before incrementation. 110 * 106 111 */ 107 static inline longatomic_postinc(atomic_t *val)112 NO_TRACE static inline atomic_count_t atomic_postinc(atomic_t *val) 108 113 { 109 114 return atomic_add(val, 1) - 1; … … 114 119 * @param val Variable to be decremented. 115 120 * @return Value before decrementation. 121 * 116 122 */ 117 static inline longatomic_postdec(atomic_t *val)123 NO_TRACE static inline atomic_count_t atomic_postdec(atomic_t *val) 118 124 { 119 125 return atomic_add(val, -1) + 1; -
kernel/arch/arm32/include/context.h
r24a2517 rc621f4aa 52 52 #ifndef __ASM__ 53 53 54 #include < arch/types.h>54 #include <typedefs.h> 55 55 56 56 /** Thread context containing registers that must be preserved across function -
kernel/arch/arm32/include/cpu.h
r24a2517 rc621f4aa 37 37 #define KERN_arm32_CPU_H_ 38 38 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 #include <arch/asm.h> 41 41 -
kernel/arch/arm32/include/cycle.h
r24a2517 rc621f4aa 37 37 #define KERN_arm32_CYCLE_H_ 38 38 39 /** Returns count of CPU cycles. 39 #include <trace.h> 40 41 /** Return count of CPU cycles. 40 42 * 41 * No such instruction on ARM to get count of cycles.43 * No such instruction on ARM to get count of cycles. 42 44 * 43 * @return Count of CPU cycles. 45 * @return Count of CPU cycles. 46 * 44 47 */ 45 static inline uint64_t get_cycle(void)48 NO_TRACE static inline uint64_t get_cycle(void) 46 49 { 47 50 return 0; -
kernel/arch/arm32/include/exception.h
r24a2517 rc621f4aa 28 28 */ 29 29 30 /** @addtogroup arm32 30 /** @addtogroup arm32 31 31 * @{ 32 32 */ … … 38 38 #define KERN_arm32_EXCEPTION_H_ 39 39 40 #include < arch/types.h>40 #include <typedefs.h> 41 41 #include <arch/regutils.h> 42 #include <trace.h> 42 43 43 44 /** If defined, forces using of high exception vectors. */ … … 45 46 46 47 #ifdef HIGH_EXCEPTION_VECTORS 47 #define EXC_BASE_ADDRESS 0xffff000048 #define EXC_BASE_ADDRESS 0xffff0000 48 49 #else 49 #define EXC_BASE_ADDRESS 0x050 #define EXC_BASE_ADDRESS 0x0 50 51 #endif 51 52 52 53 /* Exception Vectors */ 53 #define EXC_RESET_VEC (EXC_BASE_ADDRESS + 0x0)54 #define EXC_UNDEF_INSTR_VEC (EXC_BASE_ADDRESS + 0x4)55 #define EXC_SWI_VEC (EXC_BASE_ADDRESS + 0x8)56 #define EXC_PREFETCH_ABORT_VEC (EXC_BASE_ADDRESS + 0xc)57 #define EXC_DATA_ABORT_VEC (EXC_BASE_ADDRESS + 0x10)58 #define EXC_IRQ_VEC (EXC_BASE_ADDRESS + 0x18)59 #define EXC_FIQ_VEC (EXC_BASE_ADDRESS + 0x1c)54 #define EXC_RESET_VEC (EXC_BASE_ADDRESS + 0x0) 55 #define EXC_UNDEF_INSTR_VEC (EXC_BASE_ADDRESS + 0x4) 56 #define EXC_SWI_VEC (EXC_BASE_ADDRESS + 0x8) 57 #define EXC_PREFETCH_ABORT_VEC (EXC_BASE_ADDRESS + 0xc) 58 #define EXC_DATA_ABORT_VEC (EXC_BASE_ADDRESS + 0x10) 59 #define EXC_IRQ_VEC (EXC_BASE_ADDRESS + 0x18) 60 #define EXC_FIQ_VEC (EXC_BASE_ADDRESS + 0x1c) 60 61 61 62 /* Exception numbers */ … … 68 69 #define EXC_FIQ 6 69 70 70 71 71 /** Kernel stack pointer. 72 72 * 73 73 * It is set when thread switches to user mode, 74 74 * and then used for exception handling. 75 * 75 76 */ 76 77 extern uintptr_t supervisor_sp; 77 78 78 79 79 /** Temporary exception stack pointer. … … 81 81 * Temporary stack is used in exceptions handling routines 82 82 * before switching to thread's kernel stack. 83 * 83 84 */ 84 85 extern uintptr_t exc_stack; 85 86 86 87 87 /** Struct representing CPU state saved when an exception occurs. */ … … 90 90 uint32_t sp; 91 91 uint32_t lr; 92 92 93 93 uint32_t r0; 94 94 uint32_t r1; … … 104 104 uint32_t fp; 105 105 uint32_t r12; 106 106 107 107 uint32_t pc; 108 108 } istate_t; 109 109 110 111 /** Sets Program Counter member of given istate structure. 110 /** Set Program Counter member of given istate structure. 112 111 * 113 * @param istate istate structure112 * @param istate istate structure 114 113 * @param retaddr new value of istate's PC member 114 * 115 115 */ 116 static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr) 116 NO_TRACE static inline void istate_set_retaddr(istate_t *istate, 117 uintptr_t retaddr) 117 118 { 118 istate->pc = retaddr;119 istate->pc = retaddr; 119 120 } 120 121 121 122 /** Returns true if exception happened while in userspace. */ 123 static inline int istate_from_uspace(istate_t *istate) 122 /** Return true if exception happened while in userspace. */ 123 NO_TRACE static inline int istate_from_uspace(istate_t *istate) 124 124 { 125 return (istate->spsr & STATUS_REG_MODE_MASK) == USER_MODE;125 return (istate->spsr & STATUS_REG_MODE_MASK) == USER_MODE; 126 126 } 127 127 128 129 /** Returns Program Counter member of given istate structure. */ 130 static inline unative_t istate_get_pc(istate_t *istate) 128 /** Return Program Counter member of given istate structure. */ 129 NO_TRACE static inline unative_t istate_get_pc(istate_t *istate) 131 130 { 132 return istate->pc;131 return istate->pc; 133 132 } 134 133 135 static inline unative_t istate_get_fp(istate_t *istate)134 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate) 136 135 { 137 136 return istate->fp; 138 137 } 139 138 140 141 139 extern void install_exception_handlers(void); 142 140 extern void exception_init(void); 143 extern void print_istate(istate_t *istate);144 141 extern void reset_exception_entry(void); 145 142 extern void irq_exception_entry(void); … … 150 147 extern void swi_exception_entry(void); 151 148 152 153 149 #endif 154 150 -
kernel/arch/arm32/include/faddr.h
r24a2517 rc621f4aa 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ … … 37 37 #define KERN_arm32_FADDR_H_ 38 38 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 41 41 /** Calculate absolute address of function referenced by fptr pointer. 42 42 * 43 43 * @param fptr Function pointer. 44 * 44 45 */ 45 #define FADDR(fptr) ((uintptr_t) (fptr))46 #define FADDR(fptr) ((uintptr_t) (fptr)) 46 47 47 48 #endif -
kernel/arch/arm32/include/fpu_context.h
r24a2517 rc621f4aa 39 39 #define KERN_arm32_FPU_CONTEXT_H_ 40 40 41 #include < arch/types.h>41 #include <typedefs.h> 42 42 43 43 #define FPU_CONTEXT_ALIGN 0 -
kernel/arch/arm32/include/interrupt.h
r24a2517 rc621f4aa 37 37 #define KERN_arm32_INTERRUPT_H_ 38 38 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 #include <arch/exception.h> 41 41 42 42 /** Initial size of exception dispatch table. */ 43 #define IVT_ITEMS 643 #define IVT_ITEMS 6 44 44 45 45 /** Index of the first item in exception dispatch table. */ 46 #define IVT_FIRST 0 47 46 #define IVT_FIRST 0 48 47 49 48 extern void interrupt_init(void); … … 52 51 extern void interrupts_restore(ipl_t ipl); 53 52 extern ipl_t interrupts_read(void); 54 53 extern bool interrupts_disabled(void); 55 54 56 55 #endif -
kernel/arch/arm32/include/mach/integratorcp/integratorcp.h
r24a2517 rc621f4aa 36 36 */ 37 37 38 #ifndef KERN_arm32_ MACHINE_H_39 #define KERN_arm32_ MACHINE_H_38 #ifndef KERN_arm32_icp_H_ 39 #define KERN_arm32_icp_H_ 40 40 41 41 #include <arch/machine_func.h> … … 102 102 extern void icp_timer_irq_start(void); 103 103 extern void icp_cpu_halt(void); 104 extern void icp_irq_exception( int exc_no, istate_t *istate);105 extern uintptr_t icp_get_memory_size(void);104 extern void icp_irq_exception(unsigned int, istate_t *); 105 extern void icp_get_memory_extents(uintptr_t *, uintptr_t *); 106 106 extern void icp_frame_init(void); 107 108 extern struct arm_machine_ops icp_machine_ops; 109 110 /** Size of IntegratorCP IRQ number range (starting from 0) */ 111 #define ICP_IRQ_COUNT 8 107 112 108 113 #endif -
kernel/arch/arm32/include/mach/testarm/testarm.h
r24a2517 rc621f4aa 37 37 */ 38 38 39 #ifndef KERN_arm32_ MACHINE_H_40 #define KERN_arm32_ MACHINE_H_39 #ifndef KERN_arm32_testarm_H_ 40 #define KERN_arm32_testarm_H_ 41 41 42 42 #include <arch/machine_func.h> 43 43 44 /** Last interrupt number (beginning from 0) whose status is probed 45 * from interrupt controller 46 */ 47 #define GXEMUL_IRQC_MAX_IRQ 8 48 #define GXEMUL_KBD_IRQ 2 49 #define GXEMUL_TIMER_IRQ 4 44 /** Size of GXemul IRQ number range (starting from 0) */ 45 #define GXEMUL_IRQ_COUNT 32 46 #define GXEMUL_KBD_IRQ 2 47 #define GXEMUL_TIMER_IRQ 4 50 48 51 49 /** Timer frequency */ … … 72 70 extern void gxemul_timer_irq_start(void); 73 71 extern void gxemul_cpu_halt(void); 74 extern void gxemul_irq_exception( int exc_no, istate_t *istate);75 extern uintptr_t gxemul_get_memory_size(void);72 extern void gxemul_irq_exception(unsigned int, istate_t *); 73 extern void gxemul_get_memory_extents(uintptr_t *, uintptr_t *); 76 74 extern void gxemul_frame_init(void); 77 75 76 extern struct arm_machine_ops gxemul_machine_ops; 78 77 79 78 #endif -
kernel/arch/arm32/include/machine_func.h
r24a2517 rc621f4aa 43 43 44 44 #include <console/console.h> 45 #include < arch/types.h>45 #include <typedefs.h> 46 46 #include <arch/exception.h> 47 47 48 #define MACHINE_GENFUNC machine_genfunc49 50 48 struct arm_machine_ops { 51 void (*machine_init)(void);52 void (*machine_timer_irq_start)(void);53 void (*machine_cpu_halt)(void);54 uintptr_t (*machine_get_memory_size)(void);55 void (*machine_irq_exception)(int, istate_t*);56 void (*machine_frame_init)(void);57 void (*machine_output_init)(void);58 void (*machine_input_init)(void);49 void (*machine_init)(void); 50 void (*machine_timer_irq_start)(void); 51 void (*machine_cpu_halt)(void); 52 void (*machine_get_memory_extents)(uintptr_t *, uintptr_t *); 53 void (*machine_irq_exception)(unsigned int, istate_t *); 54 void (*machine_frame_init)(void); 55 void (*machine_output_init)(void); 56 void (*machine_input_init)(void); 59 57 }; 60 58 61 extern struct arm_machine_ops machine_ops; 59 /** Pointer to arm_machine_ops structure being used. */ 60 extern struct arm_machine_ops *machine_ops; 62 61 62 /** Initialize machine_ops pointer. */ 63 extern void machine_ops_init(void); 63 64 64 65 /** Maps HW devices to the kernel address space using #hw_map. */ … … 73 74 extern void machine_cpu_halt(void); 74 75 75 76 /** Returns size of available memory. 76 /** Get extents of available memory. 77 77 * 78 * @return Size of available memory. 78 * @param start Place to store memory start address. 79 * @param size Place to store memory size. 79 80 */ 80 extern uintptr_t machine_get_memory_size(void); 81 81 extern void machine_get_memory_extents(uintptr_t *start, uintptr_t *size); 82 82 83 83 /** Interrupt exception handler. … … 86 86 * @param istate Saved processor state. 87 87 */ 88 extern void machine_irq_exception( int exc_no, istate_t *istate);88 extern void machine_irq_exception(unsigned int exc_no, istate_t *istate); 89 89 90 90 … … 104 104 extern void machine_input_init(void); 105 105 106 extern void machine_genfunc(void); 106 extern size_t machine_get_irq_count(void); 107 107 108 #endif 108 109 -
kernel/arch/arm32/include/memstr.h
r24a2517 rc621f4aa 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ … … 39 39 #define memcpy(dst, src, cnt) __builtin_memcpy((dst), (src), (cnt)) 40 40 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); 41 extern void memsetw(void *, size_t, uint16_t); 42 extern void memsetb(void *, size_t, uint8_t); 45 43 46 44 #endif -
kernel/arch/arm32/include/mm/asid.h
r24a2517 rc621f4aa 39 39 #define KERN_arm32_ASID_H_ 40 40 41 #include < arch/types.h>41 #include <typedefs.h> 42 42 43 43 #define ASID_MAX_ARCH 3 /* minimal required number */ -
kernel/arch/arm32/include/mm/frame.h
r24a2517 rc621f4aa 43 43 #ifndef __ASM__ 44 44 45 #include < arch/types.h>45 #include <typedefs.h> 46 46 47 47 #define BOOT_PAGE_TABLE_SIZE 0x4000 48 #define BOOT_PAGE_TABLE_ADDRESS 0x4000 48 49 #ifdef MACHINE_gta02 50 #define BOOT_PAGE_TABLE_ADDRESS 0x30010000 51 #else 52 #define BOOT_PAGE_TABLE_ADDRESS 0x00008000 53 #endif 49 54 50 55 #define BOOT_PAGE_TABLE_START_FRAME (BOOT_PAGE_TABLE_ADDRESS >> FRAME_WIDTH) 51 56 #define BOOT_PAGE_TABLE_SIZE_IN_FRAMES (BOOT_PAGE_TABLE_SIZE >> FRAME_WIDTH) 57 58 #ifdef MACHINE_gta02 59 #define PHYSMEM_START_ADDR 0x30008000 60 #else 61 #define PHYSMEM_START_ADDR 0x00000000 62 #endif 52 63 53 64 extern uintptr_t last_frame; -
kernel/arch/arm32/include/mm/page.h
r24a2517 rc621f4aa 27 27 */ 28 28 29 /** @addtogroup arm32mm 29 /** @addtogroup arm32mm 30 30 * @{ 31 31 */ … … 40 40 #include <mm/mm.h> 41 41 #include <arch/exception.h> 42 #include <trace.h> 42 43 43 44 #define PAGE_WIDTH FRAME_WIDTH … … 192 193 /** Sets the address of level 0 page table. 193 194 * 194 * @param pt Pointer to the page table to set. 195 */ 196 static inline void set_ptl0_addr(pte_t *pt) 195 * @param pt Pointer to the page table to set. 196 * 197 */ 198 NO_TRACE static inline void set_ptl0_addr(pte_t *pt) 197 199 { 198 200 asm volatile ( … … 205 207 /** Returns level 0 page table entry flags. 206 208 * 207 * @param pt Level 0 page table. 208 * @param i Index of the entry to return. 209 */ 210 static inline int get_pt_level0_flags(pte_t *pt, size_t i) 209 * @param pt Level 0 page table. 210 * @param i Index of the entry to return. 211 * 212 */ 213 NO_TRACE static inline int get_pt_level0_flags(pte_t *pt, size_t i) 211 214 { 212 215 pte_level0_t *p = &pt[i].l0; 213 216 int np = (p->descriptor_type == PTE_DESCRIPTOR_NOT_PRESENT); 214 217 215 218 return (np << PAGE_PRESENT_SHIFT) | (1 << PAGE_USER_SHIFT) | 216 219 (1 << PAGE_READ_SHIFT) | (1 << PAGE_WRITE_SHIFT) | … … 220 223 /** Returns level 1 page table entry flags. 221 224 * 222 * @param pt Level 1 page table. 223 * @param i Index of the entry to return. 224 */ 225 static inline int get_pt_level1_flags(pte_t *pt, size_t i) 225 * @param pt Level 1 page table. 226 * @param i Index of the entry to return. 227 * 228 */ 229 NO_TRACE static inline int get_pt_level1_flags(pte_t *pt, size_t i) 226 230 { 227 231 pte_level1_t *p = &pt[i].l1; 228 232 229 233 int dt = p->descriptor_type; 230 234 int ap = p->access_permission_0; 231 235 232 236 return ((dt == PTE_DESCRIPTOR_NOT_PRESENT) << PAGE_PRESENT_SHIFT) | 233 237 ((ap == PTE_AP_USER_RO_KERNEL_RW) << PAGE_READ_SHIFT) | … … 241 245 } 242 246 243 244 247 /** Sets flags of level 0 page table entry. 245 248 * 246 * @param pt level 0 page table 247 * @param i index of the entry to be changed 248 * @param flags new flags 249 */ 250 static inline void set_pt_level0_flags(pte_t *pt, size_t i, int flags) 249 * @param pt level 0 page table 250 * @param i index of the entry to be changed 251 * @param flags new flags 252 * 253 */ 254 NO_TRACE static inline void set_pt_level0_flags(pte_t *pt, size_t i, int flags) 251 255 { 252 256 pte_level0_t *p = &pt[i].l0; 253 257 254 258 if (flags & PAGE_NOT_PRESENT) { 255 259 p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT; … … 262 266 p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE; 263 267 p->should_be_zero = 0; 264 }268 } 265 269 } 266 270 … … 268 272 /** Sets flags of level 1 page table entry. 269 273 * 270 * We use same access rights for the whole page. When page is not preset we 271 * store 1 in acess_rigts_3 so that at least one bit is 1 (to mark correct 272 * page entry, see #PAGE_VALID_ARCH). 273 * 274 * @param pt Level 1 page table. 275 * @param i Index of the entry to be changed. 276 * @param flags New flags. 277 */ 278 static inline void set_pt_level1_flags(pte_t *pt, size_t i, int flags) 274 * We use same access rights for the whole page. When page 275 * is not preset we store 1 in acess_rigts_3 so that at least 276 * one bit is 1 (to mark correct page entry, see #PAGE_VALID_ARCH). 277 * 278 * @param pt Level 1 page table. 279 * @param i Index of the entry to be changed. 280 * @param flags New flags. 281 * 282 */ 283 NO_TRACE static inline void set_pt_level1_flags(pte_t *pt, size_t i, int flags) 279 284 { 280 285 pte_level1_t *p = &pt[i].l1; … … 287 292 p->access_permission_3 = p->access_permission_0; 288 293 } 289 294 290 295 p->cacheable = p->bufferable = (flags & PAGE_CACHEABLE) != 0; 291 296 292 297 /* default access permission */ 293 298 p->access_permission_0 = p->access_permission_1 = 294 299 p->access_permission_2 = p->access_permission_3 = 295 300 PTE_AP_USER_NO_KERNEL_RW; 296 301 297 302 if (flags & PAGE_USER) { 298 303 if (flags & PAGE_READ) { -
kernel/arch/arm32/include/mm/page_fault.h
r24a2517 rc621f4aa 37 37 #define KERN_arm32_PAGE_FAULT_H_ 38 38 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 41 41 … … 81 81 } instruction_union_t; 82 82 83 extern void prefetch_abort( int n, istate_t *istate);84 extern void data_abort( int n, istate_t *istate);83 extern void prefetch_abort(unsigned int, istate_t *); 84 extern void data_abort(unsigned int, istate_t *); 85 85 86 86 #endif -
kernel/arch/arm32/include/mm/tlb.h
r24a2517 rc621f4aa 27 27 */ 28 28 29 /** @addtogroup arm32mm 29 /** @addtogroup arm32mm 30 30 * @{ 31 31 */ -
kernel/arch/arm32/include/ras.h
r24a2517 rc621f4aa 1 1 /* 2 * Copyright (c) 2009 Jakub Jermar 2 * Copyright (c) 2009 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 38 38 39 39 #include <arch/exception.h> 40 #include < arch/types.h>40 #include <typedefs.h> 41 41 42 #define RAS_START 043 #define RAS_END 142 #define RAS_START 0 43 #define RAS_END 1 44 44 45 45 extern uintptr_t *ras_page; 46 46 47 47 extern void ras_init(void); 48 extern void ras_check( int, istate_t *);48 extern void ras_check(unsigned int, istate_t *); 49 49 50 50 #endif -
kernel/arch/arm32/include/types.h
r24a2517 rc621f4aa 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ … … 38 38 39 39 #ifndef DOXYGEN 40 # define ATTRIBUTE_PACKED __attribute__((packed))40 #define ATTRIBUTE_PACKED __attribute__((packed)) 41 41 #else 42 #define ATTRIBUTE_PACKED42 #define ATTRIBUTE_PACKED 43 43 #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;54 44 55 45 typedef uint32_t size_t; … … 62 52 typedef uint32_t unative_t; 63 53 typedef int32_t native_t; 54 typedef uint32_t atomic_count_t; 64 55 65 56 typedef struct { 66 57 } fncptr_t; 67 58 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. */ 70 61 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. */ 76 67 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. */ 82 73 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. */ 88 79 89 80 #endif -
kernel/arch/arm32/src/arm32.c
r24a2517 rc621f4aa 45 45 #include <interrupt.h> 46 46 #include <arch/regutils.h> 47 #include <arch/machine_func.h> 47 48 #include <userspace.h> 48 49 #include <macros.h> 49 #include <str ing.h>50 #include <str.h> 50 51 #include <arch/ras.h> 51 52 #ifdef MACHINE_testarm53 #include <arch/mach/testarm/testarm.h>54 #endif55 56 #ifdef MACHINE_integratorcp57 #include <arch/mach/integratorcp/integratorcp.h>58 #endif59 60 52 61 53 /** Performs arm32-specific initialization before main_bsp() is called. */ 62 54 void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo) 63 55 { 64 unsigned int i;56 init.cnt = min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 65 57 66 init.cnt = bootinfo->cnt; 67 68 for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); ++i) { 69 init.tasks[i].addr = bootinfo->tasks[i].addr; 58 size_t i; 59 for (i = 0; i < init.cnt; i++) { 60 init.tasks[i].addr = (uintptr_t) bootinfo->tasks[i].addr; 70 61 init.tasks[i].size = bootinfo->tasks[i].size; 71 62 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 72 63 bootinfo->tasks[i].name); 73 64 } 65 66 /* Initialize machine_ops pointer. */ 67 machine_ops_init(); 74 68 } 75 69 -
kernel/arch/arm32/src/asm.S
r24a2517 rc621f4aa 1 # 2 #Copyright (c) 2007 Michal Kebrt3 #All rights reserved.4 # 5 #Redistribution and use in source and binary forms, with or without6 #modification, are permitted provided that the following conditions7 #are met:8 # 9 #- Redistributions of source code must retain the above copyright10 #notice, this list of conditions and the following disclaimer.11 #- Redistributions in binary form must reproduce the above copyright12 #notice, this list of conditions and the following disclaimer in the13 #documentation and/or other materials provided with the distribution.14 #- The name of the author may not be used to endorse or promote products15 #derived from this software without specific prior written permission.16 # 17 #THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR18 #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES19 #OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.20 #IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,21 #INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT22 #NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23 #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24 #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25 #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF26 #THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27 # 1 /* 2 * Copyright (c) 2007 Michal Kebrt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 28 29 30 29 .text 31 30 … … 37 36 .global memcpy_from_uspace_failover_address 38 37 .global memcpy_to_uspace_failover_address 38 .global early_putchar 39 39 40 40 memsetb: … … 47 47 memcpy_from_uspace: 48 48 memcpy_to_uspace: 49 add r3, r1, #3 50 bic r3, r3, #3 51 cmp r1, r3 52 stmdb sp!, {r4, r5, lr} 53 mov r5, r0 /* save dst */ 54 beq 4f 55 1: 56 cmp r2, #0 57 movne ip, #0 58 beq 3f 59 2: 60 ldrb r3, [ip, r1] 61 strb r3, [ip, r0] 62 add ip, ip, #1 63 cmp ip, r2 64 bne 2b 65 3: 66 mov r0, r5 67 ldmia sp!, {r4, r5, pc} 68 4: 69 add r3, r0, #3 70 bic r3, r3, #3 71 cmp r0, r3 72 bne 1b 73 movs r4, r2, lsr #2 74 moveq lr, r4 75 beq 6f 76 mov lr, #0 77 mov ip, lr 78 5: 79 ldr r3, [ip, r1] 80 add lr, lr, #1 81 cmp lr, r4 82 str r3, [ip, r0] 83 add ip, ip, #4 84 bne 5b 85 6: 86 ands r4, r2, #3 87 beq 3b 88 mov r3, lr, lsl #2 89 add r0, r3, r0 90 add ip, r3, r1 91 mov r2, #0 92 7: 93 ldrb r3, [r2, ip] 94 strb r3, [r2, r0] 95 add r2, r2, #1 96 cmp r2, r4 97 bne 7b 98 b 3b 49 add r3, r1, #3 50 bic r3, r3, #3 51 cmp r1, r3 52 stmdb sp!, {r4, r5, lr} 53 mov r5, r0 /* save dst */ 54 beq 4f 55 56 1: 57 cmp r2, #0 58 movne ip, #0 59 beq 3f 60 61 2: 62 ldrb r3, [ip, r1] 63 strb r3, [ip, r0] 64 add ip, ip, #1 65 cmp ip, r2 66 bne 2b 67 68 3: 69 mov r0, r5 70 ldmia sp!, {r4, r5, pc} 71 72 4: 73 add r3, r0, #3 74 bic r3, r3, #3 75 cmp r0, r3 76 bne 1b 77 movs r4, r2, lsr #2 78 moveq lr, r4 79 beq 6f 80 mov lr, #0 81 mov ip, lr 82 83 5: 84 ldr r3, [ip, r1] 85 add lr, lr, #1 86 cmp lr, r4 87 str r3, [ip, r0] 88 add ip, ip, #4 89 bne 5b 90 91 6: 92 ands r4, r2, #3 93 beq 3b 94 mov r3, lr, lsl #2 95 add r0, r3, r0 96 add ip, r3, r1 97 mov r2, #0 98 99 7: 100 ldrb r3, [r2, ip] 101 strb r3, [r2, r0] 102 add r2, r2, #1 103 cmp r2, r4 104 bne 7b 105 b 3b 99 106 100 107 memcpy_from_uspace_failover_address: 101 108 memcpy_to_uspace_failover_address: 102 mov r0, #0 103 ldmia sp!, {r4, r5, pc} 109 mov r0, #0 110 ldmia sp!, {r4, r5, pc} 111 112 early_putchar: 113 mov pc, lr -
kernel/arch/arm32/src/cpu/cpu.c
r24a2517 rc621f4aa 43 43 44 44 /** Implementators (vendor) names */ 45 static c har *imp_data[] = {45 static const char *imp_data[] = { 46 46 "?", /* IMP_DATA_START_OFFSET */ 47 47 "ARM Ltd", /* 0x41 */ … … 60 60 61 61 /** Architecture names */ 62 static c har *arch_data[] = {62 static const char *arch_data[] = { 63 63 "?", /* 0x0 */ 64 64 "4", /* 0x1 */ … … 108 108 void cpu_print_report(cpu_t *m) 109 109 { 110 c har *vendor = imp_data[0];111 c har *architecture = arch_data[0];110 const char *vendor = imp_data[0]; 111 const char *architecture = arch_data[0]; 112 112 cpu_arch_t * cpu_arch = &m->arch; 113 113 -
kernel/arch/arm32/src/ddi/ddi.c
r24a2517 rc621f4aa 36 36 #include <ddi/ddi.h> 37 37 #include <proc/task.h> 38 #include < arch/types.h>38 #include <typedefs.h> 39 39 40 40 /** Enable I/O space range for task. -
kernel/arch/arm32/src/debug/stacktrace.c
r24a2517 rc621f4aa 35 35 #include <stacktrace.h> 36 36 #include <syscall/copy.h> 37 #include <arch/types.h>38 37 #include <typedefs.h> 39 38 … … 41 40 #define FRAME_OFFSET_RA -1 42 41 43 bool kernel_ frame_pointer_validate(uintptr_t fp)42 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 44 43 { 45 return fp != 0;44 return ctx->fp != 0; 46 45 } 47 46 48 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)47 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 49 48 { 50 uint32_t *stack = (void *) fp;49 uint32_t *stack = (void *) ctx->fp; 51 50 52 51 *prev = stack[FRAME_OFFSET_FP_PREV]; … … 54 53 } 55 54 56 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)55 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 57 56 { 58 uint32_t *stack = (void *) fp;57 uint32_t *stack = (void *) ctx->fp; 59 58 60 59 *ra = stack[FRAME_OFFSET_RA]; … … 62 61 } 63 62 64 bool uspace_ frame_pointer_validate(uintptr_t fp)63 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 65 64 { 66 return fp != 0;65 return ctx->fp != 0; 67 66 } 68 67 69 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)68 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 70 69 { 71 70 return !copy_from_uspace((void *) prev, 72 (uint32_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));71 (uint32_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev)); 73 72 } 74 73 75 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)74 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 76 75 { 77 return !copy_from_uspace((void *) ra, (uint32_t *) fp + FRAME_OFFSET_RA,78 sizeof(*ra));76 return !copy_from_uspace((void *) ra, 77 (uint32_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra)); 79 78 } 80 79 -
kernel/arch/arm32/src/dummy.S
r24a2517 rc621f4aa 1 1 # 2 # Copyright (c) 2007 Michal Kebr y, Pavel Jancik, Petr Stepan2 # Copyright (c) 2007 Michal Kebrt, Pavel Jancik, Petr Stepan 3 3 # All rights reserved. 4 4 # -
kernel/arch/arm32/src/exc_handler.S
r24a2517 rc621f4aa 96 96 ldmfd r3!, {r4-r7} 97 97 stmfd r13!, {r4-r7} 98 stmfd r13!, {r13, lr}^ 98 mov r4, r13 99 stmfd r4, {r13, lr}^ 100 nop /* Cannot access r13 immediately after stm(2) */ 101 sub r13, r13, #8 99 102 stmfd r13!, {r2} 103 104 # Stop stack traces here 105 mov fp, #0 106 100 107 b 2f 101 108 … … 123 130 stmfd r13!, {r2} 124 131 2: 125 # Stop stack traces here126 mov fp, #0127 132 .endm 128 133 … … 135 140 136 141 # return to user mode 137 ldmfd r13!, {r13, lr}^ 142 mov r0, r13 143 ldmfd r0, {r13, lr}^ 144 nop /* Cannot access r13 immediately after ldm(2) */ 145 add r13, r13, #8 138 146 b 2f 139 147 … … 150 158 mov r0, #0 151 159 mov r1, r13 152 bl ras_check 160 bl ras_check 153 161 LOAD_REGS_FROM_STACK 154 162 … … 158 166 mov r0, #5 159 167 mov r1, r13 160 bl ras_check 168 bl ras_check 161 169 LOAD_REGS_FROM_STACK 162 170 … … 166 174 mov r0, #6 167 175 mov r1, r13 168 bl ras_check 176 bl ras_check 169 177 LOAD_REGS_FROM_STACK 170 178 … … 173 181 mov r0, #1 174 182 mov r1, r13 175 bl ras_check 183 bl ras_check 176 184 LOAD_REGS_FROM_STACK 177 185 … … 181 189 mov r0, #3 182 190 mov r1, r13 183 bl ras_check 191 bl ras_check 184 192 LOAD_REGS_FROM_STACK 185 193 … … 189 197 mov r0, #4 190 198 mov r1, r13 191 bl ras_check 199 bl ras_check 192 200 LOAD_REGS_FROM_STACK 193 201 -
kernel/arch/arm32/src/exception.c
r24a2517 rc621f4aa 37 37 #include <arch/memstr.h> 38 38 #include <arch/regutils.h> 39 #include <arch/machine_func.h> 39 40 #include <interrupt.h> 40 41 #include <arch/mm/page_fault.h> … … 43 44 #include <syscall/syscall.h> 44 45 #include <stacktrace.h> 45 46 #ifdef MACHINE_testarm47 #include <arch/mach/testarm/testarm.h>48 #endif49 50 #ifdef MACHINE_integratorcp51 #include <arch/mach/integratorcp/integratorcp.h>52 #endif53 46 54 47 /** Offset used in calculation of exception handler's relative address. … … 91 84 * 92 85 * Dispatches the syscall. 86 * 93 87 */ 94 static void swi_exception( int exc_no, istate_t *istate)88 static void swi_exception(unsigned int exc_no, istate_t *istate) 95 89 { 96 90 istate->r0 = syscall_handler(istate->r0, istate->r1, istate->r2, … … 148 142 * Determines the sources of interrupt and calls their handlers. 149 143 */ 150 static void irq_exception( int exc_no, istate_t *istate)144 static void irq_exception(unsigned int exc_no, istate_t *istate) 151 145 { 152 146 machine_irq_exception(exc_no, istate); … … 165 159 install_exception_handlers(); 166 160 167 exc_register(EXC_IRQ, "interrupt", (iroutine) irq_exception); 168 exc_register(EXC_PREFETCH_ABORT, "prefetch abort", 169 (iroutine) prefetch_abort); 170 exc_register(EXC_DATA_ABORT, "data abort", (iroutine) data_abort); 171 exc_register(EXC_SWI, "software interrupt", (iroutine) swi_exception); 161 exc_register(EXC_IRQ, "interrupt", true, 162 (iroutine_t) irq_exception); 163 exc_register(EXC_PREFETCH_ABORT, "prefetch abort", true, 164 (iroutine_t) prefetch_abort); 165 exc_register(EXC_DATA_ABORT, "data abort", true, 166 (iroutine_t) data_abort); 167 exc_register(EXC_SWI, "software interrupt", true, 168 (iroutine_t) swi_exception); 172 169 } 173 170 … … 176 173 * @param istate Structure to be printed. 177 174 */ 178 void print_istate(istate_t *istate)175 void istate_decode(istate_t *istate) 179 176 { 180 printf("istate dump:\n"); 181 182 printf(" r0: %x r1: %x r2: %x r3: %x\n", 177 printf("r0 =%#0.8lx\tr1 =%#0.8lx\tr2 =%#0.8lx\tr3 =%#0.8lx\n", 183 178 istate->r0, istate->r1, istate->r2, istate->r3); 184 printf(" r4: %x r5: %x r6: %x r7: %x\n",179 printf("r4 =%#0.8lx\tr5 =%#0.8lx\tr6 =%#0.8lx\tr7 =%#0.8lx\n", 185 180 istate->r4, istate->r5, istate->r6, istate->r7); 186 printf(" r8: %x r8: %x r10: %x fp: %x\n",181 printf("r8 =%#0.8lx\tr9 =%#0.8lx\tr10=%#0.8lx\tfp =%#0.8lx\n", 187 182 istate->r8, istate->r9, istate->r10, istate->fp); 188 printf(" r12: %x sp: %x lr: %x spsr: %x\n",183 printf("r12=%#0.8lx\tsp =%#0.8lx\tlr =%#0.8lx\tspsr=%#0.8lx\n", 189 184 istate->r12, istate->sp, istate->lr, istate->spsr); 190 191 printf(" pc: %x\n", istate->pc);192 193 stack_trace_istate(istate);194 185 } 195 186 -
kernel/arch/arm32/src/interrupt.c
r24a2517 rc621f4aa 36 36 #include <arch/asm.h> 37 37 #include <arch/regutils.h> 38 #include <arch/machine_func.h> 38 39 #include <ddi/irq.h> 39 40 #include <ddi/device.h> 40 41 #include <interrupt.h> 41 42 #ifdef MACHINE_testarm43 #include <arch/mach/testarm/testarm.h>44 #endif45 46 #ifdef MACHINE_integratorcp47 #include <arch/mach/integratorcp/integratorcp.h>48 #endif49 50 /** Initial size of a table holding interrupt handlers. */51 #define IRQ_COUNT 852 42 53 43 /** Disable interrupts. … … 97 87 } 98 88 89 /** Check interrupts state. 90 * 91 * @return True if interrupts are disabled. 92 * 93 */ 94 bool interrupts_disabled(void) 95 { 96 return current_status_reg_read() & STATUS_REG_IRQ_DISABLED_BIT; 97 } 98 99 99 /** Initialize basic tables for exception dispatching 100 100 * and starts the timer. … … 102 102 void interrupt_init(void) 103 103 { 104 irq_init(IRQ_COUNT, IRQ_COUNT); 104 size_t irq_count; 105 106 irq_count = machine_get_irq_count(); 107 irq_init(irq_count, irq_count); 108 105 109 machine_timer_irq_start(); 106 110 } -
kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
r24a2517 rc621f4aa 56 56 static icp_hw_map_t icp_hw_map; 57 57 static irq_t icp_timer_irq; 58 struct arm_machine_ops machine_ops = {58 struct arm_machine_ops icp_machine_ops = { 59 59 icp_init, 60 60 icp_timer_irq_start, 61 61 icp_cpu_halt, 62 icp_get_memory_ size,62 icp_get_memory_extents, 63 63 icp_irq_exception, 64 64 icp_frame_init, … … 214 214 } 215 215 216 /** Returns the size of emulated memory. 217 * 218 * @return Size in bytes. 219 */ 220 size_t icp_get_memory_size(void) 221 { 216 /** Get extents of available memory. 217 * 218 * @param start Place to store memory start address. 219 * @param size Place to store memory size. 220 */ 221 void icp_get_memory_extents(uintptr_t *start, uintptr_t *size) 222 { 223 *start = 0; 224 222 225 if (hw_map_init_called) { 223 return (sdram[((*(uint32_t *)icp_hw_map.sdramcr & ICP_SDRAM_MASK) >> 2)]); 226 *size = (sdram[((*(uint32_t *)icp_hw_map.sdramcr & 227 ICP_SDRAM_MASK) >> 2)]); 224 228 } else { 225 return SDRAM_SIZE; 226 } 227 229 *size = SDRAM_SIZE; 230 } 228 231 } 229 232 … … 242 245 * @param istate Saved processor state. 243 246 */ 244 void icp_irq_exception( int exc_no, istate_t *istate)247 void icp_irq_exception(unsigned int exc_no, istate_t *istate) 245 248 { 246 249 uint32_t sources = icp_irqc_get_sources(); 247 int i;250 unsigned int i; 248 251 249 252 for (i = 0; i < ICP_IRQC_MAX_IRQ; i++) { -
kernel/arch/arm32/src/mach/testarm/testarm.c
r24a2517 rc621f4aa 56 56 static irq_t gxemul_timer_irq; 57 57 58 struct arm_machine_ops machine_ops = {58 struct arm_machine_ops gxemul_machine_ops = { 59 59 gxemul_init, 60 60 gxemul_timer_irq_start, 61 61 gxemul_cpu_halt, 62 gxemul_get_memory_ size,62 gxemul_get_memory_extents, 63 63 gxemul_irq_exception, 64 64 gxemul_frame_init, … … 185 185 } 186 186 187 /** Returns the size of emulated memory. 188 * 189 * @return Size in bytes. 190 */ 191 uintptr_t gxemul_get_memory_size(void) 192 { 193 return *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET)); 194 } 195 187 /** Get extents of available memory. 188 * 189 * @param start Place to store memory start address. 190 * @param size Place to store memory size. 191 */ 192 void gxemul_get_memory_extents(uintptr_t *start, uintptr_t *size) 193 { 194 *start = 0; 195 *size = *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET)); 196 } 196 197 197 198 /** Returns the mask of active interrupts. */ … … 205 206 * Determines the sources of interrupt and calls their handlers. 206 207 */ 207 void gxemul_irq_exception( int exc_no, istate_t *istate)208 void gxemul_irq_exception(unsigned int exc_no, istate_t *istate) 208 209 { 209 210 uint32_t sources = gxemul_irqc_get_sources(); 210 211 unsigned int i; 211 212 212 for (i = 0; i < GXEMUL_IRQ C_MAX_IRQ; i++) {213 for (i = 0; i < GXEMUL_IRQ_COUNT; i++) { 213 214 if (sources & (1 << i)) { 214 215 irq_t *irq = irq_dispatch_and_lock(i); -
kernel/arch/arm32/src/machine_func.c
r24a2517 rc621f4aa 39 39 40 40 #include <arch/machine_func.h> 41 #include <arch/mach/gta02/gta02.h> 42 #include <arch/mach/integratorcp/integratorcp.h> 43 #include <arch/mach/testarm/testarm.h> 41 44 45 /** Pointer to machine_ops structure being used. */ 46 struct arm_machine_ops *machine_ops; 47 48 /** Initialize machine_ops pointer. */ 49 void machine_ops_init(void) 50 { 51 #if defined(MACHINE_gta02) 52 machine_ops = >a02_machine_ops; 53 #elif defined(MACHINE_testarm) 54 machine_ops = &gxemul_machine_ops; 55 #elif defined(MACHINE_integratorcp) 56 machine_ops = &icp_machine_ops; 57 #else 58 #error Machine type not defined. 59 #endif 60 } 42 61 43 62 /** Maps HW devices to the kernel address space using #hw_map. */ 44 63 void machine_init(void) 45 64 { 46 (machine_ops .machine_init)();65 (machine_ops->machine_init)(); 47 66 } 48 67 … … 51 70 void machine_timer_irq_start(void) 52 71 { 53 (machine_ops .machine_timer_irq_start)();72 (machine_ops->machine_timer_irq_start)(); 54 73 } 55 74 … … 58 77 void machine_cpu_halt(void) 59 78 { 60 (machine_ops .machine_cpu_halt)();79 (machine_ops->machine_cpu_halt)(); 61 80 } 62 81 63 64 /** Returns size of available memory. 82 /** Get extents of available memory. 65 83 * 66 * @return Size of available memory. 84 * @param start Place to store memory start address. 85 * @param size Place to store memory size. 67 86 */ 68 uintptr_t machine_get_memory_size(void)87 void machine_get_memory_extents(uintptr_t *start, uintptr_t *size) 69 88 { 70 return (machine_ops.machine_get_memory_size)();89 (machine_ops->machine_get_memory_extents)(start, size); 71 90 } 72 91 … … 76 95 * @param istate Saved processor state. 77 96 */ 78 void machine_irq_exception( int exc_no, istate_t *istate)97 void machine_irq_exception(unsigned int exc_no, istate_t *istate) 79 98 { 80 (machine_ops .machine_irq_exception)(exc_no, istate);99 (machine_ops->machine_irq_exception)(exc_no, istate); 81 100 } 82 101 … … 87 106 void machine_frame_init(void) 88 107 { 89 (machine_ops .machine_frame_init)();108 (machine_ops->machine_frame_init)(); 90 109 } 91 110 … … 95 114 void machine_output_init(void) 96 115 { 97 (machine_ops .machine_output_init)();116 (machine_ops->machine_output_init)(); 98 117 } 99 118 … … 103 122 void machine_input_init(void) 104 123 { 105 (machine_ops .machine_input_init)();124 (machine_ops->machine_input_init)(); 106 125 } 107 126 108 /* 109 * Generic function to use, if sepcific function doesn't define any of the above functions. 110 */ 111 void machine_genfunc() 127 /** Get IRQ number range used by machine. */ 128 size_t machine_get_irq_count(void) 112 129 { 130 size_t irq_count; 131 132 #if defined(MACHINE_gta02) 133 irq_count = GTA02_IRQ_COUNT; 134 #elif defined(MACHINE_testarm) 135 irq_count = GXEMUL_IRQ_COUNT; 136 #elif defined(MACHINE_integratorcp) 137 irq_count = ICP_IRQ_COUNT; 138 #else 139 #error Machine type not defined. 140 #endif 141 return irq_count; 113 142 } 114 143 -
kernel/arch/arm32/src/mm/frame.c
r24a2517 rc621f4aa 36 36 #include <mm/frame.h> 37 37 #include <arch/mm/frame.h> 38 #include <arch/machine_func.h> 38 39 #include <config.h> 39 40 #ifdef MACHINE_testarm 41 #include <arch/mach/testarm/testarm.h> 42 #endif 43 44 #ifdef MACHINE_integratorcp 45 #include <arch/mach/integratorcp/integratorcp.h> 46 #endif 40 #include <align.h> 47 41 48 42 /** Address of the last frame in the memory. */ … … 52 46 void frame_arch_init(void) 53 47 { 54 last_frame = machine_get_memory_size(); 48 uintptr_t mem_start, mem_size; 49 uintptr_t first_frame; 50 uintptr_t num_frames; 51 52 machine_get_memory_extents(&mem_start, &mem_size); 53 first_frame = ALIGN_UP(mem_start, FRAME_SIZE); 54 last_frame = ALIGN_DOWN(mem_start + mem_size, FRAME_SIZE); 55 num_frames = (last_frame - first_frame) >> FRAME_WIDTH; 55 56 56 57 /* All memory as one zone */ 57 zone_create( 0, ADDR2PFN(last_frame),58 zone_create(first_frame >> FRAME_WIDTH, num_frames, 58 59 BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0); 59 60 -
kernel/arch/arm32/src/mm/page.c
r24a2517 rc621f4aa 27 27 */ 28 28 29 /** @addtogroup arm32mm 29 /** @addtogroup arm32mm 30 30 * @{ 31 31 */ … … 41 41 #include <arch/exception.h> 42 42 #include <typedefs.h> 43 #include <arch/types.h>44 43 #include <interrupt.h> 45 44 #include <arch/mm/frame.h> … … 54 53 int flags = PAGE_CACHEABLE; 55 54 page_mapping_operations = &pt_mapping_operations; 55 56 page_table_lock(AS_KERNEL, true); 56 57 57 58 uintptr_t cur; 58 59 /* Kernel identity mapping */ 59 for (cur = 0; cur < last_frame; cur += FRAME_SIZE)60 for (cur = PHYSMEM_START_ADDR; cur < last_frame; cur += FRAME_SIZE) 60 61 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 61 62 … … 67 68 #error "Only high exception vector supported now" 68 69 #endif 70 cur = ALIGN_DOWN(0x50008010, FRAME_SIZE); 71 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 72 73 page_table_unlock(AS_KERNEL, true); 69 74 70 75 as_switch(NULL, AS_KERNEL); … … 93 98 uintptr_t virtaddr = PA2KA(last_frame); 94 99 pfn_t i; 100 101 page_table_lock(AS_KERNEL, true); 95 102 for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) { 96 103 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), … … 98 105 PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL); 99 106 } 107 page_table_unlock(AS_KERNEL, true); 100 108 101 109 last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); -
kernel/arch/arm32/src/mm/page_fault.c
r24a2517 rc621f4aa 167 167 /** Handles "data abort" exception (load or store at invalid address). 168 168 * 169 * @param exc_no Exception number. 170 * @param istate CPU state when exception occured. 171 */ 172 void data_abort(int exc_no, istate_t *istate) 169 * @param exc_no Exception number. 170 * @param istate CPU state when exception occured. 171 * 172 */ 173 void data_abort(unsigned int exc_no, istate_t *istate) 173 174 { 174 175 fault_status_t fsr __attribute__ ((unused)) = … … 182 183 if (ret == AS_PF_FAULT) { 183 184 fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr); 184 print_istate(istate); 185 printf("page fault - pc: %x, va: %x, status: %x(%x), " 186 "access:%d\n", istate->pc, badvaddr, fsr.status, fsr, 187 access); 188 189 panic("Page fault."); 185 panic_memtrap(istate, access, badvaddr, NULL); 190 186 } 191 187 } … … 193 189 /** Handles "prefetch abort" exception (instruction couldn't be executed). 194 190 * 195 * @param exc_no Exception number. 196 * @param istate CPU state when exception occured. 197 */ 198 void prefetch_abort(int exc_no, istate_t *istate) 191 * @param exc_no Exception number. 192 * @param istate CPU state when exception occured. 193 * 194 */ 195 void prefetch_abort(unsigned int exc_no, istate_t *istate) 199 196 { 200 197 int ret = as_page_fault(istate->pc, PF_ACCESS_EXEC, istate); 201 198 202 199 if (ret == AS_PF_FAULT) { 203 printf("prefetch_abort\n"); 204 print_istate(istate); 205 panic("page fault - prefetch_abort at address: %x.", 206 istate->pc); 200 fault_if_from_uspace(istate, 201 "Page fault - prefetch_abort: %#x.", istate->pc); 202 panic_memtrap(istate, PF_ACCESS_EXEC, istate->pc, NULL); 207 203 } 208 204 } -
kernel/arch/arm32/src/mm/tlb.c
r24a2517 rc621f4aa 37 37 #include <arch/mm/asid.h> 38 38 #include <arch/asm.h> 39 #include < arch/types.h>39 #include <typedefs.h> 40 40 #include <arch/mm/page.h> 41 41 -
kernel/arch/arm32/src/ras.c
r24a2517 rc621f4aa 1 1 /* 2 * Copyright (c) 2009 Jakub Jermar 2 * Copyright (c) 2009 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 44 44 #include <arch.h> 45 45 #include <memstr.h> 46 #include < arch/types.h>46 #include <typedefs.h> 47 47 48 48 uintptr_t *ras_page = NULL; … … 66 66 } 67 67 68 void ras_check( int n, istate_t *istate)68 void ras_check(unsigned int n, istate_t *istate) 69 69 { 70 70 uintptr_t rewrite_pc = istate->pc; -
kernel/arch/arm32/src/userspace.c
r24a2517 rc621f4aa 97 97 "mov sp, %[ustate]\n" 98 98 "msr spsr_c, %[user_mode]\n" 99 "ldmfd sp!, {r0-r12, sp, lr}^\n" 99 "ldmfd sp, {r0-r12, sp, lr}^\n" 100 "nop\n" /* Cannot access sp immediately after ldm(2) */ 101 "add sp, sp, #(15*4)\n" 100 102 "ldmfd sp!, {pc}^\n" 101 103 :: [ustate] "r" (&ustate), [user_mode] "r" (user_mode)
Note:
See TracChangeset
for help on using the changeset viewer.
