Skip to content

Commit edfcbef

Browse files
WDC overlay manager code (#16)
* add comrv code * remove output directory and *.pyc * remove .sconsign.dblite * support build from riscv repo, and from infra repo * Update README.md Co-authored-by: ofer shinaar <ofer.shinaar@wdc.com> Co-authored-by: oferShinaar <40337637+oferShinaar@users.noreply.github.com>
1 parent e2f5872 commit edfcbef

File tree

16 files changed

+3795
-0
lines changed

16 files changed

+3795
-0
lines changed

comrv/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# Overlay Run-Time engine code
3+
4+
This directory includes the RT-Engine source code, implemented according to the [HLD](https://github.com/riscv/riscv-overlay/blob/master/docs/overlay-hld.adoc)
5+
Following are instructions for building it.
6+
7+
8+
# Prerequisites
9+
10+
- Install scons build system (for Debian OS)
11+
```
12+
$ sudo apt-get install scons
13+
```
14+
- Toolchain
15+
- You can download the latest LLVM toolchain (executables) here: [LLVM-Debian download link](https://wdc.box.com/s/hqign6gmlzojoxevbzv5xi62li3igple)
16+
- The toolchain build includes `binutils-gdb` changes needed for the Overlay engine build/link and support.
17+
- Alternatively you can build it yourself, please check section [Build overlay toolchain](#Build-overlay-toolchain)
18+
19+
20+
# Configure comrv build
21+
22+
Comrv has compile-switch flags to disable/enable features in the RT engine.
23+
To change these flags open the file ```./build/SConstruct``` and comment/uncomment relevant comrv features under ```Env['PUBLIC_DEF']```
24+
25+
# Build comrv library
26+
$ cd build
27+
$ scons llvmpath=<path-to-overlay-llvm-installed-directory> gccpath=<path-to-overlay-gcc-installed-directory>
28+
29+
# Build overlay toolchain
30+
- The active development repo can be found in this link [llvm-project](https://github.com/westerndigitalcorporation/llvm-project/tree/comrv)
31+
Follow instructions to build llvm with Overlay support.
32+
- You will need to build `binutils-gdb` as well to be used for link and debug.
33+
It's advised to build the entry GNU toolchain from this link [riscv-gnu-toolchain](https://github.com/westerndigitalcorporation/riscv-gnu-toolchain/tree/comrv-devel)
34+
35+
Build description:
36+
```
37+
url=https://github.com/westerndigitalcorporation/riscv-gnu-toolchain.git
38+
branch=comrv-devel
39+
hash=f456f6d03fe702d6190a63d035566a935fba95db
40+
```

comrv/api_inc/comrv_api.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright 2019-2021 Western Digital Corporation or its affiliates.
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+
* @file comrv_api.h
19+
* @author Ronen Haen
20+
* @date 11.06.2019
21+
* @brief The file defines the COM-RV interfaces
22+
*/
23+
#ifndef __COMRV_TASK_API_H__
24+
#define __COMRV_TASK_API_H__
25+
26+
#ifndef __clang__
27+
#error comrv can compile only with llvm
28+
#endif // #ifndef __clang__
29+
30+
/**
31+
* include files
32+
*/
33+
#include "comrv_types.h"
34+
35+
/**
36+
* definitions
37+
*/
38+
39+
/**
40+
* macros
41+
*/
42+
43+
/**
44+
* types
45+
*/
46+
47+
/**
48+
* local prototypes
49+
*/
50+
51+
/**
52+
* external prototypes
53+
*/
54+
55+
/**
56+
* global variables
57+
*/
58+
59+
/**
60+
* APIs
61+
*/
62+
void comrvEnable(void);
63+
void comrvDisable(void);
64+
void comrvLoadTables(void);
65+
const comrvCB_t* comrvGetDatabase(void);
66+
void comrvDataOverlayRelease(const void* pToken);
67+
void comrvReset(comrvResetType_t eResetType);
68+
void comrvInit(comrvInitArgs_t* pInitParams);
69+
void comrvConfigureLoadOperation(u08_t ucEnable);
70+
void comrvGetStatus(comrvStatus_t* pComrvStatus);
71+
D_COMRV_NO_INLINE u32_t comrvInitApplicationStack(void);
72+
const void* comrvDataOverlayAllocation(const void* pToken);
73+
u32_t comrvLockUnlockOverlayGroupByFunction(const void* pAddress, comrvLockState_t eLockState);
74+
#ifdef D_COMRV_RTOS_SUPPORT
75+
u32_t* comrvSaveContextSwitch(volatile u32_t* pMepc, volatile u32_t* pRegisterT3,
76+
comrvTaskStackRegsVal_t** pComrvTaskStackRegs);
77+
#endif /* D_COMRV_RTOS_SUPPORT */
78+
79+
#endif /* __COMRV_TASK_API_H__ */

comrv/api_inc/comrv_base_types.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright 2019-2021 Western Digital Corporation or its affiliates.
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+
* @file comrv_defines.h
19+
* @author Ronen Haen
20+
* @date 11.06.2019
21+
* @brief This file provides COM-RV defines
22+
*
23+
*/
24+
#ifndef __COMRV_BASE_TYPES__
25+
#define __COMRV_BASE_TYPES__
26+
27+
/**
28+
* include files
29+
*/
30+
31+
/**
32+
* types
33+
*/
34+
typedef signed char s08_t;
35+
typedef signed short s16_t;
36+
typedef signed int s32_t;
37+
typedef signed long long s64_t;
38+
typedef unsigned char u08_t;
39+
typedef unsigned short u16_t;
40+
typedef unsigned int u32_t;
41+
typedef unsigned long long u64_t;
42+
43+
#endif /* __COMRV_BASE_TYPES__ */

comrv/api_inc/comrv_config.h

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright 2019-2021 Western Digital Corporation or its affiliates.
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+
* @file comrv_config.h
19+
* @author Ronen Haen
20+
* @date 11.06.2019
21+
* @brief The file defines the COM-RV configuration
22+
*/
23+
#ifndef __COMRV_CONFIG_H__
24+
#define __COMRV_CONFIG_H__
25+
26+
/**
27+
* include files
28+
*/
29+
30+
/**
31+
* definitions
32+
*/
33+
/* specify eviction policy */
34+
//#define D_COMRV_EVICTION_POLICY=1
35+
36+
/* enable multi-group support */
37+
#ifdef D_COMRV_ENABLE_MULTI_GROUP_SUPPORT
38+
#define D_COMRV_MULTI_GROUP_SUPPORT
39+
/* this will use upto 2^8 -1 multi groups; if not defined,
40+
the maximum number of groups will be used (2^16 - 1) */
41+
#ifdef D_COMRV_ENABLE_MIN_NUM_OF_MULTI_GROUP_SUPPORT
42+
#define D_COMRV_MIN_NUM_OF_MULTI_GROUPS
43+
#endif /* D_COMRV_ENABLE_MAX_MULTI_GROUP_SIZE_SUPPORT */
44+
#endif /* D_COMRV_USE_MULTI_GROUP_SUPPORT */
45+
46+
/* enable instrumentation */
47+
#ifdef D_COMRV_ENABLE_FW_INSTRUMENTATION_SUPPORT
48+
#define D_COMRV_FW_INSTRUMENTATION
49+
#endif /* D_COMRV_ENABLE_FW_INSTRUMENTATION_SUPPORT */
50+
51+
#ifdef D_COMRV_ALLOW_CALLS_AFTER_SEARCH_LOAD_SUPPORT
52+
/* Mark we allow non comrv function calls after search and load
53+
indication - applies only for rtos support to handle
54+
cases where we get a context switch during calls to such functions */
55+
#define D_COMRV_ALLOW_CALLS_AFTER_SEARCH_LOAD
56+
#endif /* D_COMRV_ENABLE_FW_INSTRUMENTATION_NON_ATOMIC_SUPPORT */
57+
58+
/* enable init vars run time validation */
59+
#ifdef D_COMRV_ENABLE_VERIFY_INIT_ARGS_SUPPORT
60+
#define D_COMRV_VERIFY_INIT_ARGS
61+
#endif /* D_COMRV_ENABLE_VERIFY_INIT_ARGS_SUPPORT */
62+
63+
/* enable overlay data usage */
64+
#ifdef D_COMRV_ENABLE_OVL_DATA_SUPPORT
65+
#define D_COMRV_OVL_DATA_SUPPORT
66+
#endif /* D_COMRV_ENABLE_OVL_DATA_SUPPORT */
67+
68+
/* enable CRC */
69+
#ifdef D_COMRV_ENABLE_CRC_SUPPORT
70+
#define D_COMRV_CRC
71+
#endif /* D_COMRV_ENABLE_CRC_SUPPORT */
72+
73+
#ifdef D_COMRV_ENABLE_DEBUG_SUPPORT
74+
#define D_COMRV_DEBUG
75+
#endif /* D_COMRV_ENABLE_DEBUG_SUPPORT */
76+
77+
/* enable the ability to enable/disable comrv */
78+
#ifdef D_COMRV_ENABLE_CONTROL_SUPPORT
79+
#define D_COMRV_CONTROL_SUPPORT
80+
#endif /* D_COMRV_ENABLE_CONTROL_SUPPORT */
81+
82+
/* enable comrv error notifications */
83+
#ifdef D_COMRV_ENABLE_ERROR_NOTIFICATIONS
84+
#define D_COMRV_ERROR_NOTIFICATIONS
85+
#endif /* M_COMRV_ENABLE_ERROR_NOTIFICATIONS */
86+
87+
/* enable rtos support */
88+
#ifdef D_COMRV_ENABLE_RTOS_SUPPORT
89+
#define D_COMRV_RTOS_SUPPORT
90+
#endif /* D_COMRV_ENABLE_RTOS_SUPPORT */
91+
92+
/* enable comrv asserts */
93+
#ifdef D_COMRV_ENABLE_ASSERT_SUPPORT
94+
#define D_COMRV_ASSERT_ENABLED
95+
#endif /* D_COMRV_ENABLE_ASSERT_SUPPORT */
96+
97+
/* minimum size of an overlay group */
98+
#if D_COMRV_MIN_GROUP_SIZE_IN_BYTES > 0
99+
#if D_COMRV_MIN_GROUP_SIZE_IN_BYTES < 512
100+
#error "unsupported size D_COMRV_MIN_GROUP_SIZE_IN_BYTES provided"
101+
#endif /* D_COMRV_MIN_GROUP_SIZE_IN_BYTES < 512 */
102+
#define D_COMRV_OVL_GROUP_SIZE_MIN D_COMRV_MIN_GROUP_SIZE_IN_BYTES
103+
#else
104+
#define D_COMRV_OVL_GROUP_SIZE_MIN 512
105+
#endif /* D_COMRV_MIN_GROUP_SIZE_IN_BYTES */
106+
107+
/* maximum size of an overlay group */
108+
#if D_COMRV_MAX_GROUP_SIZE_IN_BYTES > 0
109+
#if D_COMRV_MAX_GROUP_SIZE_IN_BYTES > 4096
110+
#error "unsupported size D_COMRV_MAX_GROUP_SIZE_IN_BYTES provided"
111+
#endif /* D_COMRV_MAX_GROUP_SIZE_IN_BYTES > 4096 */
112+
#define D_COMRV_OVL_GROUP_SIZE_MAX D_COMRV_MAX_GROUP_SIZE_IN_BYTES
113+
#else
114+
#define D_COMRV_OVL_GROUP_SIZE_MAX 4096
115+
#endif /* D_COMRV_MAX_GROUP_SIZE_IN_BYTES */
116+
117+
/* maximum number of overlay calls depth within the
118+
entire application; if the application contains several tasks
119+
this define must cover the max number at any given time */
120+
#if D_COMRV_MAX_CALL_STACK_DEPTH > 0
121+
#define D_COMRV_CALL_STACK_DEPTH D_COMRV_MAX_CALL_STACK_DEPTH
122+
#else
123+
#define D_COMRV_CALL_STACK_DEPTH 10
124+
#endif /* D_COMRV_MAX_CALL_STACK_DEPTH */
125+
126+
/* size of the overlay cache - the size of the RAM provided
127+
for loading and executing the overlay groups; granularity
128+
expressed in bytes */
129+
#if D_COMRV_MAX_OVL_CACHE_SIZE_IN_BYTES > 0
130+
#define D_COMRV_OVL_CACHE_SIZE_IN_BYTES D_COMRV_MAX_OVL_CACHE_SIZE_IN_BYTES
131+
#else
132+
#define D_COMRV_OVL_CACHE_SIZE_IN_BYTES 1536
133+
#endif /* D_COMRV_MAX_OVL_CACHE_SIZE_IN_BYTES */
134+
135+
/* eviction algorithm definition */
136+
#if (D_COMRV_EVICTION_POLICY == 0)
137+
#ifndef D_COMRV_EVICTION_POLICY
138+
/* can be that D_COMRV_EVICTION_POLICY wasn't defined - same as if it was
139+
set to 0 so set it to 1 - 0 and 1 are the same - lru */
140+
#define D_COMRV_EVICTION_POLICY 1
141+
#endif /* D_COMRV_EVICTION_POLICY */
142+
#define D_COMRV_EVICTION_LRU
143+
#elif (D_COMRV_EVICTION_POLICY == 1)
144+
#define D_COMRV_EVICTION_LRU
145+
#elif (D_COMRV_EVICTION_POLICY == 2)
146+
#define D_COMRV_EVICTION_LFU
147+
#elif (D_COMRV_EVICTION_POLICY == 3)
148+
#define D_COMRV_EVICTION_MIX_LRU_LFU
149+
#endif /* */
150+
151+
#ifdef D_COMRV_ENABLE_LOAD_CONFIG_SUPPORT
152+
#define D_COMRV_LOAD_CONFIG_SUPPORT
153+
#endif /* D_COMRV_ENABLE_LOAD_CONFIG_SUPPORT */
154+
155+
156+
#ifdef D_COMRV_ENABLE_OVL_DATA_SUPPORT
157+
#define D_COMRV_OVL_DATA_SUPPORT
158+
#endif /* D_COMRV_ENABLE_LOAD_CONFIG_SUPPORT */
159+
160+
#ifdef D_COMRV_ENABLE_CODE_SIZE
161+
#define D_COMRV_CODE_SIZE_SUPPORT
162+
#endif /* D_COMRV_ENABLE_CODE_SIZE */
163+
164+
#endif /* __COMRV_CONFIG_H__ */
165+

0 commit comments

Comments
 (0)