--- trunk/src/devices/dev_cpc700.c 2007/10/08 16:19:28 21 +++ trunk/src/devices/dev_cpc700.c 2007/10/08 16:19:37 22 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Anders Gavare. All rights reserved. + * Copyright (C) 2005-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,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_cpc700.c,v 1.3 2005/11/22 02:07:39 debug Exp $ + * $Id: dev_cpc700.c,v 1.7 2006/01/01 13:17:16 debug Exp $ * * IBM CPC700 bridge; PCI and interrupt controller. */ @@ -48,29 +48,31 @@ /* * dev_cpc700_pci_access(): * - * Passes PCI indirect addr and data accesses onto bus_pci_access(). + * Passes PCI indirect addr and data accesses onto bus_pci. */ -int dev_cpc700_pci_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(cpc700_pci) { uint64_t idata = 0, odata = 0; + int bus, dev, func, reg; struct cpc700_data *d = extra; if (writeflag == MEM_WRITE) - idata = memory_readmax64(cpu, data, len); + idata = memory_readmax64(cpu, data, len|MEM_PCI_LITTLE_ENDIAN); - relative_addr += BUS_PCI_ADDR; + switch (relative_addr) { + case 0: /* Address: */ + bus_pci_decompose_1(idata, &bus, &dev, &func, ®); + bus_pci_setaddr(cpu, d->pci_data, bus, dev, func, reg); + break; - if (writeflag == MEM_WRITE) - bus_pci_access(cpu, mem, relative_addr, &idata, - len, writeflag, d->pci_data); - else - bus_pci_access(cpu, mem, relative_addr, &odata, - len, writeflag, d->pci_data); + case 4: /* Data: */ + bus_pci_data_access(cpu, d->pci_data, writeflag == MEM_READ? + &odata : &idata, len, writeflag); + break; + } if (writeflag == MEM_READ) - memory_writemax64(cpu, data, len, odata); + memory_writemax64(cpu, data, len|MEM_PCI_LITTLE_ENDIAN, odata); return 1; } @@ -81,9 +83,7 @@ * * The interrupt controller. */ -int dev_cpc700_int_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(cpc700_int) { struct cpc700_data *d = extra; uint64_t idata = 0, odata = 0; @@ -160,6 +160,7 @@ /* Register a PCI bus: */ d->pci_data = bus_pci_init( + machine, 0 /* pciirq: TODO */, 0, /* pci device io offset */ 0, /* pci device mem offset */