[kernel] explicitely enable bootmem on 2.6.35 - required by crashlog (#7695)
[openwrt.git] / target / linux / s3c24xx / files-2.6.30 / drivers / ar6000 / include / htc.h
1 /*
2 * Copyright (c) 2007 Atheros Communications Inc.
3 * All rights reserved.
4 *
5 * $ATH_LICENSE_HOSTSDK0_C$
6 *
7 */
8
9
10 #ifndef __HTC_H__
11 #define __HTC_H__
12
13 #ifndef ATH_TARGET
14 #include "athstartpack.h"
15 #endif
16
17 #define A_OFFSETOF(type,field) (int)(&(((type *)NULL)->field))
18
19 #define ASSEMBLE_UNALIGNED_UINT16(p,highbyte,lowbyte) \
20 (((A_UINT16)(((A_UINT8 *)(p))[(highbyte)])) << 8 | (A_UINT16)(((A_UINT8 *)(p))[(lowbyte)]))
21
22 /* alignment independent macros (little-endian) to fetch UINT16s or UINT8s from a
23 * structure using only the type and field name.
24 * Use these macros if there is the potential for unaligned buffer accesses. */
25 #define A_GET_UINT16_FIELD(p,type,field) \
26 ASSEMBLE_UNALIGNED_UINT16(p,\
27 A_OFFSETOF(type,field) + 1, \
28 A_OFFSETOF(type,field))
29
30 #define A_SET_UINT16_FIELD(p,type,field,value) \
31 { \
32 ((A_UINT8 *)(p))[A_OFFSETOF(type,field)] = (A_UINT8)(value); \
33 ((A_UINT8 *)(p))[A_OFFSETOF(type,field) + 1] = (A_UINT8)((value) >> 8); \
34 }
35
36 #define A_GET_UINT8_FIELD(p,type,field) \
37 ((A_UINT8 *)(p))[A_OFFSETOF(type,field)]
38
39 #define A_SET_UINT8_FIELD(p,type,field,value) \
40 ((A_UINT8 *)(p))[A_OFFSETOF(type,field)] = (value)
41
42 /****** DANGER DANGER ***************
43 *
44 * The frame header length and message formats defined herein were
45 * selected to accommodate optimal alignment for target processing. This reduces code
46 * size and improves performance.
47 *
48 * Any changes to the header length may alter the alignment and cause exceptions
49 * on the target. When adding to the message structures insure that fields are
50 * properly aligned.
51 *
52 */
53
54 /* HTC frame header */
55 typedef PREPACK struct _HTC_FRAME_HDR{
56 /* do not remove or re-arrange these fields, these are minimally required
57 * to take advantage of 4-byte lookaheads in some hardware implementations */
58 A_UINT8 EndpointID;
59 A_UINT8 Flags;
60 A_UINT16 PayloadLen; /* length of data (including trailer) that follows the header */
61
62 /***** end of 4-byte lookahead ****/
63
64 A_UINT8 ControlBytes[2];
65
66 /* message payload starts after the header */
67
68 } POSTPACK HTC_FRAME_HDR;
69
70 /* frame header flags */
71 #define HTC_FLAGS_NEED_CREDIT_UPDATE (1 << 0)
72 #define HTC_FLAGS_RECV_TRAILER (1 << 1)
73
74
75 #define HTC_HDR_LENGTH (sizeof(HTC_FRAME_HDR))
76 #define HTC_MAX_TRAILER_LENGTH 255
77 #define HTC_MAX_PAYLOAD_LENGTH (2048 - sizeof(HTC_FRAME_HDR))
78
79 /* HTC control message IDs */
80 typedef enum {
81 HTC_MSG_READY_ID = 1,
82 HTC_MSG_CONNECT_SERVICE_ID = 2,
83 HTC_MSG_CONNECT_SERVICE_RESPONSE_ID = 3,
84 HTC_MSG_SETUP_COMPLETE_ID = 4,
85 } HTC_MSG_IDS;
86
87 #define HTC_MAX_CONTROL_MESSAGE_LENGTH 256
88
89 /* base message ID header */
90 typedef PREPACK struct {
91 A_UINT16 MessageID;
92 } POSTPACK HTC_UNKNOWN_MSG;
93
94 /* HTC ready message
95 * direction : target-to-host */
96 typedef PREPACK struct {
97 A_UINT16 MessageID; /* ID */
98 A_UINT16 CreditCount; /* number of credits the target can offer */
99 A_UINT16 CreditSize; /* size of each credit */
100 A_UINT8 MaxEndpoints; /* maximum number of endpoints the target has resources for */
101 A_UINT8 _Pad1;
102 } POSTPACK HTC_READY_MSG;
103
104 #define HTC_SERVICE_META_DATA_MAX_LENGTH 128
105
106 /* connect service
107 * direction : host-to-target */
108 typedef PREPACK struct {
109 A_UINT16 MessageID;
110 A_UINT16 ServiceID; /* service ID of the service to connect to */
111 A_UINT16 ConnectionFlags; /* connection flags */
112
113 #define HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE (1 << 2) /* reduce credit dribbling when
114 the host needs credits */
115 #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK (0x3)
116 #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_FOURTH 0x0
117 #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF 0x1
118 #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_THREE_FOURTHS 0x2
119 #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_UNITY 0x3
120
121 A_UINT8 ServiceMetaLength; /* length of meta data that follows */
122 A_UINT8 _Pad1;
123
124 /* service-specific meta data starts after the header */
125
126 } POSTPACK HTC_CONNECT_SERVICE_MSG;
127
128 /* connect response
129 * direction : target-to-host */
130 typedef PREPACK struct {
131 A_UINT16 MessageID;
132 A_UINT16 ServiceID; /* service ID that the connection request was made */
133 A_UINT8 Status; /* service connection status */
134 A_UINT8 EndpointID; /* assigned endpoint ID */
135 A_UINT16 MaxMsgSize; /* maximum expected message size on this endpoint */
136 A_UINT8 ServiceMetaLength; /* length of meta data that follows */
137 A_UINT8 _Pad1;
138
139 /* service-specific meta data starts after the header */
140
141 } POSTPACK HTC_CONNECT_SERVICE_RESPONSE_MSG;
142
143 typedef PREPACK struct {
144 A_UINT16 MessageID;
145 /* currently, no other fields */
146 } POSTPACK HTC_SETUP_COMPLETE_MSG;
147
148
149 /* connect response status codes */
150 #define HTC_SERVICE_SUCCESS 0 /* success */
151 #define HTC_SERVICE_NOT_FOUND 1 /* service could not be found */
152 #define HTC_SERVICE_FAILED 2 /* specific service failed the connect */
153 #define HTC_SERVICE_NO_RESOURCES 3 /* no resources (i.e. no more endpoints) */
154 #define HTC_SERVICE_NO_MORE_EP 4 /* specific service is not allowing any more
155 endpoints */
156
157 /* report record IDs */
158 typedef enum {
159 HTC_RECORD_NULL = 0,
160 HTC_RECORD_CREDITS = 1,
161 HTC_RECORD_LOOKAHEAD = 2,
162 } HTC_RPT_IDS;
163
164 typedef PREPACK struct {
165 A_UINT8 RecordID; /* Record ID */
166 A_UINT8 Length; /* Length of record */
167 } POSTPACK HTC_RECORD_HDR;
168
169 typedef PREPACK struct {
170 A_UINT8 EndpointID; /* Endpoint that owns these credits */
171 A_UINT8 Credits; /* credits to report since last report */
172 } POSTPACK HTC_CREDIT_REPORT;
173
174 typedef PREPACK struct {
175 A_UINT8 PreValid; /* pre valid guard */
176 A_UINT8 LookAhead[4]; /* 4 byte lookahead */
177 A_UINT8 PostValid; /* post valid guard */
178
179 /* NOTE: the LookAhead array is guarded by a PreValid and Post Valid guard bytes.
180 * The PreValid bytes must equal the inverse of the PostValid byte */
181
182 } POSTPACK HTC_LOOKAHEAD_REPORT;
183
184 #ifndef ATH_TARGET
185 #include "athendpack.h"
186 #endif
187
188
189 #endif /* __HTC_H__ */
190
This page took 0.053812 seconds and 5 git commands to generate.