25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_sgi_ip32.c,v 1.51 2007/01/29 18:32:01 debug Exp $ |
* $Id: dev_sgi_ip32.c,v 1.53 2007/06/15 19:57:34 debug Exp $ |
29 |
* |
* |
30 |
* SGI IP32 devices. |
* COMMENT: SGI IP32 stuff (CRIME, MACE, MACEPCI, mec, ust, mte) |
31 |
* |
* |
32 |
* o) CRIME |
* o) CRIME |
33 |
* o) MACE |
* o) MACE |
131 |
* A R10000 is detected as running at |
* A R10000 is detected as running at |
132 |
* CRIME_SPEED_FACTOR * 66 MHz. (TODO: this is not correct anymore) |
* CRIME_SPEED_FACTOR * 66 MHz. (TODO: this is not correct anymore) |
133 |
*/ |
*/ |
134 |
void dev_crime_tick(struct cpu *cpu, void *extra) |
DEVICE_TICK(crime) |
135 |
{ |
{ |
136 |
int j, carry, old, new, add_byte; |
int j, carry, old, new, add_byte; |
137 |
uint64_t what_to_add = (1<<CRIME_TICKSHIFT) |
uint64_t what_to_add = (1<<CRIME_TICKSHIFT) |
274 |
char tmpstr[200]; |
char tmpstr[200]; |
275 |
int i; |
int i; |
276 |
|
|
277 |
d = malloc(sizeof(struct crime_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct crime_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
278 |
memset(d, 0, sizeof(struct crime_data)); |
memset(d, 0, sizeof(struct crime_data)); |
279 |
|
|
280 |
d->use_fb = use_fb; |
d->use_fb = use_fb; |
281 |
|
|
282 |
INTERRUPT_CONNECT(irq_path, d->irq); |
INTERRUPT_CONNECT(irq_path, d->irq); |
303 |
device_add(machine, tmpstr); |
device_add(machine, tmpstr); |
304 |
|
|
305 |
machine_add_tickfunction(machine, dev_crime_tick, d, |
machine_add_tickfunction(machine, dev_crime_tick, d, |
306 |
CRIME_TICKSHIFT, 0.0); |
CRIME_TICKSHIFT); |
307 |
} |
} |
308 |
|
|
309 |
|
|
426 |
char tmpstr[300]; |
char tmpstr[300]; |
427 |
int i; |
int i; |
428 |
|
|
429 |
d = malloc(sizeof(struct mace_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct mace_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
430 |
memset(d, 0, sizeof(struct mace_data)); |
memset(d, 0, sizeof(struct mace_data)); |
431 |
|
|
432 |
snprintf(tmpstr, sizeof(tmpstr), "%s.0x%x", |
snprintf(tmpstr, sizeof(tmpstr), "%s.0x%x", |
480 |
|
|
481 |
DEVICE_ACCESS(macepci) |
DEVICE_ACCESS(macepci) |
482 |
{ |
{ |
483 |
struct macepci_data *d = (struct macepci_data *) extra; |
struct macepci_data *d = extra; |
484 |
uint64_t idata = 0, odata=0; |
uint64_t idata = 0, odata=0; |
485 |
int regnr, res = 1, bus, dev, func, pcireg; |
int regnr, res = 1, bus, dev, func, pcireg; |
486 |
|
|
547 |
struct pci_data *dev_macepci_init(struct machine *machine, |
struct pci_data *dev_macepci_init(struct machine *machine, |
548 |
struct memory *mem, uint64_t baseaddr, char *irq_path) |
struct memory *mem, uint64_t baseaddr, char *irq_path) |
549 |
{ |
{ |
550 |
struct macepci_data *d = malloc(sizeof(struct macepci_data)); |
struct macepci_data *d; |
551 |
if (d == NULL) { |
|
552 |
fprintf(stderr, "out of memory\n"); |
CHECK_ALLOCATION(d = malloc(sizeof(struct macepci_data))); |
|
exit(1); |
|
|
} |
|
553 |
memset(d, 0, sizeof(struct macepci_data)); |
memset(d, 0, sizeof(struct macepci_data)); |
554 |
|
|
555 |
/* TODO: PCI vs ISA interrupt? */ |
/* TODO: PCI vs ISA interrupt? */ |
891 |
} |
} |
892 |
|
|
893 |
|
|
894 |
/* |
DEVICE_TICK(sgi_mec) |
|
* dev_sgi_mec_tick(): |
|
|
*/ |
|
|
void dev_sgi_mec_tick(struct cpu *cpu, void *extra) |
|
895 |
{ |
{ |
896 |
struct sgi_mec_data *d = (struct sgi_mec_data *) extra; |
struct sgi_mec_data *d = extra; |
897 |
int n = 0; |
int n = 0; |
898 |
|
|
899 |
while (mec_try_tx(cpu, d)) |
while (mec_try_tx(cpu, d)) |
917 |
|
|
918 |
DEVICE_ACCESS(sgi_mec) |
DEVICE_ACCESS(sgi_mec) |
919 |
{ |
{ |
920 |
struct sgi_mec_data *d = (struct sgi_mec_data *) extra; |
struct sgi_mec_data *d = extra; |
921 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
922 |
int regnr; |
int regnr; |
923 |
|
|
1079 |
{ |
{ |
1080 |
char *name2; |
char *name2; |
1081 |
size_t nlen = 55; |
size_t nlen = 55; |
1082 |
struct sgi_mec_data *d = malloc(sizeof(struct sgi_mec_data)); |
struct sgi_mec_data *d; |
1083 |
|
|
1084 |
if (d == NULL) { |
CHECK_ALLOCATION(d = malloc(sizeof(struct sgi_mec_data))); |
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
1085 |
memset(d, 0, sizeof(struct sgi_mec_data)); |
memset(d, 0, sizeof(struct sgi_mec_data)); |
1086 |
|
|
1087 |
INTERRUPT_CONNECT(irq_path, d->irq); |
INTERRUPT_CONNECT(irq_path, d->irq); |
1088 |
memcpy(d->macaddr, macaddr, 6); |
memcpy(d->macaddr, macaddr, 6); |
1089 |
mec_reset(d); |
mec_reset(d); |
1090 |
|
|
1091 |
name2 = malloc(nlen); |
CHECK_ALLOCATION(name2 = malloc(nlen)); |
|
if (name2 == NULL) { |
|
|
fprintf(stderr, "out of memory in dev_sgi_mec_init()\n"); |
|
|
exit(1); |
|
|
} |
|
1092 |
snprintf(name2, nlen, "mec [%02x:%02x:%02x:%02x:%02x:%02x]", |
snprintf(name2, nlen, "mec [%02x:%02x:%02x:%02x:%02x:%02x]", |
1093 |
d->macaddr[0], d->macaddr[1], d->macaddr[2], |
d->macaddr[0], d->macaddr[1], d->macaddr[2], |
1094 |
d->macaddr[3], d->macaddr[4], d->macaddr[5]); |
d->macaddr[3], d->macaddr[4], d->macaddr[5]); |
1098 |
DM_DEFAULT, NULL); |
DM_DEFAULT, NULL); |
1099 |
|
|
1100 |
machine_add_tickfunction(machine, dev_sgi_mec_tick, d, |
machine_add_tickfunction(machine, dev_sgi_mec_tick, d, |
1101 |
MEC_TICK_SHIFT, 0.0); |
MEC_TICK_SHIFT); |
1102 |
|
|
1103 |
net_add_nic(machine->emul->net, d, macaddr); |
net_add_nic(machine->emul->net, d, macaddr); |
1104 |
} |
} |
1114 |
|
|
1115 |
DEVICE_ACCESS(sgi_ust) |
DEVICE_ACCESS(sgi_ust) |
1116 |
{ |
{ |
1117 |
struct sgi_ust_data *d = (struct sgi_ust_data *) extra; |
struct sgi_ust_data *d = extra; |
1118 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
1119 |
int regnr; |
int regnr; |
1120 |
|
|
1153 |
*/ |
*/ |
1154 |
void dev_sgi_ust_init(struct memory *mem, uint64_t baseaddr) |
void dev_sgi_ust_init(struct memory *mem, uint64_t baseaddr) |
1155 |
{ |
{ |
1156 |
struct sgi_ust_data *d = malloc(sizeof(struct sgi_ust_data)); |
struct sgi_ust_data *d; |
1157 |
if (d == NULL) { |
|
1158 |
fprintf(stderr, "out of memory\n"); |
CHECK_ALLOCATION(d = malloc(sizeof(struct sgi_ust_data))); |
|
exit(1); |
|
|
} |
|
1159 |
memset(d, 0, sizeof(struct sgi_ust_data)); |
memset(d, 0, sizeof(struct sgi_ust_data)); |
1160 |
|
|
1161 |
memory_device_register(mem, "sgi_ust", baseaddr, |
memory_device_register(mem, "sgi_ust", baseaddr, |
1185 |
|
|
1186 |
DEVICE_ACCESS(sgi_mte) |
DEVICE_ACCESS(sgi_mte) |
1187 |
{ |
{ |
1188 |
struct sgi_mte_data *d = (struct sgi_mte_data *) extra; |
struct sgi_mte_data *d = extra; |
1189 |
uint64_t first_addr, last_addr, zerobuflen, fill_addr, fill_len; |
uint64_t first_addr, last_addr, zerobuflen, fill_addr, fill_len; |
1190 |
unsigned char zerobuf[ZERO_CHUNK_LEN]; |
unsigned char zerobuf[ZERO_CHUNK_LEN]; |
1191 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
1425 |
*/ |
*/ |
1426 |
void dev_sgi_mte_init(struct memory *mem, uint64_t baseaddr) |
void dev_sgi_mte_init(struct memory *mem, uint64_t baseaddr) |
1427 |
{ |
{ |
1428 |
struct sgi_mte_data *d = malloc(sizeof(struct sgi_mte_data)); |
struct sgi_mte_data *d; |
1429 |
if (d == NULL) { |
|
1430 |
fprintf(stderr, "out of memory\n"); |
CHECK_ALLOCATION(d = malloc(sizeof(struct sgi_mte_data))); |
|
exit(1); |
|
|
} |
|
1431 |
memset(d, 0, sizeof(struct sgi_mte_data)); |
memset(d, 0, sizeof(struct sgi_mte_data)); |
1432 |
|
|
1433 |
memory_device_register(mem, "sgi_mte", baseaddr, DEV_SGI_MTE_LENGTH, |
memory_device_register(mem, "sgi_mte", baseaddr, DEV_SGI_MTE_LENGTH, |