1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 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.14 2005/10/26 14:37:04 debug Exp $ |
* $Id: dev_sii.c,v 1.19 2007/01/05 15:20:06 debug Exp $ |
29 |
* |
* |
30 |
* SII SCSI controller, used in some DECstation systems. |
* SII SCSI controller, used in some DECstation systems. |
31 |
* |
* |
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 |
|
|
172 |
combine_sii_bits(d); |
combine_sii_bits(d); |
173 |
|
|
174 |
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)) |
175 |
cpu_interrupt(cpu, d->irq_nr); |
INTERRUPT_ASSERT(d->irq); |
176 |
else |
else |
177 |
cpu_interrupt_ack(cpu, d->irq_nr); |
INTERRUPT_DEASSERT(d->irq); |
178 |
} |
} |
179 |
|
|
180 |
|
|
181 |
/* |
DEVICE_ACCESS(sii) |
|
* dev_sii_access(): |
|
|
*/ |
|
|
int dev_sii_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
182 |
{ |
{ |
183 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
184 |
int regnr; |
int regnr; |
446 |
* dev_sii_init(): |
* dev_sii_init(): |
447 |
*/ |
*/ |
448 |
void dev_sii_init(struct machine *machine, struct memory *mem, |
void dev_sii_init(struct machine *machine, struct memory *mem, |
449 |
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, |
450 |
|
char *irq_path) |
451 |
{ |
{ |
452 |
struct sii_data *d = malloc(sizeof(struct sii_data)); |
struct sii_data *d = malloc(sizeof(struct sii_data)); |
453 |
if (d == NULL) { |
if (d == NULL) { |
456 |
} |
} |
457 |
|
|
458 |
memset(d, 0, sizeof(struct sii_data)); |
memset(d, 0, sizeof(struct sii_data)); |
459 |
d->irq_nr = irq_nr; |
INTERRUPT_CONNECT(irq_path, d->irq); |
460 |
d->buf_start = buf_start; |
d->buf_start = buf_start; |
461 |
d->buf_end = buf_end; |
d->buf_end = buf_end; |
462 |
|
d->regs = (uint16_t *) &d->siiregs; |
|
d->regs = (uint16_t *) &d->siiregs; |
|
463 |
|
|
464 |
memory_device_register(mem, "sii", baseaddr, DEV_SII_LENGTH, |
memory_device_register(mem, "sii", baseaddr, DEV_SII_LENGTH, |
465 |
dev_sii_access, (void *)d, MEM_DEFAULT, NULL); |
dev_sii_access, (void *)d, DM_DEFAULT, NULL); |
466 |
|
|
467 |
machine_add_tickfunction(machine, dev_sii_tick, d, SII_TICK_SHIFT); |
machine_add_tickfunction(machine, dev_sii_tick, d, |
468 |
|
SII_TICK_SHIFT, 0.0); |
469 |
} |
} |
470 |
|
|