Staging: heci: fix the problem that file_ext->state should be protected by device_lock
[linux-2.6] / drivers / staging / heci / heci_interface.h
1 /*
2  * Part of Intel(R) Manageability Engine Interface Linux driver
3  *
4  * Copyright (c) 2003 - 2008 Intel Corp.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions, and the following disclaimer,
12  *    without modification.
13  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14  *    substantially similar to the "NO WARRANTY" disclaimer below
15  *    ("Disclaimer") and any redistribution must be conditioned upon
16  *    including a substantially similar Disclaimer requirement for further
17  *    binary redistribution.
18  * 3. Neither the names of the above-listed copyright holders nor the names
19  *    of any contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  * Alternatively, this software may be distributed under the terms of the
23  * GNU General Public License ("GPL") version 2 as published by the Free
24  * Software Foundation.
25  *
26  * NO WARRANTY
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGES.
38  *
39  */
40
41
42 #ifndef _HECI_INTERFACE_H_
43 #define _HECI_INTERFACE_H_
44
45 #include <linux/spinlock.h>
46 #include <linux/list.h>
47 #include <linux/pci.h>
48 #include <linux/timer.h>
49 #include <linux/interrupt.h>
50 #include <linux/workqueue.h>
51 #include <linux/module.h>
52 #include <linux/aio.h>
53 #include <linux/types.h>
54 #include "heci_data_structures.h"
55
56
57 #define HBM_MINOR_VERSION                   0
58 #define HBM_MAJOR_VERSION                   1
59 #define HBM_TIMEOUT                         1   /* 1 second */
60
61
62 #define HOST_START_REQ_CMD                  0x01
63 #define HOST_START_RES_CMD                  0x81
64
65 #define HOST_STOP_REQ_CMD                   0x02
66 #define HOST_STOP_RES_CMD                   0x82
67
68 #define ME_STOP_REQ_CMD                     0x03
69
70 #define HOST_ENUM_REQ_CMD                   0x04
71 #define HOST_ENUM_RES_CMD                   0x84
72
73 #define HOST_CLIENT_PROPERTEIS_REQ_CMD      0x05
74 #define HOST_CLIENT_PROPERTEIS_RES_CMD      0x85
75
76 #define CLIENT_CONNECT_REQ_CMD              0x06
77 #define CLIENT_CONNECT_RES_CMD              0x86
78
79 #define CLIENT_DISCONNECT_REQ_CMD           0x07
80 #define CLIENT_DISCONNECT_RES_CMD           0x87
81
82 #define HECI_FLOW_CONTROL_CMD               0x08
83
84
85 #define AMT_WD_VALUE 120        /* seconds */
86
87 #define HECI_WATCHDOG_DATA_SIZE         16
88 #define HECI_START_WD_DATA_SIZE         20
89 #define HECI_WD_PARAMS_SIZE             4
90
91 /* IOCTL commands */
92 #define IOCTL_HECI_GET_VERSION \
93     _IOWR('H' , 0x0, struct heci_message_data)
94 #define IOCTL_HECI_CONNECT_CLIENT \
95     _IOWR('H' , 0x01, struct heci_message_data)
96 #define IOCTL_HECI_WD \
97     _IOWR('H' , 0x02, struct heci_message_data)
98 #define IOCTL_HECI_BYPASS_WD \
99     _IOWR('H' , 0x10, struct heci_message_data)
100
101 enum heci_stop_reason_types{
102         DRIVER_STOP_REQUEST = 0x00,
103         DEVICE_D1_ENTRY = 0x01,
104         DEVICE_D2_ENTRY = 0x02,
105         DEVICE_D3_ENTRY = 0x03,
106         SYSTEM_S1_ENTRY = 0x04,
107         SYSTEM_S2_ENTRY = 0x05,
108         SYSTEM_S3_ENTRY = 0x06,
109         SYSTEM_S4_ENTRY = 0x07,
110         SYSTEM_S5_ENTRY = 0x08
111 };
112
113 enum me_stop_reason_types{
114         FW_UPDATE = 0x00
115 };
116
117 enum client_connect_status_types{
118         CCS_SUCCESS = 0x00,
119         CCS_NOT_FOUND = 0x01,
120         CCS_ALREADY_STARTED = 0x02,
121         CCS_OUT_OF_RESOURCES = 0x03,
122         CCS_MESSAGE_SMALL = 0x04
123 };
124
125 enum client_disconnect_status_types{
126         CDS_SUCCESS = 0x00
127 };
128
129
130 /*
131  * heci interface function prototypes
132  */
133 void heci_set_csr_register(struct iamt_heci_device *dev);
134 void heci_csr_enable_interrupts(struct iamt_heci_device *dev);
135 void heci_csr_disable_interrupts(struct iamt_heci_device *dev);
136 void heci_csr_clear_his(struct iamt_heci_device *dev);
137
138 void heci_read_slots(struct iamt_heci_device *dev,
139                      unsigned char *buffer, unsigned long buffer_length);
140
141 int heci_write_message(struct iamt_heci_device *dev,
142                              struct heci_msg_hdr *header,
143                              unsigned char *write_buffer,
144                              unsigned long write_length);
145
146 int host_buffer_is_empty(struct iamt_heci_device *dev);
147
148 __s32 count_full_read_slots(struct iamt_heci_device *dev);
149
150 __s32 count_empty_write_slots(const struct iamt_heci_device *dev);
151
152 int flow_ctrl_creds(struct iamt_heci_device *dev,
153                                    struct heci_file_private *file_ext);
154
155 int heci_send_wd(struct iamt_heci_device *dev);
156
157 void flow_ctrl_reduce(struct iamt_heci_device *dev,
158                          struct heci_file_private *file_ext);
159
160 int heci_send_flow_control(struct iamt_heci_device *dev,
161                                  struct heci_file_private *file_ext);
162
163 int heci_disconnect(struct iamt_heci_device *dev,
164                           struct heci_file_private *file_ext);
165 int other_client_is_connecting(struct iamt_heci_device *dev,
166                                      struct heci_file_private *file_ext);
167 int heci_connect(struct iamt_heci_device *dev,
168                        struct heci_file_private *file_ext);
169
170 #endif /* _HECI_INTERFACE_H_ */