1 |
/* |
/* |
2 |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-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_sii.c,v 1.16 2006/01/01 13:17:17 debug Exp $ |
* $Id: dev_sii.c,v 1.21 2007/06/15 19:57:34 debug Exp $ |
29 |
* |
* |
30 |
* SII SCSI controller, used in some DECstation systems. |
* COMMENT: SII SCSI controller, used in some DECstation systems |
31 |
* |
* |
32 |
* TODO: This is huge and ugly. Fix this. |
* TODO: This is huge and ugly. Fix this. |
33 |
*/ |
*/ |
38 |
|
|
39 |
#include "cpu.h" |
#include "cpu.h" |
40 |
#include "devices.h" |
#include "devices.h" |
41 |
|
#include "interrupt.h" |
42 |
#include "machine.h" |
#include "machine.h" |
43 |
#include "memory.h" |
#include "memory.h" |
44 |
#include "misc.h" |
#include "misc.h" |
50 |
|
|
51 |
|
|
52 |
struct sii_data { |
struct sii_data { |
53 |
int irq_nr; |
struct interrupt irq; |
54 |
|
|
55 |
uint64_t buf_start; |
uint64_t buf_start; |
56 |
uint64_t buf_end; |
uint64_t buf_end; |
57 |
|
|
93 |
} |
} |
94 |
|
|
95 |
|
|
96 |
/* |
DEVICE_TICK(sii) |
|
* dev_sii_tick(): |
|
|
*/ |
|
|
void dev_sii_tick(struct cpu *cpu, void *extra) |
|
97 |
{ |
{ |
98 |
struct sii_data *d = extra; |
struct sii_data *d = extra; |
99 |
|
|
169 |
combine_sii_bits(d); |
combine_sii_bits(d); |
170 |
|
|
171 |
if (d->siiregs.csr & SII_IE && d->siiregs.cstat & (SII_CI | SII_DI)) |
if (d->siiregs.csr & SII_IE && d->siiregs.cstat & (SII_CI | SII_DI)) |
172 |
cpu_interrupt(cpu, d->irq_nr); |
INTERRUPT_ASSERT(d->irq); |
173 |
else |
else |
174 |
cpu_interrupt_ack(cpu, d->irq_nr); |
INTERRUPT_DEASSERT(d->irq); |
175 |
} |
} |
176 |
|
|
177 |
|
|
|
/* |
|
|
* dev_sii_access(): |
|
|
*/ |
|
178 |
DEVICE_ACCESS(sii) |
DEVICE_ACCESS(sii) |
179 |
{ |
{ |
180 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
439 |
} |
} |
440 |
|
|
441 |
|
|
|
/* |
|
|
* dev_sii_init(): |
|
|
*/ |
|
442 |
void dev_sii_init(struct machine *machine, struct memory *mem, |
void dev_sii_init(struct machine *machine, struct memory *mem, |
443 |
uint64_t baseaddr, uint64_t buf_start, uint64_t buf_end, int irq_nr) |
uint64_t baseaddr, uint64_t buf_start, uint64_t buf_end, |
444 |
|
char *irq_path) |
445 |
{ |
{ |
446 |
struct sii_data *d = malloc(sizeof(struct sii_data)); |
struct sii_data *d; |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
447 |
|
|
448 |
|
CHECK_ALLOCATION(d = malloc(sizeof(struct sii_data))); |
449 |
memset(d, 0, sizeof(struct sii_data)); |
memset(d, 0, sizeof(struct sii_data)); |
450 |
d->irq_nr = irq_nr; |
|
451 |
|
INTERRUPT_CONNECT(irq_path, d->irq); |
452 |
d->buf_start = buf_start; |
d->buf_start = buf_start; |
453 |
d->buf_end = buf_end; |
d->buf_end = buf_end; |
454 |
|
d->regs = (uint16_t *) &d->siiregs; |
|
d->regs = (uint16_t *) &d->siiregs; |
|
455 |
|
|
456 |
memory_device_register(mem, "sii", baseaddr, DEV_SII_LENGTH, |
memory_device_register(mem, "sii", baseaddr, DEV_SII_LENGTH, |
457 |
dev_sii_access, (void *)d, DM_DEFAULT, NULL); |
dev_sii_access, (void *)d, DM_DEFAULT, NULL); |
458 |
|
|
459 |
machine_add_tickfunction(machine, dev_sii_tick, d, SII_TICK_SHIFT); |
machine_add_tickfunction(machine, dev_sii_tick, d, |
460 |
|
SII_TICK_SHIFT); |
461 |
} |
} |
462 |
|
|