2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 #ifndef _SCI_BASE_REQUST_H_
55 #define _SCI_BASE_REQUST_H_
60 * @brief This file contains all of the constants, types, and method
61 * declarations for the SCI base IO and task request objects.
68 #include <dev/isci/scil/sci_base_logger.h>
69 #include <dev/isci/scil/sci_base_state_machine.h>
70 #include <dev/isci/scil/sci_base_state_machine_logger.h>
73 * @enum SCI_BASE_REQUEST_STATES
75 * @brief This enumeration depicts all the states for the common request
78 typedef enum _SCI_BASE_REQUEST_STATES
81 * Simply the initial state for the base request state machine.
83 SCI_BASE_REQUEST_STATE_INITIAL,
86 * This state indicates that the request has been constructed. This state
87 * is entered from the INITIAL state.
89 SCI_BASE_REQUEST_STATE_CONSTRUCTED,
92 * This state indicates that the request has been started. This state is
93 * entered from the CONSTRUCTED state.
95 SCI_BASE_REQUEST_STATE_STARTED,
98 * This state indicates that the request has completed.
99 * This state is entered from the STARTED state. This state is entered from
100 * the ABORTING state.
102 SCI_BASE_REQUEST_STATE_COMPLETED,
105 * This state indicates that the request is in the process of being
106 * terminated/aborted.
107 * This state is entered from the CONSTRUCTED state.
108 * This state is entered from the STARTED state.
110 SCI_BASE_REQUEST_STATE_ABORTING,
113 * Simply the final state for the base request state machine.
115 SCI_BASE_REQUEST_STATE_FINAL,
117 SCI_BASE_REQUEST_MAX_STATES
119 } SCI_BASE_REQUEST_STATES;
122 * @struct SCI_BASE_REQUEST
124 * @brief The base request object abstracts the fields common to all SCI IO
125 * and task request objects.
127 typedef struct SCI_BASE_REQUEST
130 * The field specifies that the parent object for the base request is the
131 * base object itself.
133 SCI_BASE_OBJECT_T parent;
136 * This field contains the information for the base request state machine.
138 SCI_BASE_STATE_MACHINE_T state_machine;
141 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
142 #endif // SCI_LOGGING
144 } SCI_BASE_REQUEST_T;
146 typedef SCI_STATUS (*SCI_BASE_REQUEST_HANDLER_T)(
147 SCI_BASE_REQUEST_T * this_request
151 * @struct SCI_BASE_REQUEST_STATE_HANDLER
153 * @brief This structure contains all of the state handler methods common to
154 * base IO and task request state machines. Handler methods provide
155 * the ability to change the behavior for user requests or
156 * transitions depending on the state the machine is in.
159 typedef struct SCI_BASE_REQUEST_STATE_HANDLER
162 * The start_handler specifies the method invoked when a user attempts to
165 SCI_BASE_REQUEST_HANDLER_T start_handler;
168 * The abort_handler specifies the method invoked when a user attempts to
171 SCI_BASE_REQUEST_HANDLER_T abort_handler;
174 * The complete_handler specifies the method invoked when a user attempts to
175 * complete a request.
177 SCI_BASE_REQUEST_HANDLER_T complete_handler;
180 * The destruct_handler specifies the method invoked when a user attempts to
181 * destruct a request.
183 SCI_BASE_REQUEST_HANDLER_T destruct_handler;
185 } SCI_BASE_REQUEST_STATE_HANDLER_T;
188 * @brief Construct the base request.
190 * @param[in] this_request This parameter specifies the base request
192 * @param[in] logger This parameter specifies the logger associated with
193 * this base request object.
194 * @param[in] state_table This parameter specifies the table of state
195 * definitions to be utilized for the request state machine.
199 void sci_base_request_construct(
200 SCI_BASE_REQUEST_T * this_request,
201 SCI_BASE_LOGGER_T * logger,
202 SCI_BASE_STATE_T * state_table
207 #endif // __cplusplus
209 #endif // _SCI_BASE_REQUST_H_