1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "hpi_internal.h"
25#include "hpimsginit.h"
26
27
28static u16 msg_size[HPI_OBJ_MAXINDEX + 1] = HPI_MESSAGE_SIZE_BY_OBJECT;
29
30static u16 res_size[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT;
31
32static u16 gwSSX2_bypass;
33
34
35
36
37static void hpi_init_message(struct hpi_message *phm, u16 object,
38 u16 function)
39{
40 u16 size;
41
42 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
43 size = msg_size[object];
44 else
45 size = sizeof(*phm);
46
47 memset(phm, 0, size);
48 phm->size = size;
49
50 if (gwSSX2_bypass)
51 phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE;
52 else
53 phm->type = HPI_TYPE_REQUEST;
54 phm->object = object;
55 phm->function = function;
56 phm->version = 0;
57 phm->adapter_index = HPI_ADAPTER_INDEX_INVALID;
58
59}
60
61
62
63
64void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
65 u16 error)
66{
67 u16 size;
68
69 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
70 size = res_size[object];
71 else
72 size = sizeof(*phr);
73
74 memset(phr, 0, sizeof(*phr));
75 phr->size = size;
76 phr->type = HPI_TYPE_RESPONSE;
77 phr->object = object;
78 phr->function = function;
79 phr->error = error;
80 phr->specific_error = 0;
81 phr->version = 0;
82}
83
84void hpi_init_message_response(struct hpi_message *phm,
85 struct hpi_response *phr, u16 object, u16 function)
86{
87 hpi_init_message(phm, object, function);
88
89
90 hpi_init_response(phr, object, function,
91 HPI_ERROR_PROCESSING_MESSAGE);
92}
93
94static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
95 u16 object, u16 function)
96{
97 memset(phm, 0, size);
98 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
99 phm->size = size;
100 phm->type = HPI_TYPE_REQUEST;
101 phm->object = object;
102 phm->function = function;
103 phm->version = 1;
104
105 }
106}
107
108void hpi_init_responseV1(struct hpi_response_header *phr, u16 size,
109 u16 object, u16 function)
110{
111 (void)object;
112 (void)function;
113 memset(phr, 0, size);
114 phr->size = size;
115 phr->version = 1;
116 phr->type = HPI_TYPE_RESPONSE;
117 phr->error = HPI_ERROR_PROCESSING_MESSAGE;
118}
119
120void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size,
121 struct hpi_response_header *phr, u16 res_size, u16 object,
122 u16 function)
123{
124 hpi_init_messageV1(phm, msg_size, object, function);
125 hpi_init_responseV1(phr, res_size, object, function);
126}
127