--- trunk/src/devices/dev_lpt.c 2007/10/08 16:22:20 41 +++ trunk/src/devices/dev_lpt.c 2007/10/08 16:22:32 42 @@ -25,9 +25,9 @@ * SUCH DAMAGE. * * - * $Id: dev_lpt.c,v 1.11 2007/04/20 11:17:24 debug Exp $ + * $Id: dev_lpt.c,v 1.14 2007/06/15 19:11:15 debug Exp $ * - * LPT (parallel printer) controller. + * COMMENT: LPT (parallel printer) controller */ #include @@ -37,6 +37,7 @@ #include "console.h" #include "cpu.h" #include "device.h" +#include "interrupt.h" #include "machine.h" #include "memory.h" #include "misc.h" @@ -50,12 +51,12 @@ #define DEV_LPT_LENGTH 3 struct lpt_data { - int irqnr; - char *name; - int console_handle; + char *name; + struct interrupt irq; + int console_handle; - unsigned char data; - unsigned char control; + uint8_t data; + uint8_t control; }; @@ -111,16 +112,15 @@ DEVINIT(lpt) { - struct lpt_data *d = malloc(sizeof(struct lpt_data)); + struct lpt_data *d; size_t nlen; char *name; - if (d == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(d = malloc(sizeof(struct lpt_data))); memset(d, 0, sizeof(struct lpt_data)); - d->irqnr = devinit->irq_nr; + + INTERRUPT_CONNECT(devinit->interrupt_path, d->irq); + d->name = devinit->name2 != NULL? devinit->name2 : ""; d->console_handle = console_start_slave(devinit->machine, devinit->name, CONSOLE_OUTPUT_ONLY); @@ -128,11 +128,7 @@ nlen = strlen(devinit->name) + 10; if (devinit->name2 != NULL) nlen += strlen(devinit->name2); - name = malloc(nlen); - if (name == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(name = malloc(nlen)); if (devinit->name2 != NULL && devinit->name2[0]) snprintf(name, nlen, "%s [%s]", devinit->name, devinit->name2); else @@ -141,7 +137,7 @@ memory_device_register(devinit->machine->memory, name, devinit->addr, DEV_LPT_LENGTH, dev_lpt_access, d, DM_DEFAULT, NULL); machine_add_tickfunction(devinit->machine, dev_lpt_tick, d, - TICK_SHIFT, 0.0); + TICK_SHIFT); /* * NOTE: Ugly cast into a pointer, because this is a convenient way