|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 1991,1990 Carnegie Mellon University
4: * All Rights Reserved.
5: *
6: * Permission to use, copy, modify and distribute this software and its
7: * documentation is hereby granted, provided that both the copyright
8: * notice and this permission notice appear in all copies of the
9: * software, derivative works or modified versions, and any portions
10: * thereof, and that both notices appear in supporting documentation.
11: *
12: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15: *
16: * Carnegie Mellon requests users of this software to return to
17: *
18: * Software Distribution Coordinator or [email protected]
19: * School of Computer Science
20: * Carnegie Mellon University
21: * Pittsburgh PA 15213-3890
22: *
23: * any improvements or extensions that they make and grant Carnegie Mellon
24: * the rights to redistribute these changes.
25: */
26: /*
27: * File: scsi_cpu.c
28: * Author: Alessandro Forin, Carnegie Mellon University
29: * Date: 10/90
30: *
31: * Middle layer of the SCSI driver: SCSI protocol implementation
32: *
33: * This file contains code for SCSI commands for PROCESSOR devices.
34: */
35:
36: #include <mach/std_types.h>
37: #include <scsi/compat_30.h>
38:
39: #include <scsi/scsi.h>
40: #include <scsi/scsi2.h>
41: #include <scsi/scsi_defs.h>
42:
43: #if (NSCSI > 0)
44:
45: char *sccpu_name(internal)
46: boolean_t internal;
47: {
48: return internal ? "sc" : "cpu";
49: }
50:
51: void scsi_send( tgt, ior)
52: register target_info_t *tgt;
53: io_req_t ior;
54: {
55: scsi_cmd_write_t *cmd;
56: unsigned len; /* in bytes */
57: unsigned int max_dma_data;
58:
59: max_dma_data = scsi_softc[(unsigned char)tgt->masterno]->max_dma_data;
60:
61: len = ior->io_count;
62: if (len > max_dma_data)
63: len = max_dma_data;
64: if (len < tgt->block_size)
65: len = tgt->block_size;
66:
67: cmd = (scsi_cmd_write_t*) (tgt->cmd_ptr);
68: cmd->scsi_cmd_code = SCSI_CMD_SEND;
69: cmd->scsi_cmd_lun_and_lba1 = 0;
70: cmd->scsi_cmd_lba2 = len >> 16;
71: cmd->scsi_cmd_lba3 = len >> 8;
72: cmd->scsi_cmd_xfer_len = len;
73: cmd->scsi_cmd_ctrl_byte = 0; /* not linked */
74:
75: tgt->cur_cmd = SCSI_CMD_SEND;
76:
77: scsi_go(tgt, sizeof(*cmd), 0, FALSE);
78: }
79:
80: void scsi_receive( tgt, ior)
81: register target_info_t *tgt;
82: io_req_t ior;
83: {
84: scsi_cmd_read_t *cmd;
85: register unsigned len;
86: unsigned int max_dma_data;
87:
88: max_dma_data = scsi_softc[(unsigned char)tgt->masterno]->max_dma_data;
89:
90: len = ior->io_count;
91: if (len > max_dma_data)
92: len = max_dma_data;
93: if (len < tgt->block_size)
94: len = tgt->block_size;
95:
96: cmd = (scsi_cmd_read_t*) (tgt->cmd_ptr);
97: cmd->scsi_cmd_code = SCSI_CMD_RECEIVE;
98: cmd->scsi_cmd_lun_and_lba1 = 0;
99: cmd->scsi_cmd_lba2 = len >> 16;
100: cmd->scsi_cmd_lba3 = len >> 8;
101: cmd->scsi_cmd_xfer_len = len;
102: cmd->scsi_cmd_ctrl_byte = 0; /* not linked */
103:
104: tgt->cur_cmd = SCSI_CMD_RECEIVE;
105:
106: scsi_go(tgt, sizeof(*cmd), len, FALSE);
107: }
108:
109: #endif /* NSCSI > 0 */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.