--- trunk/src/devices/dev_pccmos.c 2007/10/08 16:19:11 18 +++ trunk/src/devices/dev_pccmos.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,9 +25,9 @@ * SUCH DAMAGE. * * - * $Id: dev_pccmos.c,v 1.8 2005/10/26 14:37:04 debug Exp $ + * $Id: dev_pccmos.c,v 1.22 2006/02/09 20:02:59 debug Exp $ * - * PC CMOS/RTC device. + * PC CMOS/RTC device (ISA ports 0x70 and 0x71). * * The main point of this device is to be a "PC style wrapper" for accessing * the MC146818 (the RTC). In most other respects, this device is bogus, and @@ -59,13 +59,12 @@ /* * dev_pccmos_access(): */ -int dev_pccmos_access(struct cpu *cpu, struct memory *mem, - uint64_t relative_addr, unsigned char *data, size_t len, - int writeflag, void *extra) +DEVICE_ACCESS(pccmos) { struct pccmos_data *d = (struct pccmos_data *) extra; uint64_t idata = 0, odata = 0; unsigned char b = 0; + int r = 1; if (writeflag == MEM_WRITE) b = idata = memory_readmax64(cpu, data, len); @@ -79,7 +78,7 @@ if (writeflag == MEM_WRITE) { d->select = idata; if (idata <= 0x0d) { - cpu->memory_rw(cpu, cpu->mem, + r = cpu->memory_rw(cpu, cpu->mem, PCCMOS_MC146818_FAKE_ADDR, &b, 1, MEM_WRITE, PHYSICAL); } @@ -88,11 +87,11 @@ } else { if (d->select <= 0x0d) { if (writeflag == MEM_WRITE) { - cpu->memory_rw(cpu, cpu->mem, + r = cpu->memory_rw(cpu, cpu->mem, PCCMOS_MC146818_FAKE_ADDR + 1, &b, 1, MEM_WRITE, PHYSICAL); } else { - cpu->memory_rw(cpu, cpu->mem, + r = cpu->memory_rw(cpu, cpu->mem, PCCMOS_MC146818_FAKE_ADDR + 1, &b, 1, MEM_READ, PHYSICAL); odata = b; @@ -105,6 +104,9 @@ } } + if (r == 0) + fatal("[ pccmos: memory_rw() error! ]\n"); + if (writeflag == MEM_READ) memory_writemax64(cpu, data, len, odata); @@ -112,10 +114,7 @@ } -/* - * devinit_pccmos(): - */ -int devinit_pccmos(struct devinit *devinit) +DEVINIT(pccmos) { struct pccmos_data *d = malloc(sizeof(struct pccmos_data)); int irq_nr, type = MC146818_PC_CMOS, len = DEV_PCCMOS_LENGTH; @@ -131,14 +130,39 @@ */ switch (devinit->machine->machine_type) { case MACHINE_CATS: + case MACHINE_NETWINDER: irq_nr = 32 + 8; type = MC146818_CATS; d->ram[0x48] = 20; /* century */ len = DEV_PCCMOS_LENGTH * 2; break; + case MACHINE_ALGOR: + irq_nr = 8 + 8; + type = MC146818_ALGOR; + break; + case MACHINE_ARC: + fatal("\nARC pccmos: TODO\n\n"); + irq_nr = 8 + 8; /* TODO */ + type = MC146818_ALGOR; + break; + case MACHINE_EVBMIPS: + /* Malta etc. */ + irq_nr = 8 + 8; + type = MC146818_ALGOR; + break; case MACHINE_X86: irq_nr = 16; /* "No" irq */ break; + case MACHINE_BEBOX: + case MACHINE_PREP: + case MACHINE_MVMEPPC: + irq_nr = 32 + 8; + break; + case MACHINE_SHARK: + case MACHINE_IYONIX: + /* TODO */ + irq_nr = 32 + 8; + break; default:fatal("devinit_pccmos(): unimplemented machine type" " %i\n", devinit->machine->machine_type); exit(1); @@ -146,7 +170,7 @@ memory_device_register(devinit->machine->memory, devinit->name, devinit->addr, len, dev_pccmos_access, (void *)d, - MEM_DEFAULT, NULL); + DM_DEFAULT, NULL); dev_mc146818_init(devinit->machine, devinit->machine->memory, PCCMOS_MC146818_FAKE_ADDR, irq_nr, type, 1);