1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | #ifndef KHRN_CLIENT_CACHE_H |
28 | #define KHRN_CLIENT_CACHE_H |
29 | |
30 | //#define WORKAROUND_HW2551 // define to pad header structure to 32 bytes |
31 | |
32 | #include "interface/khronos/common/khrn_client_pointermap.h" |
33 | #include "interface/khronos/common/khrn_client.h" |
34 | |
35 | typedef struct CACHE_LINK_S { |
36 | struct CACHE_LINK_S *prev; |
37 | struct CACHE_LINK_S *next; |
38 | } CACHE_LINK_T; |
39 | |
40 | typedef struct { |
41 | CACHE_LINK_T link; |
42 | |
43 | int len; |
44 | int key; |
45 | |
46 | #ifdef WORKAROUND_HW2551 |
47 | uint8_t pad[16]; |
48 | #endif |
49 | |
50 | //on the server side |
51 | //we store a KHRN_INTERLOCK_T in the |
52 | //same space as this struct |
53 | uint8_t pad_for_interlock[24]; |
54 | |
55 | uint8_t data[1]; |
56 | } CACHE_ENTRY_T; |
57 | |
58 | typedef struct { |
59 | uint8_t *tree; |
60 | uint8_t *data; |
61 | |
62 | int client_depth; |
63 | int server_depth; |
64 | |
65 | CACHE_LINK_T start; |
66 | CACHE_LINK_T end; |
67 | |
68 | KHRN_POINTER_MAP_T map; |
69 | } KHRN_CACHE_T; |
70 | |
71 | #define CACHE_LOG2_BLOCK_SIZE 6 |
72 | #define CACHE_MAX_DEPTH 16 |
73 | |
74 | #define CACHE_SIG_ATTRIB_0 0 |
75 | #define CACHE_SIG_ATTRIB_1 1 |
76 | #define CACHE_SIG_ATTRIB_2 2 |
77 | #define CACHE_SIG_ATTRIB_3 3 |
78 | #define CACHE_SIG_ATTRIB_4 4 |
79 | #define CACHE_SIG_ATTRIB_5 5 |
80 | #define CACHE_SIG_ATTRIB_6 6 |
81 | #define CACHE_SIG_ATTRIB_7 7 |
82 | |
83 | #define CACHE_SIG_INDEX 8 |
84 | |
85 | extern int khrn_cache_init(KHRN_CACHE_T *cache); |
86 | extern void khrn_cache_term(KHRN_CACHE_T *cache); |
87 | |
88 | extern int khrn_cache_lookup(CLIENT_THREAD_STATE_T *thread, KHRN_CACHE_T *cache, const void *data, int len, int sig); |
89 | extern int khrn_cache_get_entries(KHRN_CACHE_T *cache); |
90 | |
91 | #endif |
92 | |
93 | |