Skip to content

Commit 961dfd1

Browse files
committed
auto_configure: add attributes of device global to autodiscovery string parsing
1 parent 1847ee9 commit 961dfd1

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

include/acl.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,25 @@ typedef class acl_device_program_info_t *acl_device_program_info;
496496
*/
497497
#define ACL_MEM_CAPABILITY_P2P (1 << 3)
498498

499+
typedef enum {
500+
ACL_DEVICE_GLOBAL_HOST_ACCESS_NONE,
501+
ACL_DEVICE_GLOBAL_HOST_ACCESS_READ_ONLY,
502+
ACL_DEVICE_GLOBAL_HOST_ACCESS_WRITE_ONLY,
503+
ACL_DEVICE_GLOBAL_HOST_ACCESS_READ_WRITE
504+
} acl_device_global_host_access_t;
505+
506+
typedef enum {
507+
ACL_DEVICE_GLOBAL_INIT_MODE_REPROGRAM,
508+
ACL_DEVICE_GLOBAL_INIT_MODE_RESET
509+
} acl_device_global_init_mode_t;
510+
499511
// Definition of device global.
500512
struct acl_device_global_mem_def_t {
501513
uint32_t address;
502514
uint32_t size;
515+
acl_device_global_host_access_t host_access;
516+
acl_device_global_init_mode_t init_mode;
517+
bool implement_in_csr;
503518
};
504519

505520
// Part of acl_device_def_t where members are populated from the information

src/acl_auto_configure.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,27 @@ static bool read_device_global_mem_defs(
474474
read_uint32_counters(config_str, curr_pos, dev_global_size, counters);
475475
}
476476

477-
acl_device_global_mem_def_t dev_global_def = {dev_global_addr,
478-
dev_global_size};
477+
// read device global properties
478+
auto host_access = 0U;
479+
if (result && counters.back() > 0) {
480+
result = read_uint_counters(config_str, curr_pos, host_access, counters);
481+
}
482+
auto init_mode = 0U;
483+
if (result && counters.back() > 0) {
484+
result = read_uint_counters(config_str, curr_pos, init_mode, counters);
485+
}
486+
unsigned int value = 0;
487+
bool implement_in_csr = false; // default to false
488+
if (result && counters.back() > 0) {
489+
result = read_uint_counters(config_str, curr_pos, value, counters);
490+
}
491+
implement_in_csr = value;
492+
493+
acl_device_global_mem_def_t dev_global_def = {
494+
dev_global_addr, dev_global_size,
495+
static_cast<acl_device_global_host_access_t>(host_access),
496+
static_cast<acl_device_global_init_mode_t>(init_mode),
497+
implement_in_csr};
479498
bool ok =
480499
device_global_mem_defs.insert({device_global_name, dev_global_def})
481500
.second;

test/acl_auto_configure_test.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TEST(auto_configure, simple) {
3636
#define VERSIONIDSTRINGIFY(x) #x
3737
#define VERSIONIDTOSTR(x) VERSIONIDSTRINGIFY(x)
3838
#define DEVICE_FIELDS " 23"
39-
#define DEVICE_FIELDS_DEV_GLOBAL " 30"
39+
#define DEVICE_FIELDS_DEV_GLOBAL " 36"
4040
#define DEVICE_FIELDS_OLD " 18"
4141
#define BOARDNAME "de4_gen2x4_swdimm"
4242
#define BOARDNAME2 "pcie385_a7"
@@ -99,10 +99,11 @@ TEST(auto_configure, simple) {
9999

100100
// Device global autodiscovery entries
101101
#define NUM_DEV_GLOBAL " 2"
102-
#define NUM_DEV_GLOBAL_FIELD " 3" // containing dev_globa_name, address, size
103-
#define DEV_GLOBAL_1 \
104-
" kernel15_dev_global 4096 2048" // in format of dev_globa_name, address, size
105-
#define DEV_GLOBAL_2 " kernel15_dev_global2 2048 1024"
102+
#define NUM_DEV_GLOBAL_FIELD \
103+
" 6" // contains dev_globa_name, address, size, host_access, init_mode,
104+
// implement_in_csr with the above format
105+
#define DEV_GLOBAL_1 " kernel15_dev_global 4096 2048 0 1 0"
106+
#define DEV_GLOBAL_2 " kernel15_dev_global2 2048 1024 2 0 1"
106107

107108
int parsed;
108109
std::string err_str;
@@ -283,8 +284,18 @@ TEST(auto_configure, simple) {
283284
m_device_def.autodiscovery_def.device_global_mem_defs.end());
284285
CHECK_EQUAL(4096, kernel15_dev_global->second.address);
285286
CHECK_EQUAL(2048, kernel15_dev_global->second.size);
287+
CHECK_EQUAL((acl_device_global_host_access_t)0,
288+
kernel15_dev_global->second.host_access);
289+
CHECK_EQUAL((acl_device_global_init_mode_t)1,
290+
kernel15_dev_global->second.init_mode);
291+
CHECK_EQUAL(false, kernel15_dev_global->second.implement_in_csr);
286292
CHECK_EQUAL(2048, kernel15_dev_global2->second.address);
287293
CHECK_EQUAL(1024, kernel15_dev_global2->second.size);
294+
CHECK_EQUAL((acl_device_global_host_access_t)2,
295+
kernel15_dev_global2->second.host_access);
296+
CHECK_EQUAL((acl_device_global_init_mode_t)0,
297+
kernel15_dev_global2->second.init_mode);
298+
CHECK_EQUAL(true, kernel15_dev_global2->second.implement_in_csr);
288299

289300
// Check a second parsing.
290301
// It should allocate a new string for the name.

0 commit comments

Comments
 (0)