1 /*
2  * Copyright (c) 1998,1999,2000
3  *	Traakan, Inc., Los Altos, CA
4  *	All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice unmodified, this list of conditions, and the following
11  *    disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 /*
30  * Project:  NDMJOB
31  * Ident:    $Id: $
32  *
33  * Description:
34  *
35  */
36 
37 
38 #include "ndmagents.h"
39 
40 
41 #ifndef NDMOS_OPTION_NO_ROBOT_AGENT
42 
43 
44 /*
45  * Initialization and Cleanup
46  ****************************************************************
47  */
48 
49 /* Initialize -- Set data structure to know value, ignore current value */
50 int
ndmra_initialize(struct ndm_session * sess)51 ndmra_initialize (struct ndm_session *sess)
52 {
53 	sess->robot_acb = NDMOS_API_MALLOC (sizeof(struct ndm_robot_agent));
54 	if (!sess->robot_acb)
55 		return -1;
56 	NDMOS_MACRO_ZEROFILL (sess->robot_acb);
57 	sess->robot_acb->scsi_state.error = NDMP9_DEV_NOT_OPEN_ERR;
58 
59 	return 0;
60 }
61 
62 /* Commission -- Get agent ready. Entire session has been initialize()d */
63 int
ndmra_commission(struct ndm_session * sess)64 ndmra_commission (struct ndm_session *sess)
65 {
66 	return 0;
67 }
68 
69 /* Decommission -- Discard agent */
70 int
ndmra_decommission(struct ndm_session * sess)71 ndmra_decommission (struct ndm_session *sess)
72 {
73 	return 0;
74 }
75 
76 /* Destroy -- Destroy agent */
77 int
ndmra_destroy(struct ndm_session * sess)78 ndmra_destroy (struct ndm_session *sess)
79 {
80 	if (!sess->robot_acb) {
81 		return 0;
82 	}
83 
84 #ifdef NDMOS_OPTION_ROBOT_SIMULATOR
85 	if (sess->robot_acb->sim_dir) {
86 		NDMOS_API_FREE (sess->robot_acb->sim_dir);
87 	}
88 #endif
89 
90 	NDMOS_API_FREE (sess->robot_acb);
91 	sess->robot_acb = NULL;
92 
93 	return 0;
94 }
95 
96 /*
97  * Semantic actions are all handled directly by ndmos_scsi_*
98  */
99 
100 #endif /* !NDMOS_OPTION_NO_ROBOT_AGENT */
101