45,7 → 45,7 |
#include <arch/debug/print.h> |
|
|
/** Address of devices. */ |
/** Addresses of devices. */ |
#define GXEMUL_VIDEORAM 0x10000000 |
#define GXEMUL_KBD 0x10000000 |
#define GXEMUL_HALT_OFFSET 0x10 |
83,7 → 83,7 |
.read = gxemul_do_read, |
}; |
|
/** Return the mask of active interrupts. */ |
/** Returns the mask of active interrupts. */ |
static inline uint32_t gxemul_irqc_get_sources(void) |
{ |
return *(uint32_t*) gxemul_hw_map.irqc; |
238,6 → 238,10 |
return IRQ_ACCEPT; |
} |
|
/** Timer interrupt handler. |
* |
* @param irq interrupt information |
*/ |
static void gxemul_timer_irq_handler(irq_t *irq, void *arg, ...) |
{ |
/* TODO time drifts ?? |
269,8 → 273,7 |
*/ |
} |
|
/** |
* Initializes and registers timer interrupt handler. |
/** Initializes and registers timer interrupt handler. |
*/ |
static void gxemul_timer_irq_init() |
{ |
283,6 → 286,11 |
irq_register(&gxemul_timer_irq); |
} |
|
/** Starts timer. |
* |
* Initiates regular timer interrupts after initializing |
* corresponding interrupt handler. |
*/ |
void machine_timer_irq_start() |
{ |
gxemul_timer_irq_init(); |
289,6 → 297,10 |
gxemul_timer_start(GXEMUL_TIMER_FREQ); |
} |
|
/** Returns the size of emulated memory. |
* |
* @return size in bytes |
*/ |
size_t machine_get_memory_size(void) |
{ |
return *((int*)(GXEMUL_MP + GXEMUL_MP_MEMSIZE_OFFSET)); |
306,6 → 318,7 |
*(addr) = ch; |
} |
|
/** Stops gxemul. */ |
void machine_cpu_halt(void) |
{ |
char * addr = 0; |
318,26 → 331,16 |
*(addr + GXEMUL_HALT_OFFSET) = '\0'; |
} |
|
/** Gxemul specific interrupt exception handler. |
* |
* Determines sources of the interrupt from interrupt controller and |
* calls high-level handlers for them. |
* |
* @param exc_no interrupt exception number |
* @param istate saved processor state |
*/ |
void machine_irq_exception(int exc_no, istate_t *istate) |
{ |
/* switch to Undefined mode */ |
/* |
asm volatile( |
"stmfd sp!, {r0-r3}\n" |
"mov r1, sp\n" |
"mov r2, lr\n" |
"mrs r3, spsr\n" |
"mrs r0, cpsr\n" |
"bic r0, r0, #0x1f\n" |
"orr r0, r0, #0x1b\n" |
"msr cpsr_c, r0\n" |
"mov sp, r1\n" |
"mov lr, r2\n" |
"msr spsr, r3\n" |
"ldmfd sp!, {r0-r3}\n" |
); |
*/ |
|
uint32_t sources = gxemul_irqc_get_sources(); |
int i = 0; |
for (; i < GXEMUL_IRQC_MAX_IRQ; i++) { |
353,30 → 356,8 |
} |
} |
} |
/* TODO remove after testing the above code |
noirq = 0; |
if (i == CONSOLE_IRQ) { |
char readchar = *(char*)0x10000000; |
if (readchar == 0) { |
aux_puts("?"); |
} |
else { |
dprintf("%c", readchar); |
} |
|
} |
else if (i == TIMER_IRQ) { |
dprintf("\n.\n"); |
//acknowledge |
*(uint32_t*)0x15000110 = 0; |
} |
} |
} |
|
if (noirq) |
aux_puts("IRQ exception without source\n");*/ |
} |
|
|
/** @} |
*/ |