Changeset 46c20c8 in mainline for kernel/arch/arm32/src
- Timestamp:
- 2010-11-26T20:08:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 45df59a
- Parents:
- fb150d78 (diff), ffdd2b9 (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/src
- Files:
-
- 1 added
- 18 edited
-
arm32.c (modified) (1 diff)
-
asm.S (modified) (3 diffs)
-
cpu/cpu.c (modified) (3 diffs)
-
ddi/ddi.c (modified) (1 diff)
-
debug/stacktrace.c (modified) (4 diffs)
-
dummy.S (modified) (1 diff)
-
exc_handler.S (modified) (9 diffs)
-
exception.c (modified) (6 diffs)
-
interrupt.c (modified) (3 diffs)
-
mach/gta02/gta02.c (added)
-
mach/integratorcp/integratorcp.c (modified) (4 diffs)
-
mach/testarm/testarm.c (modified) (4 diffs)
-
machine_func.c (modified) (7 diffs)
-
mm/frame.c (modified) (2 diffs)
-
mm/page.c (modified) (6 diffs)
-
mm/page_fault.c (modified) (5 diffs)
-
mm/tlb.c (modified) (1 diff)
-
ras.c (modified) (3 diffs)
-
userspace.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/arm32.c
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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" PRIx32 "\tr1 =%#0" PRIx32 "\t" 178 "r2 =%#0" PRIx32 "\tr3 =%#0" PRIx32 "\n", 183 179 istate->r0, istate->r1, istate->r2, istate->r3); 184 printf(" r4: %x r5: %x r6: %x r7: %x\n", 180 printf("r4 =%#" PRIx32 "\tr5 =%#0" PRIx32 "\t" 181 "r6 =%#0" PRIx32 "\tr7 =%#0" PRIx32 "\n", 185 182 istate->r4, istate->r5, istate->r6, istate->r7); 186 printf(" r8: %x r8: %x r10: %x fp: %x\n", 187 istate->r8, istate->r9, istate->r10, istate->fp); 188 printf(" r12: %x sp: %x lr: %x spsr: %x\n", 189 istate->r12, istate->sp, istate->lr, istate->spsr); 190 191 printf(" pc: %x\n", istate->pc); 192 193 stack_trace_istate(istate); 183 printf("r8 =%#0" PRIx32 "\tr9 =%#0" PRIx32 "\t" 184 "r10=%#0" PRIx32 "\tfp =%p\n", 185 istate->r8, istate->r9, istate->r10, 186 (void *) istate->fp); 187 printf("r12=%#0" PRIx32 "\tsp =%p\tlr =%p\tspsr=%p\n", 188 istate->r12, (void *) istate->sp, 189 (void *) istate->lr, (void *) istate->spsr); 194 190 } 195 191 -
kernel/arch/arm32/src/interrupt.c
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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, 65 65 icp_output_init, 66 icp_input_init 66 icp_input_init, 67 icp_get_irq_count 67 68 }; 68 69 … … 214 215 } 215 216 216 /** Returns the size of emulated memory. 217 * 218 * @return Size in bytes. 219 */ 220 size_t icp_get_memory_size(void) 221 { 217 /** Get extents of available memory. 218 * 219 * @param start Place to store memory start address. 220 * @param size Place to store memory size. 221 */ 222 void icp_get_memory_extents(uintptr_t *start, uintptr_t *size) 223 { 224 *start = 0; 225 222 226 if (hw_map_init_called) { 223 return (sdram[((*(uint32_t *)icp_hw_map.sdramcr & ICP_SDRAM_MASK) >> 2)]); 227 *size = (sdram[((*(uint32_t *)icp_hw_map.sdramcr & 228 ICP_SDRAM_MASK) >> 2)]); 224 229 } else { 225 return SDRAM_SIZE; 226 } 227 230 *size = SDRAM_SIZE; 231 } 228 232 } 229 233 … … 242 246 * @param istate Saved processor state. 243 247 */ 244 void icp_irq_exception( int exc_no, istate_t *istate)248 void icp_irq_exception(unsigned int exc_no, istate_t *istate) 245 249 { 246 250 uint32_t sources = icp_irqc_get_sources(); 247 int i;251 unsigned int i; 248 252 249 253 for (i = 0; i < ICP_IRQC_MAX_IRQ; i++) { … … 333 337 } 334 338 339 size_t icp_get_irq_count(void) 340 { 341 return ICP_IRQ_COUNT; 342 } 335 343 336 344 /** @} -
kernel/arch/arm32/src/mach/testarm/testarm.c
rfb150d78 r46c20c8 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, 65 65 gxemul_output_init, 66 gxemul_input_init 66 gxemul_input_init, 67 gxemul_get_irq_count 67 68 }; 68 69 … … 126 127 } 127 128 129 size_t gxemul_get_irq_count(void) 130 { 131 return GXEMUL_IRQ_COUNT; 132 } 133 128 134 /** Starts gxemul Real Time Clock device, which asserts regular interrupts. 129 135 * … … 185 191 } 186 192 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 193 /** Get extents of available memory. 194 * 195 * @param start Place to store memory start address. 196 * @param size Place to store memory size. 197 */ 198 void gxemul_get_memory_extents(uintptr_t *start, uintptr_t *size) 199 { 200 *start = 0; 201 *size = *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET)); 202 } 196 203 197 204 /** Returns the mask of active interrupts. */ … … 205 212 * Determines the sources of interrupt and calls their handlers. 206 213 */ 207 void gxemul_irq_exception( int exc_no, istate_t *istate)214 void gxemul_irq_exception(unsigned int exc_no, istate_t *istate) 208 215 { 209 216 uint32_t sources = gxemul_irqc_get_sources(); 210 217 unsigned int i; 211 218 212 for (i = 0; i < GXEMUL_IRQ C_MAX_IRQ; i++) {219 for (i = 0; i < GXEMUL_IRQ_COUNT; i++) { 213 220 if (sources & (1 << i)) { 214 221 irq_t *irq = irq_dispatch_and_lock(i); -
kernel/arch/arm32/src/machine_func.c
rfb150d78 r46c20c8 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 return (machine_ops->machine_get_irq_count)(); 113 131 } 114 132 -
kernel/arch/arm32/src/mm/frame.c
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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); … … 88 93 KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) { 89 94 panic("Unable to map physical memory %p (%d bytes).", 90 physaddr, size);95 (void *) physaddr, size); 91 96 } 92 97 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
rfb150d78 r46c20c8 141 141 if (instr.condition == 0xf) { 142 142 panic("page_fault - instruction does not access memory " 143 "(instr_code: %x, badvaddr:%x).", instr, badvaddr); 143 "(instr_code: %#0" PRIx32 ", badvaddr:%p).", 144 instr_union.pc, (void *) badvaddr); 144 145 return PF_ACCESS_EXEC; 145 146 } … … 160 161 161 162 panic("page_fault - instruction doesn't access memory " 162 "(instr_code: %x, badvaddr:%x).", instr, badvaddr); 163 "(instr_code: %#0" PRIx32 ", badvaddr:%p).", 164 instr_union.pc, (void *) badvaddr); 163 165 164 166 return PF_ACCESS_EXEC; … … 167 169 /** Handles "data abort" exception (load or store at invalid address). 168 170 * 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) 171 * @param exc_no Exception number. 172 * @param istate CPU state when exception occured. 173 * 174 */ 175 void data_abort(unsigned int exc_no, istate_t *istate) 173 176 { 174 177 fault_status_t fsr __attribute__ ((unused)) = … … 182 185 if (ret == AS_PF_FAULT) { 183 186 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."); 187 panic_memtrap(istate, access, badvaddr, NULL); 190 188 } 191 189 } … … 193 191 /** Handles "prefetch abort" exception (instruction couldn't be executed). 194 192 * 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) 193 * @param exc_no Exception number. 194 * @param istate CPU state when exception occured. 195 * 196 */ 197 void prefetch_abort(unsigned int exc_no, istate_t *istate) 199 198 { 200 199 int ret = as_page_fault(istate->pc, PF_ACCESS_EXEC, istate); 201 200 202 201 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); 202 fault_if_from_uspace(istate, 203 "Page fault - prefetch_abort: %#x.", istate->pc); 204 panic_memtrap(istate, PF_ACCESS_EXEC, istate->pc, NULL); 207 205 } 208 206 } -
kernel/arch/arm32/src/mm/tlb.c
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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
rfb150d78 r46c20c8 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.
