Changeset 00287cc in mainline


Ignore:
Timestamp:
2009-03-12T23:26:32Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
648c9d9
Parents:
3b122e9
Message:

arm32: update for the new scheme of device drivers and keyboard/serial modules
streamline arm32 port (as GXemul is still the only machine supported), more cleanup is needed

Files:
3 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r3b122e9 r00287cc  
    4747
    4848% Machine type
    49 @ "gxemul" GXEmul
    50 ! [PLATFORM=arm32] MACHINE (choice)
    51 
    52 % Machine type
    5349@ "i460GX" i460GX chipset machine
    5450@ "ski" Ski ia64 simulator
     
    334330@ "generic" Keyboard or serial line
    335331@ "none" No input device
    336 ! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=mips32] CONFIG_HID_IN (choice)
     332! [PLATFORM=ia32|PLATFORM=arm32|PLATFORM=amd64|PLATFORM=mips32] CONFIG_HID_IN (choice)
    337333
    338334% Output device class
     
    348344! [PLATFORM=mips32&(MACHINE=bgxemul|MACHINE=lgxemul)] CONFIG_HID_OUT (choice)
    349345
     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
    350353% PC keyboard support
    351354! [CONFIG_HID_IN=generic&(PLATFORM=ia32|PLATFORM=amd64)] CONFIG_PC_KBD (y/n)
     
    357360! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=mips32] CONFIG_MIPS_PRN (y/n)
    358361
     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
    359368% i8042 controller support
    360369! [CONFIG_PC_KBD=y] CONFIG_I8042 (y)
    361370
    362371% Dummy serial line input
    363 ! [CONFIG_MIPS_KBD=y] CONFIG_DSRLNIN (y)
     372! [CONFIG_MIPS_KBD=y|CONFIG_ARM_KBD=y] CONFIG_DSRLNIN (y)
    364373
    365374% Dummy serial line output
    366 ! [CONFIG_MIPS_PRN=y] CONFIG_DSRLNOUT (y)
     375! [CONFIG_MIPS_PRN=y|CONFIG_ARM_PRN=y] CONFIG_DSRLNOUT (y)
    367376
    368377% Serial line input module
     
    398407% Framebuffer support
    399408! [(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)
    400412
    401413% Framebuffer support
  • defaults/arm32/Makefile.config

    r3b122e9 r00287cc  
    2424
    2525# What is your input device?
    26 CONFIG_HID_IN = keyboard
     26CONFIG_HID_IN = generic
    2727
    2828# What is your output device?
    29 CONFIG_HID_OUT = monitor
    30 
    31 # Framebuffer support
    32 CONFIG_FB = y
     29CONFIG_HID_OUT = generic
    3330
    3431# Keyboard layout
  • kernel/arch/arm32/Makefile.inc

    r3b122e9 r00287cc  
    5252        arch/$(KARCH)/src/ddi/ddi.c \
    5353        arch/$(KARCH)/src/interrupt.c \
    54         arch/$(KARCH)/src/debug/print.c \
    5554        arch/$(KARCH)/src/console.c \
    5655        arch/$(KARCH)/src/exception.c \
  • kernel/arch/arm32/include/asm/boot.h

    r3b122e9 r00287cc  
    3838
    3939/** Size of a temporary stack used for initial kernel start. */
    40 #define TEMP_STACK_SIZE 0x100
     40#define TEMP_STACK_SIZE  0x100
    4141
    4242#endif
  • kernel/arch/arm32/include/drivers/gxemul.h

    r3b122e9 r00287cc  
    3939#define KERN_arm32_GXEMUL_H_
    4040
    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
    4442 * from interrupt controller
    4543 */
    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
    4747
    4848/** Timer frequency */
    49 #define GXEMUL_TIMER_FREQ               100
     49#define GXEMUL_TIMER_FREQ  100
    5050
    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
    6456
    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);
     57extern void *gxemul_kbd;
     58extern void *gxemul_rtc;
     59extern 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
     66extern void gxemul_init(void);
    7567
    7668#endif
  • kernel/arch/arm32/src/arm32.c

    r3b122e9 r00287cc  
    4040#include <genarch/fb/fb.h>
    4141#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>
    4246#include <ddi/irq.h>
    43 #include <arch/debug/print.h>
     47#include <arch/drivers/gxemul.h>
    4448#include <print.h>
    4549#include <config.h>
    4650#include <interrupt.h>
    4751#include <arch/regutils.h>
    48 #include <arch/machine.h>
    4952#include <userspace.h>
    5053#include <macros.h>
     
    7679void arch_post_mm_init(void)
    7780{
    78         machine_hw_map_init();
    79 
     81        gxemul_init();
     82       
    8083        /* Initialize exception dispatch table */
    8184        exception_init();
    82 
    8385        interrupt_init();
    8486       
    85         machine_console_init(device_assign_devno());
    86 
    8787#ifdef CONFIG_FB
    8888        fb_properties_t prop = {
    89                 .addr = machine_get_fb_address(),
     89                .addr = GXEMUL_FB_ADDRESS,
    9090                .offset = 0,
    9191                .x = 640,
     
    9595        };
    9696        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 */
    98102}
    99103
     
    124128void arch_post_smp_init(void)
    125129{
     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
    126150}
    127151
     
    157181void cpu_halt(void)
    158182{
    159         machine_cpu_halt();
     183        *((char *) (gxemul_kbd + GXEMUL_HALT_OFFSET))
     184                = 0;
    160185}
    161186
  • kernel/arch/arm32/src/console.c

    r3b122e9 r00287cc  
    2727 */
    2828
    29 /** @addtogroup arm32   
     29/** @addtogroup arm32
    3030 * @{
    3131 */
    32 /** @file 
     32/** @file
    3333 *  @brief Console.
    3434 */
     
    3636#include <console/console.h>
    3737#include <arch/console.h>
    38 #include <arch/machine.h>
    39 
    4038#include <genarch/fb/fb.h>
    4139
  • kernel/arch/arm32/src/drivers/gxemul.c

    r3b122e9 r00287cc  
    3434 */
    3535
    36 #include <interrupt.h>
    37 #include <console/chardev.h>
    3836#include <arch/drivers/gxemul.h>
    39 #include <console/console.h>
    40 #include <sysinfo/sysinfo.h>
    41 #include <print.h>
    42 #include <ddi/device.h>
    4337#include <mm/page.h>
    44 #include <arch/machine.h>
    45 #include <arch/debug/print.h>
    4638
    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
     39void *gxemul_kbd;
     40void *gxemul_rtc;
     41void *gxemul_irqc;
    6042
    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)
     43void gxemul_init(void)
    8744{
    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);
    36248}
    36349
  • kernel/arch/arm32/src/exception.c

    r3b122e9 r00287cc  
    3535
    3636#include <arch/exception.h>
    37 #include <arch/debug/print.h>
    3837#include <arch/memstr.h>
    3938#include <arch/regutils.h>
    4039#include <interrupt.h>
    41 #include <arch/machine.h>
    4240#include <arch/mm/page_fault.h>
    4341#include <arch/barrier.h>
     42#include <arch/drivers/gxemul.h>
    4443#include <print.h>
    4544#include <syscall/syscall.h>
     
    261260static void prefetch_abort_exception_entry(void)
    262261{
    263         asm("sub lr, lr, #4");
     262        asm volatile (
     263                "sub lr, lr, #4"
     264        );
     265       
    264266        PROCESS_EXCEPTION(EXC_PREFETCH_ABORT);
    265267}
     
    268270static void data_abort_exception_entry(void)
    269271{
    270         asm("sub lr, lr, #8");
     272        asm volatile (
     273                "sub lr, lr, #8"
     274        );
     275       
    271276        PROCESS_EXCEPTION(EXC_DATA_ABORT);
    272277}
     
    280285static void irq_exception_entry(void)
    281286{
    282         asm("sub lr, lr, #4");
     287        asm volatile (
     288                "sub lr, lr, #4"
     289        );
     290       
    283291        setup_stack_and_save_regs();
    284292       
     
    300308}
    301309
     310/** Returns the mask of active interrupts. */
     311static inline uint32_t gxemul_irqc_get_sources(void)
     312{
     313        return *((uint32_t *) gxemul_irqc);
     314}
     315
    302316/** Interrupt Exception handler.
    303317 *
     
    306320static void irq_exception(int exc_no, istate_t *istate)
    307321{
    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        }
    309339}
    310340
     
    330360            (unsigned *) EXC_IRQ_VEC);
    331361       
    332         install_handler((unsigned)fiq_exception_entry,
     362        install_handler((unsigned) fiq_exception_entry,
    333363            (unsigned *) EXC_FIQ_VEC);
    334364}
     
    380410void print_istate(istate_t *istate)
    381411{
    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",
    385415            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",
    387417            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",
    389419            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",
    391421            istate->r12, istate->sp, istate->lr, istate->spsr);
    392 
    393         dprintf(" pc: %x\n", istate->pc);
     422       
     423        printf(" pc: %x\n", istate->pc);
    394424}
    395425
  • kernel/arch/arm32/src/interrupt.c

    r3b122e9 r00287cc  
    3636#include <arch/asm.h>
    3737#include <arch/regutils.h>
     38#include <arch/drivers/gxemul.h>
    3839#include <ddi/irq.h>
    39 #include <arch/machine.h>
     40#include <ddi/device.h>
    4041#include <interrupt.h>
    4142
    4243/** Initial size of a table holding interrupt handlers. */
    4344#define IRQ_COUNT 8
     45
     46static irq_t gxemul_timer_irq;
    4447
    4548/** Disable interrupts.
     
    5053{
    5154        ipl_t ipl = current_status_reg_read();
    52 
     55       
    5356        current_status_reg_control_write(STATUS_REG_IRQ_DISABLED_BIT | ipl);
    5457       
     
    6366{
    6467        ipl_t ipl = current_status_reg_read();
    65 
     68       
    6669        current_status_reg_control_write(ipl & ~STATUS_REG_IRQ_DISABLED_BIT);
    67 
     70       
    6871        return ipl;
    6972}
     
    8992}
    9093
     94/** Starts gxemul Real Time Clock device, which asserts regular interrupts.
     95 *
     96 * @param frequency Interrupts frequency (0 disables RTC).
     97 */
     98static void gxemul_timer_start(uint32_t frequency)
     99{
     100        *((uint32_t *) (gxemul_rtc + GXEMUL_RTC_FREQ_OFFSET))
     101            = frequency;
     102}
     103
     104static 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 */
     114static 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
    91129/** Initialize basic tables for exception dispatching
    92130 * and starts the timer.
     
    95133{
    96134        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);
    98145}
    99146
  • kernel/arch/arm32/src/mm/frame.c

    r3b122e9 r00287cc  
    3636#include <mm/frame.h>
    3737#include <arch/mm/frame.h>
    38 #include <arch/machine.h>
     38#include <arch/drivers/gxemul.h>
    3939#include <config.h>
    40 #include <arch/debug/print.h>
    4140
    4241/** Address of the last frame in the memory. */
     
    4645void frame_arch_init(void)
    4746{
    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),
    5051            BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0);
    51         last_frame = machine_get_memory_size();
    5252       
    5353        /* blacklist boot page table */
     
    5959void boot_page_table_free(void)
    6060{
    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++)
    6363                frame_free(i * FRAME_SIZE + BOOT_PAGE_TABLE_ADDRESS);
    64         }
    6564}
    6665
  • kernel/arch/arm32/src/mm/page.c

    r3b122e9 r00287cc  
    5252void page_arch_init(void)
    5353{
     54        int flags = PAGE_CACHEABLE;
     55        page_mapping_operations = &pt_mapping_operations;
     56       
    5457        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)
    6360                page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
    64         }
    6561       
    66         /* create mapping for exception table at high offset */
     62        /* Create mapping for exception table at high offset */
    6763#ifdef HIGH_EXCEPTION_VECTORS
    6864        void *virtaddr = frame_alloc(ONE_FRAME, FRAME_KA);
     
    7167#error "Only high exception vector supported now"
    7268#endif
    73 
     69       
    7470        as_switch(NULL, AS_KERNEL);
    75 
     71       
    7672        boot_page_table_free();
    7773}
     
    9490                    physaddr, size)
    9591        }
    96 
     92       
    9793        uintptr_t virtaddr = PA2KA(last_frame);
    9894        pfn_t i;
     
    10298                    PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL);
    10399        }
    104 
     100       
    105101        last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
    106102        return virtaddr;
  • kernel/arch/arm32/src/mm/page_fault.c

    r3b122e9 r00287cc  
    3535#include <panic.h>
    3636#include <arch/exception.h>
    37 #include <arch/debug/print.h>
    3837#include <arch/mm/page_fault.h>
    3938#include <mm/as.h>
     
    183182        if (ret == AS_PF_FAULT) {
    184183                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), "
    186185                    "access:%d\n", istate->pc, badvaddr, fsr.status, fsr,
    187186                    access);
    188 
     187               
    189188                fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr);
    190189                panic("Page fault.");
     
    202201
    203202        if (ret == AS_PF_FAULT) {
    204                 dprintf("prefetch_abort\n");
     203                printf("prefetch_abort\n");
    205204                print_istate(istate);
    206205                panic("page fault - prefetch_abort at address: %x.",
  • kernel/arch/arm32/src/panic.S

    r3b122e9 r00287cc  
    3232
    3333panic_printf:
    34         bl debug_printf
     34        bl printf
    3535        bl cpu_halt
Note: See TracChangeset for help on using the changeset viewer.