4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #pragma ident "%Z%%M% %I% %E% SMI"
31 * This file contains functions that implement the cache menu commands.
35 #include <sys/resource.h>
39 #include <sys/fcntl.h>
42 #include <sys/dklabel.h>
47 #include "menu_cache.h"
52 #include "partition.h"
56 #include "ctlr_scsi.h"
57 #include "auto_sense.h"
58 #include "hardware_structs.h"
60 extern struct menu_item menu_cache
[];
61 extern struct menu_item menu_write_cache
[];
62 extern struct menu_item menu_read_cache
[];
70 run_menu(menu_cache
, "CACHE", "cache", 0);
80 run_menu(menu_write_cache
, "WRITE_CACHE", "write_cache", 0);
90 run_menu(menu_read_cache
, "READ_CACHE", "read_cache", 0);
98 struct mode_cache
*page8
;
99 struct scsi_ms_header header
;
102 struct mode_cache page8
;
103 char rawbuf
[MAX_MODE_SENSE_SIZE
];
106 page8
= &u_page8
.page8
;
108 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
109 MODE_SENSE_PC_CURRENT
, (caddr_t
)page8
,
110 MAX_MODE_SENSE_SIZE
, &header
);
114 fmt_print("Write Cache is enabled\n");
116 fmt_print("Write Cache is disabled\n");
119 err_print("Mode sense failed.\n");
127 struct mode_cache
*page8
;
128 struct scsi_ms_header header
;
133 struct mode_cache page8
;
134 char rawbuf
[MAX_MODE_SENSE_SIZE
];
137 page8
= &u_page8
.page8
;
139 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
140 MODE_SENSE_PC_CHANGEABLE
, (caddr_t
)page8
,
141 MAX_MODE_SENSE_SIZE
, &header
);
145 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
146 MODE_SENSE_PC_SAVED
, (caddr_t
)page8
,
147 MAX_MODE_SENSE_SIZE
, &header
);
149 status
= uscsi_mode_sense(cur_file
,
150 DAD_MODE_CACHE
, MODE_SENSE_PC_CURRENT
,
151 (caddr_t
)page8
, MAX_MODE_SENSE_SIZE
, &header
);
155 length
= MODESENSE_PAGE_LEN(page8
);
156 sp_flags
= MODE_SELECT_PF
;
157 if (page8
->mode_page
.ps
) {
158 sp_flags
|= MODE_SELECT_SP
;
161 This setting is valid until next reset only. It is not saved permanently.\n");
163 page8
->mode_page
.ps
= 0;
165 header
.mode_header
.length
= 0;
166 header
.mode_header
.device_specific
= 0;
167 status
= uscsi_mode_select(cur_file
,
168 DAD_MODE_CACHE
, sp_flags
,
169 (caddr_t
)page8
, length
, &header
);
171 err_print("Mode select failed\n");
176 err_print("Write cache setting is not changeable\n");
180 err_print("Mode sense failed.\n");
188 struct mode_cache
*page8
;
189 struct scsi_ms_header header
;
194 struct mode_cache page8
;
195 char rawbuf
[MAX_MODE_SENSE_SIZE
];
198 page8
= &u_page8
.page8
;
200 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
201 MODE_SENSE_PC_CHANGEABLE
, (caddr_t
)page8
,
202 MAX_MODE_SENSE_SIZE
, &header
);
206 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
207 MODE_SENSE_PC_SAVED
, (caddr_t
)page8
,
208 MAX_MODE_SENSE_SIZE
, &header
);
210 status
= uscsi_mode_sense(cur_file
,
211 DAD_MODE_CACHE
, MODE_SENSE_PC_CURRENT
,
212 (caddr_t
)page8
, MAX_MODE_SENSE_SIZE
, &header
);
216 length
= MODESENSE_PAGE_LEN(page8
);
217 sp_flags
= MODE_SELECT_PF
;
218 if (page8
->mode_page
.ps
) {
219 sp_flags
|= MODE_SELECT_SP
;
222 This setting is valid until next reset only. It is not saved permanently.\n");
224 page8
->mode_page
.ps
= 0;
226 header
.mode_header
.length
= 0;
227 header
.mode_header
.device_specific
= 0;
228 status
= uscsi_mode_select(cur_file
,
229 DAD_MODE_CACHE
, sp_flags
,
230 (caddr_t
)page8
, length
, &header
);
232 err_print("Mode select failed\n");
237 err_print("Write cache setting is not changeable\n");
241 err_print("Mode sense failed.\n");
249 struct mode_cache
*page8
;
250 struct scsi_ms_header header
;
253 struct mode_cache page8
;
254 char rawbuf
[MAX_MODE_SENSE_SIZE
];
257 page8
= &u_page8
.page8
;
259 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
260 MODE_SENSE_PC_CURRENT
, (caddr_t
)page8
,
261 MAX_MODE_SENSE_SIZE
, &header
);
265 fmt_print("Read Cache is disabled\n");
267 fmt_print("Read Cache is enabled\n");
270 err_print("Mode sense failed.\n");
278 struct mode_cache
*page8
;
279 struct scsi_ms_header header
;
284 struct mode_cache page8
;
285 char rawbuf
[MAX_MODE_SENSE_SIZE
];
288 page8
= &u_page8
.page8
;
290 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
291 MODE_SENSE_PC_CHANGEABLE
, (caddr_t
)page8
,
292 MAX_MODE_SENSE_SIZE
, &header
);
296 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
297 MODE_SENSE_PC_SAVED
, (caddr_t
)page8
,
298 MAX_MODE_SENSE_SIZE
, &header
);
300 status
= uscsi_mode_sense(cur_file
,
301 DAD_MODE_CACHE
, MODE_SENSE_PC_CURRENT
,
302 (caddr_t
)page8
, MAX_MODE_SENSE_SIZE
, &header
);
306 length
= MODESENSE_PAGE_LEN(page8
);
307 sp_flags
= MODE_SELECT_PF
;
308 if (page8
->mode_page
.ps
) {
309 sp_flags
|= MODE_SELECT_SP
;
312 This setting is valid until next reset only. It is not saved permanently.\n");
314 page8
->mode_page
.ps
= 0;
316 header
.mode_header
.length
= 0;
317 header
.mode_header
.device_specific
= 0;
318 status
= uscsi_mode_select(cur_file
,
319 DAD_MODE_CACHE
, sp_flags
,
320 (caddr_t
)page8
, length
, &header
);
322 err_print("Mode select failed\n");
327 err_print("Read cache setting is not changeable\n");
331 err_print("Mode sense failed.\n");
339 struct mode_cache
*page8
;
340 struct scsi_ms_header header
;
345 struct mode_cache page8
;
346 char rawbuf
[MAX_MODE_SENSE_SIZE
];
349 page8
= &u_page8
.page8
;
351 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
352 MODE_SENSE_PC_CHANGEABLE
, (caddr_t
)page8
,
353 MAX_MODE_SENSE_SIZE
, &header
);
357 status
= uscsi_mode_sense(cur_file
, DAD_MODE_CACHE
,
358 MODE_SENSE_PC_SAVED
, (caddr_t
)page8
,
359 MAX_MODE_SENSE_SIZE
, &header
);
361 status
= uscsi_mode_sense(cur_file
,
362 DAD_MODE_CACHE
, MODE_SENSE_PC_CURRENT
,
363 (caddr_t
)page8
, MAX_MODE_SENSE_SIZE
, &header
);
367 length
= MODESENSE_PAGE_LEN(page8
);
368 sp_flags
= MODE_SELECT_PF
;
369 if (page8
->mode_page
.ps
) {
370 sp_flags
|= MODE_SELECT_SP
;
373 This setting is valid until next reset only. It is not saved permanently.\n");
375 page8
->mode_page
.ps
= 0;
377 header
.mode_header
.length
= 0;
378 header
.mode_header
.device_specific
= 0;
379 status
= uscsi_mode_select(cur_file
,
380 DAD_MODE_CACHE
, sp_flags
,
381 (caddr_t
)page8
, length
, &header
);
383 err_print("Mode select failed\n");
388 err_print("Read cache setting is not changeable\n");
392 err_print("Mode sense failed.\n");