25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_pcic.c,v 1.18 2007/01/21 21:02:57 debug Exp $ |
* $Id: dev_pcic.c,v 1.20 2007/06/15 19:57:33 debug Exp $ |
29 |
* |
* |
30 |
* Intel 82365SL PC Card Interface Controller (called "pcic" by NetBSD). |
* COMMENT: Intel 82365SL PC Card Interface Controller |
31 |
|
* |
32 |
|
* (Called "pcic" by NetBSD.) |
33 |
* |
* |
34 |
* TODO: Lots of stuff. This is just a quick hack. Don't rely on it. |
* TODO: Lots of stuff. This is just a quick hack. Don't rely on it. |
35 |
*/ |
*/ |
41 |
#include "cpu.h" |
#include "cpu.h" |
42 |
#include "device.h" |
#include "device.h" |
43 |
#include "emul.h" |
#include "emul.h" |
44 |
|
#include "interrupt.h" |
45 |
#include "machine.h" |
#include "machine.h" |
46 |
#include "memory.h" |
#include "memory.h" |
47 |
#include "misc.h" |
#include "misc.h" |
55 |
#define DEV_PCIC_LENGTH 2 |
#define DEV_PCIC_LENGTH 2 |
56 |
|
|
57 |
struct pcic_data { |
struct pcic_data { |
58 |
int irq_nr; |
struct interrupt irq; |
59 |
int regnr; |
int regnr; |
60 |
}; |
}; |
61 |
|
|
62 |
|
|
|
/* |
|
|
* dev_pcic_cis_access(): |
|
|
*/ |
|
63 |
DEVICE_ACCESS(pcic_cis) |
DEVICE_ACCESS(pcic_cis) |
64 |
{ |
{ |
65 |
/* struct pcic_data *d = (struct pcic_data *) extra; */ |
/* struct pcic_data *d = (struct pcic_data *) extra; */ |
140 |
} |
} |
141 |
|
|
142 |
|
|
|
/* |
|
|
* dev_pcic_access(): |
|
|
*/ |
|
143 |
DEVICE_ACCESS(pcic) |
DEVICE_ACCESS(pcic) |
144 |
{ |
{ |
145 |
struct pcic_data *d = (struct pcic_data *) extra; |
struct pcic_data *d = extra; |
146 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
147 |
int controller_nr, socket_nr; |
int controller_nr, socket_nr; |
148 |
|
|
153 |
socket_nr = d->regnr & 0x40? 1 : 0; |
socket_nr = d->regnr & 0x40? 1 : 0; |
154 |
|
|
155 |
switch (relative_addr) { |
switch (relative_addr) { |
156 |
|
|
157 |
case 0: /* Register select: */ |
case 0: /* Register select: */ |
158 |
if (writeflag == MEM_WRITE) |
if (writeflag == MEM_WRITE) |
159 |
d->regnr = idata; |
d->regnr = idata; |
160 |
else |
else |
161 |
odata = d->regnr; |
odata = d->regnr; |
162 |
break; |
break; |
163 |
|
|
164 |
case 1: /* Register access: */ |
case 1: /* Register access: */ |
165 |
switch (d->regnr & 0x3f) { |
switch (d->regnr & 0x3f) { |
166 |
|
|
167 |
case PCIC_IDENT: |
case PCIC_IDENT: |
168 |
/* This causes sockets A and B to be present on |
/* This causes sockets A and B to be present on |
169 |
controller 0, and only socket A on controller 1. */ |
controller 0, and only socket A on controller 1. */ |
178 |
odata = PCIC_INTR_IRQ3; |
odata = PCIC_INTR_IRQ3; |
179 |
break; |
break; |
180 |
#endif |
#endif |
181 |
|
|
182 |
case PCIC_CSC: |
case PCIC_CSC: |
183 |
odata = PCIC_CSC_GPI; |
odata = PCIC_CSC_GPI; |
184 |
break; |
break; |
185 |
|
|
186 |
case PCIC_IF_STATUS: |
case PCIC_IF_STATUS: |
187 |
odata = PCIC_IF_STATUS_READY |
odata = PCIC_IF_STATUS_READY |
188 |
| PCIC_IF_STATUS_POWERACTIVE; |
| PCIC_IF_STATUS_POWERACTIVE; |
189 |
if (controller_nr == 0 && socket_nr == 0) |
if (controller_nr == 0 && socket_nr == 0) |
190 |
odata |= PCIC_IF_STATUS_CARDDETECT_PRESENT; |
odata |= PCIC_IF_STATUS_CARDDETECT_PRESENT; |
191 |
break; |
break; |
192 |
|
|
193 |
default: |
default: |
194 |
if (writeflag == MEM_WRITE) { |
if (writeflag == MEM_WRITE) { |
195 |
debug("[ pcic: unimplemented write to " |
debug("[ pcic: unimplemented write to " |
216 |
DEVINIT(pcic) |
DEVINIT(pcic) |
217 |
{ |
{ |
218 |
char tmpstr[200]; |
char tmpstr[200]; |
219 |
struct pcic_data *d = malloc(sizeof(struct pcic_data)); |
struct pcic_data *d; |
220 |
|
|
221 |
if (d == NULL) { |
CHECK_ALLOCATION(d = malloc(sizeof(struct pcic_data))); |
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
222 |
memset(d, 0, sizeof(struct pcic_data)); |
memset(d, 0, sizeof(struct pcic_data)); |
223 |
d->irq_nr = devinit->irq_nr; |
|
224 |
|
INTERRUPT_CONNECT(devinit->interrupt_path, d->irq); |
225 |
|
|
226 |
memory_device_register(devinit->machine->memory, devinit->name, |
memory_device_register(devinit->machine->memory, devinit->name, |
227 |
devinit->addr, DEV_PCIC_LENGTH, |
devinit->addr, DEV_PCIC_LENGTH, |