1 |
/* |
/* |
2 |
* Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2004-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_spd.c,v 1.12 2005/10/26 14:37:04 debug Exp $ |
* $Id: dev_ps2_spd.c,v 1.17 2007/06/15 19:57:33 debug Exp $ |
29 |
* |
* |
30 |
* Playstation 2 "SPD" harddisk controller. |
* COMMENT: PlayStation 2 SPD harddisk controller |
31 |
* |
* |
32 |
* TODO |
* TODO |
33 |
*/ |
*/ |
38 |
|
|
39 |
#include "cpu.h" |
#include "cpu.h" |
40 |
#include "device.h" |
#include "device.h" |
41 |
#include "devices.h" |
#include "machine.h" |
42 |
#include "memory.h" |
#include "memory.h" |
43 |
#include "misc.h" |
#include "misc.h" |
44 |
|
|
45 |
|
|
46 |
|
#define DEV_PS2_SPD_LENGTH 0x800 |
47 |
|
|
48 |
|
|
49 |
struct ps2_spd_data { |
struct ps2_spd_data { |
50 |
uint64_t wdcaddr; |
uint64_t wdcaddr; |
51 |
}; |
}; |
52 |
|
|
53 |
|
|
54 |
/* |
DEVICE_ACCESS(ps2_spd) |
|
* dev_ps2_spd_access(): |
|
|
*/ |
|
|
int dev_ps2_spd_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
55 |
{ |
{ |
56 |
struct ps2_spd_data *d = extra; |
struct ps2_spd_data *d = extra; |
57 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
94 |
} |
} |
95 |
|
|
96 |
|
|
97 |
/* |
DEVINIT(ps2_spd) |
|
* dev_ps2_spd_init(): |
|
|
*/ |
|
|
void dev_ps2_spd_init(struct machine *machine, struct memory *mem, |
|
|
uint64_t baseaddr) |
|
98 |
{ |
{ |
99 |
struct ps2_spd_data *d; |
struct ps2_spd_data *d; |
100 |
char tmpstr[200]; |
char tmpstr[200]; |
101 |
|
|
102 |
d = malloc(sizeof(struct ps2_spd_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct ps2_spd_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
103 |
memset(d, 0, sizeof(struct ps2_spd_data)); |
memset(d, 0, sizeof(struct ps2_spd_data)); |
|
d->wdcaddr = baseaddr + DEV_PS2_SPD_LENGTH; |
|
104 |
|
|
105 |
memory_device_register(mem, "ps2_spd", baseaddr, DEV_PS2_SPD_LENGTH, |
d->wdcaddr = devinit->addr + DEV_PS2_SPD_LENGTH; |
106 |
dev_ps2_spd_access, d, MEM_DEFAULT, NULL); |
|
107 |
|
memory_device_register(devinit->machine->memory, "ps2_spd", |
108 |
|
devinit->addr, DEV_PS2_SPD_LENGTH, |
109 |
|
dev_ps2_spd_access, d, DM_DEFAULT, NULL); |
110 |
|
|
111 |
/* Register a generic wdc device at a bogus address: */ |
/* Register a generic wdc device at a bogus address: */ |
112 |
/* (irq 8 + 32 + 0 means SBUS/PCMCIA) */ |
/* IRQ = PS2 SBUS irq 0 */ |
113 |
snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i", |
snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%s.ps2_sbus.0", |
114 |
(long long)d->wdcaddr, 8 + 32 + 0); |
(long long)d->wdcaddr, devinit->interrupt_path); |
115 |
device_add(machine, tmpstr); |
device_add(devinit->machine, tmpstr); |
116 |
|
|
117 |
|
return 1; |
118 |
} |
} |
119 |
|
|