Changeset 00287cc in mainline
- Timestamp:
- 2009-03-12T23:26:32Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 648c9d9
- Parents:
- 3b122e9
- Files:
-
- 3 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r3b122e9 r00287cc 47 47 48 48 % Machine type 49 @ "gxemul" GXEmul50 ! [PLATFORM=arm32] MACHINE (choice)51 52 % Machine type53 49 @ "i460GX" i460GX chipset machine 54 50 @ "ski" Ski ia64 simulator … … 334 330 @ "generic" Keyboard or serial line 335 331 @ "none" No input device 336 ! [PLATFORM=ia32|PLATFORM=a md64|PLATFORM=mips32] CONFIG_HID_IN (choice)332 ! [PLATFORM=ia32|PLATFORM=arm32|PLATFORM=amd64|PLATFORM=mips32] CONFIG_HID_IN (choice) 337 333 338 334 % Output device class … … 348 344 ! [PLATFORM=mips32&(MACHINE=bgxemul|MACHINE=lgxemul)] CONFIG_HID_OUT (choice) 349 345 346 % Output device class 347 @ "generic" Monitor or serial line 348 @ "monitor" Monitor 349 @ "serial" Serial line 350 @ "none" No output device 351 ! [PLATFORM=arm32] CONFIG_HID_OUT (choice) 352 350 353 % PC keyboard support 351 354 ! [CONFIG_HID_IN=generic&(PLATFORM=ia32|PLATFORM=amd64)] CONFIG_PC_KBD (y/n) … … 357 360 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=mips32] CONFIG_MIPS_PRN (y/n) 358 361 362 % Support for GXemul keyboard 363 ! [CONFIG_HID_IN=generic&PLATFORM=arm32] CONFIG_ARM_KBD (y/n) 364 365 % Support for GXemul printer 366 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32] CONFIG_ARM_PRN (y/n) 367 359 368 % i8042 controller support 360 369 ! [CONFIG_PC_KBD=y] CONFIG_I8042 (y) 361 370 362 371 % Dummy serial line input 363 ! [CONFIG_MIPS_KBD=y ] CONFIG_DSRLNIN (y)372 ! [CONFIG_MIPS_KBD=y|CONFIG_ARM_KBD=y] CONFIG_DSRLNIN (y) 364 373 365 374 % Dummy serial line output 366 ! [CONFIG_MIPS_PRN=y ] CONFIG_DSRLNOUT (y)375 ! [CONFIG_MIPS_PRN=y|CONFIG_ARM_PRN=y] CONFIG_DSRLNOUT (y) 367 376 368 377 % Serial line input module … … 398 407 % Framebuffer support 399 408 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=monitor)&PLATFORM=mips32&(MACHINE=lgxemul|MACHINE=bgxemul)] CONFIG_FB (y/n) 409 410 % Framebuffer support 411 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=monitor)&PLATFORM=arm32] CONFIG_FB (y/n) 400 412 401 413 % Framebuffer support -
defaults/arm32/Makefile.config
r3b122e9 r00287cc 24 24 25 25 # What is your input device? 26 CONFIG_HID_IN = keyboard26 CONFIG_HID_IN = generic 27 27 28 28 # What is your output device? 29 CONFIG_HID_OUT = monitor 30 31 # Framebuffer support 32 CONFIG_FB = y 29 CONFIG_HID_OUT = generic 33 30 34 31 # Keyboard layout -
kernel/arch/arm32/Makefile.inc
r3b122e9 r00287cc 52 52 arch/$(KARCH)/src/ddi/ddi.c \ 53 53 arch/$(KARCH)/src/interrupt.c \ 54 arch/$(KARCH)/src/debug/print.c \55 54 arch/$(KARCH)/src/console.c \ 56 55 arch/$(KARCH)/src/exception.c \ -
kernel/arch/arm32/include/asm/boot.h
r3b122e9 r00287cc 38 38 39 39 /** Size of a temporary stack used for initial kernel start. */ 40 #define TEMP_STACK_SIZE 0x10040 #define TEMP_STACK_SIZE 0x100 41 41 42 42 #endif -
kernel/arch/arm32/include/drivers/gxemul.h
r3b122e9 r00287cc 39 39 #define KERN_arm32_GXEMUL_H_ 40 40 41 #include <console/chardev.h> 42 43 /** Last interrupt number (beginning from 0) whose status is probed 41 /** Last interrupt number (beginning from 0) whose status is probed 44 42 * from interrupt controller 45 43 */ 46 #define GXEMUL_IRQC_MAX_IRQ 8 44 #define GXEMUL_IRQC_MAX_IRQ 8 45 #define GXEMUL_KBD_IRQ 2 46 #define GXEMUL_TIMER_IRQ 4 47 47 48 48 /** Timer frequency */ 49 #define GXEMUL_TIMER_FREQ 49 #define GXEMUL_TIMER_FREQ 100 50 50 51 /** Struct containing mappings of gxemul HW devices into kernel part 52 * of virtual address space. 53 */ 54 typedef struct { 55 uintptr_t videoram; 56 uintptr_t kbd; 57 uintptr_t rtc; 58 uintptr_t rtc_freq; 59 uintptr_t rtc_ack; 60 uintptr_t irqc; 61 uintptr_t irqc_mask; 62 uintptr_t irqc_unmask; 63 } gxemul_hw_map_t; 51 #define GXEMUL_KBD_ADDRESS 0x10000000 52 #define GXEMUL_MP_ADDRESS 0x11000000 53 #define GXEMUL_FB_ADDRESS 0x12000000 54 #define GXEMUL_RTC_ADDRESS 0x15000000 55 #define GXEMUL_IRQC_ADDRESS 0x16000000 64 56 65 extern void gxemul_hw_map_init(void);66 extern void gxemul_console_init(devno_t devno);67 extern void gxemul_release_console(void);68 extern void gxemul_grab_console(void); 69 extern void gxemul_timer_irq_start(void); 70 extern void gxemul_debug_putc(char ch); 71 extern void gxemul_cpu_halt(void); 72 extern void gxemul_irq_exception(int exc_no, istate_t *istate); 73 extern size_t gxemul_get_memory_size(void); 74 extern uintptr_t gxemul_get_fb_address(void);57 extern void *gxemul_kbd; 58 extern void *gxemul_rtc; 59 extern void *gxemul_irqc; 60 61 #define GXEMUL_HALT_OFFSET 0x010 62 #define GXEMUL_RTC_FREQ_OFFSET 0x100 63 #define GXEMUL_MP_MEMSIZE_OFFSET 0x090 64 #define GXEMUL_RTC_ACK_OFFSET 0x110 65 66 extern void gxemul_init(void); 75 67 76 68 #endif -
kernel/arch/arm32/src/arm32.c
r3b122e9 r00287cc 40 40 #include <genarch/fb/fb.h> 41 41 #include <genarch/fb/visuals.h> 42 #include <genarch/drivers/dsrln/dsrlnin.h> 43 #include <genarch/drivers/dsrln/dsrlnout.h> 44 #include <genarch/srln/srln.h> 45 #include <sysinfo/sysinfo.h> 42 46 #include <ddi/irq.h> 43 #include <arch/d ebug/print.h>47 #include <arch/drivers/gxemul.h> 44 48 #include <print.h> 45 49 #include <config.h> 46 50 #include <interrupt.h> 47 51 #include <arch/regutils.h> 48 #include <arch/machine.h>49 52 #include <userspace.h> 50 53 #include <macros.h> … … 76 79 void arch_post_mm_init(void) 77 80 { 78 machine_hw_map_init();79 81 gxemul_init(); 82 80 83 /* Initialize exception dispatch table */ 81 84 exception_init(); 82 83 85 interrupt_init(); 84 86 85 machine_console_init(device_assign_devno());86 87 87 #ifdef CONFIG_FB 88 88 fb_properties_t prop = { 89 .addr = machine_get_fb_address(),89 .addr = GXEMUL_FB_ADDRESS, 90 90 .offset = 0, 91 91 .x = 640, … … 95 95 }; 96 96 fb_init(&prop); 97 #endif 97 #else 98 #ifdef CONFIG_ARM_PRN 99 dsrlnout_init((ioport8_t *) gxemul_kbd); 100 #endif /* CONFIG_ARM_PRN */ 101 #endif /* CONFIG_FB */ 98 102 } 99 103 … … 124 128 void arch_post_smp_init(void) 125 129 { 130 #ifdef CONFIG_ARM_KBD 131 devno_t devno = device_assign_devno(); 132 133 /* 134 * Initialize the msim/GXemul keyboard port. Then initialize the serial line 135 * module and connect it to the msim/GXemul keyboard. Enable keyboard interrupts. 136 */ 137 indev_t *kbrdin = dsrlnin_init((dsrlnin_t *) gxemul_kbd, devno, GXEMUL_KBD_IRQ); 138 if (kbrdin) 139 srln_init(kbrdin); 140 141 /* 142 * This is the necessary evil until the userspace driver is entirely 143 * self-sufficient. 144 */ 145 sysinfo_set_item_val("kbd", NULL, true); 146 sysinfo_set_item_val("kbd.devno", NULL, devno); 147 sysinfo_set_item_val("kbd.inr", NULL, GXEMUL_KBD_IRQ); 148 sysinfo_set_item_val("kbd.address.virtual", NULL, (unative_t) gxemul_kbd); 149 #endif 126 150 } 127 151 … … 157 181 void cpu_halt(void) 158 182 { 159 machine_cpu_halt(); 183 *((char *) (gxemul_kbd + GXEMUL_HALT_OFFSET)) 184 = 0; 160 185 } 161 186 -
kernel/arch/arm32/src/console.c
r3b122e9 r00287cc 27 27 */ 28 28 29 /** @addtogroup arm32 29 /** @addtogroup arm32 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file 33 33 * @brief Console. 34 34 */ … … 36 36 #include <console/console.h> 37 37 #include <arch/console.h> 38 #include <arch/machine.h>39 40 38 #include <genarch/fb/fb.h> 41 39 -
kernel/arch/arm32/src/drivers/gxemul.c
r3b122e9 r00287cc 34 34 */ 35 35 36 #include <interrupt.h>37 #include <console/chardev.h>38 36 #include <arch/drivers/gxemul.h> 39 #include <console/console.h>40 #include <sysinfo/sysinfo.h>41 #include <print.h>42 #include <ddi/device.h>43 37 #include <mm/page.h> 44 #include <arch/machine.h>45 #include <arch/debug/print.h>46 38 47 /* Addresses of devices. */ 48 #define GXEMUL_VIDEORAM 0x10000000 49 #define GXEMUL_KBD 0x10000000 50 #define GXEMUL_HALT_OFFSET 0x10 51 #define GXEMUL_RTC 0x15000000 52 #define GXEMUL_RTC_FREQ_OFFSET 0x100 53 #define GXEMUL_RTC_ACK_OFFSET 0x110 54 #define GXEMUL_IRQC 0x16000000 55 #define GXEMUL_IRQC_MASK_OFFSET 0x4 56 #define GXEMUL_IRQC_UNMASK_OFFSET 0x8 57 #define GXEMUL_MP 0x11000000 58 #define GXEMUL_MP_MEMSIZE_OFFSET 0x0090 59 #define GXEMUL_FB 0x12000000 39 void *gxemul_kbd; 40 void *gxemul_rtc; 41 void *gxemul_irqc; 60 42 61 /* IRQs */ 62 #define GXEMUL_KBD_IRQ 2 63 #define GXEMUL_TIMER_IRQ 4 64 65 static gxemul_hw_map_t gxemul_hw_map; 66 static chardev_t console; 67 static irq_t gxemul_console_irq; 68 static irq_t gxemul_timer_irq; 69 70 static bool hw_map_init_called = false; 71 72 static void gxemul_kbd_enable(chardev_t *dev); 73 static void gxemul_kbd_disable(chardev_t *dev); 74 static void gxemul_write(chardev_t *dev, const char ch, bool silent); 75 static char gxemul_do_read(chardev_t *dev); 76 77 static chardev_operations_t gxemul_ops = { 78 .resume = gxemul_kbd_enable, 79 .suspend = gxemul_kbd_disable, 80 .write = gxemul_write, 81 .read = gxemul_do_read, 82 }; 83 84 85 /** Returns the mask of active interrupts. */ 86 static inline uint32_t gxemul_irqc_get_sources(void) 43 void gxemul_init(void) 87 44 { 88 return *((uint32_t *) gxemul_hw_map.irqc); 89 } 90 91 92 /** Masks interrupt. 93 * 94 * @param irq interrupt number 95 */ 96 static inline void gxemul_irqc_mask(uint32_t irq) 97 { 98 *((uint32_t *) gxemul_hw_map.irqc_mask) = irq; 99 } 100 101 102 /** Unmasks interrupt. 103 * 104 * @param irq interrupt number 105 */ 106 static inline void gxemul_irqc_unmask(uint32_t irq) 107 { 108 *((uint32_t *) gxemul_hw_map.irqc_unmask) = irq; 109 } 110 111 112 /** Initializes #gxemul_hw_map. */ 113 void gxemul_hw_map_init(void) 114 { 115 gxemul_hw_map.videoram = hw_map(GXEMUL_VIDEORAM, PAGE_SIZE); 116 gxemul_hw_map.kbd = hw_map(GXEMUL_KBD, PAGE_SIZE); 117 gxemul_hw_map.rtc = hw_map(GXEMUL_RTC, PAGE_SIZE); 118 gxemul_hw_map.irqc = hw_map(GXEMUL_IRQC, PAGE_SIZE); 119 120 gxemul_hw_map.rtc_freq = gxemul_hw_map.rtc + GXEMUL_RTC_FREQ_OFFSET; 121 gxemul_hw_map.rtc_ack = gxemul_hw_map.rtc + GXEMUL_RTC_ACK_OFFSET; 122 gxemul_hw_map.irqc_mask = gxemul_hw_map.irqc + GXEMUL_IRQC_MASK_OFFSET; 123 gxemul_hw_map.irqc_unmask = gxemul_hw_map.irqc + 124 GXEMUL_IRQC_UNMASK_OFFSET; 125 126 hw_map_init_called = true; 127 } 128 129 130 /** Putchar that works with gxemul. 131 * 132 * @param dev Not used. 133 * @param ch Characted to be printed. 134 */ 135 static void gxemul_write(chardev_t *dev, const char ch, bool silent) 136 { 137 if (!silent) 138 *((char *) gxemul_hw_map.videoram) = ch; 139 } 140 141 /** Enables gxemul keyboard (interrupt unmasked). 142 * 143 * @param dev Not used. 144 * 145 * Called from getc(). 146 */ 147 static void gxemul_kbd_enable(chardev_t *dev) 148 { 149 gxemul_irqc_unmask(GXEMUL_KBD_IRQ); 150 } 151 152 /** Disables gxemul keyboard (interrupt masked). 153 * 154 * @param dev not used 155 * 156 * Called from getc(). 157 */ 158 static void gxemul_kbd_disable(chardev_t *dev) 159 { 160 gxemul_irqc_mask(GXEMUL_KBD_IRQ); 161 } 162 163 /** Read character using polling, assume interrupts disabled. 164 * 165 * @param dev Not used. 166 */ 167 static char gxemul_do_read(chardev_t *dev) 168 { 169 char ch; 170 171 while (1) { 172 ch = *((volatile char *) gxemul_hw_map.kbd); 173 if (ch) { 174 if (ch == '\r') 175 return '\n'; 176 if (ch == 0x7f) 177 return '\b'; 178 return ch; 179 } 180 } 181 } 182 183 /** Process keyboard interrupt. 184 * 185 * @param irq IRQ information. 186 */ 187 static void gxemul_irq_handler(irq_t *irq) 188 { 189 char ch = 0; 190 191 ch = *((char *) gxemul_hw_map.kbd); 192 if (ch == '\r') { 193 ch = '\n'; 194 } 195 if (ch == 0x7f) { 196 ch = '\b'; 197 } 198 chardev_push_character(&console, ch); 199 } 200 201 static irq_ownership_t gxemul_claim(irq_t *irq) 202 { 203 return IRQ_ACCEPT; 204 } 205 206 /** Initializes console object representing gxemul console. 207 * 208 * @param devno device number. 209 */ 210 void gxemul_console_init(devno_t devno) 211 { 212 chardev_initialize("gxemul_console", &console, &gxemul_ops); 213 stdin = &console; 214 stdout = &console; 215 216 irq_initialize(&gxemul_console_irq); 217 gxemul_console_irq.devno = devno; 218 gxemul_console_irq.inr = GXEMUL_KBD_IRQ; 219 gxemul_console_irq.claim = gxemul_claim; 220 gxemul_console_irq.handler = gxemul_irq_handler; 221 irq_register(&gxemul_console_irq); 222 223 gxemul_irqc_unmask(GXEMUL_KBD_IRQ); 224 225 sysinfo_set_item_val("kbd", NULL, true); 226 sysinfo_set_item_val("kbd.devno", NULL, devno); 227 sysinfo_set_item_val("kbd.inr", NULL, GXEMUL_KBD_IRQ); 228 sysinfo_set_item_val("kbd.address.virtual", NULL, gxemul_hw_map.kbd); 229 } 230 231 /** Starts gxemul Real Time Clock device, which asserts regular interrupts. 232 * 233 * @param frequency Interrupts frequency (0 disables RTC). 234 */ 235 static void gxemul_timer_start(uint32_t frequency) 236 { 237 *((uint32_t*) gxemul_hw_map.rtc_freq) = frequency; 238 } 239 240 static irq_ownership_t gxemul_timer_claim(irq_t *irq) 241 { 242 return IRQ_ACCEPT; 243 } 244 245 /** Timer interrupt handler. 246 * 247 * @param irq Interrupt information. 248 * @param arg Not used. 249 */ 250 static void gxemul_timer_irq_handler(irq_t *irq) 251 { 252 /* 253 * We are holding a lock which prevents preemption. 254 * Release the lock, call clock() and reacquire the lock again. 255 */ 256 spinlock_unlock(&irq->lock); 257 clock(); 258 spinlock_lock(&irq->lock); 259 260 /* acknowledge tick */ 261 *((uint32_t*) gxemul_hw_map.rtc_ack) = 0; 262 } 263 264 /** Initializes and registers timer interrupt handler. */ 265 static void gxemul_timer_irq_init(void) 266 { 267 irq_initialize(&gxemul_timer_irq); 268 gxemul_timer_irq.devno = device_assign_devno(); 269 gxemul_timer_irq.inr = GXEMUL_TIMER_IRQ; 270 gxemul_timer_irq.claim = gxemul_timer_claim; 271 gxemul_timer_irq.handler = gxemul_timer_irq_handler; 272 273 irq_register(&gxemul_timer_irq); 274 } 275 276 277 /** Starts timer. 278 * 279 * Initiates regular timer interrupts after initializing 280 * corresponding interrupt handler. 281 */ 282 void gxemul_timer_irq_start(void) 283 { 284 gxemul_timer_irq_init(); 285 gxemul_timer_start(GXEMUL_TIMER_FREQ); 286 } 287 288 /** Returns the size of emulated memory. 289 * 290 * @return Size in bytes. 291 */ 292 size_t gxemul_get_memory_size(void) 293 { 294 return *((int *) (GXEMUL_MP + GXEMUL_MP_MEMSIZE_OFFSET)); 295 } 296 297 /** Prints a character. 298 * 299 * @param ch Character to be printed. 300 */ 301 void gxemul_debug_putc(char ch) 302 { 303 char *addr = 0; 304 if (!hw_map_init_called) { 305 addr = (char *) GXEMUL_KBD; 306 } else { 307 addr = (char *) gxemul_hw_map.videoram; 308 } 309 310 *(addr) = ch; 311 } 312 313 /** Stops gxemul. */ 314 void gxemul_cpu_halt(void) 315 { 316 char * addr = 0; 317 if (!hw_map_init_called) { 318 addr = (char *) GXEMUL_KBD; 319 } else { 320 addr = (char *) gxemul_hw_map.videoram; 321 } 322 323 *(addr + GXEMUL_HALT_OFFSET) = '\0'; 324 } 325 326 /** Gxemul specific interrupt exception handler. 327 * 328 * Determines sources of the interrupt from interrupt controller and 329 * calls high-level handlers for them. 330 * 331 * @param exc_no Interrupt exception number. 332 * @param istate Saved processor state. 333 */ 334 void gxemul_irq_exception(int exc_no, istate_t *istate) 335 { 336 uint32_t sources = gxemul_irqc_get_sources(); 337 int i; 338 339 for (i = 0; i < GXEMUL_IRQC_MAX_IRQ; i++) { 340 if (sources & (1 << i)) { 341 irq_t *irq = irq_dispatch_and_lock(i); 342 if (irq) { 343 /* The IRQ handler was found. */ 344 irq->handler(irq); 345 spinlock_unlock(&irq->lock); 346 } else { 347 /* Spurious interrupt.*/ 348 dprintf("cpu%d: spurious interrupt (inum=%d)\n", 349 CPU->id, i); 350 } 351 } 352 } 353 } 354 355 /** Returns address of framebuffer device. 356 * 357 * @return Address of framebuffer device. 358 */ 359 uintptr_t gxemul_get_fb_address(void) 360 { 361 return (uintptr_t) GXEMUL_FB; 45 gxemul_kbd = (void *) hw_map(GXEMUL_KBD_ADDRESS, PAGE_SIZE); 46 gxemul_rtc = (void *) hw_map(GXEMUL_RTC_ADDRESS, PAGE_SIZE); 47 gxemul_irqc = (void *) hw_map(GXEMUL_IRQC_ADDRESS, PAGE_SIZE); 362 48 } 363 49 -
kernel/arch/arm32/src/exception.c
r3b122e9 r00287cc 35 35 36 36 #include <arch/exception.h> 37 #include <arch/debug/print.h>38 37 #include <arch/memstr.h> 39 38 #include <arch/regutils.h> 40 39 #include <interrupt.h> 41 #include <arch/machine.h>42 40 #include <arch/mm/page_fault.h> 43 41 #include <arch/barrier.h> 42 #include <arch/drivers/gxemul.h> 44 43 #include <print.h> 45 44 #include <syscall/syscall.h> … … 261 260 static void prefetch_abort_exception_entry(void) 262 261 { 263 asm("sub lr, lr, #4"); 262 asm volatile ( 263 "sub lr, lr, #4" 264 ); 265 264 266 PROCESS_EXCEPTION(EXC_PREFETCH_ABORT); 265 267 } … … 268 270 static void data_abort_exception_entry(void) 269 271 { 270 asm("sub lr, lr, #8"); 272 asm volatile ( 273 "sub lr, lr, #8" 274 ); 275 271 276 PROCESS_EXCEPTION(EXC_DATA_ABORT); 272 277 } … … 280 285 static void irq_exception_entry(void) 281 286 { 282 asm("sub lr, lr, #4"); 287 asm volatile ( 288 "sub lr, lr, #4" 289 ); 290 283 291 setup_stack_and_save_regs(); 284 292 … … 300 308 } 301 309 310 /** Returns the mask of active interrupts. */ 311 static inline uint32_t gxemul_irqc_get_sources(void) 312 { 313 return *((uint32_t *) gxemul_irqc); 314 } 315 302 316 /** Interrupt Exception handler. 303 317 * … … 306 320 static void irq_exception(int exc_no, istate_t *istate) 307 321 { 308 machine_irq_exception(exc_no, istate); 322 uint32_t sources = gxemul_irqc_get_sources(); 323 unsigned int i; 324 325 for (i = 0; i < GXEMUL_IRQC_MAX_IRQ; i++) { 326 if (sources & (1 << i)) { 327 irq_t *irq = irq_dispatch_and_lock(i); 328 if (irq) { 329 /* The IRQ handler was found. */ 330 irq->handler(irq); 331 spinlock_unlock(&irq->lock); 332 } else { 333 /* Spurious interrupt.*/ 334 printf("cpu%d: spurious interrupt (inum=%d)\n", 335 CPU->id, i); 336 } 337 } 338 } 309 339 } 310 340 … … 330 360 (unsigned *) EXC_IRQ_VEC); 331 361 332 install_handler((unsigned) fiq_exception_entry,362 install_handler((unsigned) fiq_exception_entry, 333 363 (unsigned *) EXC_FIQ_VEC); 334 364 } … … 380 410 void print_istate(istate_t *istate) 381 411 { 382 dprintf("istate dump:\n");383 384 dprintf(" r0: %x r1: %x r2: %x r3: %x\n",412 printf("istate dump:\n"); 413 414 printf(" r0: %x r1: %x r2: %x r3: %x\n", 385 415 istate->r0, istate->r1, istate->r2, istate->r3); 386 dprintf(" r4: %x r5: %x r6: %x r7: %x\n",416 printf(" r4: %x r5: %x r6: %x r7: %x\n", 387 417 istate->r4, istate->r5, istate->r6, istate->r7); 388 dprintf(" r8: %x r8: %x r10: %x r11: %x\n",418 printf(" r8: %x r8: %x r10: %x r11: %x\n", 389 419 istate->r8, istate->r9, istate->r10, istate->r11); 390 dprintf(" r12: %x sp: %x lr: %x spsr: %x\n",420 printf(" r12: %x sp: %x lr: %x spsr: %x\n", 391 421 istate->r12, istate->sp, istate->lr, istate->spsr); 392 393 dprintf(" pc: %x\n", istate->pc);422 423 printf(" pc: %x\n", istate->pc); 394 424 } 395 425 -
kernel/arch/arm32/src/interrupt.c
r3b122e9 r00287cc 36 36 #include <arch/asm.h> 37 37 #include <arch/regutils.h> 38 #include <arch/drivers/gxemul.h> 38 39 #include <ddi/irq.h> 39 #include < arch/machine.h>40 #include <ddi/device.h> 40 41 #include <interrupt.h> 41 42 42 43 /** Initial size of a table holding interrupt handlers. */ 43 44 #define IRQ_COUNT 8 45 46 static irq_t gxemul_timer_irq; 44 47 45 48 /** Disable interrupts. … … 50 53 { 51 54 ipl_t ipl = current_status_reg_read(); 52 55 53 56 current_status_reg_control_write(STATUS_REG_IRQ_DISABLED_BIT | ipl); 54 57 … … 63 66 { 64 67 ipl_t ipl = current_status_reg_read(); 65 68 66 69 current_status_reg_control_write(ipl & ~STATUS_REG_IRQ_DISABLED_BIT); 67 70 68 71 return ipl; 69 72 } … … 89 92 } 90 93 94 /** Starts gxemul Real Time Clock device, which asserts regular interrupts. 95 * 96 * @param frequency Interrupts frequency (0 disables RTC). 97 */ 98 static void gxemul_timer_start(uint32_t frequency) 99 { 100 *((uint32_t *) (gxemul_rtc + GXEMUL_RTC_FREQ_OFFSET)) 101 = frequency; 102 } 103 104 static irq_ownership_t gxemul_timer_claim(irq_t *irq) 105 { 106 return IRQ_ACCEPT; 107 } 108 109 /** Timer interrupt handler. 110 * 111 * @param irq Interrupt information. 112 * @param arg Not used. 113 */ 114 static void gxemul_timer_irq_handler(irq_t *irq) 115 { 116 /* 117 * We are holding a lock which prevents preemption. 118 * Release the lock, call clock() and reacquire the lock again. 119 */ 120 spinlock_unlock(&irq->lock); 121 clock(); 122 spinlock_lock(&irq->lock); 123 124 /* acknowledge tick */ 125 *((uint32_t *) (gxemul_rtc + GXEMUL_RTC_ACK_OFFSET)) 126 = 0; 127 } 128 91 129 /** Initialize basic tables for exception dispatching 92 130 * and starts the timer. … … 95 133 { 96 134 irq_init(IRQ_COUNT, IRQ_COUNT); 97 machine_timer_irq_start(); 135 136 irq_initialize(&gxemul_timer_irq); 137 gxemul_timer_irq.devno = device_assign_devno(); 138 gxemul_timer_irq.inr = GXEMUL_TIMER_IRQ; 139 gxemul_timer_irq.claim = gxemul_timer_claim; 140 gxemul_timer_irq.handler = gxemul_timer_irq_handler; 141 142 irq_register(&gxemul_timer_irq); 143 144 gxemul_timer_start(GXEMUL_TIMER_FREQ); 98 145 } 99 146 -
kernel/arch/arm32/src/mm/frame.c
r3b122e9 r00287cc 36 36 #include <mm/frame.h> 37 37 #include <arch/mm/frame.h> 38 #include <arch/ machine.h>38 #include <arch/drivers/gxemul.h> 39 39 #include <config.h> 40 #include <arch/debug/print.h>41 40 42 41 /** Address of the last frame in the memory. */ … … 46 45 void frame_arch_init(void) 47 46 { 48 /* all memory as one zone */ 49 zone_create(0, ADDR2PFN(machine_get_memory_size()), 47 last_frame = *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET)); 48 49 /* All memory as one zone */ 50 zone_create(0, ADDR2PFN(last_frame), 50 51 BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0); 51 last_frame = machine_get_memory_size();52 52 53 53 /* blacklist boot page table */ … … 59 59 void boot_page_table_free(void) 60 60 { 61 int i;62 for (i = 0; i < BOOT_PAGE_TABLE_SIZE_IN_FRAMES; i++) {61 unsigned int i; 62 for (i = 0; i < BOOT_PAGE_TABLE_SIZE_IN_FRAMES; i++) 63 63 frame_free(i * FRAME_SIZE + BOOT_PAGE_TABLE_ADDRESS); 64 }65 64 } 66 65 -
kernel/arch/arm32/src/mm/page.c
r3b122e9 r00287cc 52 52 void page_arch_init(void) 53 53 { 54 int flags = PAGE_CACHEABLE; 55 page_mapping_operations = &pt_mapping_operations; 56 54 57 uintptr_t cur; 55 int flags; 56 57 page_mapping_operations = &pt_mapping_operations; 58 59 flags = PAGE_CACHEABLE; 60 61 /* PA2KA(identity) mapping for all frames until last_frame */ 62 for (cur = 0; cur < last_frame; cur += FRAME_SIZE) { 58 /* Kernel identity mapping */ 59 for (cur = 0; cur < last_frame; cur += FRAME_SIZE) 63 60 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 64 }65 61 66 /* create mapping for exception table at high offset */62 /* Create mapping for exception table at high offset */ 67 63 #ifdef HIGH_EXCEPTION_VECTORS 68 64 void *virtaddr = frame_alloc(ONE_FRAME, FRAME_KA); … … 71 67 #error "Only high exception vector supported now" 72 68 #endif 73 69 74 70 as_switch(NULL, AS_KERNEL); 75 71 76 72 boot_page_table_free(); 77 73 } … … 94 90 physaddr, size) 95 91 } 96 92 97 93 uintptr_t virtaddr = PA2KA(last_frame); 98 94 pfn_t i; … … 102 98 PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL); 103 99 } 104 100 105 101 last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE); 106 102 return virtaddr; -
kernel/arch/arm32/src/mm/page_fault.c
r3b122e9 r00287cc 35 35 #include <panic.h> 36 36 #include <arch/exception.h> 37 #include <arch/debug/print.h>38 37 #include <arch/mm/page_fault.h> 39 38 #include <mm/as.h> … … 183 182 if (ret == AS_PF_FAULT) { 184 183 print_istate(istate); 185 dprintf("page fault - pc: %x, va: %x, status: %x(%x), "184 printf("page fault - pc: %x, va: %x, status: %x(%x), " 186 185 "access:%d\n", istate->pc, badvaddr, fsr.status, fsr, 187 186 access); 188 187 189 188 fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr); 190 189 panic("Page fault."); … … 202 201 203 202 if (ret == AS_PF_FAULT) { 204 dprintf("prefetch_abort\n");203 printf("prefetch_abort\n"); 205 204 print_istate(istate); 206 205 panic("page fault - prefetch_abort at address: %x.", -
kernel/arch/arm32/src/panic.S
r3b122e9 r00287cc 32 32 33 33 panic_printf: 34 bl debug_printf34 bl printf 35 35 bl cpu_halt
Note:
See TracChangeset
for help on using the changeset viewer.