--- trunk/src/devices/dev_cons.c 2007/10/08 16:18:38 12 +++ trunk/src/devices/dev_cons.c 2007/10/08 16:21:17 34 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2005 Anders Gavare. All rights reserved. + * Copyright (C) 2003-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_cons.c,v 1.27 2005/07/12 08:49:13 debug Exp $ + * $Id: dev_cons.c,v 1.40 2007/02/03 20:14:23 debug Exp $ * * A simple console device, useful for simple tests. * @@ -42,45 +42,45 @@ #include "console.h" #include "cpu.h" #include "device.h" -#include "devices.h" #include "machine.h" #include "memory.h" #include "misc.h" +#include "testmachine/dev_cons.h" #define CONS_TICK_SHIFT 14 +struct cons_data { + int console_handle; + int in_use; + struct interrupt irq; +}; -/* - * dev_cons_tick(): - */ -void dev_cons_tick(struct cpu *cpu, void *extra) + +DEVICE_TICK(cons) { - struct cpu *c = cpu->machine->cpus[0]; struct cons_data *d = extra; - cpu_interrupt_ack(c, d->irq_nr); + INTERRUPT_DEASSERT(d->irq); if (console_charavail(d->console_handle)) - cpu_interrupt(c, d->irq_nr); + INTERRUPT_ASSERT(d->irq); } -/* - * dev_cons_access(): - */ -int dev_cons_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(cons) { struct cons_data *d = extra; - int i; + unsigned int i; /* Exit the emulator: */ if (relative_addr == DEV_CONS_HALT) { - cpu->running = 0; - cpu->machine->exit_without_entering_debugger = 1; - return 1; + /* cpu->running = 0; + cpu->machine->exit_without_entering_debugger = 1; + return 1; */ + /* TODO: this doesn't work yet. for now, let's + simply use exit() */ + exit(1); } if (writeflag == MEM_WRITE) { @@ -112,10 +112,7 @@ } -/* - * devinit_cons(): - */ -int devinit_cons(struct devinit *devinit) +DEVINIT(cons) { struct cons_data *d; char *name3; @@ -141,16 +138,20 @@ else snprintf(name3, nlen, "%s", devinit->name); - d->irq_nr = devinit->irq_nr; - d->console_handle = console_start_slave(devinit->machine, name3); + INTERRUPT_CONNECT(devinit->interrupt_path, d->irq); + + d->in_use = devinit->in_use; + d->console_handle = console_start_slave(devinit->machine, name3, + d->in_use); memory_device_register(devinit->machine->memory, name3, devinit->addr, DEV_CONS_LENGTH, dev_cons_access, d, - MEM_DEFAULT, NULL); + DM_DEFAULT, NULL); machine_add_tickfunction(devinit->machine, dev_cons_tick, - d, CONS_TICK_SHIFT); + d, CONS_TICK_SHIFT, 0.0); - devinit->return_ptr = d; + /* NOTE: Ugly cast into pointer */ + devinit->return_ptr = (void *)(size_t)d->console_handle; return 1; }