Subversion Repositories HelenOS

Rev

Rev 2304 | Rev 2326 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2304 Rev 2306
Line 36... Line 36...
36
#include <arch/exception.h>
36
#include <arch/exception.h>
37
#include <arch/debug_print/print.h>
37
#include <arch/debug_print/print.h>
38
#include <arch/memstr.h>
38
#include <arch/memstr.h>
39
#include <arch/regutils.h>
39
#include <arch/regutils.h>
40
#include <interrupt.h>
40
#include <interrupt.h>
41
#include <arch/drivers/gxemul.h>
41
#include <arch/machine.h>
42
#include <arch/mm/page_fault.h>
42
#include <arch/mm/page_fault.h>
43
#include <print.h>
43
#include <print.h>
44
#include <syscall/syscall.h>
44
#include <syscall/syscall.h>
45
 
45
 
46
#define PREFETCH_OFFSET     0x8
46
#define PREFETCH_OFFSET      0x8
47
#define BRANCH_OPCODE       0xea000000
47
#define BRANCH_OPCODE        0xea000000
48
#define LDR_OPCODE      0xe59ff000
48
#define LDR_OPCODE           0xe59ff000
49
#define VALID_BRANCH_MASK   0xff000000
49
#define VALID_BRANCH_MASK    0xff000000
50
#define EXC_VECTORS_SIZE    0x20
50
#define EXC_VECTORS_SIZE     0x20
51
#define EXC_VECTORS     0x8
51
#define EXC_VECTORS          0x8
52
 
52
 
53
extern uintptr_t supervisor_sp;
53
extern uintptr_t supervisor_sp;
54
extern uintptr_t exc_stack;
54
extern uintptr_t exc_stack;
55
 
55
 
56
inline static void setup_stack_and_save_regs()
56
inline static void setup_stack_and_save_regs()
Line 261... Line 261...
261
 *
261
 *
262
 * Determines the sources of interrupt, and calls their handlers.
262
 * Determines the sources of interrupt, and calls their handlers.
263
 */
263
 */
264
static void irq_exception(int exc_no, istate_t *istate)
264
static void irq_exception(int exc_no, istate_t *istate)
265
{
265
{
266
// TODO: move somewhere to gxemul.c and use machine_irq_exception (or some similar
-
 
267
// name) to avoid using MACHINE == MACHINE_GXEMUL_TESTARM
-
 
268
#if MACHINE == MACHINE_GXEMUL_TESTARM
-
 
269
    uint32_t sources = gxemul_irqc_get_sources();
-
 
270
    int i = 0;
-
 
271
    for (; i < GXEMUL_IRQC_MAX_IRQ; i++) {
-
 
272
        if (sources & (1 << i)) {
-
 
273
            irq_t *irq = irq_dispatch_and_lock(i);
-
 
274
            if (irq) {
-
 
275
                /* The IRQ handler was found. */
-
 
276
                irq->handler(irq, irq->arg);
-
 
277
                spinlock_unlock(&irq->lock);
-
 
278
            } else {
-
 
279
                /* Spurious interrupt.*/
-
 
280
                dprintf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, i);
-
 
281
            }
-
 
282
        }
-
 
283
    }
-
 
284
#endif
-
 
285
/* TODO remove after testing the above code
-
 
286
            noirq = 0;
-
 
287
            if (i == CONSOLE_IRQ) {
-
 
288
                char readchar = *(char*)0x10000000;
-
 
289
                if (readchar == 0) {
-
 
290
                    aux_puts("?");
-
 
291
                }
-
 
292
                else {
-
 
293
                    dprintf("%c", readchar);
-
 
294
                }
-
 
295
               
-
 
296
            }
-
 
297
            else if (i == TIMER_IRQ) {
-
 
298
                dprintf("\n.\n");
-
 
299
                //acknowledge
-
 
300
                *(uint32_t*)0x15000110 = 0;
-
 
301
            }
-
 
302
        }
-
 
303
    }
-
 
304
 
-
 
305
    if (noirq)
-
 
306
    aux_puts("IRQ exception without source\n");*/
266
    machine_irq_exception(exc_no, istate);
307
}
267
}
308
 
268
 
309
/** Fills exception vectors with appropriate exception handlers.
269
/** Fills exception vectors with appropriate exception handlers.
310
*/
270
*/
311
void install_exception_handlers(void)
271
void install_exception_handlers(void)