--- trunk/src/devices/dev_jazz.c 2007/10/08 16:19:11 18 +++ trunk/src/devices/dev_jazz.c 2007/10/08 16:19:37 22 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2005 Anders Gavare. All rights reserved. + * Copyright (C) 2004-2006 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,9 +25,13 @@ * SUCH DAMAGE. * * - * $Id: dev_jazz.c,v 1.19 2005/10/26 14:37:04 debug Exp $ + * $Id: dev_jazz.c,v 1.23 2006/02/09 20:02:59 debug Exp $ * * Microsoft Jazz-related stuff (Acer PICA-61, etc). + * + * TODO/NOTE: This is mostly a quick hack, it doesn't really implement + * much of the Jazz architecture. Also, the a0/20 isa-like stuff is + * not supposed to be here. */ #include @@ -91,7 +95,7 @@ dma_addr = d->dma0_addr; i = 0; - while (dma_addr < d->dma0_addr + d->dma0_count && i < len) { + while (dma_addr < d->dma0_addr + d->dma0_count && i < (int32_t)len) { res = cpu->memory_rw(cpu, cpu->mem, d->dma_translation_table_base + (dma_addr >> 12) * 8, @@ -111,9 +115,9 @@ /* Speed up the copying by copying 16 or 256 bytes: */ ncpy = 1; - if ((phys_addr & 15) == 0 && i + 15 <= len) + if ((phys_addr & 15) == 0 && i + 15 <= (int32_t)len) ncpy = 15; - if ((phys_addr & 255) == 0 && i + 255 <= len) + if ((phys_addr & 255) == 0 && i + 255 <= (int32_t)len) ncpy = 255; res = cpu->memory_rw(cpu, cpu->mem, phys_addr, @@ -161,9 +165,7 @@ /* * dev_jazz_access(): */ -int dev_jazz_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(jazz) { struct jazz_data *d = (struct jazz_data *) extra; uint64_t idata = 0, odata = 0; @@ -298,9 +300,7 @@ /* * dev_jazz_led_access(): */ -int dev_jazz_led_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(jazz_led) { struct jazz_data *d = (struct jazz_data *) extra; uint64_t idata = 0, odata = 0; @@ -340,13 +340,13 @@ /* - * dev_jazz_access_a0(): + * dev_jazz_a0_access(): * * ISA interrupt stuff, high 8 interrupts. + * + * TODO: use isa8 stuff instead! */ -int dev_jazz_access_a0(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(jazz_a0) { struct jazz_data *d = (struct jazz_data *) extra; uint64_t idata = 0, odata = 0; @@ -393,13 +393,11 @@ /* - * dev_jazz_access_20(): + * dev_jazz_20_access(): * * ISA interrupt stuff, low 8 interrupts. */ -int dev_jazz_access_20(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(jazz_20) { struct jazz_data *d = (struct jazz_data *) extra; uint64_t idata = 0, odata = 0; @@ -446,14 +444,12 @@ /* - * dev_jazz_access_jazzio(): + * dev_jazz_jazzio_access(): * * See jazzio_intr() in NetBSD's * /usr/src/sys/arch/arc/jazz/jazzio.c for more info. */ -int dev_jazz_access_jazzio(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(jazz_jazzio) { struct jazz_data *d = (struct jazz_data *) extra; uint64_t idata = 0, odata = 0; @@ -502,10 +498,7 @@ } -/* - * devinit_jazz(): - */ -int devinit_jazz(struct devinit *devinit) +DEVINIT(jazz) { struct jazz_data *d = malloc(sizeof(struct jazz_data)); if (d == NULL) { @@ -520,22 +513,22 @@ memory_device_register(devinit->machine->memory, "jazz", devinit->addr, DEV_JAZZ_LENGTH, - dev_jazz_access, (void *)d, MEM_DEFAULT, NULL); + dev_jazz_access, (void *)d, DM_DEFAULT, NULL); /* At least for Magnum and Pica-61: */ memory_device_register(devinit->machine->memory, "jazz_led", 0x08000f000ULL, 4, dev_jazz_led_access, (void *)d, - MEM_DEFAULT, NULL); + DM_DEFAULT, NULL); memory_device_register(devinit->machine->memory, "jazz_isa_20", - 0x90000020ULL, 2, dev_jazz_access_20, (void *)d, MEM_DEFAULT, NULL); + 0x90000020ULL, 2, dev_jazz_20_access, (void *)d, DM_DEFAULT, NULL); memory_device_register(devinit->machine->memory, "jazz_isa_a0", - 0x900000a0ULL, 2, dev_jazz_access_a0, (void *)d, MEM_DEFAULT, NULL); + 0x900000a0ULL, 2, dev_jazz_a0_access, (void *)d, DM_DEFAULT, NULL); memory_device_register(devinit->machine->memory, "pica_jazzio", - 0xf0000000ULL, 4, dev_jazz_access_jazzio, (void *)d, - MEM_DEFAULT, NULL); + 0xf0000000ULL, 4, dev_jazz_jazzio_access, (void *)d, + DM_DEFAULT, NULL); machine_add_tickfunction(devinit->machine, dev_jazz_tick, d, DEV_JAZZ_TICKSHIFT);