1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 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_ps2_ether.c,v 1.3 2005/10/26 14:37:04 debug Exp $ |
* $Id: dev_ps2_ether.c,v 1.8 2007/06/15 19:57:33 debug Exp $ |
29 |
* |
* |
30 |
* Playstation 2 ethernet (smap and emac3). |
* COMMENT: PlayStation 2 ethernet (smap and emac3) |
31 |
* |
* |
32 |
* TODO |
* TODO |
33 |
*/ |
*/ |
50 |
}; |
}; |
51 |
|
|
52 |
|
|
53 |
/* |
DEVICE_ACCESS(ps2_ether) |
|
* dev_ps2_ether_access(): |
|
|
*/ |
|
|
int dev_ps2_ether_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
54 |
{ |
{ |
55 |
/* struct ps2_ether_data *d = extra; */ |
/* struct ps2_ether_data *d = extra; */ |
56 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
59 |
idata = memory_readmax64(cpu, data, len); |
idata = memory_readmax64(cpu, data, len); |
60 |
|
|
61 |
switch (relative_addr) { |
switch (relative_addr) { |
62 |
|
|
63 |
case 0x105c: |
case 0x105c: |
64 |
/* TODO: make these register accesses nicer */ |
/* TODO: make these register accesses nicer */ |
65 |
break; |
break; |
66 |
|
|
67 |
case 0x105e: |
case 0x105e: |
68 |
odata = 0x8000; /* STACR_OC */ |
odata = 0x8000; /* STACR_OC */ |
69 |
break; |
break; |
70 |
|
|
71 |
default: |
default: |
72 |
if (writeflag==MEM_READ) { |
if (writeflag==MEM_READ) { |
73 |
debug("[ ps2_ether: read from addr 0x%x: 0x%llx ]\n", |
debug("[ ps2_ether: read from addr 0x%x: 0x%llx ]\n", |
85 |
} |
} |
86 |
|
|
87 |
|
|
88 |
/* |
DEVINIT(ps2_ether) |
|
* devinit_ps2_ether(): |
|
|
*/ |
|
|
int devinit_ps2_ether(struct devinit *devinit) |
|
89 |
{ |
{ |
90 |
struct ps2_ether_data *d; |
struct ps2_ether_data *d; |
91 |
|
|
92 |
d = malloc(sizeof(struct ps2_ether_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct ps2_ether_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
93 |
memset(d, 0, sizeof(struct ps2_ether_data)); |
memset(d, 0, sizeof(struct ps2_ether_data)); |
94 |
|
|
95 |
memory_device_register(devinit->machine->memory, devinit->name, |
memory_device_register(devinit->machine->memory, devinit->name, |
96 |
devinit->addr, 0x4000, |
devinit->addr, 0x4000, |
97 |
dev_ps2_ether_access, d, MEM_DEFAULT, NULL); |
dev_ps2_ether_access, d, DM_DEFAULT, NULL); |
98 |
|
|
99 |
return 1; |
return 1; |
100 |
} |
} |