1 |
/* |
/* |
2 |
* Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2004-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_vr41xx.c,v 1.29 2005/04/09 12:11:46 debug Exp $ |
* $Id: dev_vr41xx.c,v 1.35 2006/01/01 13:17:18 debug Exp $ |
29 |
* |
* |
30 |
* VR41xx (actually, VR4122 and VR4131) misc functions. |
* VR41xx (actually, VR4122 and VR4131) misc functions. |
31 |
* |
* |
389 |
/* |
/* |
390 |
* dev_vr41xx_access(): |
* dev_vr41xx_access(): |
391 |
*/ |
*/ |
392 |
int dev_vr41xx_access(struct cpu *cpu, struct memory *mem, |
DEVICE_ACCESS(vr41xx) |
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
393 |
{ |
{ |
394 |
struct vr41xx_data *d = (struct vr41xx_data *) extra; |
struct vr41xx_data *d = (struct vr41xx_data *) extra; |
395 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
396 |
int regnr; |
int regnr; |
397 |
int revision = 0; |
int revision = 0; |
398 |
|
|
399 |
idata = memory_readmax64(cpu, data, len); |
if (writeflag == MEM_WRITE) |
400 |
|
idata = memory_readmax64(cpu, data, len); |
401 |
|
|
402 |
regnr = relative_addr / sizeof(uint64_t); |
regnr = relative_addr / sizeof(uint64_t); |
403 |
|
|
404 |
/* KIU ("Keyboard Interface Unit") is handled separately. */ |
/* KIU ("Keyboard Interface Unit") is handled separately. */ |
544 |
struct memory *mem, int cpumodel) |
struct memory *mem, int cpumodel) |
545 |
{ |
{ |
546 |
uint64_t baseaddr = 0; |
uint64_t baseaddr = 0; |
547 |
|
char tmps[100]; |
548 |
struct vr41xx_data *d = malloc(sizeof(struct vr41xx_data)); |
struct vr41xx_data *d = malloc(sizeof(struct vr41xx_data)); |
549 |
|
|
550 |
if (d == NULL) { |
if (d == NULL) { |
551 |
fprintf(stderr, "out of memory\n"); |
fprintf(stderr, "out of memory\n"); |
552 |
exit(1); |
exit(1); |
557 |
|
|
558 |
/* TODO: VRC4173 has the KIU at offset 0x100? */ |
/* TODO: VRC4173 has the KIU at offset 0x100? */ |
559 |
d->kiu_offset = 0x180; |
d->kiu_offset = 0x180; |
560 |
d->kiu_console_handle = console_start_slave_inputonly(machine, "kiu"); |
d->kiu_console_handle = console_start_slave_inputonly( |
561 |
|
machine, "kiu", 1); |
562 |
d->kiu_irq_nr = VRIP_INTR_KIU; |
d->kiu_irq_nr = VRIP_INTR_KIU; |
563 |
|
|
564 |
switch (cpumodel) { |
switch (cpumodel) { |
570 |
break; |
break; |
571 |
case 4181: |
case 4181: |
572 |
baseaddr = 0xa000000; |
baseaddr = 0xa000000; |
573 |
dev_ram_init(mem, 0xb000000, 0x1000000, DEV_RAM_MIRROR, |
dev_ram_init(machine, 0xb000000, 0x1000000, DEV_RAM_MIRROR, |
574 |
0xa000000); |
0xa000000); |
575 |
break; |
break; |
576 |
case 4122: |
case 4122: |
583 |
} |
} |
584 |
|
|
585 |
memory_device_register(mem, "vr41xx", baseaddr, DEV_VR41XX_LENGTH, |
memory_device_register(mem, "vr41xx", baseaddr, DEV_VR41XX_LENGTH, |
586 |
dev_vr41xx_access, (void *)d, MEM_DEFAULT, NULL); |
dev_vr41xx_access, (void *)d, DM_DEFAULT, NULL); |
587 |
|
|
588 |
/* |
/* |
589 |
* TODO: Find out which controllers are at which addresses on |
* TODO: Find out which controllers are at which addresses on |
590 |
* which chips. |
* which chips. |
591 |
*/ |
*/ |
592 |
if (cpumodel == 4131) { |
if (cpumodel == 4131) { |
593 |
dev_ns16550_init(machine, mem, baseaddr + 0x800, |
snprintf(tmps, sizeof(tmps), "ns16550 irq=%i addr=0x%llx " |
594 |
8 + VRIP_INTR_SIU, 1, 1, "vr41xx siu"); |
"name2=siu", 8+VRIP_INTR_SIU, (long long)(baseaddr+0x800)); |
595 |
|
device_add(machine, tmps); |
596 |
} else { |
} else { |
597 |
/* This is used by Linux and NetBSD: */ |
/* This is used by Linux and NetBSD: */ |
598 |
dev_ns16550_init(machine, mem, 0xc000000, |
snprintf(tmps, sizeof(tmps), "ns16550 irq=%i addr=0x%x " |
599 |
8 + VRIP_INTR_SIU, 1, 1, "vr41xx serial"); |
"name2=serial", 8+VRIP_INTR_SIU, 0xc000000); |
600 |
|
device_add(machine, tmps); |
601 |
} |
} |
602 |
|
|
603 |
/* Hm... maybe this should not be here. TODO */ |
/* Hm... maybe this should not be here. TODO */ |
608 |
|
|
609 |
/* Some machines (?) use ISA space at 0x15000000 instead of |
/* Some machines (?) use ISA space at 0x15000000 instead of |
610 |
0x14000000, eg IBM WorkPad Z50. */ |
0x14000000, eg IBM WorkPad Z50. */ |
611 |
dev_ram_init(mem, 0x15000000, 0x1000000, DEV_RAM_MIRROR, 0x14000000); |
dev_ram_init(machine, 0x15000000, 0x1000000, DEV_RAM_MIRROR, |
612 |
|
0x14000000); |
613 |
|
|
614 |
return d; |
return d; |
615 |
} |
} |