@@ -198,6 +198,36 @@ static bool read_ulonglong_counters(const std::string &str,
198
198
return true ;
199
199
}
200
200
201
+ // Reads the next word in str and converts it into a uintptr_t.
202
+ // Returns true if a valid integer was read or false if an error occurred.
203
+ // pos is updated to the position immediately following the parsed word
204
+ // even if an error occurs.
205
+ static bool read_uintptr_counters (const std::string &str,
206
+ std::string::size_type &pos, uintptr_t &val,
207
+ std::vector<int > &counters) noexcept {
208
+ std::string result;
209
+ pos = read_word (str, pos, result);
210
+ decrement_section_counters (counters);
211
+
212
+ size_t end = 0 ;
213
+ unsigned long long parsed;
214
+ try {
215
+ parsed = std::stoull (result, &end);
216
+ } catch (const std::exception &) {
217
+ return false ;
218
+ }
219
+ if (end != result.size ()) {
220
+ return false ;
221
+ }
222
+
223
+ val = static_cast <uintptr_t >(parsed);
224
+ if (val != parsed) {
225
+ return false ;
226
+ }
227
+
228
+ return true ;
229
+ }
230
+
201
231
// Reads the next word in str and converts it into an unsigned or using its
202
232
// default value. Returns true if a valid integer was read or false if an error
203
233
// occurred. pos is updated to the position immediately following the parsed
@@ -593,6 +623,44 @@ static bool read_streaming_kernel_arg_info(
593
623
result = read_string_counters (config_str, curr_pos,
594
624
streaming_arg_info.interface_name , counters);
595
625
}
626
+ return result;
627
+ }
628
+
629
+ static bool read_hostpipe_mappings (
630
+ const std::string &config_str, std::string::size_type &curr_pos,
631
+ std::vector<acl_hostpipe_mapping> &hostpipe_mappings,
632
+ std::vector<int > &counters, std::string &err_str) noexcept {
633
+ unsigned int num_mappings = 0 ;
634
+ bool result =
635
+ read_uint_counters (config_str, curr_pos, num_mappings, counters);
636
+
637
+ unsigned int num_fields_per_mapping = 0 ;
638
+ if (result) {
639
+ result = read_uint_counters (config_str, curr_pos, num_fields_per_mapping,
640
+ counters);
641
+ }
642
+
643
+ for (unsigned int i = 0 ; result && (i < num_mappings); i++) {
644
+ counters.emplace_back (num_fields_per_mapping);
645
+
646
+ acl_hostpipe_mapping mapping{};
647
+ result = read_string_counters (config_str, curr_pos, mapping.logical_name ,
648
+ counters) &&
649
+ read_string_counters (config_str, curr_pos, mapping.physical_name ,
650
+ counters) &&
651
+ read_bool_counters (config_str, curr_pos, mapping.implement_in_csr ,
652
+ counters) &&
653
+ read_uintptr_counters (config_str, curr_pos, mapping.csr_address ,
654
+ counters);
655
+ hostpipe_mappings.emplace_back (mapping);
656
+
657
+ while (result && counters.back () > 0 ) {
658
+ std::string tmp;
659
+ result = read_string_counters (config_str, curr_pos, tmp, counters);
660
+ }
661
+ check_section_counters (counters);
662
+ counters.pop_back ();
663
+ }
596
664
597
665
return result;
598
666
}
@@ -1129,6 +1197,11 @@ bool acl_load_device_def_from_str(const std::string &config_str,
1129
1197
if (result && counters.back () > 0 ) {
1130
1198
result = read_bool_counters (config_str, curr_pos,
1131
1199
devdef.cra_ring_root_exist , counters);
1200
+
1201
+ // Read program scoped hostpipes mappings
1202
+ if (result && counters.back () > 0 ) {
1203
+ result = read_hostpipe_mappings (
1204
+ config_str, curr_pos, devdef.hostpipe_mappings , counters, err_str);
1132
1205
}
1133
1206
1134
1207
// forward compatibility: bypassing remaining fields at the end of device
0 commit comments