blob: 1b52470573c83cff3daa9eadf0ee256cb1b9ffba [file] [log] [blame]
Luis Farias9d66fca2020-05-28 19:01:58 -07001/******************************************************************************
2*
3* Copyright (c) 2019 Intel.
4*
5* Licensed under the Apache License, Version 2.0 (the "License");
6* you may not use this file except in compliance with the License.
7* You may obtain a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*
17*******************************************************************************/
18
19#ifndef __SYSLIB_H__
20#define __SYSLIB_H__
21
22typedef unsigned char U8; /* unsigned 8-bit integer */
23typedef unsigned short U16; /* unsigned 16-bit integer */
24typedef unsigned int U32; /* unsigned 32-bit integer */
25#ifdef __x86_64__
26typedef unsigned long U64; /* unsigned 64-bit integer */
27#else
28typedef unsigned long long U64; /* unsigned 64-bit integer */
29#endif
30
31typedef volatile unsigned char V8;
32typedef volatile unsigned short V16;
33typedef volatile unsigned int V32;
34typedef volatile unsigned long V4;
35
36typedef signed char S8; /* 8-bit signed integer */
37typedef signed short S16; /* 16-bit signed integer */
38typedef signed int S32; /* 32-bit signed integer */
39
40#ifdef __x86_64__
41typedef signed long S64; /* unsigned 64-bit integer */
42#else
43typedef signed long long S64; /* unsigned 64-bit integer */
44#endif
45
46#ifndef _PVOID_
47#define _PVOID_
48typedef void *PVOID;
49#endif
50
51typedef U64 (*wls_us_addr_conv)(void*, U64);
52
53
54#define K 1024
55#define M (K*K)
56#define KHZ 1000
57#define MHZ (KHZ * KHZ)
58
59#ifndef TRUE
60#define TRUE (1)
61#endif
62
63#ifndef FALSE
64#define FALSE (0)
65#endif
66
67#ifndef NULL
68#define NULL ((PVOID)(0))
69#endif
70#define HANDLE PVOID
71
72#ifdef __KERNEL__
73#define DSB() smp_mb()
74#define DMB() smp_wmb()
75#else
76#define DSB() __asm__ __volatile__("mfence": : :"memory")
77#define DMB() __asm__ __volatile__("sfence": : :"memory")
78#endif
79
80typedef struct tagWLS_MSG_HANDLE
81{
82 U64 pIaPaMsg;
83 U32 pWlsPaMsg;
84 U32 MsgSize;
85 U16 TypeID; // used to identify destination
86 U16 flags;
87 U32 res1;
88} WLS_MSG_HANDLE, *PWLS_MSG_HANDLE; /* 4 x QW */
89
90typedef struct tagFASTQUEUE {
91 U64 pStorage;
92 U32 BlockSize;
93 U32 sema;
94 V32 get;
95 V32 put;
96 U32 size;
97 U32 res;
98} FASTQUEUE, *PFASTQUEUE;
99
100typedef struct tagWLS_MSG_QUEUE {
101 U64 pStorage;
102 U32 sema;
103 V32 get;
104 V32 put;
105 U32 size;
106} WLS_MSG_QUEUE, *PWLS_MSG_QUEUE;
107
108#define COUNT(some_array) ( sizeof(some_array)/sizeof((some_array)[0]) )
109
110void SFL_DefQueue(PFASTQUEUE pq, void *pStorage, int StorageSize);
111int SFL_WlsEnqueue(PFASTQUEUE pq, U64 pData, wls_us_addr_conv change_addr, void* hWls);
112int SFL_Enqueue_NoSync(PFASTQUEUE pq, PVOID pData);
113U64 SFL_WlsDequeue(PFASTQUEUE pq, wls_us_addr_conv change_addr, void *hWls);
114
115PVOID SFL_Dequeue_NoSync(PFASTQUEUE pq);
116U32 SFL_Queue_BatchRead( PFASTQUEUE pq, unsigned long *pDestArr, U32 Count);
117U32 SFL_Queue_BatchWrite( PFASTQUEUE pq, unsigned long *pSrcArr, U32 Count);
118
119void WLS_MsgDefineQueue(PWLS_MSG_QUEUE pq, PWLS_MSG_HANDLE pStorage, U32 size, U32 sema);
120U32 WLS_MsgEnqueue(PWLS_MSG_QUEUE pq, U64 pIaPaMsg, U32 MsgSize, U16 TypeID, U16 flags, wls_us_addr_conv change_addr, void* h);
121int WLS_MsgDequeue(PWLS_MSG_QUEUE pq, PWLS_MSG_HANDLE pDestItem, wls_us_addr_conv change_addr, void *hWls);
122U32 WLS_GetNumItemsInTheQueue(PWLS_MSG_QUEUE fpq);
123U32 SFL_GetNumItemsInTheQueue(FASTQUEUE *fpq);
124
125
126
127
128
129#endif // __SYSLIB_H__
130
131