1f11c7f63SJim Harris /*-
2*718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3*718cf2ccSPedro F. Giffuni *
4f11c7f63SJim Harris * This file is provided under a dual BSD/GPLv2 license. When using or
5f11c7f63SJim Harris * redistributing this file, you may do so under either license.
6f11c7f63SJim Harris *
7f11c7f63SJim Harris * GPL LICENSE SUMMARY
8f11c7f63SJim Harris *
9f11c7f63SJim Harris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10f11c7f63SJim Harris *
11f11c7f63SJim Harris * This program is free software; you can redistribute it and/or modify
12f11c7f63SJim Harris * it under the terms of version 2 of the GNU General Public License as
13f11c7f63SJim Harris * published by the Free Software Foundation.
14f11c7f63SJim Harris *
15f11c7f63SJim Harris * This program is distributed in the hope that it will be useful, but
16f11c7f63SJim Harris * WITHOUT ANY WARRANTY; without even the implied warranty of
17f11c7f63SJim Harris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18f11c7f63SJim Harris * General Public License for more details.
19f11c7f63SJim Harris *
20f11c7f63SJim Harris * You should have received a copy of the GNU General Public License
21f11c7f63SJim Harris * along with this program; if not, write to the Free Software
22f11c7f63SJim Harris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23f11c7f63SJim Harris * The full GNU General Public License is included in this distribution
24f11c7f63SJim Harris * in the file called LICENSE.GPL.
25f11c7f63SJim Harris *
26f11c7f63SJim Harris * BSD LICENSE
27f11c7f63SJim Harris *
28f11c7f63SJim Harris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29f11c7f63SJim Harris * All rights reserved.
30f11c7f63SJim Harris *
31f11c7f63SJim Harris * Redistribution and use in source and binary forms, with or without
32f11c7f63SJim Harris * modification, are permitted provided that the following conditions
33f11c7f63SJim Harris * are met:
34f11c7f63SJim Harris *
35f11c7f63SJim Harris * * Redistributions of source code must retain the above copyright
36f11c7f63SJim Harris * notice, this list of conditions and the following disclaimer.
37f11c7f63SJim Harris * * Redistributions in binary form must reproduce the above copyright
38f11c7f63SJim Harris * notice, this list of conditions and the following disclaimer in
39f11c7f63SJim Harris * the documentation and/or other materials provided with the
40f11c7f63SJim Harris * distribution.
41f11c7f63SJim Harris *
42f11c7f63SJim Harris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43f11c7f63SJim Harris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44f11c7f63SJim Harris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45f11c7f63SJim Harris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46f11c7f63SJim Harris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47f11c7f63SJim Harris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48f11c7f63SJim Harris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49f11c7f63SJim Harris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50f11c7f63SJim Harris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51f11c7f63SJim Harris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52f11c7f63SJim Harris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53f11c7f63SJim Harris */
54f11c7f63SJim Harris
55f11c7f63SJim Harris #include <sys/cdefs.h>
56f11c7f63SJim Harris /**
57f11c7f63SJim Harris * @file
58f11c7f63SJim Harris *
59f11c7f63SJim Harris * @brief This file contains the implementation of remote device, it's
60f11c7f63SJim Harris * methods and state machine.
61f11c7f63SJim Harris */
62f11c7f63SJim Harris
63f11c7f63SJim Harris #include <dev/isci/scil/intel_sas.h>
64f11c7f63SJim Harris #include <dev/isci/scil/sci_util.h>
65f11c7f63SJim Harris #include <dev/isci/scil/scic_port.h>
66f11c7f63SJim Harris #include <dev/isci/scil/scic_phy.h>
67f11c7f63SJim Harris #include <dev/isci/scil/scic_remote_device.h>
68f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_port.h>
69f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_phy.h>
70f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_remote_device.h>
71f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_request.h>
72f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_controller.h>
73f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_logger.h>
74f11c7f63SJim Harris #include <dev/isci/scil/scic_user_callback.h>
75f11c7f63SJim Harris #include <dev/isci/scil/scic_controller.h>
76f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_logger.h>
77f11c7f63SJim Harris #include <dev/isci/scil/scic_sds_remote_node_context.h>
78f11c7f63SJim Harris #include <dev/isci/scil/scu_event_codes.h>
79f11c7f63SJim Harris
80f11c7f63SJim Harris #define SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT (1000)
81f11c7f63SJim Harris
82f11c7f63SJim Harris //*****************************************************************************
83f11c7f63SJim Harris //* CORE REMOTE DEVICE PUBLIC METHODS
84f11c7f63SJim Harris //*****************************************************************************
85f11c7f63SJim Harris
scic_remote_device_get_object_size(void)86f11c7f63SJim Harris U32 scic_remote_device_get_object_size(void)
87f11c7f63SJim Harris {
88f11c7f63SJim Harris return sizeof(SCIC_SDS_REMOTE_DEVICE_T)
89f11c7f63SJim Harris + sizeof(SCIC_SDS_REMOTE_NODE_CONTEXT_T);
90f11c7f63SJim Harris }
91f11c7f63SJim Harris
92f11c7f63SJim Harris // ---------------------------------------------------------------------------
93f11c7f63SJim Harris
scic_remote_device_construct(SCI_PORT_HANDLE_T port,void * remote_device_memory,SCI_REMOTE_DEVICE_HANDLE_T * new_remote_device_handle)94f11c7f63SJim Harris void scic_remote_device_construct(
95f11c7f63SJim Harris SCI_PORT_HANDLE_T port,
96f11c7f63SJim Harris void * remote_device_memory,
97f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T * new_remote_device_handle
98f11c7f63SJim Harris )
99f11c7f63SJim Harris {
100f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T*)
101f11c7f63SJim Harris remote_device_memory;
102f11c7f63SJim Harris SCIC_SDS_PORT_T *the_port = (SCIC_SDS_PORT_T*) port;
103f11c7f63SJim Harris
104f11c7f63SJim Harris SCIC_LOG_TRACE((
105f11c7f63SJim Harris sci_base_object_get_logger(the_port),
106f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
107f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
108f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
109f11c7f63SJim Harris "scic_remote_device_construct(0x%x, 0x%x, 0x%x) enter\n",
110f11c7f63SJim Harris port, remote_device_memory, new_remote_device_handle
111f11c7f63SJim Harris ));
112f11c7f63SJim Harris
113f11c7f63SJim Harris memset(remote_device_memory, 0, sizeof(SCIC_SDS_REMOTE_DEVICE_T));
114f11c7f63SJim Harris
115f11c7f63SJim Harris *new_remote_device_handle = this_device;
116f11c7f63SJim Harris this_device->owning_port = the_port;
117f11c7f63SJim Harris this_device->started_request_count = 0;
118f11c7f63SJim Harris this_device->rnc = (SCIC_SDS_REMOTE_NODE_CONTEXT_T *)
119f11c7f63SJim Harris ((char *)this_device + sizeof(SCIC_SDS_REMOTE_DEVICE_T));
120f11c7f63SJim Harris
121f11c7f63SJim Harris sci_base_remote_device_construct(
122f11c7f63SJim Harris &this_device->parent,
123f11c7f63SJim Harris sci_base_object_get_logger(the_port),
124f11c7f63SJim Harris scic_sds_remote_device_state_table
125f11c7f63SJim Harris );
126f11c7f63SJim Harris
127f11c7f63SJim Harris scic_sds_remote_node_context_construct(
128f11c7f63SJim Harris this_device,
129f11c7f63SJim Harris this_device->rnc,
130f11c7f63SJim Harris SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
131f11c7f63SJim Harris );
132f11c7f63SJim Harris
133f11c7f63SJim Harris sci_object_set_association(this_device->rnc, this_device);
134f11c7f63SJim Harris
135f11c7f63SJim Harris scic_sds_remote_device_initialize_state_logging(this_device);
136f11c7f63SJim Harris }
137f11c7f63SJim Harris
138f11c7f63SJim Harris // ---------------------------------------------------------------------------
139f11c7f63SJim Harris
scic_remote_device_da_construct(SCI_REMOTE_DEVICE_HANDLE_T remote_device)140f11c7f63SJim Harris SCI_STATUS scic_remote_device_da_construct(
141f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device
142f11c7f63SJim Harris )
143f11c7f63SJim Harris {
144f11c7f63SJim Harris SCI_STATUS status;
145f11c7f63SJim Harris U16 remote_node_index;
146f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T*)
147f11c7f63SJim Harris remote_device;
148f11c7f63SJim Harris SCI_SAS_IDENTIFY_ADDRESS_FRAME_PROTOCOLS_T protocols;
149f11c7f63SJim Harris SCIC_PORT_PROPERTIES_T properties;
150f11c7f63SJim Harris
151f11c7f63SJim Harris SCIC_LOG_TRACE((
152f11c7f63SJim Harris sci_base_object_get_logger(this_device->owning_port),
153f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
154f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
155f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
156f11c7f63SJim Harris "scic_remote_device_da_construct(0x%x) enter\n",
157f11c7f63SJim Harris remote_device
158f11c7f63SJim Harris ));
159f11c7f63SJim Harris
160f11c7f63SJim Harris // This information is request to determine how many remote node context
161f11c7f63SJim Harris // entries will be needed to store the remote node.
162f11c7f63SJim Harris scic_sds_port_get_attached_protocols(this_device->owning_port,&protocols);
163f11c7f63SJim Harris this_device->target_protocols.u.all = protocols.u.all;
164f11c7f63SJim Harris this_device->is_direct_attached = TRUE;
165f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
166f11c7f63SJim Harris this_device->is_atapi = scic_sds_remote_device_is_atapi(this_device);
167f11c7f63SJim Harris #endif
168f11c7f63SJim Harris
169f11c7f63SJim Harris scic_port_get_properties(this_device->owning_port, &properties);
170f11c7f63SJim Harris //Get accurate port width from port's phy mask for a DA device.
171f11c7f63SJim Harris SCI_GET_BITS_SET_COUNT(properties.phy_mask, this_device->device_port_width);
172f11c7f63SJim Harris
173f11c7f63SJim Harris status = scic_sds_controller_allocate_remote_node_context(
174f11c7f63SJim Harris this_device->owning_port->owning_controller,
175f11c7f63SJim Harris this_device,
176f11c7f63SJim Harris &remote_node_index
177f11c7f63SJim Harris );
178f11c7f63SJim Harris
179f11c7f63SJim Harris if (status == SCI_SUCCESS)
180f11c7f63SJim Harris {
181f11c7f63SJim Harris scic_sds_remote_node_context_set_remote_node_index(
182f11c7f63SJim Harris this_device->rnc, remote_node_index
183f11c7f63SJim Harris );
184f11c7f63SJim Harris
185f11c7f63SJim Harris scic_sds_port_get_attached_sas_address(
186f11c7f63SJim Harris this_device->owning_port, &this_device->device_address
187f11c7f63SJim Harris );
188f11c7f63SJim Harris
189f11c7f63SJim Harris if (this_device->target_protocols.u.bits.attached_ssp_target)
190f11c7f63SJim Harris {
191f11c7f63SJim Harris this_device->has_ready_substate_machine = FALSE;
192f11c7f63SJim Harris }
193f11c7f63SJim Harris else if (this_device->target_protocols.u.bits.attached_stp_target)
194f11c7f63SJim Harris {
195f11c7f63SJim Harris this_device->has_ready_substate_machine = TRUE;
196f11c7f63SJim Harris
197f11c7f63SJim Harris sci_base_state_machine_construct(
198f11c7f63SJim Harris &this_device->ready_substate_machine,
199f11c7f63SJim Harris &this_device->parent.parent,
200f11c7f63SJim Harris scic_sds_stp_remote_device_ready_substate_table,
201f11c7f63SJim Harris SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
202f11c7f63SJim Harris );
203f11c7f63SJim Harris }
204f11c7f63SJim Harris else if (this_device->target_protocols.u.bits.attached_smp_target)
205f11c7f63SJim Harris {
206f11c7f63SJim Harris this_device->has_ready_substate_machine = TRUE;
207f11c7f63SJim Harris
208f11c7f63SJim Harris //add the SMP ready substate machine construction here
209f11c7f63SJim Harris sci_base_state_machine_construct(
210f11c7f63SJim Harris &this_device->ready_substate_machine,
211f11c7f63SJim Harris &this_device->parent.parent,
212f11c7f63SJim Harris scic_sds_smp_remote_device_ready_substate_table,
213f11c7f63SJim Harris SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
214f11c7f63SJim Harris );
215f11c7f63SJim Harris }
216f11c7f63SJim Harris
217f11c7f63SJim Harris this_device->connection_rate = scic_sds_port_get_max_allowed_speed(
218f11c7f63SJim Harris this_device->owning_port
219f11c7f63SJim Harris );
220f11c7f63SJim Harris
221f11c7f63SJim Harris /// @todo Should I assign the port width by reading all of the phys on the port?
222f11c7f63SJim Harris this_device->device_port_width = 1;
223f11c7f63SJim Harris }
224f11c7f63SJim Harris
225f11c7f63SJim Harris return status;
226f11c7f63SJim Harris }
227f11c7f63SJim Harris
228f11c7f63SJim Harris
229f11c7f63SJim Harris // ---------------------------------------------------------------------------
230f11c7f63SJim Harris
scic_sds_remote_device_get_info_from_smp_discover_response(SCIC_SDS_REMOTE_DEVICE_T * this_device,SMP_RESPONSE_DISCOVER_T * discover_response)231f11c7f63SJim Harris void scic_sds_remote_device_get_info_from_smp_discover_response(
232f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device,
233f11c7f63SJim Harris SMP_RESPONSE_DISCOVER_T * discover_response
234f11c7f63SJim Harris )
235f11c7f63SJim Harris {
236f11c7f63SJim Harris // decode discover_response to set sas_address to this_device.
237f11c7f63SJim Harris this_device->device_address.high =
238f11c7f63SJim Harris discover_response->attached_sas_address.high;
239f11c7f63SJim Harris
240f11c7f63SJim Harris this_device->device_address.low =
241f11c7f63SJim Harris discover_response->attached_sas_address.low;
242f11c7f63SJim Harris
243f11c7f63SJim Harris this_device->target_protocols.u.all = discover_response->protocols.u.all;
244f11c7f63SJim Harris }
245f11c7f63SJim Harris
246f11c7f63SJim Harris
247f11c7f63SJim Harris // ---------------------------------------------------------------------------
248f11c7f63SJim Harris
scic_remote_device_ea_construct(SCI_REMOTE_DEVICE_HANDLE_T remote_device,SMP_RESPONSE_DISCOVER_T * discover_response)249f11c7f63SJim Harris SCI_STATUS scic_remote_device_ea_construct(
250f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
251f11c7f63SJim Harris SMP_RESPONSE_DISCOVER_T * discover_response
252f11c7f63SJim Harris )
253f11c7f63SJim Harris {
254f11c7f63SJim Harris SCI_STATUS status;
255f11c7f63SJim Harris
256f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
257f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T *the_controller;
258f11c7f63SJim Harris
259f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
260f11c7f63SJim Harris
261f11c7f63SJim Harris SCIC_LOG_TRACE((
262f11c7f63SJim Harris sci_base_object_get_logger(this_device->owning_port),
263f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
264f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
265f11c7f63SJim Harris "scic_remote_device_ea_sas_construct0x%x, 0x%x) enter\n",
266f11c7f63SJim Harris remote_device, discover_response
267f11c7f63SJim Harris ));
268f11c7f63SJim Harris
269f11c7f63SJim Harris the_controller = scic_sds_port_get_controller(this_device->owning_port);
270f11c7f63SJim Harris
271f11c7f63SJim Harris scic_sds_remote_device_get_info_from_smp_discover_response(
272f11c7f63SJim Harris this_device, discover_response
273f11c7f63SJim Harris );
274f11c7f63SJim Harris
275f11c7f63SJim Harris status = scic_sds_controller_allocate_remote_node_context(
276f11c7f63SJim Harris the_controller,
277f11c7f63SJim Harris this_device,
278f11c7f63SJim Harris &this_device->rnc->remote_node_index
279f11c7f63SJim Harris );
280f11c7f63SJim Harris
281f11c7f63SJim Harris if (status == SCI_SUCCESS)
282f11c7f63SJim Harris {
283f11c7f63SJim Harris if (this_device->target_protocols.u.bits.attached_ssp_target)
284f11c7f63SJim Harris {
285f11c7f63SJim Harris this_device->has_ready_substate_machine = FALSE;
286f11c7f63SJim Harris }
287f11c7f63SJim Harris else if (this_device->target_protocols.u.bits.attached_smp_target)
288f11c7f63SJim Harris {
289f11c7f63SJim Harris this_device->has_ready_substate_machine = TRUE;
290f11c7f63SJim Harris
291f11c7f63SJim Harris //add the SMP ready substate machine construction here
292f11c7f63SJim Harris sci_base_state_machine_construct(
293f11c7f63SJim Harris &this_device->ready_substate_machine,
294f11c7f63SJim Harris &this_device->parent.parent,
295f11c7f63SJim Harris scic_sds_smp_remote_device_ready_substate_table,
296f11c7f63SJim Harris SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
297f11c7f63SJim Harris );
298f11c7f63SJim Harris }
299f11c7f63SJim Harris else if (this_device->target_protocols.u.bits.attached_stp_target)
300f11c7f63SJim Harris {
301f11c7f63SJim Harris this_device->has_ready_substate_machine = TRUE;
302f11c7f63SJim Harris
303f11c7f63SJim Harris sci_base_state_machine_construct(
304f11c7f63SJim Harris &this_device->ready_substate_machine,
305f11c7f63SJim Harris &this_device->parent.parent,
306f11c7f63SJim Harris scic_sds_stp_remote_device_ready_substate_table,
307f11c7f63SJim Harris SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE
308f11c7f63SJim Harris );
309f11c7f63SJim Harris }
310f11c7f63SJim Harris
311f11c7f63SJim Harris // For SAS-2 the physical link rate is actually a logical link
312f11c7f63SJim Harris // rate that incorporates multiplexing. The SCU doesn't
313f11c7f63SJim Harris // incorporate multiplexing and for the purposes of the
314f11c7f63SJim Harris // connection the logical link rate is that same as the
315f11c7f63SJim Harris // physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay
316f11c7f63SJim Harris // one another, so this code works for both situations.
317f11c7f63SJim Harris this_device->connection_rate = MIN(
318f11c7f63SJim Harris scic_sds_port_get_max_allowed_speed( this_device->owning_port),
319f11c7f63SJim Harris discover_response->u2.sas1_1.negotiated_physical_link_rate
320f11c7f63SJim Harris );
321f11c7f63SJim Harris
322f11c7f63SJim Harris /// @todo Should I assign the port width by reading all of the phys on the port?
323f11c7f63SJim Harris this_device->device_port_width = 1;
324f11c7f63SJim Harris }
325f11c7f63SJim Harris
326f11c7f63SJim Harris return status;
327f11c7f63SJim Harris }
328f11c7f63SJim Harris
329f11c7f63SJim Harris // ---------------------------------------------------------------------------
330f11c7f63SJim Harris
scic_remote_device_destruct(SCI_REMOTE_DEVICE_HANDLE_T remote_device)331f11c7f63SJim Harris SCI_STATUS scic_remote_device_destruct(
332f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device
333f11c7f63SJim Harris )
334f11c7f63SJim Harris {
335f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
336f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
337f11c7f63SJim Harris
338f11c7f63SJim Harris SCIC_LOG_TRACE((
339f11c7f63SJim Harris sci_base_object_get_logger(this_device),
340f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
341f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
342f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
343f11c7f63SJim Harris "scic_remote_device_destruct(0x%x) enter\n",
344f11c7f63SJim Harris remote_device
345f11c7f63SJim Harris ));
346f11c7f63SJim Harris
347f11c7f63SJim Harris return this_device->state_handlers->parent.destruct_handler(&this_device->parent);
348f11c7f63SJim Harris }
349f11c7f63SJim Harris
350f11c7f63SJim Harris // ---------------------------------------------------------------------------
351f11c7f63SJim Harris
352f11c7f63SJim Harris #if !defined(DISABLE_WIDE_PORTED_TARGETS)
353f11c7f63SJim Harris
scic_remote_device_set_port_width(SCI_REMOTE_DEVICE_HANDLE_T remote_device,U8 new_port_width)354f11c7f63SJim Harris SCI_STATUS scic_remote_device_set_port_width(
355f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
356f11c7f63SJim Harris U8 new_port_width
357f11c7f63SJim Harris )
358f11c7f63SJim Harris {
359f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
360f11c7f63SJim Harris
361f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
362f11c7f63SJim Harris
363f11c7f63SJim Harris SCIC_LOG_TRACE((
364f11c7f63SJim Harris sci_base_object_get_logger(this_device),
365f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
366f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
367f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
368f11c7f63SJim Harris "scic_remote_device_set_port_width(0x%x, 0x%x) enter\n",
369f11c7f63SJim Harris remote_device, new_port_width
370f11c7f63SJim Harris ));
371f11c7f63SJim Harris
372f11c7f63SJim Harris if(new_port_width != 0)
373f11c7f63SJim Harris {
374f11c7f63SJim Harris this_device->device_port_width = new_port_width;
375f11c7f63SJim Harris
376f11c7f63SJim Harris return SCI_SUCCESS;
377f11c7f63SJim Harris }
378f11c7f63SJim Harris else
379f11c7f63SJim Harris return SCI_FAILURE;
380f11c7f63SJim Harris }
381f11c7f63SJim Harris
382f11c7f63SJim Harris // ---------------------------------------------------------------------------
383f11c7f63SJim Harris
scic_remote_device_get_port_width(SCI_REMOTE_DEVICE_HANDLE_T remote_device)384f11c7f63SJim Harris U8 scic_remote_device_get_port_width(
385f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device
386f11c7f63SJim Harris )
387f11c7f63SJim Harris {
388f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
389f11c7f63SJim Harris
390f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
391f11c7f63SJim Harris
392f11c7f63SJim Harris SCIC_LOG_TRACE((
393f11c7f63SJim Harris sci_base_object_get_logger(this_device),
394f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
395f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
396f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
397f11c7f63SJim Harris "scic_remote_device_get_port_width(0x%x) enter\n",
398f11c7f63SJim Harris remote_device
399f11c7f63SJim Harris ));
400f11c7f63SJim Harris
401f11c7f63SJim Harris return (U8)this_device->device_port_width;
402f11c7f63SJim Harris }
403f11c7f63SJim Harris
404f11c7f63SJim Harris #endif // !defined(DISABLE_WIDE_PORTED_TARGETS)
405f11c7f63SJim Harris
406f11c7f63SJim Harris // ---------------------------------------------------------------------------
407f11c7f63SJim Harris
scic_remote_device_start(SCI_REMOTE_DEVICE_HANDLE_T remote_device,U32 timeout)408f11c7f63SJim Harris SCI_STATUS scic_remote_device_start(
409f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
410f11c7f63SJim Harris U32 timeout
411f11c7f63SJim Harris )
412f11c7f63SJim Harris {
413f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
414f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
415f11c7f63SJim Harris
416f11c7f63SJim Harris SCIC_LOG_TRACE((
417f11c7f63SJim Harris sci_base_object_get_logger(this_device),
418f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
419f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
420f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
421f11c7f63SJim Harris "scic_remote_device_start(0x%x, 0x%x) enter\n",
422f11c7f63SJim Harris remote_device, timeout
423f11c7f63SJim Harris ));
424f11c7f63SJim Harris
425f11c7f63SJim Harris return this_device->state_handlers->parent.start_handler(&this_device->parent);
426f11c7f63SJim Harris }
427f11c7f63SJim Harris
428f11c7f63SJim Harris // ---------------------------------------------------------------------------
429f11c7f63SJim Harris
scic_remote_device_stop(SCI_REMOTE_DEVICE_HANDLE_T remote_device,U32 timeout)430f11c7f63SJim Harris SCI_STATUS scic_remote_device_stop(
431f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
432f11c7f63SJim Harris U32 timeout
433f11c7f63SJim Harris )
434f11c7f63SJim Harris {
435f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
436f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
437f11c7f63SJim Harris
438f11c7f63SJim Harris SCIC_LOG_TRACE((
439f11c7f63SJim Harris sci_base_object_get_logger(this_device),
440f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
441f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
442f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
443f11c7f63SJim Harris "scic_remote_device_stop(0x%x, 0x%x) enter\n",
444f11c7f63SJim Harris remote_device, timeout
445f11c7f63SJim Harris ));
446f11c7f63SJim Harris
447f11c7f63SJim Harris return this_device->state_handlers->parent.stop_handler(&this_device->parent);
448f11c7f63SJim Harris }
449f11c7f63SJim Harris
450f11c7f63SJim Harris /**
451f11c7f63SJim Harris * This method invokes the remote device reset handler.
452f11c7f63SJim Harris *
453f11c7f63SJim Harris * @param[in] this_device The remote device for which the reset is being
454f11c7f63SJim Harris * requested.
455f11c7f63SJim Harris *
456f11c7f63SJim Harris * @return SCI_STATUS
457f11c7f63SJim Harris */
scic_remote_device_reset(SCI_REMOTE_DEVICE_HANDLE_T remote_device)458f11c7f63SJim Harris SCI_STATUS scic_remote_device_reset(
459f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device
460f11c7f63SJim Harris )
461f11c7f63SJim Harris {
462f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
463f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
464f11c7f63SJim Harris
465f11c7f63SJim Harris SCIC_LOG_TRACE((
466f11c7f63SJim Harris sci_base_object_get_logger(this_device),
467f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
468f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
469f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
470f11c7f63SJim Harris "scic_remote_device_reset(0x%x) enter\n",
471f11c7f63SJim Harris remote_device
472f11c7f63SJim Harris ));
473f11c7f63SJim Harris
474f11c7f63SJim Harris return this_device->state_handlers->parent.reset_handler(&this_device->parent);
475f11c7f63SJim Harris }
476f11c7f63SJim Harris
477f11c7f63SJim Harris /**
478f11c7f63SJim Harris * This method invokes the remote device reset handler.
479f11c7f63SJim Harris *
480f11c7f63SJim Harris * @param[in] this_device The remote device for which the reset is being
481f11c7f63SJim Harris * requested.
482f11c7f63SJim Harris *
483f11c7f63SJim Harris * @return SCI_STATUS
484f11c7f63SJim Harris */
scic_remote_device_reset_complete(SCI_REMOTE_DEVICE_HANDLE_T remote_device)485f11c7f63SJim Harris SCI_STATUS scic_remote_device_reset_complete(
486f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device
487f11c7f63SJim Harris )
488f11c7f63SJim Harris {
489f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
490f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
491f11c7f63SJim Harris
492f11c7f63SJim Harris SCIC_LOG_TRACE((
493f11c7f63SJim Harris sci_base_object_get_logger(this_device),
494f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
495f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
496f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
497f11c7f63SJim Harris "scic_remote_device_reset_complete(0x%x) enter\n",
498f11c7f63SJim Harris remote_device
499f11c7f63SJim Harris ));
500f11c7f63SJim Harris
501f11c7f63SJim Harris return this_device->state_handlers->parent.reset_complete_handler(&this_device->parent);
502f11c7f63SJim Harris }
503f11c7f63SJim Harris
504f11c7f63SJim Harris /**
505f11c7f63SJim Harris * This method invokes the remote device reset handler.
506f11c7f63SJim Harris *
507f11c7f63SJim Harris * @param[in] this_device The remote device for which the reset is being
508f11c7f63SJim Harris * requested.
509f11c7f63SJim Harris *
510f11c7f63SJim Harris * @return SCI_STATUS
511f11c7f63SJim Harris */
scic_remote_device_get_suggested_reset_timeout(SCI_REMOTE_DEVICE_HANDLE_T remote_device)512f11c7f63SJim Harris U32 scic_remote_device_get_suggested_reset_timeout(
513f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device
514f11c7f63SJim Harris )
515f11c7f63SJim Harris {
516f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
517f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
518f11c7f63SJim Harris
519f11c7f63SJim Harris SCIC_LOG_TRACE((
520f11c7f63SJim Harris sci_base_object_get_logger(this_device),
521f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
522f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
523f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
524f11c7f63SJim Harris "scic_remote_device_get_suggested_reset_timeout(0x%x) enter\n",
525f11c7f63SJim Harris remote_device
526f11c7f63SJim Harris ));
527f11c7f63SJim Harris
528f11c7f63SJim Harris if (this_device->target_protocols.u.bits.attached_stp_target)
529f11c7f63SJim Harris {
530f11c7f63SJim Harris return SCIC_SDS_SIGNATURE_FIS_TIMEOUT;
531f11c7f63SJim Harris }
532f11c7f63SJim Harris
533f11c7f63SJim Harris return SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT;
534f11c7f63SJim Harris }
535f11c7f63SJim Harris
536f11c7f63SJim Harris // ---------------------------------------------------------------------------
537f11c7f63SJim Harris
scic_remote_device_set_max_connection_rate(SCI_REMOTE_DEVICE_HANDLE_T remote_device,SCI_SAS_LINK_RATE connection_rate)538f11c7f63SJim Harris SCI_STATUS scic_remote_device_set_max_connection_rate(
539f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
540f11c7f63SJim Harris SCI_SAS_LINK_RATE connection_rate
541f11c7f63SJim Harris )
542f11c7f63SJim Harris {
543f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
544f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
545f11c7f63SJim Harris
546f11c7f63SJim Harris SCIC_LOG_TRACE((
547f11c7f63SJim Harris sci_base_object_get_logger(this_device),
548f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
549f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
550f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
551f11c7f63SJim Harris "scic_remote_device_set_max_connection_rate(0x%x, 0x%x) enter\n",
552f11c7f63SJim Harris remote_device, connection_rate
553f11c7f63SJim Harris ));
554f11c7f63SJim Harris
555f11c7f63SJim Harris this_device->connection_rate = connection_rate;
556f11c7f63SJim Harris
557f11c7f63SJim Harris return SCI_SUCCESS;
558f11c7f63SJim Harris }
559f11c7f63SJim Harris
560f11c7f63SJim Harris // ---------------------------------------------------------------------------
561f11c7f63SJim Harris
scic_remote_device_get_connection_rate(SCI_REMOTE_DEVICE_HANDLE_T remote_device)562f11c7f63SJim Harris SCI_SAS_LINK_RATE scic_remote_device_get_connection_rate(
563f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device
564f11c7f63SJim Harris )
565f11c7f63SJim Harris {
566f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
567f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
568f11c7f63SJim Harris
569f11c7f63SJim Harris SCIC_LOG_TRACE((
570f11c7f63SJim Harris sci_base_object_get_logger(this_device),
571f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
572f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
573f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
574f11c7f63SJim Harris "scic_remote_device_get_connection_rate(0x%x) enter\n",
575f11c7f63SJim Harris remote_device
576f11c7f63SJim Harris ));
577f11c7f63SJim Harris
578f11c7f63SJim Harris return this_device->connection_rate;
579f11c7f63SJim Harris }
580f11c7f63SJim Harris
581f11c7f63SJim Harris // ---------------------------------------------------------------------------
582f11c7f63SJim Harris
scic_remote_device_get_protocols(SCI_REMOTE_DEVICE_HANDLE_T remote_device,SMP_DISCOVER_RESPONSE_PROTOCOLS_T * protocols)583f11c7f63SJim Harris void scic_remote_device_get_protocols(
584f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
585f11c7f63SJim Harris SMP_DISCOVER_RESPONSE_PROTOCOLS_T * protocols
586f11c7f63SJim Harris )
587f11c7f63SJim Harris {
588f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)
589f11c7f63SJim Harris remote_device;
590f11c7f63SJim Harris
591f11c7f63SJim Harris SCIC_LOG_TRACE((
592f11c7f63SJim Harris sci_base_object_get_logger(this_device),
593f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
594f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
595f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
596f11c7f63SJim Harris "scic_remote_device_get_protocols(0x%x) enter\n",
597f11c7f63SJim Harris remote_device
598f11c7f63SJim Harris ));
599f11c7f63SJim Harris
600f11c7f63SJim Harris protocols->u.all = this_device->target_protocols.u.all;
601f11c7f63SJim Harris }
602f11c7f63SJim Harris
603f11c7f63SJim Harris // ---------------------------------------------------------------------------
604f11c7f63SJim Harris
scic_remote_device_get_sas_address(SCI_REMOTE_DEVICE_HANDLE_T remote_device,SCI_SAS_ADDRESS_T * sas_address)605f11c7f63SJim Harris void scic_remote_device_get_sas_address(
606f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
607f11c7f63SJim Harris SCI_SAS_ADDRESS_T * sas_address
608f11c7f63SJim Harris )
609f11c7f63SJim Harris {
610f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device;
611f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)remote_device;
612f11c7f63SJim Harris
613f11c7f63SJim Harris SCIC_LOG_TRACE((
614f11c7f63SJim Harris sci_base_object_get_logger(this_device),
615f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
616f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET |
617f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET,
618f11c7f63SJim Harris "scic_remote_device_get_sas_address(0x%x, 0x%x) enter\n",
619f11c7f63SJim Harris remote_device, sas_address
620f11c7f63SJim Harris ));
621f11c7f63SJim Harris
622f11c7f63SJim Harris sas_address->low = this_device->device_address.low;
623f11c7f63SJim Harris sas_address->high = this_device->device_address.high;
624f11c7f63SJim Harris }
625f11c7f63SJim Harris
626f11c7f63SJim Harris // ---------------------------------------------------------------------------
627f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
scic_remote_device_is_atapi(SCI_REMOTE_DEVICE_HANDLE_T device_handle)628f11c7f63SJim Harris BOOL scic_remote_device_is_atapi(
629f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T device_handle
630f11c7f63SJim Harris )
631f11c7f63SJim Harris {
632f11c7f63SJim Harris return ((SCIC_SDS_REMOTE_DEVICE_T *)device_handle)->is_atapi;
633f11c7f63SJim Harris }
634f11c7f63SJim Harris #endif
635f11c7f63SJim Harris
636f11c7f63SJim Harris
637f11c7f63SJim Harris //*****************************************************************************
638f11c7f63SJim Harris //* SCU DRIVER STANDARD (SDS) REMOTE DEVICE IMPLEMENTATIONS
639f11c7f63SJim Harris //*****************************************************************************
640f11c7f63SJim Harris
641f11c7f63SJim Harris /**
642f11c7f63SJim Harris * Remote device timer requirements
643f11c7f63SJim Harris */
644f11c7f63SJim Harris #define SCIC_SDS_REMOTE_DEVICE_MINIMUM_TIMER_COUNT (0)
645f11c7f63SJim Harris #define SCIC_SDS_REMOTE_DEVICE_MAXIMUM_TIMER_COUNT (SCI_MAX_REMOTE_DEVICES)
646f11c7f63SJim Harris
647f11c7f63SJim Harris /**
648f11c7f63SJim Harris * @brief This method returns the minimum number of timers required for all
649f11c7f63SJim Harris * remote devices.
650f11c7f63SJim Harris *
651f11c7f63SJim Harris * @return U32
652f11c7f63SJim Harris */
scic_sds_remote_device_get_min_timer_count(void)653f11c7f63SJim Harris U32 scic_sds_remote_device_get_min_timer_count(void)
654f11c7f63SJim Harris {
655f11c7f63SJim Harris return SCIC_SDS_REMOTE_DEVICE_MINIMUM_TIMER_COUNT;
656f11c7f63SJim Harris }
657f11c7f63SJim Harris
658f11c7f63SJim Harris /**
659f11c7f63SJim Harris * @brief This method returns the maximum number of timers requried for all
660f11c7f63SJim Harris * remote devices.
661f11c7f63SJim Harris *
662f11c7f63SJim Harris * @return U32
663f11c7f63SJim Harris */
scic_sds_remote_device_get_max_timer_count(void)664f11c7f63SJim Harris U32 scic_sds_remote_device_get_max_timer_count(void)
665f11c7f63SJim Harris {
666f11c7f63SJim Harris return SCIC_SDS_REMOTE_DEVICE_MAXIMUM_TIMER_COUNT;
667f11c7f63SJim Harris }
668f11c7f63SJim Harris
669f11c7f63SJim Harris // ---------------------------------------------------------------------------
670f11c7f63SJim Harris
671f11c7f63SJim Harris #ifdef SCI_LOGGING
672f11c7f63SJim Harris /**
673f11c7f63SJim Harris * This method will enable and turn on state transition logging for the remote
674f11c7f63SJim Harris * device object.
675f11c7f63SJim Harris *
676f11c7f63SJim Harris * @param[in] this_device The device for which state transition logging is to
677f11c7f63SJim Harris * be enabled.
678f11c7f63SJim Harris *
679f11c7f63SJim Harris * @return Nothing
680f11c7f63SJim Harris */
scic_sds_remote_device_initialize_state_logging(SCIC_SDS_REMOTE_DEVICE_T * this_device)681f11c7f63SJim Harris void scic_sds_remote_device_initialize_state_logging(
682f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device
683f11c7f63SJim Harris )
684f11c7f63SJim Harris {
685f11c7f63SJim Harris sci_base_state_machine_logger_initialize(
686f11c7f63SJim Harris &this_device->parent.state_machine_logger,
687f11c7f63SJim Harris &this_device->parent.state_machine,
688f11c7f63SJim Harris &this_device->parent.parent,
689f11c7f63SJim Harris scic_cb_logger_log_states,
690f11c7f63SJim Harris "SCIC_SDS_REMOTE_DEVICE_T", "base state machine",
691f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
692f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
693f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET
694f11c7f63SJim Harris );
695f11c7f63SJim Harris
696f11c7f63SJim Harris if (this_device->has_ready_substate_machine)
697f11c7f63SJim Harris {
698f11c7f63SJim Harris sci_base_state_machine_logger_initialize(
699f11c7f63SJim Harris &this_device->ready_substate_machine_logger,
700f11c7f63SJim Harris &this_device->ready_substate_machine,
701f11c7f63SJim Harris &this_device->parent.parent,
702f11c7f63SJim Harris scic_cb_logger_log_states,
703f11c7f63SJim Harris "SCIC_SDS_REMOTE_DEVICE_T", "ready substate machine",
704f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
705f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
706f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET
707f11c7f63SJim Harris );
708f11c7f63SJim Harris }
709f11c7f63SJim Harris }
710f11c7f63SJim Harris
711f11c7f63SJim Harris /**
712f11c7f63SJim Harris * This method will stop the state machine logging for this object and should
713f11c7f63SJim Harris * be called before the object is destroyed.
714f11c7f63SJim Harris *
715f11c7f63SJim Harris * @param[in] this_device The device on which to stop logging state
716f11c7f63SJim Harris * transitions.
717f11c7f63SJim Harris *
718f11c7f63SJim Harris * @return Nothing
719f11c7f63SJim Harris */
scic_sds_remote_device_deinitialize_state_logging(SCIC_SDS_REMOTE_DEVICE_T * this_device)720f11c7f63SJim Harris void scic_sds_remote_device_deinitialize_state_logging(
721f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device
722f11c7f63SJim Harris )
723f11c7f63SJim Harris {
724f11c7f63SJim Harris sci_base_state_machine_logger_deinitialize(
725f11c7f63SJim Harris &this_device->parent.state_machine_logger,
726f11c7f63SJim Harris &this_device->parent.state_machine
727f11c7f63SJim Harris );
728f11c7f63SJim Harris
729f11c7f63SJim Harris if (this_device->has_ready_substate_machine)
730f11c7f63SJim Harris {
731f11c7f63SJim Harris sci_base_state_machine_logger_deinitialize(
732f11c7f63SJim Harris &this_device->ready_substate_machine_logger,
733f11c7f63SJim Harris &this_device->ready_substate_machine
734f11c7f63SJim Harris );
735f11c7f63SJim Harris }
736f11c7f63SJim Harris }
737f11c7f63SJim Harris #endif
738f11c7f63SJim Harris
739f11c7f63SJim Harris /**
740f11c7f63SJim Harris * This method invokes the remote device suspend state handler.
741f11c7f63SJim Harris *
742f11c7f63SJim Harris * @param[in] this_device The remote device for which the suspend is being
743f11c7f63SJim Harris * requested.
744f11c7f63SJim Harris *
745f11c7f63SJim Harris * @return SCI_STATUS
746f11c7f63SJim Harris */
scic_sds_remote_device_suspend(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 suspend_type)747f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_suspend(
748f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
749f11c7f63SJim Harris U32 suspend_type
750f11c7f63SJim Harris )
751f11c7f63SJim Harris {
752f11c7f63SJim Harris return this_device->state_handlers->suspend_handler(this_device, suspend_type);
753f11c7f63SJim Harris }
754f11c7f63SJim Harris
755f11c7f63SJim Harris /**
756f11c7f63SJim Harris * This method invokes the remote device resume state handler.
757f11c7f63SJim Harris *
758f11c7f63SJim Harris * @param[in] this_device The remote device for which the resume is being
759f11c7f63SJim Harris * requested.
760f11c7f63SJim Harris *
761f11c7f63SJim Harris * @return SCI_STATUS
762f11c7f63SJim Harris */
scic_sds_remote_device_resume(SCIC_SDS_REMOTE_DEVICE_T * this_device)763f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_resume(
764f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device
765f11c7f63SJim Harris )
766f11c7f63SJim Harris {
767f11c7f63SJim Harris return this_device->state_handlers->resume_handler(this_device);
768f11c7f63SJim Harris }
769f11c7f63SJim Harris
770f11c7f63SJim Harris /**
771f11c7f63SJim Harris * This method invokes the frame handler for the remote device state machine
772f11c7f63SJim Harris *
773f11c7f63SJim Harris * @param[in] this_device The remote device for which the event handling is
774f11c7f63SJim Harris * being requested.
775f11c7f63SJim Harris * @param[in] frame_index This is the frame index that is being processed.
776f11c7f63SJim Harris *
777f11c7f63SJim Harris * @return SCI_STATUS
778f11c7f63SJim Harris */
scic_sds_remote_device_frame_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 frame_index)779f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_frame_handler(
780f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
781f11c7f63SJim Harris U32 frame_index
782f11c7f63SJim Harris )
783f11c7f63SJim Harris {
784f11c7f63SJim Harris return this_device->state_handlers->frame_handler(this_device, frame_index);
785f11c7f63SJim Harris }
786f11c7f63SJim Harris
787f11c7f63SJim Harris /**
788f11c7f63SJim Harris * This method invokes the remote device event handler.
789f11c7f63SJim Harris *
790f11c7f63SJim Harris * @param[in] this_device The remote device for which the event handling is
791f11c7f63SJim Harris * being requested.
792f11c7f63SJim Harris * @param[in] event_code This is the event code that is to be processed.
793f11c7f63SJim Harris *
794f11c7f63SJim Harris * @return SCI_STATUS
795f11c7f63SJim Harris */
scic_sds_remote_device_event_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 event_code)796f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_event_handler(
797f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
798f11c7f63SJim Harris U32 event_code
799f11c7f63SJim Harris )
800f11c7f63SJim Harris {
801f11c7f63SJim Harris return this_device->state_handlers->event_handler(this_device, event_code);
802f11c7f63SJim Harris }
803f11c7f63SJim Harris
804f11c7f63SJim Harris /**
805f11c7f63SJim Harris * This method invokes the remote device start io handler.
806f11c7f63SJim Harris *
807f11c7f63SJim Harris * @param[in] controller The controller that is starting the io request.
808f11c7f63SJim Harris * @param[in] this_device The remote device for which the start io handling is
809f11c7f63SJim Harris * being requested.
810f11c7f63SJim Harris * @param[in] io_request The io request that is being started.
811f11c7f63SJim Harris *
812f11c7f63SJim Harris * @return SCI_STATUS
813f11c7f63SJim Harris */
scic_sds_remote_device_start_io(SCIC_SDS_CONTROLLER_T * controller,SCIC_SDS_REMOTE_DEVICE_T * this_device,SCIC_SDS_REQUEST_T * io_request)814f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_start_io(
815f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T *controller,
816f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
817f11c7f63SJim Harris SCIC_SDS_REQUEST_T *io_request
818f11c7f63SJim Harris )
819f11c7f63SJim Harris {
820f11c7f63SJim Harris return this_device->state_handlers->parent.start_io_handler(
821f11c7f63SJim Harris &this_device->parent, &io_request->parent);
822f11c7f63SJim Harris }
823f11c7f63SJim Harris
824f11c7f63SJim Harris /**
825f11c7f63SJim Harris * This method invokes the remote device complete io handler.
826f11c7f63SJim Harris *
827f11c7f63SJim Harris * @param[in] controller The controller that is completing the io request.
828f11c7f63SJim Harris * @param[in] this_device The remote device for which the complete io handling
829f11c7f63SJim Harris * is being requested.
830f11c7f63SJim Harris * @param[in] io_request The io request that is being completed.
831f11c7f63SJim Harris *
832f11c7f63SJim Harris * @return SCI_STATUS
833f11c7f63SJim Harris */
scic_sds_remote_device_complete_io(SCIC_SDS_CONTROLLER_T * controller,SCIC_SDS_REMOTE_DEVICE_T * this_device,SCIC_SDS_REQUEST_T * io_request)834f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_complete_io(
835f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T *controller,
836f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
837f11c7f63SJim Harris SCIC_SDS_REQUEST_T *io_request
838f11c7f63SJim Harris )
839f11c7f63SJim Harris {
840f11c7f63SJim Harris return this_device->state_handlers->parent.complete_io_handler(
841f11c7f63SJim Harris &this_device->parent, &io_request->parent);
842f11c7f63SJim Harris }
843f11c7f63SJim Harris
844f11c7f63SJim Harris /**
845f11c7f63SJim Harris * This method invokes the remote device start task handler.
846f11c7f63SJim Harris *
847f11c7f63SJim Harris * @param[in] controller The controller that is starting the task request.
848f11c7f63SJim Harris * @param[in] this_device The remote device for which the start task handling
849f11c7f63SJim Harris * is being requested.
850f11c7f63SJim Harris * @param[in] io_request The task request that is being started.
851f11c7f63SJim Harris *
852f11c7f63SJim Harris * @return SCI_STATUS
853f11c7f63SJim Harris */
scic_sds_remote_device_start_task(SCIC_SDS_CONTROLLER_T * controller,SCIC_SDS_REMOTE_DEVICE_T * this_device,SCIC_SDS_REQUEST_T * io_request)854f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_start_task(
855f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T *controller,
856f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
857f11c7f63SJim Harris SCIC_SDS_REQUEST_T *io_request
858f11c7f63SJim Harris )
859f11c7f63SJim Harris {
860f11c7f63SJim Harris return this_device->state_handlers->parent.start_task_handler(
861f11c7f63SJim Harris &this_device->parent, &io_request->parent);
862f11c7f63SJim Harris }
863f11c7f63SJim Harris
864f11c7f63SJim Harris /**
865f11c7f63SJim Harris * This method takes the request and bulids an appropriate SCU context for the
866f11c7f63SJim Harris * request and then requests the controller to post the request.
867f11c7f63SJim Harris *
868f11c7f63SJim Harris * @param[in] this_device
869f11c7f63SJim Harris * @param[in] request
870f11c7f63SJim Harris *
871f11c7f63SJim Harris * @return none
872f11c7f63SJim Harris */
scic_sds_remote_device_post_request(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 request)873f11c7f63SJim Harris void scic_sds_remote_device_post_request(
874f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device,
875f11c7f63SJim Harris U32 request
876f11c7f63SJim Harris )
877f11c7f63SJim Harris {
878f11c7f63SJim Harris U32 context;
879f11c7f63SJim Harris
880f11c7f63SJim Harris context = scic_sds_remote_device_build_command_context(this_device, request);
881f11c7f63SJim Harris
882f11c7f63SJim Harris scic_sds_controller_post_request(
883f11c7f63SJim Harris scic_sds_remote_device_get_controller(this_device),
884f11c7f63SJim Harris context
885f11c7f63SJim Harris );
886f11c7f63SJim Harris }
887f11c7f63SJim Harris
888f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
889f11c7f63SJim Harris /**
890f11c7f63SJim Harris * This method check the signature fis of a stp device to decide whether
891f11c7f63SJim Harris * a device is atapi or not.
892f11c7f63SJim Harris *
893f11c7f63SJim Harris * @param[in] this_device The device to be checked.
894f11c7f63SJim Harris *
895f11c7f63SJim Harris * @return TRUE if a device is atapi device. False if a device is not atapi.
896f11c7f63SJim Harris */
scic_sds_remote_device_is_atapi(SCIC_SDS_REMOTE_DEVICE_T * this_device)897f11c7f63SJim Harris BOOL scic_sds_remote_device_is_atapi(
898f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device
899f11c7f63SJim Harris )
900f11c7f63SJim Harris {
901f11c7f63SJim Harris if (!this_device->target_protocols.u.bits.attached_stp_target)
902f11c7f63SJim Harris return FALSE;
903f11c7f63SJim Harris else if (this_device->is_direct_attached)
904f11c7f63SJim Harris {
905f11c7f63SJim Harris SCIC_SDS_PHY_T * phy;
906f11c7f63SJim Harris SCIC_SATA_PHY_PROPERTIES_T properties;
907f11c7f63SJim Harris SATA_FIS_REG_D2H_T * signature_fis;
908f11c7f63SJim Harris phy = scic_sds_port_get_a_connected_phy(this_device->owning_port);
909f11c7f63SJim Harris scic_sata_phy_get_properties(phy, &properties);
910f11c7f63SJim Harris
911f11c7f63SJim Harris //decode the signature fis.
912f11c7f63SJim Harris signature_fis = &(properties.signature_fis);
913f11c7f63SJim Harris
914f11c7f63SJim Harris if ( (signature_fis->sector_count == 0x01)
915f11c7f63SJim Harris && (signature_fis->lba_low == 0x01)
916f11c7f63SJim Harris && (signature_fis->lba_mid == 0x14)
917f11c7f63SJim Harris && (signature_fis->lba_high == 0xEB)
918f11c7f63SJim Harris && ( (signature_fis->device & 0x5F) == 0x00)
919f11c7f63SJim Harris )
920f11c7f63SJim Harris {
921f11c7f63SJim Harris // An ATA device supporting the PACKET command set.
922f11c7f63SJim Harris return TRUE;
923f11c7f63SJim Harris }
924f11c7f63SJim Harris else
925f11c7f63SJim Harris return FALSE;
926f11c7f63SJim Harris }
927f11c7f63SJim Harris else
928f11c7f63SJim Harris {
929f11c7f63SJim Harris //Expander supported ATAPI device is not currently supported.
930f11c7f63SJim Harris return FALSE;
931f11c7f63SJim Harris }
932f11c7f63SJim Harris }
933f11c7f63SJim Harris
934f11c7f63SJim Harris #endif // !defined(DISABLE_ATAPI)
935f11c7f63SJim Harris
936f11c7f63SJim Harris //******************************************************************************
937f11c7f63SJim Harris //* REMOTE DEVICE STATE MACHINE
938f11c7f63SJim Harris //******************************************************************************
939f11c7f63SJim Harris
940f11c7f63SJim Harris /**
941f11c7f63SJim Harris * This method is called once the remote node context is ready to be
942f11c7f63SJim Harris * freed. The remote device can now report that its stop operation is
943f11c7f63SJim Harris * complete.
944f11c7f63SJim Harris *
945f11c7f63SJim Harris * @param[in] user_parameter This is cast to a remote device object.
946f11c7f63SJim Harris *
947f11c7f63SJim Harris * @return none
948f11c7f63SJim Harris */
949f11c7f63SJim Harris static
scic_sds_cb_remote_device_rnc_destruct_complete(void * user_parameter)950f11c7f63SJim Harris void scic_sds_cb_remote_device_rnc_destruct_complete(
951f11c7f63SJim Harris void * user_parameter
952f11c7f63SJim Harris )
953f11c7f63SJim Harris {
954f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device;
955f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)user_parameter;
956f11c7f63SJim Harris
957f11c7f63SJim Harris ASSERT(this_device->started_request_count == 0);
958f11c7f63SJim Harris
959f11c7f63SJim Harris sci_base_state_machine_change_state(
960f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device),
961f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
962f11c7f63SJim Harris );
963f11c7f63SJim Harris }
964f11c7f63SJim Harris
965f11c7f63SJim Harris /**
966f11c7f63SJim Harris * This method is called once the remote node context has transisitioned to a
967f11c7f63SJim Harris * ready state. This is the indication that the remote device object can also
968f11c7f63SJim Harris * transition to ready.
969f11c7f63SJim Harris *
970f11c7f63SJim Harris * @param[in] user_parameter This is cast to a remote device object.
971f11c7f63SJim Harris *
972f11c7f63SJim Harris * @return none
973f11c7f63SJim Harris */
974f11c7f63SJim Harris static
scic_sds_remote_device_resume_complete_handler(void * user_parameter)975f11c7f63SJim Harris void scic_sds_remote_device_resume_complete_handler(
976f11c7f63SJim Harris void * user_parameter
977f11c7f63SJim Harris )
978f11c7f63SJim Harris {
979f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device;
980f11c7f63SJim Harris this_device = (SCIC_SDS_REMOTE_DEVICE_T *)user_parameter;
981f11c7f63SJim Harris
982f11c7f63SJim Harris if (
983f11c7f63SJim Harris sci_base_state_machine_get_state(&this_device->parent.state_machine)
984f11c7f63SJim Harris != SCI_BASE_REMOTE_DEVICE_STATE_READY
985f11c7f63SJim Harris )
986f11c7f63SJim Harris {
987f11c7f63SJim Harris sci_base_state_machine_change_state(
988f11c7f63SJim Harris &this_device->parent.state_machine,
989f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_READY
990f11c7f63SJim Harris );
991f11c7f63SJim Harris }
992f11c7f63SJim Harris }
993f11c7f63SJim Harris
994f11c7f63SJim Harris /**
995f11c7f63SJim Harris * This method will perform the STP request start processing common
996f11c7f63SJim Harris * to IO requests and task requests of all types.
997f11c7f63SJim Harris *
998f11c7f63SJim Harris * @param[in] device This parameter specifies the device for which the
999f11c7f63SJim Harris * request is being started.
1000f11c7f63SJim Harris * @param[in] request This parameter specifies the request being started.
1001f11c7f63SJim Harris * @param[in] status This parameter specifies the current start operation
1002f11c7f63SJim Harris * status.
1003f11c7f63SJim Harris *
1004f11c7f63SJim Harris * @return none
1005f11c7f63SJim Harris */
scic_sds_remote_device_start_request(SCIC_SDS_REMOTE_DEVICE_T * this_device,SCIC_SDS_REQUEST_T * the_request,SCI_STATUS status)1006f11c7f63SJim Harris void scic_sds_remote_device_start_request(
1007f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device,
1008f11c7f63SJim Harris SCIC_SDS_REQUEST_T * the_request,
1009f11c7f63SJim Harris SCI_STATUS status
1010f11c7f63SJim Harris )
1011f11c7f63SJim Harris {
1012f11c7f63SJim Harris // We still have a fault in starting the io complete it on the port
1013f11c7f63SJim Harris if (status == SCI_SUCCESS)
1014f11c7f63SJim Harris scic_sds_remote_device_increment_request_count(this_device);
1015f11c7f63SJim Harris else
1016f11c7f63SJim Harris {
1017f11c7f63SJim Harris this_device->owning_port->state_handlers->complete_io_handler(
1018f11c7f63SJim Harris this_device->owning_port, this_device, the_request
1019f11c7f63SJim Harris );
1020f11c7f63SJim Harris }
1021f11c7f63SJim Harris }
1022f11c7f63SJim Harris
1023f11c7f63SJim Harris
1024f11c7f63SJim Harris /**
1025f11c7f63SJim Harris * This method will continue to post tc for a STP request. This method usually
1026f11c7f63SJim Harris * serves as a callback when RNC gets resumed during a task management sequence.
1027f11c7f63SJim Harris *
1028f11c7f63SJim Harris * @param[in] request This parameter specifies the request being continued.
1029f11c7f63SJim Harris *
1030f11c7f63SJim Harris * @return none
1031f11c7f63SJim Harris */
scic_sds_remote_device_continue_request(SCIC_SDS_REMOTE_DEVICE_T * this_device)1032f11c7f63SJim Harris void scic_sds_remote_device_continue_request(
1033f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device
1034f11c7f63SJim Harris )
1035f11c7f63SJim Harris {
1036f11c7f63SJim Harris // we need to check if this request is still valid to continue.
1037f11c7f63SJim Harris if (this_device->working_request != NULL)
1038f11c7f63SJim Harris {
1039f11c7f63SJim Harris SCIC_SDS_REQUEST_T * this_request = this_device->working_request;
1040f11c7f63SJim Harris
1041f11c7f63SJim Harris this_request->owning_controller->state_handlers->parent.continue_io_handler(
1042f11c7f63SJim Harris &this_request->owning_controller->parent,
1043f11c7f63SJim Harris &this_request->target_device->parent,
1044f11c7f63SJim Harris &this_request->parent
1045f11c7f63SJim Harris );
1046f11c7f63SJim Harris }
1047f11c7f63SJim Harris }
1048f11c7f63SJim Harris
1049f11c7f63SJim Harris /**
1050f11c7f63SJim Harris * @brief This method will terminate all of the IO requests in the
1051f11c7f63SJim Harris * controllers IO request table that were targeted for this
1052f11c7f63SJim Harris * device.
1053f11c7f63SJim Harris *
1054f11c7f63SJim Harris * @param[in] this_device This parameter specifies the remote device
1055f11c7f63SJim Harris * for which to attempt to terminate all requests.
1056f11c7f63SJim Harris *
1057f11c7f63SJim Harris * @return This method returns an indication as to whether all requests
1058f11c7f63SJim Harris * were successfully terminated. If a single request fails to
1059f11c7f63SJim Harris * be terminated, then this method will return the failure.
1060f11c7f63SJim Harris */
1061f11c7f63SJim Harris static
scic_sds_remote_device_terminate_requests(SCIC_SDS_REMOTE_DEVICE_T * this_device)1062f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_terminate_requests(
1063f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device
1064f11c7f63SJim Harris )
1065f11c7f63SJim Harris {
1066f11c7f63SJim Harris return scic_sds_terminate_reqests(
1067f11c7f63SJim Harris this_device->owning_port->owning_controller,
1068f11c7f63SJim Harris this_device,
1069f11c7f63SJim Harris NULL);
1070f11c7f63SJim Harris }
1071f11c7f63SJim Harris
1072f11c7f63SJim Harris //*****************************************************************************
1073f11c7f63SJim Harris //* DEFAULT STATE HANDLERS
1074f11c7f63SJim Harris //*****************************************************************************
1075f11c7f63SJim Harris
1076f11c7f63SJim Harris /**
1077f11c7f63SJim Harris * This method is the default start handler. It logs a warning and returns a
1078f11c7f63SJim Harris * failure.
1079f11c7f63SJim Harris *
1080f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1081f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1082f11c7f63SJim Harris *
1083f11c7f63SJim Harris * @return SCI_STATUS
1084f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1085f11c7f63SJim Harris */
scic_sds_remote_device_default_start_handler(SCI_BASE_REMOTE_DEVICE_T * device)1086f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_start_handler(
1087f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1088f11c7f63SJim Harris )
1089f11c7f63SJim Harris {
1090f11c7f63SJim Harris SCIC_LOG_WARNING((
1091f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1092f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1093f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1094f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1095f11c7f63SJim Harris "SCIC Remote Device requested to start while in wrong state %d\n",
1096f11c7f63SJim Harris sci_base_state_machine_get_state(
1097f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1098f11c7f63SJim Harris ));
1099f11c7f63SJim Harris
1100f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1101f11c7f63SJim Harris }
1102f11c7f63SJim Harris
1103f11c7f63SJim Harris /**
1104f11c7f63SJim Harris * This method is the default stop handler. It logs a warning and returns a
1105f11c7f63SJim Harris * failure.
1106f11c7f63SJim Harris *
1107f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1108f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1109f11c7f63SJim Harris *
1110f11c7f63SJim Harris * @return SCI_STATUS
1111f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1112f11c7f63SJim Harris */
scic_sds_remote_device_default_stop_handler(SCI_BASE_REMOTE_DEVICE_T * device)1113f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_stop_handler(
1114f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1115f11c7f63SJim Harris )
1116f11c7f63SJim Harris {
1117f11c7f63SJim Harris SCIC_LOG_WARNING((
1118f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1119f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1120f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1121f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1122f11c7f63SJim Harris "SCIC Remote Device requested to stop while in wrong state %d\n",
1123f11c7f63SJim Harris sci_base_state_machine_get_state(
1124f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1125f11c7f63SJim Harris ));
1126f11c7f63SJim Harris
1127f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1128f11c7f63SJim Harris }
1129f11c7f63SJim Harris
1130f11c7f63SJim Harris /**
1131f11c7f63SJim Harris * This method is the default fail handler. It logs a warning and returns a
1132f11c7f63SJim Harris * failure.
1133f11c7f63SJim Harris *
1134f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1135f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1136f11c7f63SJim Harris *
1137f11c7f63SJim Harris * @return SCI_STATUS
1138f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1139f11c7f63SJim Harris */
scic_sds_remote_device_default_fail_handler(SCI_BASE_REMOTE_DEVICE_T * device)1140f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_fail_handler(
1141f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1142f11c7f63SJim Harris )
1143f11c7f63SJim Harris {
1144f11c7f63SJim Harris SCIC_LOG_WARNING((
1145f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1146f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1147f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1148f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1149f11c7f63SJim Harris "SCIC Remote Device requested to fail while in wrong state %d\n",
1150f11c7f63SJim Harris sci_base_state_machine_get_state(
1151f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1152f11c7f63SJim Harris ));
1153f11c7f63SJim Harris
1154f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1155f11c7f63SJim Harris }
1156f11c7f63SJim Harris
1157f11c7f63SJim Harris /**
1158f11c7f63SJim Harris * This method is the default destruct handler. It logs a warning and returns
1159f11c7f63SJim Harris * a failure.
1160f11c7f63SJim Harris *
1161f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1162f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1163f11c7f63SJim Harris *
1164f11c7f63SJim Harris * @return SCI_STATUS
1165f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1166f11c7f63SJim Harris */
scic_sds_remote_device_default_destruct_handler(SCI_BASE_REMOTE_DEVICE_T * device)1167f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_destruct_handler(
1168f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1169f11c7f63SJim Harris )
1170f11c7f63SJim Harris {
1171f11c7f63SJim Harris SCIC_LOG_WARNING((
1172f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1173f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1174f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1175f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1176f11c7f63SJim Harris "SCIC Remote Device requested to destroy while in wrong state %d\n",
1177f11c7f63SJim Harris sci_base_state_machine_get_state(
1178f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1179f11c7f63SJim Harris ));
1180f11c7f63SJim Harris
1181f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1182f11c7f63SJim Harris }
1183f11c7f63SJim Harris
1184f11c7f63SJim Harris /**
1185f11c7f63SJim Harris * This method is the default reset handler. It logs a warning and returns a
1186f11c7f63SJim Harris * failure.
1187f11c7f63SJim Harris *
1188f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1189f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1190f11c7f63SJim Harris *
1191f11c7f63SJim Harris * @return SCI_STATUS
1192f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1193f11c7f63SJim Harris */
scic_sds_remote_device_default_reset_handler(SCI_BASE_REMOTE_DEVICE_T * device)1194f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_reset_handler(
1195f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1196f11c7f63SJim Harris )
1197f11c7f63SJim Harris {
1198f11c7f63SJim Harris SCIC_LOG_WARNING((
1199f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1200f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1201f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1202f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1203f11c7f63SJim Harris "SCIC Remote Device requested to reset while in wrong state %d\n",
1204f11c7f63SJim Harris sci_base_state_machine_get_state(
1205f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1206f11c7f63SJim Harris ));
1207f11c7f63SJim Harris
1208f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1209f11c7f63SJim Harris }
1210f11c7f63SJim Harris
1211f11c7f63SJim Harris /**
1212f11c7f63SJim Harris * This method is the default reset complete handler. It logs a warning and
1213f11c7f63SJim Harris * returns a failure.
1214f11c7f63SJim Harris *
1215f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1216f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1217f11c7f63SJim Harris *
1218f11c7f63SJim Harris * @return SCI_STATUS
1219f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1220f11c7f63SJim Harris */
scic_sds_remote_device_default_reset_complete_handler(SCI_BASE_REMOTE_DEVICE_T * device)1221f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_reset_complete_handler(
1222f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1223f11c7f63SJim Harris )
1224f11c7f63SJim Harris {
1225f11c7f63SJim Harris SCIC_LOG_WARNING((
1226f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1227f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1228f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1229f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1230f11c7f63SJim Harris "SCIC Remote Device requested to complete reset while in wrong state %d\n",
1231f11c7f63SJim Harris sci_base_state_machine_get_state(
1232f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1233f11c7f63SJim Harris ));
1234f11c7f63SJim Harris
1235f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1236f11c7f63SJim Harris }
1237f11c7f63SJim Harris
1238f11c7f63SJim Harris /**
1239f11c7f63SJim Harris * This method is the default suspend handler. It logs a warning and returns
1240f11c7f63SJim Harris * a failure.
1241f11c7f63SJim Harris *
1242f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1243f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1244f11c7f63SJim Harris *
1245f11c7f63SJim Harris * @return SCI_STATUS
1246f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1247f11c7f63SJim Harris */
scic_sds_remote_device_default_suspend_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 suspend_type)1248f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_suspend_handler(
1249f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
1250f11c7f63SJim Harris U32 suspend_type
1251f11c7f63SJim Harris )
1252f11c7f63SJim Harris {
1253f11c7f63SJim Harris SCIC_LOG_WARNING((
1254f11c7f63SJim Harris sci_base_object_get_logger(this_device),
1255f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1256f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1257f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1258f11c7f63SJim Harris "SCIC Remote Device 0x%x requested to suspend %d while in wrong state %d\n",
1259f11c7f63SJim Harris this_device, suspend_type,
1260f11c7f63SJim Harris sci_base_state_machine_get_state(
1261f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device))
1262f11c7f63SJim Harris ));
1263f11c7f63SJim Harris
1264f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1265f11c7f63SJim Harris }
1266f11c7f63SJim Harris
1267f11c7f63SJim Harris /**
1268f11c7f63SJim Harris * This method is the default resume handler. It logs a warning and returns a
1269f11c7f63SJim Harris * failure.
1270f11c7f63SJim Harris *
1271f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1272f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1273f11c7f63SJim Harris *
1274f11c7f63SJim Harris * @return SCI_STATUS
1275f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1276f11c7f63SJim Harris */
scic_sds_remote_device_default_resume_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device)1277f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_resume_handler(
1278f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device
1279f11c7f63SJim Harris )
1280f11c7f63SJim Harris {
1281f11c7f63SJim Harris SCIC_LOG_WARNING((
1282f11c7f63SJim Harris sci_base_object_get_logger(this_device),
1283f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1284f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1285f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1286f11c7f63SJim Harris "SCIC Remote Device requested to resume while in wrong state %d\n",
1287f11c7f63SJim Harris sci_base_state_machine_get_state(
1288f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device))
1289f11c7f63SJim Harris ));
1290f11c7f63SJim Harris
1291f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1292f11c7f63SJim Harris }
1293f11c7f63SJim Harris
1294f11c7f63SJim Harris #if defined(SCI_LOGGING)
1295f11c7f63SJim Harris /**
1296f11c7f63SJim Harris * This is a private method for emitting log messages related to events reported
1297f11c7f63SJim Harris * to the remote device from the controller object.
1298f11c7f63SJim Harris *
1299f11c7f63SJim Harris * @param [in] this_device This is the device object that is receiving the
1300f11c7f63SJim Harris * event.
1301f11c7f63SJim Harris * @param [in] event_code The event code to process.
1302f11c7f63SJim Harris *
1303f11c7f63SJim Harris * @return None
1304f11c7f63SJim Harris */
scic_sds_emit_event_log_message(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 event_code,char * message_guts,BOOL ready_state)1305f11c7f63SJim Harris static void scic_sds_emit_event_log_message(
1306f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device,
1307f11c7f63SJim Harris U32 event_code,
1308f11c7f63SJim Harris char * message_guts,
1309f11c7f63SJim Harris BOOL ready_state
1310f11c7f63SJim Harris )
1311f11c7f63SJim Harris {
1312f11c7f63SJim Harris SCIC_LOG_WARNING((
1313f11c7f63SJim Harris sci_base_object_get_logger(this_device),
1314f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1315f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1316f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1317f11c7f63SJim Harris "SCIC Remote device 0x%x (state %d) received %s %x while in the %sready %s%d\n",
1318f11c7f63SJim Harris this_device,
1319f11c7f63SJim Harris sci_base_state_machine_get_state(
1320f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device)),
1321f11c7f63SJim Harris message_guts, event_code,
1322f11c7f63SJim Harris (ready_state)
1323f11c7f63SJim Harris ? ""
1324f11c7f63SJim Harris : "not ",
1325f11c7f63SJim Harris (this_device->has_ready_substate_machine)
1326f11c7f63SJim Harris ? "substate "
1327f11c7f63SJim Harris : "",
1328f11c7f63SJim Harris (this_device->has_ready_substate_machine)
1329f11c7f63SJim Harris ? sci_base_state_machine_get_state(&this_device->ready_substate_machine)
1330f11c7f63SJim Harris : 0
1331f11c7f63SJim Harris ));
1332f11c7f63SJim Harris }
1333f11c7f63SJim Harris #else // defined(SCI_LOGGING)
1334f11c7f63SJim Harris #define scic_sds_emit_event_log_message(device, event_code, message, state)
1335f11c7f63SJim Harris #endif // defined(SCI_LOGGING)
1336f11c7f63SJim Harris
1337f11c7f63SJim Harris /**
1338f11c7f63SJim Harris * This method is the default event handler. It will call the RNC state
1339f11c7f63SJim Harris * machine handler for any RNC events otherwise it will log a warning and
1340f11c7f63SJim Harris * returns a failure.
1341f11c7f63SJim Harris *
1342f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1343f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1344f11c7f63SJim Harris * @param[in] event_code The event code that the SCIC_SDS_CONTROLLER wants the
1345f11c7f63SJim Harris * device object to process.
1346f11c7f63SJim Harris *
1347f11c7f63SJim Harris * @return SCI_STATUS
1348f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1349f11c7f63SJim Harris */
1350f11c7f63SJim Harris static
scic_sds_remote_device_core_event_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 event_code,BOOL is_ready_state)1351f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_core_event_handler(
1352f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
1353f11c7f63SJim Harris U32 event_code,
1354f11c7f63SJim Harris BOOL is_ready_state
1355f11c7f63SJim Harris )
1356f11c7f63SJim Harris {
1357f11c7f63SJim Harris SCI_STATUS status;
1358f11c7f63SJim Harris
1359f11c7f63SJim Harris switch (scu_get_event_type(event_code))
1360f11c7f63SJim Harris {
1361f11c7f63SJim Harris case SCU_EVENT_TYPE_RNC_OPS_MISC:
1362f11c7f63SJim Harris case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
1363f11c7f63SJim Harris case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
1364f11c7f63SJim Harris status = scic_sds_remote_node_context_event_handler(this_device->rnc, event_code);
1365f11c7f63SJim Harris break;
1366f11c7f63SJim Harris case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT:
1367f11c7f63SJim Harris
1368f11c7f63SJim Harris if( scu_get_event_code(event_code) == SCU_EVENT_IT_NEXUS_TIMEOUT )
1369f11c7f63SJim Harris {
1370f11c7f63SJim Harris status = SCI_SUCCESS;
1371f11c7f63SJim Harris
1372f11c7f63SJim Harris // Suspend the associated RNC
1373f11c7f63SJim Harris scic_sds_remote_node_context_suspend( this_device->rnc,
1374f11c7f63SJim Harris SCI_SOFTWARE_SUSPENSION,
1375f11c7f63SJim Harris NULL, NULL );
1376f11c7f63SJim Harris
1377f11c7f63SJim Harris scic_sds_emit_event_log_message(
1378f11c7f63SJim Harris this_device, event_code,
1379f11c7f63SJim Harris (is_ready_state)
1380f11c7f63SJim Harris ? "I_T_Nexus_Timeout event"
1381f11c7f63SJim Harris : "I_T_Nexus_Timeout event in wrong state",
1382f11c7f63SJim Harris is_ready_state );
1383f11c7f63SJim Harris
1384f11c7f63SJim Harris break;
1385f11c7f63SJim Harris }
1386f11c7f63SJim Harris // Else, fall through and treat as unhandled...
1387f11c7f63SJim Harris
1388f11c7f63SJim Harris default:
1389f11c7f63SJim Harris scic_sds_emit_event_log_message( this_device, event_code,
1390f11c7f63SJim Harris (is_ready_state)
1391f11c7f63SJim Harris ? "unexpected event"
1392f11c7f63SJim Harris : "unexpected event in wrong state",
1393f11c7f63SJim Harris is_ready_state );
1394f11c7f63SJim Harris status = SCI_FAILURE_INVALID_STATE;
1395f11c7f63SJim Harris break;
1396f11c7f63SJim Harris }
1397f11c7f63SJim Harris
1398f11c7f63SJim Harris return status;
1399f11c7f63SJim Harris }
1400f11c7f63SJim Harris /**
1401f11c7f63SJim Harris * This method is the default event handler. It will call the RNC state
1402f11c7f63SJim Harris * machine handler for any RNC events otherwise it will log a warning and
1403f11c7f63SJim Harris * returns a failure.
1404f11c7f63SJim Harris *
1405f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1406f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1407f11c7f63SJim Harris * @param[in] event_code The event code that the SCIC_SDS_CONTROLLER wants the
1408f11c7f63SJim Harris * device object to process.
1409f11c7f63SJim Harris *
1410f11c7f63SJim Harris * @return SCI_STATUS
1411f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1412f11c7f63SJim Harris */
scic_sds_remote_device_default_event_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 event_code)1413f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_event_handler(
1414f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
1415f11c7f63SJim Harris U32 event_code
1416f11c7f63SJim Harris )
1417f11c7f63SJim Harris {
1418f11c7f63SJim Harris return scic_sds_remote_device_core_event_handler( this_device,
1419f11c7f63SJim Harris event_code,
1420f11c7f63SJim Harris FALSE );
1421f11c7f63SJim Harris }
1422f11c7f63SJim Harris
1423f11c7f63SJim Harris /**
1424f11c7f63SJim Harris * This method is the default unsolicited frame handler. It logs a warning,
1425f11c7f63SJim Harris * releases the frame and returns a failure.
1426f11c7f63SJim Harris *
1427f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1428f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1429f11c7f63SJim Harris * @param[in] frame_index The frame index for which the SCIC_SDS_CONTROLLER
1430f11c7f63SJim Harris * wants this device object to process.
1431f11c7f63SJim Harris *
1432f11c7f63SJim Harris * @return SCI_STATUS
1433f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1434f11c7f63SJim Harris */
scic_sds_remote_device_default_frame_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 frame_index)1435f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_frame_handler(
1436f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
1437f11c7f63SJim Harris U32 frame_index
1438f11c7f63SJim Harris )
1439f11c7f63SJim Harris {
1440f11c7f63SJim Harris SCIC_LOG_WARNING((
1441f11c7f63SJim Harris sci_base_object_get_logger(this_device),
1442f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1443f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1444f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1445f11c7f63SJim Harris "SCIC Remote Device requested to handle frame %x while in wrong state %d\n",
1446f11c7f63SJim Harris frame_index,
1447f11c7f63SJim Harris sci_base_state_machine_get_state(&this_device->parent.state_machine)
1448f11c7f63SJim Harris ));
1449f11c7f63SJim Harris
1450f11c7f63SJim Harris // Return the frame back to the controller
1451f11c7f63SJim Harris scic_sds_controller_release_frame(
1452f11c7f63SJim Harris scic_sds_remote_device_get_controller(this_device), frame_index
1453f11c7f63SJim Harris );
1454f11c7f63SJim Harris
1455f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1456f11c7f63SJim Harris }
1457f11c7f63SJim Harris
1458f11c7f63SJim Harris /**
1459f11c7f63SJim Harris * This method is the default start io handler. It logs a warning and returns
1460f11c7f63SJim Harris * a failure.
1461f11c7f63SJim Harris *
1462f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1463f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1464f11c7f63SJim Harris * @param[in] request The SCI_BASE_REQUEST which is then cast into a
1465f11c7f63SJim Harris * SCIC_SDS_IO_REQUEST to start.
1466f11c7f63SJim Harris *
1467f11c7f63SJim Harris * @return SCI_STATUS
1468f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1469f11c7f63SJim Harris */
scic_sds_remote_device_default_start_request_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)1470f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_start_request_handler(
1471f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
1472f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
1473f11c7f63SJim Harris )
1474f11c7f63SJim Harris {
1475f11c7f63SJim Harris SCIC_LOG_WARNING((
1476f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1477f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1478f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1479f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1480f11c7f63SJim Harris "SCIC Remote Device requested to start io request %x while in wrong state %d\n",
1481f11c7f63SJim Harris request,
1482f11c7f63SJim Harris sci_base_state_machine_get_state(
1483f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1484f11c7f63SJim Harris ));
1485f11c7f63SJim Harris
1486f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1487f11c7f63SJim Harris }
1488f11c7f63SJim Harris
1489f11c7f63SJim Harris /**
1490f11c7f63SJim Harris * This method is the default complete io handler. It logs a warning and
1491f11c7f63SJim Harris * returns a failure.
1492f11c7f63SJim Harris *
1493f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1494f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1495f11c7f63SJim Harris * @param[in] request The SCI_BASE_REQUEST which is then cast into a
1496f11c7f63SJim Harris * SCIC_SDS_IO_REQUEST to complete.
1497f11c7f63SJim Harris *
1498f11c7f63SJim Harris *
1499f11c7f63SJim Harris * @return SCI_STATUS
1500f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1501f11c7f63SJim Harris */
scic_sds_remote_device_default_complete_request_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)1502f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_complete_request_handler(
1503f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
1504f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
1505f11c7f63SJim Harris )
1506f11c7f63SJim Harris {
1507f11c7f63SJim Harris SCIC_LOG_WARNING((
1508f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1509f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1510f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1511f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1512f11c7f63SJim Harris "SCIC Remote Device requested to complete io_request %x while in wrong state %d\n",
1513f11c7f63SJim Harris request,
1514f11c7f63SJim Harris sci_base_state_machine_get_state(
1515f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1516f11c7f63SJim Harris ));
1517f11c7f63SJim Harris
1518f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1519f11c7f63SJim Harris }
1520f11c7f63SJim Harris
1521f11c7f63SJim Harris /**
1522f11c7f63SJim Harris * This method is the default continue io handler. It logs a warning and
1523f11c7f63SJim Harris * returns a failure.
1524f11c7f63SJim Harris *
1525f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1526f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1527f11c7f63SJim Harris * @param[in] request The SCI_BASE_REQUEST which is then cast into a
1528f11c7f63SJim Harris * SCIC_SDS_IO_REQUEST to continue.
1529f11c7f63SJim Harris *
1530f11c7f63SJim Harris * @return SCI_STATUS
1531f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1532f11c7f63SJim Harris */
scic_sds_remote_device_default_continue_request_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)1533f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_default_continue_request_handler(
1534f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
1535f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
1536f11c7f63SJim Harris )
1537f11c7f63SJim Harris {
1538f11c7f63SJim Harris SCIC_LOG_WARNING((
1539f11c7f63SJim Harris sci_base_object_get_logger((SCIC_SDS_REMOTE_DEVICE_T *)device),
1540f11c7f63SJim Harris SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
1541f11c7f63SJim Harris SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
1542f11c7f63SJim Harris SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
1543f11c7f63SJim Harris "SCIC Remote Device requested to continue io request %x while in wrong state %d\n",
1544f11c7f63SJim Harris request,
1545f11c7f63SJim Harris sci_base_state_machine_get_state(
1546f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine((SCIC_SDS_REMOTE_DEVICE_T *)device))
1547f11c7f63SJim Harris ));
1548f11c7f63SJim Harris
1549f11c7f63SJim Harris return SCI_FAILURE_INVALID_STATE;
1550f11c7f63SJim Harris }
1551f11c7f63SJim Harris
1552f11c7f63SJim Harris /**
1553f11c7f63SJim Harris * This method is the general suspend handler.
1554f11c7f63SJim Harris *
1555f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1556f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1557f11c7f63SJim Harris *
1558f11c7f63SJim Harris * @return SCI_STATUS
1559f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1560f11c7f63SJim Harris */
1561f11c7f63SJim Harris static
scic_sds_remote_device_general_suspend_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 suspend_type)1562f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_general_suspend_handler(
1563f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
1564f11c7f63SJim Harris U32 suspend_type
1565f11c7f63SJim Harris )
1566f11c7f63SJim Harris {
1567f11c7f63SJim Harris return scic_sds_remote_node_context_suspend(this_device->rnc, suspend_type, NULL, NULL);
1568f11c7f63SJim Harris }
1569f11c7f63SJim Harris
1570f11c7f63SJim Harris /**
1571f11c7f63SJim Harris * This method is the general suspend handler. It logs a warning and returns
1572f11c7f63SJim Harris * a failure.
1573f11c7f63SJim Harris *
1574f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1575f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1576f11c7f63SJim Harris *
1577f11c7f63SJim Harris * @return SCI_STATUS
1578f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1579f11c7f63SJim Harris */
1580f11c7f63SJim Harris static
scic_sds_remote_device_general_resume_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device)1581f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_general_resume_handler(
1582f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device
1583f11c7f63SJim Harris )
1584f11c7f63SJim Harris {
1585f11c7f63SJim Harris return scic_sds_remote_node_context_resume(this_device->rnc, NULL, NULL);
1586f11c7f63SJim Harris }
1587f11c7f63SJim Harris
1588f11c7f63SJim Harris //*****************************************************************************
1589f11c7f63SJim Harris //* NORMAL STATE HANDLERS
1590f11c7f63SJim Harris //*****************************************************************************
1591f11c7f63SJim Harris
1592f11c7f63SJim Harris /**
1593f11c7f63SJim Harris * This method is a general ssp frame handler. In most cases the device
1594f11c7f63SJim Harris * object needs to route the unsolicited frame processing to the io request
1595f11c7f63SJim Harris * object. This method decodes the tag for the io request object and routes
1596f11c7f63SJim Harris * the unsolicited frame to that object.
1597f11c7f63SJim Harris *
1598f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is then cast into a
1599f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1600f11c7f63SJim Harris * @param[in] frame_index The frame index for which the SCIC_SDS_CONTROLLER
1601f11c7f63SJim Harris * wants this device object to process.
1602f11c7f63SJim Harris *
1603f11c7f63SJim Harris * @return SCI_STATUS
1604f11c7f63SJim Harris * @retval SCI_FAILURE_INVALID_STATE
1605f11c7f63SJim Harris */
scic_sds_remote_device_general_frame_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 frame_index)1606f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_general_frame_handler(
1607f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device,
1608f11c7f63SJim Harris U32 frame_index
1609f11c7f63SJim Harris )
1610f11c7f63SJim Harris {
1611f11c7f63SJim Harris SCI_STATUS result;
1612f11c7f63SJim Harris SCI_SSP_FRAME_HEADER_T *frame_header;
1613f11c7f63SJim Harris SCIC_SDS_REQUEST_T *io_request;
1614f11c7f63SJim Harris
1615f11c7f63SJim Harris result = scic_sds_unsolicited_frame_control_get_header(
1616f11c7f63SJim Harris &(scic_sds_remote_device_get_controller(this_device)->uf_control),
1617f11c7f63SJim Harris frame_index,
1618f11c7f63SJim Harris (void **)&frame_header
1619f11c7f63SJim Harris );
1620f11c7f63SJim Harris
1621f11c7f63SJim Harris if (SCI_SUCCESS == result)
1622f11c7f63SJim Harris {
1623f11c7f63SJim Harris io_request = scic_sds_controller_get_io_request_from_tag(
1624f11c7f63SJim Harris scic_sds_remote_device_get_controller(this_device), frame_header->tag);
1625f11c7f63SJim Harris
1626f11c7f63SJim Harris if ( (io_request == SCI_INVALID_HANDLE)
1627f11c7f63SJim Harris || (io_request->target_device != this_device) )
1628f11c7f63SJim Harris {
1629f11c7f63SJim Harris // We could not map this tag to a valid IO request
1630f11c7f63SJim Harris // Just toss the frame and continue
1631f11c7f63SJim Harris scic_sds_controller_release_frame(
1632f11c7f63SJim Harris scic_sds_remote_device_get_controller(this_device), frame_index
1633f11c7f63SJim Harris );
1634f11c7f63SJim Harris }
1635f11c7f63SJim Harris else
1636f11c7f63SJim Harris {
1637f11c7f63SJim Harris // The IO request is now in charge of releasing the frame
1638f11c7f63SJim Harris result = io_request->state_handlers->frame_handler(
1639f11c7f63SJim Harris io_request, frame_index);
1640f11c7f63SJim Harris }
1641f11c7f63SJim Harris }
1642f11c7f63SJim Harris
1643f11c7f63SJim Harris return result;
1644f11c7f63SJim Harris }
1645f11c7f63SJim Harris
1646f11c7f63SJim Harris /**
1647f11c7f63SJim Harris * This is a common method for handling events reported to the remote device
1648f11c7f63SJim Harris * from the controller object.
1649f11c7f63SJim Harris *
1650f11c7f63SJim Harris * @param [in] this_device This is the device object that is receiving the
1651f11c7f63SJim Harris * event.
1652f11c7f63SJim Harris * @param [in] event_code The event code to process.
1653f11c7f63SJim Harris *
1654f11c7f63SJim Harris * @return SCI_STATUS
1655f11c7f63SJim Harris */
scic_sds_remote_device_general_event_handler(SCIC_SDS_REMOTE_DEVICE_T * this_device,U32 event_code)1656f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_general_event_handler(
1657f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device,
1658f11c7f63SJim Harris U32 event_code
1659f11c7f63SJim Harris )
1660f11c7f63SJim Harris {
1661f11c7f63SJim Harris return scic_sds_remote_device_core_event_handler( this_device,
1662f11c7f63SJim Harris event_code,
1663f11c7f63SJim Harris TRUE );
1664f11c7f63SJim Harris }
1665f11c7f63SJim Harris
1666f11c7f63SJim Harris //*****************************************************************************
1667f11c7f63SJim Harris //* STOPPED STATE HANDLERS
1668f11c7f63SJim Harris //*****************************************************************************
1669f11c7f63SJim Harris
1670f11c7f63SJim Harris /**
1671f11c7f63SJim Harris * This method takes the SCIC_SDS_REMOTE_DEVICE from a stopped state and
1672f11c7f63SJim Harris * attempts to start it. The RNC buffer for the device is constructed and
1673f11c7f63SJim Harris * the device state machine is transitioned to the
1674f11c7f63SJim Harris * SCIC_BASE_REMOTE_DEVICE_STATE_STARTING.
1675f11c7f63SJim Harris *
1676f11c7f63SJim Harris * @param[in] device
1677f11c7f63SJim Harris *
1678f11c7f63SJim Harris * @return SCI_STATUS
1679f11c7f63SJim Harris * @retval SCI_SUCCESS if there is an RNC buffer available to construct the
1680f11c7f63SJim Harris * remote device.
1681f11c7f63SJim Harris * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if there is no RNC buffer
1682f11c7f63SJim Harris * available in which to construct the remote device.
1683f11c7f63SJim Harris */
1684f11c7f63SJim Harris static
scic_sds_remote_device_stopped_state_start_handler(SCI_BASE_REMOTE_DEVICE_T * device)1685f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_stopped_state_start_handler(
1686f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1687f11c7f63SJim Harris )
1688f11c7f63SJim Harris {
1689f11c7f63SJim Harris SCI_STATUS status;
1690f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1691f11c7f63SJim Harris
1692f11c7f63SJim Harris status = scic_sds_remote_node_context_resume(
1693f11c7f63SJim Harris this_device->rnc,
1694f11c7f63SJim Harris scic_sds_remote_device_resume_complete_handler,
1695f11c7f63SJim Harris this_device
1696f11c7f63SJim Harris );
1697f11c7f63SJim Harris
1698f11c7f63SJim Harris if (status == SCI_SUCCESS)
1699f11c7f63SJim Harris {
1700f11c7f63SJim Harris sci_base_state_machine_change_state(
1701f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device),
1702f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STARTING
1703f11c7f63SJim Harris );
1704f11c7f63SJim Harris }
1705f11c7f63SJim Harris
1706f11c7f63SJim Harris return status;
1707f11c7f63SJim Harris }
1708f11c7f63SJim Harris
1709f11c7f63SJim Harris /**
1710f11c7f63SJim Harris * This method will stop a SCIC_SDS_REMOTE_DEVICE that is already in a stopped
1711f11c7f63SJim Harris * state. This is not considered an error since the device is already
1712f11c7f63SJim Harris * stopped.
1713f11c7f63SJim Harris *
1714f11c7f63SJim Harris * @param[in] this_device The SCI_BASE_REMOTE_DEVICE which is cast into a
1715f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1716f11c7f63SJim Harris *
1717f11c7f63SJim Harris * @return SCI_STATUS
1718f11c7f63SJim Harris * @retval SCI_SUCCESS
1719f11c7f63SJim Harris */
1720f11c7f63SJim Harris static
scic_sds_remote_device_stopped_state_stop_handler(SCI_BASE_REMOTE_DEVICE_T * this_device)1721f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_stopped_state_stop_handler(
1722f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *this_device
1723f11c7f63SJim Harris )
1724f11c7f63SJim Harris {
1725f11c7f63SJim Harris return SCI_SUCCESS;
1726f11c7f63SJim Harris }
1727f11c7f63SJim Harris
1728f11c7f63SJim Harris /**
1729f11c7f63SJim Harris * This method will destruct a SCIC_SDS_REMOTE_DEVICE that is in a stopped
1730f11c7f63SJim Harris * state. This is the only state from which a destruct request will succeed.
1731f11c7f63SJim Harris * The RNi for this SCIC_SDS_REMOTE_DEVICE is returned to the free pool and
1732f11c7f63SJim Harris * the device object transitions to the SCI_BASE_REMOTE_DEVICE_STATE_FINAL.
1733f11c7f63SJim Harris *
1734f11c7f63SJim Harris * @param[in] this_device The SCI_BASE_REMOTE_DEVICE which is cast into a
1735f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
1736f11c7f63SJim Harris *
1737f11c7f63SJim Harris * @return SCI_STATUS
1738f11c7f63SJim Harris * @retval SCI_SUCCESS
1739f11c7f63SJim Harris */
1740f11c7f63SJim Harris static
scic_sds_remote_device_stopped_state_destruct_handler(SCI_BASE_REMOTE_DEVICE_T * device)1741f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_stopped_state_destruct_handler(
1742f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1743f11c7f63SJim Harris )
1744f11c7f63SJim Harris {
1745f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1746f11c7f63SJim Harris
1747f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T * the_controller =
1748f11c7f63SJim Harris scic_sds_remote_device_get_controller(this_device);
1749f11c7f63SJim Harris
1750f11c7f63SJim Harris the_controller->remote_device_sequence[this_device->rnc->remote_node_index]++;
1751f11c7f63SJim Harris
1752f11c7f63SJim Harris scic_sds_controller_free_remote_node_context(
1753f11c7f63SJim Harris the_controller,
1754f11c7f63SJim Harris this_device,
1755f11c7f63SJim Harris this_device->rnc->remote_node_index
1756f11c7f63SJim Harris );
1757f11c7f63SJim Harris
1758f11c7f63SJim Harris scic_sds_remote_node_context_set_remote_node_index(
1759f11c7f63SJim Harris this_device->rnc,
1760f11c7f63SJim Harris SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
1761f11c7f63SJim Harris );
1762f11c7f63SJim Harris
1763f11c7f63SJim Harris sci_base_state_machine_change_state(
1764f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device),
1765f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_FINAL
1766f11c7f63SJim Harris );
1767f11c7f63SJim Harris
1768f11c7f63SJim Harris scic_sds_remote_device_deinitialize_state_logging(this_device);
1769f11c7f63SJim Harris
1770f11c7f63SJim Harris return SCI_SUCCESS;
1771f11c7f63SJim Harris }
1772f11c7f63SJim Harris
1773f11c7f63SJim Harris //*****************************************************************************
1774f11c7f63SJim Harris //* STARTING STATE HANDLERS
1775f11c7f63SJim Harris //*****************************************************************************
1776f11c7f63SJim Harris
1777f11c7f63SJim Harris static
scic_sds_remote_device_starting_state_stop_handler(SCI_BASE_REMOTE_DEVICE_T * device)1778f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_starting_state_stop_handler(
1779f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1780f11c7f63SJim Harris )
1781f11c7f63SJim Harris {
1782f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1783f11c7f63SJim Harris
1784f11c7f63SJim Harris /*
1785f11c7f63SJim Harris * This device has not yet started so there had better be no IO requests
1786f11c7f63SJim Harris */
1787f11c7f63SJim Harris ASSERT(this_device->started_request_count == 0);
1788f11c7f63SJim Harris
1789f11c7f63SJim Harris /*
1790f11c7f63SJim Harris * Destroy the remote node context
1791f11c7f63SJim Harris */
1792f11c7f63SJim Harris scic_sds_remote_node_context_destruct(
1793f11c7f63SJim Harris this_device->rnc,
1794f11c7f63SJim Harris scic_sds_cb_remote_device_rnc_destruct_complete,
1795f11c7f63SJim Harris this_device
1796f11c7f63SJim Harris );
1797f11c7f63SJim Harris
1798f11c7f63SJim Harris /*
1799f11c7f63SJim Harris * Transition to the stopping state and wait for the remote node to
1800f11c7f63SJim Harris * complete being posted and invalidated.
1801f11c7f63SJim Harris */
1802f11c7f63SJim Harris sci_base_state_machine_change_state(
1803f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device),
1804f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
1805f11c7f63SJim Harris );
1806f11c7f63SJim Harris
1807f11c7f63SJim Harris return SCI_SUCCESS;
1808f11c7f63SJim Harris }
1809f11c7f63SJim Harris
1810f11c7f63SJim Harris //*****************************************************************************
1811f11c7f63SJim Harris //* INITIALIZING STATE HANDLERS
1812f11c7f63SJim Harris //*****************************************************************************
1813f11c7f63SJim Harris
1814f11c7f63SJim Harris /* There is nothing to do here for SSP devices */
1815f11c7f63SJim Harris
1816f11c7f63SJim Harris //*****************************************************************************
1817f11c7f63SJim Harris //* READY STATE HANDLERS
1818f11c7f63SJim Harris //*****************************************************************************
1819f11c7f63SJim Harris
1820f11c7f63SJim Harris /**
1821f11c7f63SJim Harris * This method is the default stop handler for the SCIC_SDS_REMOTE_DEVICE
1822f11c7f63SJim Harris * ready substate machine. It will stop the current substate machine and
1823f11c7f63SJim Harris * transition the base state machine to SCI_BASE_REMOTE_DEVICE_STATE_STOPPING.
1824f11c7f63SJim Harris *
1825f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE object which is cast to a
1826f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE object.
1827f11c7f63SJim Harris *
1828f11c7f63SJim Harris * @return SCI_STATUS
1829f11c7f63SJim Harris * @retval SCI_SUCCESS
1830f11c7f63SJim Harris */
scic_sds_remote_device_ready_state_stop_handler(SCI_BASE_REMOTE_DEVICE_T * device)1831f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_ready_state_stop_handler(
1832f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1833f11c7f63SJim Harris )
1834f11c7f63SJim Harris {
1835f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1836f11c7f63SJim Harris SCI_STATUS status = SCI_SUCCESS;
1837f11c7f63SJim Harris
1838f11c7f63SJim Harris // Request the parent state machine to transition to the stopping state
1839f11c7f63SJim Harris sci_base_state_machine_change_state(
1840f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device),
1841f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
1842f11c7f63SJim Harris );
1843f11c7f63SJim Harris
1844f11c7f63SJim Harris if (this_device->started_request_count == 0)
1845f11c7f63SJim Harris {
1846f11c7f63SJim Harris scic_sds_remote_node_context_destruct(
1847f11c7f63SJim Harris this_device->rnc,
1848f11c7f63SJim Harris scic_sds_cb_remote_device_rnc_destruct_complete,
1849f11c7f63SJim Harris this_device
1850f11c7f63SJim Harris );
1851f11c7f63SJim Harris }
1852f11c7f63SJim Harris else
1853f11c7f63SJim Harris status = scic_sds_remote_device_terminate_requests(this_device);
1854f11c7f63SJim Harris
1855f11c7f63SJim Harris return status;
1856f11c7f63SJim Harris }
1857f11c7f63SJim Harris
1858f11c7f63SJim Harris /**
1859f11c7f63SJim Harris * This is the ready state device reset handler
1860f11c7f63SJim Harris *
1861f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE object which is cast to a
1862f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE object.
1863f11c7f63SJim Harris *
1864f11c7f63SJim Harris * @return SCI_STATUS
1865f11c7f63SJim Harris */
scic_sds_remote_device_ready_state_reset_handler(SCI_BASE_REMOTE_DEVICE_T * device)1866f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_ready_state_reset_handler(
1867f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
1868f11c7f63SJim Harris )
1869f11c7f63SJim Harris {
1870f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1871f11c7f63SJim Harris
1872f11c7f63SJim Harris // Request the parent state machine to transition to the stopping state
1873f11c7f63SJim Harris sci_base_state_machine_change_state(
1874f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device),
1875f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_RESETTING
1876f11c7f63SJim Harris );
1877f11c7f63SJim Harris
1878f11c7f63SJim Harris return SCI_SUCCESS;
1879f11c7f63SJim Harris }
1880f11c7f63SJim Harris
1881f11c7f63SJim Harris /**
1882f11c7f63SJim Harris * This method will attempt to start a task request for this device object.
1883f11c7f63SJim Harris * The remote device object will issue the start request for the task and if
1884f11c7f63SJim Harris * successful it will start the request for the port object then increment its
1885f11c7f63SJim Harris * own requet count.
1886f11c7f63SJim Harris *
1887f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is cast to a
1888f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE for which the request is to be started.
1889f11c7f63SJim Harris * @param[in] request The SCI_BASE_REQUEST which is cast to a
1890f11c7f63SJim Harris * SCIC_SDS_IO_REQUEST that is to be started.
1891f11c7f63SJim Harris *
1892f11c7f63SJim Harris * @return SCI_STATUS
1893f11c7f63SJim Harris * @retval SCI_SUCCESS if the task request is started for this device object.
1894f11c7f63SJim Harris * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request object could
1895f11c7f63SJim Harris * not get the resources to start.
1896f11c7f63SJim Harris */
1897f11c7f63SJim Harris static
scic_sds_remote_device_ready_state_start_task_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)1898f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_ready_state_start_task_handler(
1899f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
1900f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
1901f11c7f63SJim Harris )
1902f11c7f63SJim Harris {
1903f11c7f63SJim Harris SCI_STATUS result;
1904f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1905f11c7f63SJim Harris SCIC_SDS_REQUEST_T *task_request = (SCIC_SDS_REQUEST_T *)request;
1906f11c7f63SJim Harris
1907f11c7f63SJim Harris // See if the port is in a state where we can start the IO request
1908f11c7f63SJim Harris result = scic_sds_port_start_io(
1909f11c7f63SJim Harris scic_sds_remote_device_get_port(this_device), this_device, task_request);
1910f11c7f63SJim Harris
1911f11c7f63SJim Harris if (result == SCI_SUCCESS)
1912f11c7f63SJim Harris {
1913f11c7f63SJim Harris result = scic_sds_remote_node_context_start_task(
1914f11c7f63SJim Harris this_device->rnc, task_request
1915f11c7f63SJim Harris );
1916f11c7f63SJim Harris
1917f11c7f63SJim Harris if (result == SCI_SUCCESS)
1918f11c7f63SJim Harris {
1919f11c7f63SJim Harris result = scic_sds_request_start(task_request);
1920f11c7f63SJim Harris }
1921f11c7f63SJim Harris
1922f11c7f63SJim Harris scic_sds_remote_device_start_request(this_device, task_request, result);
1923f11c7f63SJim Harris }
1924f11c7f63SJim Harris
1925f11c7f63SJim Harris return result;
1926f11c7f63SJim Harris }
1927f11c7f63SJim Harris
1928f11c7f63SJim Harris /**
1929f11c7f63SJim Harris * This method will attempt to start an io request for this device object. The
1930f11c7f63SJim Harris * remote device object will issue the start request for the io and if
1931f11c7f63SJim Harris * successful it will start the request for the port object then increment its
1932f11c7f63SJim Harris * own requet count.
1933f11c7f63SJim Harris *
1934f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is cast to a
1935f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE for which the request is to be started.
1936f11c7f63SJim Harris * @param[in] request The SCI_BASE_REQUEST which is cast to a
1937f11c7f63SJim Harris * SCIC_SDS_IO_REQUEST that is to be started.
1938f11c7f63SJim Harris *
1939f11c7f63SJim Harris * @return SCI_STATUS
1940f11c7f63SJim Harris * @retval SCI_SUCCESS if the io request is started for this device object.
1941f11c7f63SJim Harris * @retval SCI_FAILURE_INSUFFICIENT_RESOURCES if the io request object could
1942f11c7f63SJim Harris * not get the resources to start.
1943f11c7f63SJim Harris */
1944f11c7f63SJim Harris static
scic_sds_remote_device_ready_state_start_io_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)1945f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_ready_state_start_io_handler(
1946f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
1947f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
1948f11c7f63SJim Harris )
1949f11c7f63SJim Harris {
1950f11c7f63SJim Harris SCI_STATUS result;
1951f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1952f11c7f63SJim Harris SCIC_SDS_REQUEST_T *io_request = (SCIC_SDS_REQUEST_T *)request;
1953f11c7f63SJim Harris
1954f11c7f63SJim Harris // See if the port is in a state where we can start the IO request
1955f11c7f63SJim Harris result = scic_sds_port_start_io(
1956f11c7f63SJim Harris scic_sds_remote_device_get_port(this_device), this_device, io_request);
1957f11c7f63SJim Harris
1958f11c7f63SJim Harris if (result == SCI_SUCCESS)
1959f11c7f63SJim Harris {
1960f11c7f63SJim Harris result = scic_sds_remote_node_context_start_io(
1961f11c7f63SJim Harris this_device->rnc, io_request
1962f11c7f63SJim Harris );
1963f11c7f63SJim Harris
1964f11c7f63SJim Harris if (result == SCI_SUCCESS)
1965f11c7f63SJim Harris {
1966f11c7f63SJim Harris result = scic_sds_request_start(io_request);
1967f11c7f63SJim Harris }
1968f11c7f63SJim Harris
1969f11c7f63SJim Harris scic_sds_remote_device_start_request(this_device, io_request, result);
1970f11c7f63SJim Harris }
1971f11c7f63SJim Harris
1972f11c7f63SJim Harris return result;
1973f11c7f63SJim Harris }
1974f11c7f63SJim Harris
1975f11c7f63SJim Harris /**
1976f11c7f63SJim Harris * This method will complete the request for the remote device object. The
1977f11c7f63SJim Harris * method will call the completion handler for the request object and if
1978f11c7f63SJim Harris * successful it will complete the request on the port object then decrement
1979f11c7f63SJim Harris * its own started_request_count.
1980f11c7f63SJim Harris *
1981f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is cast to a
1982f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE for which the request is to be completed.
1983f11c7f63SJim Harris * @param[in] request The SCI_BASE_REQUEST which is cast to a
1984f11c7f63SJim Harris * SCIC_SDS_IO_REQUEST that is to be completed.
1985f11c7f63SJim Harris *
1986f11c7f63SJim Harris * @return SCI_STATUS
1987f11c7f63SJim Harris */
1988f11c7f63SJim Harris static
scic_sds_remote_device_ready_state_complete_request_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)1989f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_ready_state_complete_request_handler(
1990f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
1991f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
1992f11c7f63SJim Harris )
1993f11c7f63SJim Harris {
1994f11c7f63SJim Harris SCI_STATUS result;
1995f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
1996f11c7f63SJim Harris SCIC_SDS_REQUEST_T *the_request = (SCIC_SDS_REQUEST_T *)request;
1997f11c7f63SJim Harris
1998f11c7f63SJim Harris result = scic_sds_request_complete(the_request);
1999f11c7f63SJim Harris
2000f11c7f63SJim Harris if (result == SCI_SUCCESS)
2001f11c7f63SJim Harris {
2002f11c7f63SJim Harris // See if the port is in a state where we can start the IO request
2003f11c7f63SJim Harris result = scic_sds_port_complete_io(
2004f11c7f63SJim Harris scic_sds_remote_device_get_port(this_device), this_device, the_request);
2005f11c7f63SJim Harris
2006f11c7f63SJim Harris if (result == SCI_SUCCESS)
2007f11c7f63SJim Harris {
2008f11c7f63SJim Harris scic_sds_remote_device_decrement_request_count(this_device);
2009f11c7f63SJim Harris }
2010f11c7f63SJim Harris }
2011f11c7f63SJim Harris
2012f11c7f63SJim Harris return result;
2013f11c7f63SJim Harris }
2014f11c7f63SJim Harris
2015f11c7f63SJim Harris //*****************************************************************************
2016f11c7f63SJim Harris //* STOPPING STATE HANDLERS
2017f11c7f63SJim Harris //*****************************************************************************
2018f11c7f63SJim Harris
2019f11c7f63SJim Harris /**
2020f11c7f63SJim Harris * This method will stop a SCIC_SDS_REMOTE_DEVICE that is already in the
2021f11c7f63SJim Harris * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This is not considered an
2022f11c7f63SJim Harris * error since we allow a stop request on a device that is alreay stopping or
2023f11c7f63SJim Harris * stopped.
2024f11c7f63SJim Harris *
2025f11c7f63SJim Harris * @param[in] this_device The SCI_BASE_REMOTE_DEVICE which is cast into a
2026f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2027f11c7f63SJim Harris *
2028f11c7f63SJim Harris * @return SCI_STATUS
2029f11c7f63SJim Harris * @retval SCI_SUCCESS
2030f11c7f63SJim Harris */
2031f11c7f63SJim Harris static
scic_sds_remote_device_stopping_state_stop_handler(SCI_BASE_REMOTE_DEVICE_T * device)2032f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_stopping_state_stop_handler(
2033f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device
2034f11c7f63SJim Harris )
2035f11c7f63SJim Harris {
2036f11c7f63SJim Harris // All requests should have been terminated, but if there is an
2037f11c7f63SJim Harris // attempt to stop a device already in the stopping state, then
2038f11c7f63SJim Harris // try again to terminate.
2039f11c7f63SJim Harris return scic_sds_remote_device_terminate_requests(
2040f11c7f63SJim Harris (SCIC_SDS_REMOTE_DEVICE_T*)device);
2041f11c7f63SJim Harris }
2042f11c7f63SJim Harris
2043f11c7f63SJim Harris
2044f11c7f63SJim Harris /**
2045f11c7f63SJim Harris * This method completes requests for this SCIC_SDS_REMOTE_DEVICE while it is
2046f11c7f63SJim Harris * in the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING state. This method calls the
2047f11c7f63SJim Harris * complete method for the request object and if that is successful the port
2048f11c7f63SJim Harris * object is called to complete the task request. Then the device object
2049f11c7f63SJim Harris * itself completes the task request. If SCIC_SDS_REMOTE_DEVICE
2050f11c7f63SJim Harris * started_request_count goes to 0 and the invalidate RNC request has
2051f11c7f63SJim Harris * completed the device object can transition to the
2052f11c7f63SJim Harris * SCI_BASE_REMOTE_DEVICE_STATE_STOPPED.
2053f11c7f63SJim Harris *
2054f11c7f63SJim Harris * @param[in] device The device object for which the request is completing.
2055f11c7f63SJim Harris * @param[in] request The task request that is being completed.
2056f11c7f63SJim Harris *
2057f11c7f63SJim Harris * @return SCI_STATUS
2058f11c7f63SJim Harris */
2059f11c7f63SJim Harris static
scic_sds_remote_device_stopping_state_complete_request_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)2060f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_stopping_state_complete_request_handler(
2061f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
2062f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
2063f11c7f63SJim Harris )
2064f11c7f63SJim Harris {
2065f11c7f63SJim Harris SCI_STATUS status = SCI_SUCCESS;
2066f11c7f63SJim Harris SCIC_SDS_REQUEST_T *this_request = (SCIC_SDS_REQUEST_T *)request;
2067f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2068f11c7f63SJim Harris
2069f11c7f63SJim Harris status = scic_sds_request_complete(this_request);
2070f11c7f63SJim Harris if (status == SCI_SUCCESS)
2071f11c7f63SJim Harris {
2072f11c7f63SJim Harris status = scic_sds_port_complete_io(
2073f11c7f63SJim Harris scic_sds_remote_device_get_port(this_device),
2074f11c7f63SJim Harris this_device,
2075f11c7f63SJim Harris this_request
2076f11c7f63SJim Harris );
2077f11c7f63SJim Harris
2078f11c7f63SJim Harris if (status == SCI_SUCCESS)
2079f11c7f63SJim Harris {
2080f11c7f63SJim Harris scic_sds_remote_device_decrement_request_count(this_device);
2081f11c7f63SJim Harris
2082f11c7f63SJim Harris if (scic_sds_remote_device_get_request_count(this_device) == 0)
2083f11c7f63SJim Harris {
2084f11c7f63SJim Harris scic_sds_remote_node_context_destruct(
2085f11c7f63SJim Harris this_device->rnc,
2086f11c7f63SJim Harris scic_sds_cb_remote_device_rnc_destruct_complete,
2087f11c7f63SJim Harris this_device
2088f11c7f63SJim Harris );
2089f11c7f63SJim Harris }
2090f11c7f63SJim Harris }
2091f11c7f63SJim Harris }
2092f11c7f63SJim Harris
2093f11c7f63SJim Harris return status;
2094f11c7f63SJim Harris }
2095f11c7f63SJim Harris
2096f11c7f63SJim Harris //*****************************************************************************
2097f11c7f63SJim Harris //* RESETTING STATE HANDLERS
2098f11c7f63SJim Harris //*****************************************************************************
2099f11c7f63SJim Harris
2100f11c7f63SJim Harris /**
2101f11c7f63SJim Harris * This method will complete the reset operation when the device is in the
2102f11c7f63SJim Harris * resetting state.
2103f11c7f63SJim Harris *
2104f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is to be cast into a
2105f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE object.
2106f11c7f63SJim Harris *
2107f11c7f63SJim Harris * @return SCI_STATUS
2108f11c7f63SJim Harris */
2109f11c7f63SJim Harris static
scic_sds_remote_device_resetting_state_reset_complete_handler(SCI_BASE_REMOTE_DEVICE_T * device)2110f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_resetting_state_reset_complete_handler(
2111f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T * device
2112f11c7f63SJim Harris )
2113f11c7f63SJim Harris {
2114f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2115f11c7f63SJim Harris
2116f11c7f63SJim Harris sci_base_state_machine_change_state(
2117f11c7f63SJim Harris &this_device->parent.state_machine,
2118f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_READY
2119f11c7f63SJim Harris );
2120f11c7f63SJim Harris
2121f11c7f63SJim Harris return SCI_SUCCESS;
2122f11c7f63SJim Harris }
2123f11c7f63SJim Harris
2124f11c7f63SJim Harris /**
2125f11c7f63SJim Harris * This method will stop the remote device while in the resetting state.
2126f11c7f63SJim Harris *
2127f11c7f63SJim Harris * @param[in] device The SCI_BASE_REMOTE_DEVICE which is to be cast into a
2128f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE object.
2129f11c7f63SJim Harris *
2130f11c7f63SJim Harris * @return SCI_STATUS
2131f11c7f63SJim Harris */
2132f11c7f63SJim Harris static
scic_sds_remote_device_resetting_state_stop_handler(SCI_BASE_REMOTE_DEVICE_T * device)2133f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_resetting_state_stop_handler(
2134f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T * device
2135f11c7f63SJim Harris )
2136f11c7f63SJim Harris {
2137f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2138f11c7f63SJim Harris
2139f11c7f63SJim Harris sci_base_state_machine_change_state(
2140f11c7f63SJim Harris &this_device->parent.state_machine,
2141f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
2142f11c7f63SJim Harris );
2143f11c7f63SJim Harris
2144f11c7f63SJim Harris return SCI_SUCCESS;
2145f11c7f63SJim Harris }
2146f11c7f63SJim Harris
2147f11c7f63SJim Harris /**
2148f11c7f63SJim Harris * This method completes requests for this SCIC_SDS_REMOTE_DEVICE while it is
2149f11c7f63SJim Harris * in the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING state. This method calls the
2150f11c7f63SJim Harris * complete method for the request object and if that is successful the port
2151f11c7f63SJim Harris * object is called to complete the task request. Then the device object
2152f11c7f63SJim Harris * itself completes the task request.
2153f11c7f63SJim Harris *
2154f11c7f63SJim Harris * @param[in] device The device object for which the request is completing.
2155f11c7f63SJim Harris * @param[in] request The task request that is being completed.
2156f11c7f63SJim Harris *
2157f11c7f63SJim Harris * @return SCI_STATUS
2158f11c7f63SJim Harris */
2159f11c7f63SJim Harris static
scic_sds_remote_device_resetting_state_complete_request_handler(SCI_BASE_REMOTE_DEVICE_T * device,SCI_BASE_REQUEST_T * request)2160f11c7f63SJim Harris SCI_STATUS scic_sds_remote_device_resetting_state_complete_request_handler(
2161f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_T *device,
2162f11c7f63SJim Harris SCI_BASE_REQUEST_T *request
2163f11c7f63SJim Harris )
2164f11c7f63SJim Harris {
2165f11c7f63SJim Harris SCI_STATUS status = SCI_SUCCESS;
2166f11c7f63SJim Harris SCIC_SDS_REQUEST_T *this_request = (SCIC_SDS_REQUEST_T *)request;
2167f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)device;
2168f11c7f63SJim Harris
2169f11c7f63SJim Harris status = scic_sds_request_complete(this_request);
2170f11c7f63SJim Harris
2171f11c7f63SJim Harris if (status == SCI_SUCCESS)
2172f11c7f63SJim Harris {
2173f11c7f63SJim Harris status = scic_sds_port_complete_io(
2174f11c7f63SJim Harris scic_sds_remote_device_get_port(this_device), this_device, this_request);
2175f11c7f63SJim Harris
2176f11c7f63SJim Harris if (status == SCI_SUCCESS)
2177f11c7f63SJim Harris {
2178f11c7f63SJim Harris scic_sds_remote_device_decrement_request_count(this_device);
2179f11c7f63SJim Harris }
2180f11c7f63SJim Harris }
2181f11c7f63SJim Harris
2182f11c7f63SJim Harris return status;
2183f11c7f63SJim Harris }
2184f11c7f63SJim Harris
2185f11c7f63SJim Harris //*****************************************************************************
2186f11c7f63SJim Harris //* FAILED STATE HANDLERS
2187f11c7f63SJim Harris //*****************************************************************************
2188f11c7f63SJim Harris
2189f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_STATE_HANDLER_T
2190f11c7f63SJim Harris scic_sds_remote_device_state_handler_table[SCI_BASE_REMOTE_DEVICE_MAX_STATES] =
2191f11c7f63SJim Harris {
2192f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_INITIAL
2193f11c7f63SJim Harris {
2194f11c7f63SJim Harris {
2195f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2196f11c7f63SJim Harris scic_sds_remote_device_default_stop_handler,
2197f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2198f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2199f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2200f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2201f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2202f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler,
2203f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2204f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2205f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler
2206f11c7f63SJim Harris },
2207f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2208f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2209f11c7f63SJim Harris scic_sds_remote_device_default_event_handler,
2210f11c7f63SJim Harris scic_sds_remote_device_default_frame_handler
2211f11c7f63SJim Harris },
2212f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
2213f11c7f63SJim Harris {
2214f11c7f63SJim Harris {
2215f11c7f63SJim Harris scic_sds_remote_device_stopped_state_start_handler,
2216f11c7f63SJim Harris scic_sds_remote_device_stopped_state_stop_handler,
2217f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2218f11c7f63SJim Harris scic_sds_remote_device_stopped_state_destruct_handler,
2219f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2220f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2221f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2222f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler,
2223f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2224f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2225f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler
2226f11c7f63SJim Harris },
2227f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2228f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2229f11c7f63SJim Harris scic_sds_remote_device_default_event_handler,
2230f11c7f63SJim Harris scic_sds_remote_device_default_frame_handler
2231f11c7f63SJim Harris },
2232f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_STARTING
2233f11c7f63SJim Harris {
2234f11c7f63SJim Harris {
2235f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2236f11c7f63SJim Harris scic_sds_remote_device_starting_state_stop_handler,
2237f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2238f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2239f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2240f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2241f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2242f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler,
2243f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2244f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2245f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler
2246f11c7f63SJim Harris },
2247f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2248f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2249f11c7f63SJim Harris scic_sds_remote_device_general_event_handler,
2250f11c7f63SJim Harris scic_sds_remote_device_default_frame_handler
2251f11c7f63SJim Harris },
2252f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_READY
2253f11c7f63SJim Harris {
2254f11c7f63SJim Harris {
2255f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2256f11c7f63SJim Harris scic_sds_remote_device_ready_state_stop_handler,
2257f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2258f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2259f11c7f63SJim Harris scic_sds_remote_device_ready_state_reset_handler,
2260f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2261f11c7f63SJim Harris scic_sds_remote_device_ready_state_start_io_handler,
2262f11c7f63SJim Harris scic_sds_remote_device_ready_state_complete_request_handler,
2263f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2264f11c7f63SJim Harris scic_sds_remote_device_ready_state_start_task_handler,
2265f11c7f63SJim Harris scic_sds_remote_device_ready_state_complete_request_handler
2266f11c7f63SJim Harris },
2267f11c7f63SJim Harris scic_sds_remote_device_general_suspend_handler,
2268f11c7f63SJim Harris scic_sds_remote_device_general_resume_handler,
2269f11c7f63SJim Harris scic_sds_remote_device_general_event_handler,
2270f11c7f63SJim Harris scic_sds_remote_device_general_frame_handler,
2271f11c7f63SJim Harris },
2272f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
2273f11c7f63SJim Harris {
2274f11c7f63SJim Harris {
2275f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2276f11c7f63SJim Harris scic_sds_remote_device_stopping_state_stop_handler,
2277f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2278f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2279f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2280f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2281f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2282f11c7f63SJim Harris scic_sds_remote_device_stopping_state_complete_request_handler,
2283f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2284f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2285f11c7f63SJim Harris scic_sds_remote_device_stopping_state_complete_request_handler
2286f11c7f63SJim Harris },
2287f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2288f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2289f11c7f63SJim Harris scic_sds_remote_device_general_event_handler,
2290f11c7f63SJim Harris scic_sds_remote_device_general_frame_handler
2291f11c7f63SJim Harris },
2292f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_FAILED
2293f11c7f63SJim Harris {
2294f11c7f63SJim Harris {
2295f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2296f11c7f63SJim Harris scic_sds_remote_device_default_stop_handler,
2297f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2298f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2299f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2300f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2301f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2302f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler,
2303f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2304f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2305f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler
2306f11c7f63SJim Harris },
2307f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2308f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2309f11c7f63SJim Harris scic_sds_remote_device_default_event_handler,
2310f11c7f63SJim Harris scic_sds_remote_device_general_frame_handler
2311f11c7f63SJim Harris },
2312f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_RESETTING
2313f11c7f63SJim Harris {
2314f11c7f63SJim Harris {
2315f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2316f11c7f63SJim Harris scic_sds_remote_device_resetting_state_stop_handler,
2317f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2318f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2319f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2320f11c7f63SJim Harris scic_sds_remote_device_resetting_state_reset_complete_handler,
2321f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2322f11c7f63SJim Harris scic_sds_remote_device_resetting_state_complete_request_handler,
2323f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2324f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2325f11c7f63SJim Harris scic_sds_remote_device_resetting_state_complete_request_handler
2326f11c7f63SJim Harris },
2327f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2328f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2329f11c7f63SJim Harris scic_sds_remote_device_default_event_handler,
2330f11c7f63SJim Harris scic_sds_remote_device_general_frame_handler
2331f11c7f63SJim Harris },
2332f11c7f63SJim Harris #if !defined(DISABLE_WIDE_PORTED_TARGETS)
2333f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_UPDATING_PORT_WIDTH - unused by SCIC
2334f11c7f63SJim Harris {
2335f11c7f63SJim Harris {
2336f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2337f11c7f63SJim Harris scic_sds_remote_device_default_stop_handler,
2338f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2339f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2340f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2341f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2342f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2343f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler,
2344f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2345f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2346f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler
2347f11c7f63SJim Harris },
2348f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2349f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2350f11c7f63SJim Harris scic_sds_remote_device_default_event_handler,
2351f11c7f63SJim Harris scic_sds_remote_device_default_frame_handler
2352f11c7f63SJim Harris },
2353f11c7f63SJim Harris #endif
2354f11c7f63SJim Harris // SCI_BASE_REMOTE_DEVICE_STATE_FINAL
2355f11c7f63SJim Harris {
2356f11c7f63SJim Harris {
2357f11c7f63SJim Harris scic_sds_remote_device_default_start_handler,
2358f11c7f63SJim Harris scic_sds_remote_device_default_stop_handler,
2359f11c7f63SJim Harris scic_sds_remote_device_default_fail_handler,
2360f11c7f63SJim Harris scic_sds_remote_device_default_destruct_handler,
2361f11c7f63SJim Harris scic_sds_remote_device_default_reset_handler,
2362f11c7f63SJim Harris scic_sds_remote_device_default_reset_complete_handler,
2363f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2364f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler,
2365f11c7f63SJim Harris scic_sds_remote_device_default_continue_request_handler,
2366f11c7f63SJim Harris scic_sds_remote_device_default_start_request_handler,
2367f11c7f63SJim Harris scic_sds_remote_device_default_complete_request_handler
2368f11c7f63SJim Harris },
2369f11c7f63SJim Harris scic_sds_remote_device_default_suspend_handler,
2370f11c7f63SJim Harris scic_sds_remote_device_default_resume_handler,
2371f11c7f63SJim Harris scic_sds_remote_device_default_event_handler,
2372f11c7f63SJim Harris scic_sds_remote_device_default_frame_handler
2373f11c7f63SJim Harris }
2374f11c7f63SJim Harris };
2375f11c7f63SJim Harris
2376f11c7f63SJim Harris /**
2377f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it
2378453130d9SPedro F. Giffuni * immediately transitions the remote device object to the stopped state.
2379f11c7f63SJim Harris *
2380f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2381f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2382f11c7f63SJim Harris *
2383f11c7f63SJim Harris * @return none
2384f11c7f63SJim Harris */
2385f11c7f63SJim Harris static
scic_sds_remote_device_initial_state_enter(SCI_BASE_OBJECT_T * object)2386f11c7f63SJim Harris void scic_sds_remote_device_initial_state_enter(
2387f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2388f11c7f63SJim Harris )
2389f11c7f63SJim Harris {
2390f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2391f11c7f63SJim Harris
2392f11c7f63SJim Harris SET_STATE_HANDLER(
2393f11c7f63SJim Harris this_device,
2394f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2395f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_INITIAL
2396f11c7f63SJim Harris );
2397f11c7f63SJim Harris
2398f11c7f63SJim Harris // Initial state is a transitional state to the stopped state
2399f11c7f63SJim Harris sci_base_state_machine_change_state(
2400f11c7f63SJim Harris scic_sds_remote_device_get_base_state_machine(this_device),
2401f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
2402f11c7f63SJim Harris );
2403f11c7f63SJim Harris }
2404f11c7f63SJim Harris
2405f11c7f63SJim Harris /**
2406f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_INITIAL it
2407f11c7f63SJim Harris * sets the stopped state handlers and if this state is entered from the
2408f11c7f63SJim Harris * SCI_BASE_REMOTE_DEVICE_STATE_STOPPING then the SCI User is informed that
2409f11c7f63SJim Harris * the device stop is complete.
2410f11c7f63SJim Harris *
2411f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2412f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2413f11c7f63SJim Harris *
2414f11c7f63SJim Harris * @return none
2415f11c7f63SJim Harris */
2416f11c7f63SJim Harris static
scic_sds_remote_device_stopped_state_enter(SCI_BASE_OBJECT_T * object)2417f11c7f63SJim Harris void scic_sds_remote_device_stopped_state_enter(
2418f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2419f11c7f63SJim Harris )
2420f11c7f63SJim Harris {
2421f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2422f11c7f63SJim Harris
2423f11c7f63SJim Harris SET_STATE_HANDLER(
2424f11c7f63SJim Harris this_device,
2425f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2426f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPED
2427f11c7f63SJim Harris );
2428f11c7f63SJim Harris
2429f11c7f63SJim Harris // If we are entering from the stopping state let the SCI User know that
2430f11c7f63SJim Harris // the stop operation has completed.
2431f11c7f63SJim Harris if (this_device->parent.state_machine.previous_state_id
2432f11c7f63SJim Harris == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING)
2433f11c7f63SJim Harris {
2434f11c7f63SJim Harris scic_cb_remote_device_stop_complete(
2435f11c7f63SJim Harris scic_sds_remote_device_get_controller(this_device),
2436f11c7f63SJim Harris this_device,
2437f11c7f63SJim Harris SCI_SUCCESS
2438f11c7f63SJim Harris );
2439f11c7f63SJim Harris }
2440f11c7f63SJim Harris
2441f11c7f63SJim Harris scic_sds_controller_remote_device_stopped(
2442f11c7f63SJim Harris scic_sds_remote_device_get_controller(this_device),
2443f11c7f63SJim Harris this_device
2444f11c7f63SJim Harris );
2445f11c7f63SJim Harris }
2446f11c7f63SJim Harris
2447f11c7f63SJim Harris /**
2448f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_STARTING it
2449f11c7f63SJim Harris * sets the starting state handlers, sets the device not ready, and posts the
2450f11c7f63SJim Harris * remote node context to the hardware.
2451f11c7f63SJim Harris *
2452f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2453f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2454f11c7f63SJim Harris *
2455f11c7f63SJim Harris * @return none
2456f11c7f63SJim Harris */
2457f11c7f63SJim Harris static
scic_sds_remote_device_starting_state_enter(SCI_BASE_OBJECT_T * object)2458f11c7f63SJim Harris void scic_sds_remote_device_starting_state_enter(
2459f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2460f11c7f63SJim Harris )
2461f11c7f63SJim Harris {
2462f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T * the_controller;
2463f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2464f11c7f63SJim Harris
2465f11c7f63SJim Harris the_controller = scic_sds_remote_device_get_controller(this_device);
2466f11c7f63SJim Harris
2467f11c7f63SJim Harris SET_STATE_HANDLER(
2468f11c7f63SJim Harris this_device,
2469f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2470f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STARTING
2471f11c7f63SJim Harris );
2472f11c7f63SJim Harris
2473f11c7f63SJim Harris scic_cb_remote_device_not_ready(
2474f11c7f63SJim Harris the_controller,
2475f11c7f63SJim Harris this_device,
2476f11c7f63SJim Harris SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED
2477f11c7f63SJim Harris );
2478f11c7f63SJim Harris }
2479f11c7f63SJim Harris
2480f11c7f63SJim Harris
2481f11c7f63SJim Harris /**
2482f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_READY it sets
2483f11c7f63SJim Harris * the ready state handlers, and starts the ready substate machine.
2484f11c7f63SJim Harris *
2485f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2486f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2487f11c7f63SJim Harris *
2488f11c7f63SJim Harris * @return none
2489f11c7f63SJim Harris */
2490f11c7f63SJim Harris static
scic_sds_remote_device_ready_state_enter(SCI_BASE_OBJECT_T * object)2491f11c7f63SJim Harris void scic_sds_remote_device_ready_state_enter(
2492f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2493f11c7f63SJim Harris )
2494f11c7f63SJim Harris {
2495f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T * the_controller;
2496f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2497f11c7f63SJim Harris
2498f11c7f63SJim Harris the_controller = scic_sds_remote_device_get_controller(this_device);
2499f11c7f63SJim Harris
2500f11c7f63SJim Harris SET_STATE_HANDLER(
2501f11c7f63SJim Harris this_device,
2502f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2503f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_READY
2504f11c7f63SJim Harris );
2505f11c7f63SJim Harris
2506f11c7f63SJim Harris /// @todo Check the device object for the proper return code for this
2507f11c7f63SJim Harris /// callback
2508f11c7f63SJim Harris scic_cb_remote_device_start_complete(
2509f11c7f63SJim Harris the_controller, this_device, SCI_SUCCESS
2510f11c7f63SJim Harris );
2511f11c7f63SJim Harris
2512f11c7f63SJim Harris scic_sds_controller_remote_device_started(
2513f11c7f63SJim Harris the_controller, this_device
2514f11c7f63SJim Harris );
2515f11c7f63SJim Harris
2516f11c7f63SJim Harris if (this_device->has_ready_substate_machine)
2517f11c7f63SJim Harris {
2518f11c7f63SJim Harris sci_base_state_machine_start(&this_device->ready_substate_machine);
2519f11c7f63SJim Harris }
2520f11c7f63SJim Harris else
2521f11c7f63SJim Harris {
2522f11c7f63SJim Harris scic_cb_remote_device_ready(the_controller, this_device);
2523f11c7f63SJim Harris }
2524f11c7f63SJim Harris }
2525f11c7f63SJim Harris
2526f11c7f63SJim Harris /**
2527f11c7f63SJim Harris * This is the exit method for the SCI_BASE_REMOTE_DEVICE_STATE_READY it does
2528f11c7f63SJim Harris * nothing.
2529f11c7f63SJim Harris *
2530f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2531f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2532f11c7f63SJim Harris *
2533f11c7f63SJim Harris * @return none
2534f11c7f63SJim Harris */
2535f11c7f63SJim Harris static
scic_sds_remote_device_ready_state_exit(SCI_BASE_OBJECT_T * object)2536f11c7f63SJim Harris void scic_sds_remote_device_ready_state_exit(
2537f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2538f11c7f63SJim Harris )
2539f11c7f63SJim Harris {
2540f11c7f63SJim Harris SCIC_SDS_CONTROLLER_T * the_controller;
2541f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T * this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2542f11c7f63SJim Harris
2543f11c7f63SJim Harris the_controller = scic_sds_remote_device_get_controller(this_device);
2544f11c7f63SJim Harris
2545f11c7f63SJim Harris if (this_device->has_ready_substate_machine)
2546f11c7f63SJim Harris {
2547f11c7f63SJim Harris sci_base_state_machine_stop(&this_device->ready_substate_machine);
2548f11c7f63SJim Harris }
2549f11c7f63SJim Harris else
2550f11c7f63SJim Harris {
2551f11c7f63SJim Harris scic_cb_remote_device_not_ready(
2552f11c7f63SJim Harris the_controller,
2553f11c7f63SJim Harris this_device,
2554f11c7f63SJim Harris SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED
2555f11c7f63SJim Harris );
2556f11c7f63SJim Harris }
2557f11c7f63SJim Harris }
2558f11c7f63SJim Harris
2559f11c7f63SJim Harris /**
2560f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_STOPPING it
2561f11c7f63SJim Harris * sets the stopping state handlers and posts an RNC invalidate request to the
2562f11c7f63SJim Harris * SCU hardware.
2563f11c7f63SJim Harris *
2564f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2565f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2566f11c7f63SJim Harris *
2567f11c7f63SJim Harris * @return none
2568f11c7f63SJim Harris */
2569f11c7f63SJim Harris static
scic_sds_remote_device_stopping_state_enter(SCI_BASE_OBJECT_T * object)2570f11c7f63SJim Harris void scic_sds_remote_device_stopping_state_enter(
2571f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2572f11c7f63SJim Harris )
2573f11c7f63SJim Harris {
2574f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2575f11c7f63SJim Harris
2576f11c7f63SJim Harris SET_STATE_HANDLER(
2577f11c7f63SJim Harris this_device,
2578f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2579f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPING
2580f11c7f63SJim Harris );
2581f11c7f63SJim Harris }
2582f11c7f63SJim Harris
2583f11c7f63SJim Harris /**
2584f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_FAILED it
2585f11c7f63SJim Harris * sets the stopping state handlers.
2586f11c7f63SJim Harris *
2587f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2588f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2589f11c7f63SJim Harris *
2590f11c7f63SJim Harris * @return none
2591f11c7f63SJim Harris */
2592f11c7f63SJim Harris static
scic_sds_remote_device_failed_state_enter(SCI_BASE_OBJECT_T * object)2593f11c7f63SJim Harris void scic_sds_remote_device_failed_state_enter(
2594f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2595f11c7f63SJim Harris )
2596f11c7f63SJim Harris {
2597f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2598f11c7f63SJim Harris
2599f11c7f63SJim Harris SET_STATE_HANDLER(
2600f11c7f63SJim Harris this_device,
2601f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2602f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_FAILED
2603f11c7f63SJim Harris );
2604f11c7f63SJim Harris }
2605f11c7f63SJim Harris
2606f11c7f63SJim Harris /**
2607f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING it
2608f11c7f63SJim Harris * sets the resetting state handlers.
2609f11c7f63SJim Harris *
2610f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2611f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2612f11c7f63SJim Harris *
2613f11c7f63SJim Harris * @return none
2614f11c7f63SJim Harris */
2615f11c7f63SJim Harris static
scic_sds_remote_device_resetting_state_enter(SCI_BASE_OBJECT_T * object)2616f11c7f63SJim Harris void scic_sds_remote_device_resetting_state_enter(
2617f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2618f11c7f63SJim Harris )
2619f11c7f63SJim Harris {
2620f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2621f11c7f63SJim Harris
2622f11c7f63SJim Harris SET_STATE_HANDLER(
2623f11c7f63SJim Harris this_device,
2624f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2625f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_RESETTING
2626f11c7f63SJim Harris );
2627f11c7f63SJim Harris
2628f11c7f63SJim Harris scic_sds_remote_node_context_suspend(
2629f11c7f63SJim Harris this_device->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL);
2630f11c7f63SJim Harris }
2631f11c7f63SJim Harris
2632f11c7f63SJim Harris /**
2633f11c7f63SJim Harris * This is the exit method for the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING it
2634f11c7f63SJim Harris * does nothing.
2635f11c7f63SJim Harris *
2636f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2637f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2638f11c7f63SJim Harris *
2639f11c7f63SJim Harris * @return none
2640f11c7f63SJim Harris */
2641f11c7f63SJim Harris static
scic_sds_remote_device_resetting_state_exit(SCI_BASE_OBJECT_T * object)2642f11c7f63SJim Harris void scic_sds_remote_device_resetting_state_exit(
2643f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2644f11c7f63SJim Harris )
2645f11c7f63SJim Harris {
2646f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2647f11c7f63SJim Harris
2648f11c7f63SJim Harris scic_sds_remote_node_context_resume(this_device->rnc, NULL, NULL);
2649f11c7f63SJim Harris }
2650f11c7f63SJim Harris
2651f11c7f63SJim Harris /**
2652f11c7f63SJim Harris * This is the enter method for the SCI_BASE_REMOTE_DEVICE_STATE_FINAL it sets
2653f11c7f63SJim Harris * the final state handlers.
2654f11c7f63SJim Harris *
2655f11c7f63SJim Harris * @param[in] object This is the SCI_BASE_OBJECT that is cast into a
2656f11c7f63SJim Harris * SCIC_SDS_REMOTE_DEVICE.
2657f11c7f63SJim Harris *
2658f11c7f63SJim Harris * @return none
2659f11c7f63SJim Harris */
2660f11c7f63SJim Harris static
scic_sds_remote_device_final_state_enter(SCI_BASE_OBJECT_T * object)2661f11c7f63SJim Harris void scic_sds_remote_device_final_state_enter(
2662f11c7f63SJim Harris SCI_BASE_OBJECT_T *object
2663f11c7f63SJim Harris )
2664f11c7f63SJim Harris {
2665f11c7f63SJim Harris SCIC_SDS_REMOTE_DEVICE_T *this_device = (SCIC_SDS_REMOTE_DEVICE_T *)object;
2666f11c7f63SJim Harris
2667f11c7f63SJim Harris SET_STATE_HANDLER(
2668f11c7f63SJim Harris this_device,
2669f11c7f63SJim Harris scic_sds_remote_device_state_handler_table,
2670f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_FINAL
2671f11c7f63SJim Harris );
2672f11c7f63SJim Harris }
2673f11c7f63SJim Harris
2674f11c7f63SJim Harris // ---------------------------------------------------------------------------
2675f11c7f63SJim Harris
2676f11c7f63SJim Harris SCI_BASE_STATE_T
2677f11c7f63SJim Harris scic_sds_remote_device_state_table[SCI_BASE_REMOTE_DEVICE_MAX_STATES] =
2678f11c7f63SJim Harris {
2679f11c7f63SJim Harris {
2680f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
2681f11c7f63SJim Harris scic_sds_remote_device_initial_state_enter,
2682f11c7f63SJim Harris NULL
2683f11c7f63SJim Harris },
2684f11c7f63SJim Harris {
2685f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
2686f11c7f63SJim Harris scic_sds_remote_device_stopped_state_enter,
2687f11c7f63SJim Harris NULL
2688f11c7f63SJim Harris },
2689f11c7f63SJim Harris {
2690f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
2691f11c7f63SJim Harris scic_sds_remote_device_starting_state_enter,
2692f11c7f63SJim Harris NULL
2693f11c7f63SJim Harris },
2694f11c7f63SJim Harris {
2695f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_READY,
2696f11c7f63SJim Harris scic_sds_remote_device_ready_state_enter,
2697f11c7f63SJim Harris scic_sds_remote_device_ready_state_exit
2698f11c7f63SJim Harris },
2699f11c7f63SJim Harris {
2700f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
2701f11c7f63SJim Harris scic_sds_remote_device_stopping_state_enter,
2702f11c7f63SJim Harris NULL
2703f11c7f63SJim Harris },
2704f11c7f63SJim Harris {
2705f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
2706f11c7f63SJim Harris scic_sds_remote_device_failed_state_enter,
2707f11c7f63SJim Harris NULL
2708f11c7f63SJim Harris },
2709f11c7f63SJim Harris {
2710f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
2711f11c7f63SJim Harris scic_sds_remote_device_resetting_state_enter,
2712f11c7f63SJim Harris scic_sds_remote_device_resetting_state_exit
2713f11c7f63SJim Harris },
2714f11c7f63SJim Harris #if !defined(DISABLE_WIDE_PORTED_TARGETS)
2715f11c7f63SJim Harris { //Not used by SCIC
2716f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_UPDATING_PORT_WIDTH,
2717f11c7f63SJim Harris NULL,
2718f11c7f63SJim Harris NULL
2719f11c7f63SJim Harris },
2720f11c7f63SJim Harris #endif //#if !defined(DISABLE_WIDE_PORTED_TARGETS)
2721f11c7f63SJim Harris {
2722f11c7f63SJim Harris SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
2723f11c7f63SJim Harris scic_sds_remote_device_final_state_enter,
2724f11c7f63SJim Harris NULL
2725f11c7f63SJim Harris }
2726f11c7f63SJim Harris };
2727f11c7f63SJim Harris
2728