FreeBSD/Linux Kernel Cross Reference
sys/scsi/scsi_cpu.c
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 Software.Distribution@CS.CMU.EDU
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 * HISTORY
28 * $Log: scsi_cpu.c,v $
29 * Revision 2.10 92/08/03 17:54:54 jfriedl
30 * removed silly prototypes
31 * [92/08/02 jfriedl]
32 *
33 * Revision 2.9 92/05/21 17:24:19 jfriedl
34 * Cleanup to quiet gcc warnings.
35 * [92/05/20 jfriedl]
36 *
37 * Revision 2.8 92/02/23 22:44:52 elf
38 * Changed the interface of a number of functions not to
39 * require the scsi_softc pointer any longer. It was
40 * mostly unused, now it can be found via tgt->masterno.
41 * [92/02/22 19:29:47 af]
42 *
43 * Revision 2.7 91/08/24 12:28:34 af
44 * Filled in with what was missing. Works, too.
45 * [91/08/02 03:46:32 af]
46 *
47 * Revision 2.6 91/06/19 11:57:39 rvb
48 * File moved here from mips/PMAX since it is now "MI" code, also
49 * used by Vax3100 and soon -- the omron luna88k.
50 * [91/06/04 rvb]
51 *
52 * Revision 2.5 91/05/14 17:30:08 mrt
53 * Correcting copyright
54 *
55 * Revision 2.4 91/02/05 17:45:39 mrt
56 * Added author notices
57 * [91/02/04 11:19:23 mrt]
58 *
59 * Changed to use new Mach copyright
60 * [91/02/02 12:18:04 mrt]
61 *
62 * Revision 2.3 90/12/05 23:35:09 af
63 *
64 *
65 * Revision 2.1.1.1 90/11/01 03:39:46 af
66 * Created, from the SCSI specs:
67 * "Small Computer Systems Interface (SCSI)", ANSI Draft
68 * X3T9.2/82-2 - Rev 17B December 1985
69 * "Small Computer System Interface - 2 (SCSI-II)", ANSI Draft
70 * X3T9.2/86-109 - Rev 10C March 1990
71 * [90/10/11 af]
72 */
73 /*
74 * File: scsi_cpu.c
75 * Author: Alessandro Forin, Carnegie Mellon University
76 * Date: 10/90
77 *
78 * Middle layer of the SCSI driver: SCSI protocol implementation
79 *
80 * This file contains code for SCSI commands for PROCESSOR devices.
81 */
82
83 #include <mach/std_types.h>
84 #include <scsi/compat_30.h>
85
86 #include <scsi/scsi.h>
87 #include <scsi/scsi2.h>
88 #include <scsi/scsi_defs.h>
89
90
91
92 char *sccpu_name(internal)
93 boolean_t internal;
94 {
95 return internal ? "sc" : "cpu";
96 }
97
98 void scsi_send( tgt, ior)
99 register target_info_t *tgt;
100 io_req_t ior;
101 {
102 scsi_cmd_write_t *cmd;
103 unsigned len; /* in bytes */
104 unsigned int max_dma_data;
105
106 max_dma_data = scsi_softc[(unsigned char)tgt->masterno]->max_dma_data;
107
108 len = ior->io_count;
109 if (len > max_dma_data)
110 len = max_dma_data;
111 if (len < tgt->block_size)
112 len = tgt->block_size;
113
114 cmd = (scsi_cmd_write_t*) (tgt->cmd_ptr);
115 cmd->scsi_cmd_code = SCSI_CMD_SEND;
116 cmd->scsi_cmd_lun_and_lba1 = 0;
117 cmd->scsi_cmd_lba2 = len >> 16;
118 cmd->scsi_cmd_lba3 = len >> 8;
119 cmd->scsi_cmd_xfer_len = len;
120 cmd->scsi_cmd_ctrl_byte = 0; /* not linked */
121
122 tgt->cur_cmd = SCSI_CMD_SEND;
123
124 scsi_go(tgt, sizeof(*cmd), 0, FALSE);
125 }
126
127 void scsi_receive( tgt, ior)
128 register target_info_t *tgt;
129 io_req_t ior;
130 {
131 scsi_cmd_read_t *cmd;
132 register unsigned len;
133 unsigned int max_dma_data;
134
135 max_dma_data = scsi_softc[(unsigned char)tgt->masterno]->max_dma_data;
136
137 len = ior->io_count;
138 if (len > max_dma_data)
139 len = max_dma_data;
140 if (len < tgt->block_size)
141 len = tgt->block_size;
142
143 cmd = (scsi_cmd_read_t*) (tgt->cmd_ptr);
144 cmd->scsi_cmd_code = SCSI_CMD_RECEIVE;
145 cmd->scsi_cmd_lun_and_lba1 = 0;
146 cmd->scsi_cmd_lba2 = len >> 16;
147 cmd->scsi_cmd_lba3 = len >> 8;
148 cmd->scsi_cmd_xfer_len = len;
149 cmd->scsi_cmd_ctrl_byte = 0; /* not linked */
150
151 tgt->cur_cmd = SCSI_CMD_RECEIVE;
152
153 scsi_go(tgt, sizeof(*cmd), len, FALSE);
154 }
155
Cache object: adac3b60e1942719e5ec16d030b19e0f
|