Changeset 33c2952 in mainline for kernel/arch
- Timestamp:
- 2012-11-07T21:00:02Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dcb0751
- Parents:
- fc89e32 (diff), 94795812 (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:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/Makefile.inc
rfc89e32 r33c2952 33 33 ATSIGN = % 34 34 35 GCC_CFLAGS += -march=armv4 35 GCC_CFLAGS += -march=armv4 -fno-omit-frame-pointer -mapcs-frame 36 36 37 37 BITS = 32 -
kernel/arch/arm32/include/istate.h
rfc89e32 r33c2952 49 49 /** Struct representing CPU state saved when an exception occurs. */ 50 50 typedef struct istate { 51 uint32_t dummy; 51 52 uint32_t spsr; 52 53 uint32_t sp; -
kernel/arch/arm32/src/exc_handler.S
rfc89e32 r33c2952 130 130 stmfd r13!, {r2} 131 131 2: 132 sub sp, sp, #4 132 133 .endm 133 134 134 135 .macro LOAD_REGS_FROM_STACK 136 add sp, sp, #4 135 137 ldmfd r13!, {r0} 136 138 msr spsr, r0 -
kernel/arch/arm32/src/exception.c
rfc89e32 r33c2952 123 123 124 124 asm volatile ( 125 "mrc p15, 0, %[control_reg], c1, c 1"125 "mrc p15, 0, %[control_reg], c1, c0" 126 126 : [control_reg] "=r" (control_reg) 127 127 ); … … 131 131 132 132 asm volatile ( 133 "mcr p15, 0, %[control_reg], c1, c 1"133 "mcr p15, 0, %[control_reg], c1, c0" 134 134 :: [control_reg] "r" (control_reg) 135 135 ); -
kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
rfc89e32 r33c2952 38 38 #include <console/chardev.h> 39 39 #include <genarch/drivers/pl050/pl050.h> 40 #include <genarch/drivers/arm926_uart/arm926_uart.h> 40 41 #include <genarch/kbrd/kbrd.h> 42 #include <genarch/srln/srln.h> 41 43 #include <console/console.h> 42 44 #include <sysinfo/sysinfo.h> … … 53 55 #include <print.h> 54 56 57 55 58 #define SDRAM_SIZE (sdram[((*(uint32_t *)(ICP_CMCR+ICP_SDRAMCR_OFFSET) & ICP_SDRAM_MASK) >> 2)]) 56 static icp_hw_map_t icp_hw_map; 57 static irq_t icp_timer_irq; 59 60 static struct { 61 icp_hw_map_t hw_map; 62 irq_t timer_irq; 63 arm926_uart_t uart; 64 } icp; 65 66 67 58 68 struct arm_machine_ops icp_machine_ops = { 59 69 icp_init, … … 70 80 71 81 static bool hw_map_init_called = false; 72 static bool vga_init = false;73 82 uint32_t sdram[8] = { 74 83 16777216, /* 16mb */ … … 89 98 void icp_vga_init(void) 90 99 { 91 *(uint32_t*)((char *)(icp _hw_map.cmcr)+0x14) = 0xA05F0000;92 *(uint32_t*)((char *)(icp _hw_map.cmcr)+0x1C) = 0x12C11000;93 *(uint32_t*)icp _hw_map.vga = 0x3F1F3F9C;94 *(uint32_t*)((char *)(icp _hw_map.vga) + 0x4) = 0x080B61DF;95 *(uint32_t*)((char *)(icp _hw_map.vga) + 0x8) = 0x067F3800;96 *(uint32_t*)((char *)(icp _hw_map.vga) + 0x10) = ICP_FB;97 *(uint32_t *)((char *)(icp _hw_map.vga) + 0x1C) = 0x182B;98 *(uint32_t*)((char *)(icp _hw_map.cmcr)+0xC) = 0x33805000;100 *(uint32_t*)((char *)(icp.hw_map.cmcr)+0x14) = 0xA05F0000; 101 *(uint32_t*)((char *)(icp.hw_map.cmcr)+0x1C) = 0x12C11000; 102 *(uint32_t*)icp.hw_map.vga = 0x3F1F3F9C; 103 *(uint32_t*)((char *)(icp.hw_map.vga) + 0x4) = 0x080B61DF; 104 *(uint32_t*)((char *)(icp.hw_map.vga) + 0x8) = 0x067F3800; 105 *(uint32_t*)((char *)(icp.hw_map.vga) + 0x10) = ICP_FB; 106 *(uint32_t *)((char *)(icp.hw_map.vga) + 0x1C) = 0x182B; 107 *(uint32_t*)((char *)(icp.hw_map.cmcr)+0xC) = 0x33805000; 99 108 100 109 } … … 103 112 static inline uint32_t icp_irqc_get_sources(void) 104 113 { 105 return *((uint32_t *) icp _hw_map.irqc);114 return *((uint32_t *) icp.hw_map.irqc); 106 115 } 107 116 … … 113 122 static inline void icp_irqc_mask(uint32_t irq) 114 123 { 115 *((uint32_t *) icp _hw_map.irqc_mask) = (1 << irq);124 *((uint32_t *) icp.hw_map.irqc_mask) = (1 << irq); 116 125 } 117 126 … … 123 132 static inline void icp_irqc_unmask(uint32_t irq) 124 133 { 125 *((uint32_t *) icp _hw_map.irqc_unmask) |= (1 << irq);126 } 127 128 /** Initializes icp _hw_map. */134 *((uint32_t *) icp.hw_map.irqc_unmask) |= (1 << irq); 135 } 136 137 /** Initializes icp.hw_map. */ 129 138 void icp_init(void) 130 139 { 131 icp _hw_map.uart = km_map(ICP_UART, PAGE_SIZE,132 PAGE_WRITE | PAGE_NOT_CACHEABLE); 133 icp _hw_map.kbd_ctrl = km_map(ICP_KBD, PAGE_SIZE, PAGE_NOT_CACHEABLE);134 icp _hw_map.kbd_stat = icp_hw_map.kbd_ctrl + ICP_KBD_STAT;135 icp _hw_map.kbd_data = icp_hw_map.kbd_ctrl + ICP_KBD_DATA;136 icp _hw_map.kbd_intstat = icp_hw_map.kbd_ctrl + ICP_KBD_INTR_STAT;137 icp _hw_map.rtc = km_map(ICP_RTC, PAGE_SIZE,138 PAGE_WRITE | PAGE_NOT_CACHEABLE); 139 icp _hw_map.rtc1_load = icp_hw_map.rtc + ICP_RTC1_LOAD_OFFSET;140 icp _hw_map.rtc1_read = icp_hw_map.rtc + ICP_RTC1_READ_OFFSET;141 icp _hw_map.rtc1_ctl = icp_hw_map.rtc + ICP_RTC1_CTL_OFFSET;142 icp _hw_map.rtc1_intrclr = icp_hw_map.rtc + ICP_RTC1_INTRCLR_OFFSET;143 icp _hw_map.rtc1_bgload = icp_hw_map.rtc + ICP_RTC1_BGLOAD_OFFSET;144 icp _hw_map.rtc1_intrstat = icp_hw_map.rtc + ICP_RTC1_INTRSTAT_OFFSET;145 146 icp _hw_map.irqc = km_map(ICP_IRQC, PAGE_SIZE,147 PAGE_WRITE | PAGE_NOT_CACHEABLE); 148 icp _hw_map.irqc_mask = icp_hw_map.irqc + ICP_IRQC_MASK_OFFSET;149 icp _hw_map.irqc_unmask = icp_hw_map.irqc + ICP_IRQC_UNMASK_OFFSET;150 icp _hw_map.cmcr = km_map(ICP_CMCR, PAGE_SIZE,151 PAGE_WRITE | PAGE_NOT_CACHEABLE); 152 icp _hw_map.sdramcr = icp_hw_map.cmcr + ICP_SDRAMCR_OFFSET;153 icp _hw_map.vga = km_map(ICP_VGA, PAGE_SIZE,140 icp.hw_map.uart = km_map(ICP_UART, PAGE_SIZE, 141 PAGE_WRITE | PAGE_NOT_CACHEABLE); 142 icp.hw_map.kbd_ctrl = km_map(ICP_KBD, PAGE_SIZE, PAGE_NOT_CACHEABLE); 143 icp.hw_map.kbd_stat = icp.hw_map.kbd_ctrl + ICP_KBD_STAT; 144 icp.hw_map.kbd_data = icp.hw_map.kbd_ctrl + ICP_KBD_DATA; 145 icp.hw_map.kbd_intstat = icp.hw_map.kbd_ctrl + ICP_KBD_INTR_STAT; 146 icp.hw_map.rtc = km_map(ICP_RTC, PAGE_SIZE, 147 PAGE_WRITE | PAGE_NOT_CACHEABLE); 148 icp.hw_map.rtc1_load = icp.hw_map.rtc + ICP_RTC1_LOAD_OFFSET; 149 icp.hw_map.rtc1_read = icp.hw_map.rtc + ICP_RTC1_READ_OFFSET; 150 icp.hw_map.rtc1_ctl = icp.hw_map.rtc + ICP_RTC1_CTL_OFFSET; 151 icp.hw_map.rtc1_intrclr = icp.hw_map.rtc + ICP_RTC1_INTRCLR_OFFSET; 152 icp.hw_map.rtc1_bgload = icp.hw_map.rtc + ICP_RTC1_BGLOAD_OFFSET; 153 icp.hw_map.rtc1_intrstat = icp.hw_map.rtc + ICP_RTC1_INTRSTAT_OFFSET; 154 155 icp.hw_map.irqc = km_map(ICP_IRQC, PAGE_SIZE, 156 PAGE_WRITE | PAGE_NOT_CACHEABLE); 157 icp.hw_map.irqc_mask = icp.hw_map.irqc + ICP_IRQC_MASK_OFFSET; 158 icp.hw_map.irqc_unmask = icp.hw_map.irqc + ICP_IRQC_UNMASK_OFFSET; 159 icp.hw_map.cmcr = km_map(ICP_CMCR, PAGE_SIZE, 160 PAGE_WRITE | PAGE_NOT_CACHEABLE); 161 icp.hw_map.sdramcr = icp.hw_map.cmcr + ICP_SDRAMCR_OFFSET; 162 icp.hw_map.vga = km_map(ICP_VGA, PAGE_SIZE, 154 163 PAGE_WRITE | PAGE_NOT_CACHEABLE); 155 164 … … 164 173 { 165 174 icp_irqc_mask(ICP_TIMER_IRQ); 166 *((uint32_t*) icp _hw_map.rtc1_load) = frequency;167 *((uint32_t*) icp _hw_map.rtc1_bgload) = frequency;168 *((uint32_t*) icp _hw_map.rtc1_ctl) = ICP_RTC_CTL_VALUE;175 *((uint32_t*) icp.hw_map.rtc1_load) = frequency; 176 *((uint32_t*) icp.hw_map.rtc1_bgload) = frequency; 177 *((uint32_t*) icp.hw_map.rtc1_ctl) = ICP_RTC_CTL_VALUE; 169 178 icp_irqc_unmask(ICP_TIMER_IRQ); 170 179 } … … 172 181 static irq_ownership_t icp_timer_claim(irq_t *irq) 173 182 { 174 if (icp _hw_map.rtc1_intrstat) {175 *((uint32_t*) icp _hw_map.rtc1_intrclr) = 1;183 if (icp.hw_map.rtc1_intrstat) { 184 *((uint32_t*) icp.hw_map.rtc1_intrclr) = 1; 176 185 return IRQ_ACCEPT; 177 186 } else … … 200 209 static void icp_timer_irq_init(void) 201 210 { 202 irq_initialize(&icp _timer_irq);203 icp _timer_irq.devno = device_assign_devno();204 icp _timer_irq.inr = ICP_TIMER_IRQ;205 icp _timer_irq.claim = icp_timer_claim;206 icp _timer_irq.handler = icp_timer_irq_handler;207 208 irq_register(&icp _timer_irq);211 irq_initialize(&icp.timer_irq); 212 icp.timer_irq.devno = device_assign_devno(); 213 icp.timer_irq.inr = ICP_TIMER_IRQ; 214 icp.timer_irq.claim = icp_timer_claim; 215 icp.timer_irq.handler = icp_timer_irq_handler; 216 217 irq_register(&icp.timer_irq); 209 218 } 210 219 … … 231 240 232 241 if (hw_map_init_called) { 233 *size = (sdram[((*(uint32_t *)icp _hw_map.sdramcr &242 *size = (sdram[((*(uint32_t *)icp.hw_map.sdramcr & 234 243 ICP_SDRAM_MASK) >> 2)]); 235 244 } else { … … 286 295 { 287 296 #ifdef CONFIG_FB 297 static bool vga_init = false; 288 298 if (!vga_init) { 289 299 icp_vga_init(); … … 304 314 stdout_wire(fbdev); 305 315 #endif 316 #ifdef CONFIG_ARM926_UART 317 if (arm926_uart_init(&icp.uart, ARM926_UART0_IRQ, 318 ARM926_UART0_BASE_ADDRESS, sizeof(arm926_uart_regs_t))) 319 stdout_wire(&icp.uart.outdev); 320 #endif 306 321 } 307 322 … … 310 325 311 326 pl050_t *pl050 = malloc(sizeof(pl050_t), FRAME_ATOMIC); 312 pl050->status = (ioport8_t *)icp _hw_map.kbd_stat;313 pl050->data = (ioport8_t *)icp _hw_map.kbd_data;314 pl050->ctrl = (ioport8_t *)icp _hw_map.kbd_ctrl;327 pl050->status = (ioport8_t *)icp.hw_map.kbd_stat; 328 pl050->data = (ioport8_t *)icp.hw_map.kbd_data; 329 pl050->ctrl = (ioport8_t *)icp.hw_map.kbd_ctrl; 315 330 316 331 pl050_instance_t *pl050_instance = pl050_init(pl050, ICP_KBD_IRQ); … … 335 350 ICP_KBD); 336 351 352 #ifdef CONFIG_ARM926_UART 353 srln_instance_t *srln_instance = srln_init(); 354 if (srln_instance) { 355 indev_t *sink = stdin_wire(); 356 indev_t *srln = srln_wire(srln_instance, sink); 357 arm926_uart_input_wire(&icp.uart, srln); 358 icp_irqc_unmask(ARM926_UART0_IRQ); 359 } 360 #endif 337 361 } 338 362 -
kernel/arch/arm32/src/mm/page_fault.c
rfc89e32 r33c2952 77 77 } 78 78 79 /** Decides whether the instruction is load/store or not.80 *81 * @param instr Instruction82 *83 * @return true when instruction is load/store, false otherwise84 *85 */86 static inline bool is_load_store_instruction(instruction_t instr)87 {88 /* load store immediate offset */89 if (instr.type == 0x2)90 return true;91 92 /* load store register offset */93 if ((instr.type == 0x3) && (instr.bit4 == 0))94 return true;95 96 /* load store multiple */97 if (instr.type == 0x4)98 return true;99 100 /* oprocessor load/store */101 if (instr.type == 0x6)102 return true;103 104 return false;105 }106 107 /** Decides whether the instruction is swap or not.108 *109 * @param instr Instruction110 *111 * @return true when instruction is swap, false otherwise112 */113 static inline bool is_swap_instruction(instruction_t instr)114 {115 /* swap, swapb instruction */116 if ((instr.type == 0x0) &&117 ((instr.opcode == 0x8) || (instr.opcode == 0xa)) &&118 (instr.access == 0x0) && (instr.bits567 == 0x4) && (instr.bit4 == 1))119 return true;120 121 return false;122 }123 124 79 /** Decides whether read or write into memory is requested. 125 80 * … … 128 83 * 129 84 * @return Type of access into memory, PF_ACCESS_EXEC if no memory access is 130 * 85 * requested. 131 86 */ 132 87 static pf_access_t get_memory_access_type(uint32_t instr_addr, … … 146 101 } 147 102 148 /* load store instructions */ 149 if (is_load_store_instruction(instr)) { 150 if (instr.access == 1) { 151 return PF_ACCESS_READ; 152 } else { 153 return PF_ACCESS_WRITE; 103 /* See ARM Architecture reference manual ARMv7-A and ARMV7-R edition 104 * A5.3 (PDF p. 206) */ 105 static const struct { 106 uint32_t mask; 107 uint32_t value; 108 pf_access_t access; 109 } ls_inst[] = { 110 /* Store word/byte */ 111 { 0x0e100000, 0x04000000, PF_ACCESS_WRITE }, /*STR(B) imm*/ 112 { 0x0e100010, 0x06000000, PF_ACCESS_WRITE }, /*STR(B) reg*/ 113 /* Load word/byte */ 114 { 0x0e100000, 0x04100000, PF_ACCESS_READ }, /*LDR(B) imm*/ 115 { 0x0e100010, 0x06100000, PF_ACCESS_READ }, /*LDR(B) reg*/ 116 /* Store half-word/dual A5.2.8 */ 117 { 0x0e1000b0, 0x000000b0, PF_ACCESS_WRITE }, /*STRH imm reg*/ 118 /* Load half-word/dual A5.2.8 */ 119 { 0x0e0000f0, 0x000000d0, PF_ACCESS_READ }, /*LDRH imm reg*/ 120 { 0x0e1000b0, 0x001000b0, PF_ACCESS_READ }, /*LDRH imm reg*/ 121 /* Block data transfer, Store */ 122 { 0x0e100000, 0x08000000, PF_ACCESS_WRITE }, /* STM variants */ 123 { 0x0e100000, 0x08100000, PF_ACCESS_READ }, /* LDM variants */ 124 /* Swap */ 125 { 0x0fb00000, 0x01000000, PF_ACCESS_WRITE }, 126 }; 127 const uint32_t inst = *(uint32_t*)instr_addr; 128 for (unsigned i = 0; i < sizeof(ls_inst) / sizeof(ls_inst[0]); ++i) { 129 if ((inst & ls_inst[i].mask) == ls_inst[i].value) { 130 return ls_inst[i].access; 154 131 } 155 }156 157 /* swap, swpb instruction */158 if (is_swap_instruction(instr)) {159 return PF_ACCESS_WRITE;160 132 } 161 133 162 134 panic("page_fault - instruction doesn't access memory " 163 135 "(instr_code: %#0" PRIx32 ", badvaddr:%p).", 164 instr_union.pc, (void *) badvaddr); 165 166 return PF_ACCESS_EXEC; 136 inst, (void *) badvaddr); 167 137 } 168 138
Note:
See TracChangeset
for help on using the changeset viewer.