--- trunk/src/devices/dev_fdc.c 2007/10/08 16:18:00 4 +++ trunk/src/devices/dev_fdc.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,25 +25,29 @@ * SUCH DAMAGE. * * - * $Id: dev_fdc.c,v 1.9 2005/02/24 15:38:34 debug Exp $ + * $Id: dev_fdc.c,v 1.19 2006/12/30 13:30:58 debug Exp $ * - * Floppy controller. + * PC-style floppy controller. * * TODO! (This is just a dummy skeleton right now.) + * + * TODO 2: Make it work nicely with both ARC and PC emulation. + * + * See http://members.tripod.com/~oldboard/assembly/765.html for a + * quick overview. */ #include #include #include -#include "console.h" #include "device.h" #include "machine.h" #include "memory.h" #include "misc.h" -#define DEV_FDC_LENGTH 0x100 +#define DEV_FDC_LENGTH 6 /* TODO 8, but collision with wdc */ struct fdc_data { @@ -55,36 +59,27 @@ /* * dev_fdc_access(): */ -int dev_fdc_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(fdc) { uint64_t idata = 0, odata = 0; - int i; + size_t i; struct fdc_data *d = extra; - idata = memory_readmax64(cpu, data, len); - - /* TODO: this is 100% dummy */ + if (writeflag == MEM_WRITE) + idata = memory_readmax64(cpu, data, len); switch (relative_addr) { case 0x04: - /* no debug warning */ - if (writeflag==MEM_READ) { - odata = d->reg[relative_addr]; - } else - d->reg[relative_addr] = idata; break; - default: - if (writeflag==MEM_READ) { - debug("[ fdc: read from reg %i ]\n", + default:if (writeflag==MEM_READ) { + fatal("[ fdc: read from reg %i ]\n", (int)relative_addr); odata = d->reg[relative_addr]; } else { - debug("[ fdc: write to reg %i:", (int)relative_addr); + fatal("[ fdc: write to reg %i:", (int)relative_addr); for (i=0; ireg[relative_addr] = idata; } } @@ -96,10 +91,7 @@ } -/* - * devinit_fdc(): - */ -int devinit_fdc(struct devinit *devinit) +DEVINIT(fdc) { struct fdc_data *d; @@ -113,7 +105,7 @@ memory_device_register(devinit->machine->memory, devinit->name, devinit->addr, DEV_FDC_LENGTH, dev_fdc_access, d, - MEM_DEFAULT, NULL); + DM_DEFAULT, NULL); return 1; }