--- trunk/src/devices/dev_sgi_ip32.c 2007/10/08 16:19:28 21 +++ trunk/src/devices/dev_sgi_ip32.c 2007/10/08 16:19:37 22 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2005 Anders Gavare. All rights reserved. + * Copyright (C) 2003-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_sgi_ip32.c,v 1.38 2005/11/21 09:17:27 debug Exp $ + * $Id: dev_sgi_ip32.c,v 1.44 2006/01/01 13:17:17 debug Exp $ * * SGI IP32 devices. * @@ -106,13 +106,11 @@ /* * dev_crime_access(): */ -int dev_crime_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(crime) { struct crime_data *d = extra; uint64_t idata = 0; - int i; + size_t i; if (writeflag == MEM_WRITE) idata = memory_readmax64(cpu, data, len); @@ -182,10 +180,12 @@ idata &= ~0x200; } if (idata & 0x800) { + int j; + /* This is used by the IP32 PROM's "reboot" command: */ - for (i=0; imachine->ncpus; i++) - cpu->machine->cpus[i]->running = 0; + for (j=0; jmachine->ncpus; j++) + cpu->machine->cpus[j]->running = 0; cpu->machine-> exit_without_entering_debugger = 1; idata &= ~0x800; @@ -254,11 +254,9 @@ /* * dev_mace_access(): */ -int dev_mace_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(mace) { - int i; + size_t i; struct mace_data *d = extra; if (writeflag == MEM_WRITE) @@ -335,13 +333,11 @@ /* * dev_macepci_access(): */ -int dev_macepci_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(macepci) { struct macepci_data *d = (struct macepci_data *) extra; uint64_t idata = 0, odata=0; - int regnr, res = 1; + int regnr, res = 1, bus, dev, func, pcireg; if (writeflag == MEM_WRITE) idata = memory_readmax64(cpu, data, len); @@ -350,34 +346,38 @@ /* Read from/write to the macepci: */ switch (relative_addr) { + case 0x00: /* Error address */ if (writeflag == MEM_WRITE) { } else { odata = 0; } break; + case 0x04: /* Error flags */ if (writeflag == MEM_WRITE) { } else { odata = 0x06; } break; + case 0x0c: /* Revision number */ if (writeflag == MEM_WRITE) { } else { odata = 0x01; } break; + case 0xcf8: /* PCI ADDR */ + bus_pci_decompose_1(idata, &bus, &dev, &func, &pcireg); + bus_pci_setaddr(cpu, d->pci_data, bus, dev, func, pcireg); + break; + case 0xcfc: /* PCI DATA */ - if (writeflag == MEM_WRITE) { - res = bus_pci_access(cpu, mem, relative_addr, - &idata, len, writeflag, d->pci_data); - } else { - res = bus_pci_access(cpu, mem, relative_addr, - &odata, len, writeflag, d->pci_data); - } + bus_pci_data_access(cpu, d->pci_data, writeflag == MEM_READ? + &odata : &idata, len, writeflag); break; + default: if (writeflag == MEM_WRITE) { debug("[ macepci: unimplemented write to address " @@ -399,8 +399,8 @@ /* * dev_macepci_init(): */ -struct pci_data *dev_macepci_init(struct memory *mem, uint64_t baseaddr, - int pciirq) +struct pci_data *dev_macepci_init(struct machine *machine, + struct memory *mem, uint64_t baseaddr, int pciirq) { struct macepci_data *d = malloc(sizeof(struct macepci_data)); if (d == NULL) { @@ -409,7 +409,7 @@ } memset(d, 0, sizeof(struct macepci_data)); - d->pci_data = bus_pci_init(pciirq, 0,0, 0,0,0, 0,0,0); + d->pci_data = bus_pci_init(machine, pciirq, 0,0, 0,0,0, 0,0,0); memory_device_register(mem, "macepci", baseaddr, DEV_MACEPCI_LENGTH, dev_macepci_access, (void *)d, DM_DEFAULT, NULL); @@ -767,9 +767,7 @@ /* * dev_sgi_mec_access(): */ -int dev_sgi_mec_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(sgi_mec) { struct sgi_mec_data *d = (struct sgi_mec_data *) extra; uint64_t idata = 0, odata = 0; @@ -975,9 +973,7 @@ /* * dev_sgi_ust_access(): */ -int dev_sgi_ust_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(sgi_ust) { struct sgi_ust_data *d = (struct sgi_ust_data *) extra; uint64_t idata = 0, odata = 0; @@ -1052,9 +1048,7 @@ /* * dev_sgi_mte_access(): */ -int dev_sgi_mte_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(sgi_mte) { struct sgi_mte_data *d = (struct sgi_mte_data *) extra; uint64_t first_addr, last_addr, zerobuflen, fill_addr, fill_len; @@ -1161,7 +1155,7 @@ uint32_t x2 = (d->reg[0x2074 / sizeof(uint32_t)] >> 16) & 0xfff; uint32_t y2 = d->reg[0x2074 / sizeof(uint32_t)]& 0xfff; - int y; + uint32_t y; op >>= 24; @@ -1207,7 +1201,8 @@ uint32_t x2 = (d->reg[0x2074 / sizeof(uint32_t)] >> 16) & 0xfff; uint32_t y2 = d->reg[0x2074 / sizeof(uint32_t)]& 0xfff; - int x,y; + size_t x, y; + if (x2 < x1) { int tmp = x1; x1 = x2; x2 = tmp; } @@ -1216,6 +1211,7 @@ } if (x2-x1 <= 15) data <<= 16; + x=x1; y=y1; while (x <= x2 && y <= y2) { unsigned char buf = color;