1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2006 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_asc.c,v 1.76 2005/11/13 00:14:08 debug Exp $ |
* $Id: dev_asc.c,v 1.81 2006/07/21 16:55:41 debug Exp $ |
29 |
* |
* |
30 |
* 'asc' SCSI controller for some DECstation/DECsystem models, and |
* 'asc' SCSI controller for some DECstation/DECsystem models and PICA-61. |
|
* for PICA-61. |
|
31 |
* |
* |
32 |
* Supposed to support SCSI-1 and SCSI-2. I've not yet found any docs |
* Supposed to support SCSI-1 and SCSI-2. I've not yet found any docs |
33 |
* on NCR53C9X, so I'll try to implement this device from LSI53CF92A docs |
* on NCR53C9X, so I'll try to implement this device from LSI53CF92A docs |
49 |
* TODO: This module needs a clean-up, and some testing to see that |
* TODO: This module needs a clean-up, and some testing to see that |
50 |
* it works will all OSes that might use it (NetBSD, OpenBSD, |
* it works will all OSes that might use it (NetBSD, OpenBSD, |
51 |
* Ultrix, Linux, Mach, OSF/1, Sprite, ...) |
* Ultrix, Linux, Mach, OSF/1, Sprite, ...) |
52 |
|
* |
53 |
|
* Running Linux/DECstation 2.4.26 with no scsi disks attached causes |
54 |
|
* a warning message to be printed by Linux. (Whether this is a bug, |
55 |
|
* is is the way it works on real hardware, I don't know.) |
56 |
*/ |
*/ |
57 |
|
|
58 |
#include <stdio.h> |
#include <stdio.h> |
152 |
int to_id, int dmaflag, int n_messagebytes); |
int to_id, int dmaflag, int n_messagebytes); |
153 |
|
|
154 |
|
|
155 |
/* |
DEVICE_TICK(asc) |
|
* dev_asc_tick(): |
|
|
* |
|
|
* This function is called "every now and then" from the CPU |
|
|
* main loop. |
|
|
*/ |
|
|
void dev_asc_tick(struct cpu *cpu, void *extra) |
|
156 |
{ |
{ |
157 |
struct asc_data *d = extra; |
struct asc_data *d = extra; |
158 |
|
|
306 |
fatal("no incoming DMA data?\n"); |
fatal("no incoming DMA data?\n"); |
307 |
res = 0; |
res = 0; |
308 |
} else { |
} else { |
309 |
int len = d->xferp->data_in_len; |
size_t len = d->xferp->data_in_len; |
310 |
int len2 = d->reg_wo[NCR_TCL] + |
size_t len2 = d->reg_wo[NCR_TCL] + |
311 |
d->reg_wo[NCR_TCM] * 256; |
d->reg_wo[NCR_TCM] * 256; |
312 |
if (len2 == 0) |
if (len2 == 0) |
313 |
len2 = 65536; |
len2 = 65536; |
745 |
} |
} |
746 |
|
|
747 |
|
|
748 |
/* |
DEVICE_ACCESS(asc_address_reg) |
|
* dev_asc_address_reg_access(): |
|
|
*/ |
|
|
int dev_asc_address_reg_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
749 |
{ |
{ |
750 |
struct asc_data *d = extra; |
struct asc_data *d = extra; |
751 |
|
|
762 |
} |
} |
763 |
|
|
764 |
|
|
765 |
/* |
DEVICE_ACCESS(asc_dma) |
|
* dev_asc_dma_access(): |
|
|
*/ |
|
|
int dev_asc_dma_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
766 |
{ |
{ |
767 |
struct asc_data *d = extra; |
struct asc_data *d = extra; |
768 |
|
|
800 |
} |
} |
801 |
|
|
802 |
|
|
803 |
/* |
DEVICE_ACCESS(asc) |
|
* dev_asc_access(): |
|
|
*/ |
|
|
int dev_asc_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
804 |
{ |
{ |
805 |
int regnr; |
int regnr; |
806 |
struct asc_data *d = extra; |
struct asc_data *d = extra; |
1259 |
d->dma_controller_data = dma_controller_data; |
d->dma_controller_data = dma_controller_data; |
1260 |
|
|
1261 |
memory_device_register(mem, "asc", baseaddr, |
memory_device_register(mem, "asc", baseaddr, |
1262 |
mode == DEV_ASC_PICA? |
mode == DEV_ASC_PICA? DEV_ASC_PICA_LENGTH : DEV_ASC_DEC_LENGTH, |
|
DEV_ASC_PICA_LENGTH : DEV_ASC_DEC_LENGTH, |
|
1263 |
dev_asc_access, d, DM_DEFAULT, NULL); |
dev_asc_access, d, DM_DEFAULT, NULL); |
1264 |
|
|
1265 |
if (mode == DEV_ASC_DEC) { |
if (mode == DEV_ASC_DEC) { |
1272 |
DM_DYNTRANS_OK | DM_DYNTRANS_WRITE_OK, d->dma); |
DM_DYNTRANS_OK | DM_DYNTRANS_WRITE_OK, d->dma); |
1273 |
} |
} |
1274 |
|
|
1275 |
machine_add_tickfunction(machine, dev_asc_tick, d, ASC_TICK_SHIFT); |
machine_add_tickfunction(machine, dev_asc_tick, d, ASC_TICK_SHIFT, 0.0); |
1276 |
} |
} |
1277 |
|
|