From 7e882be15dde130810f30edfb5cb9bd640df870c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Babski?= Date: Tue, 23 Jan 2024 10:44:43 +0000 Subject: [PATCH 1/2] Fix in passthroughpacketizer to allow connection without destination port. --- src/Packetizer/PassthroughPacketizer.c | 2 +- src/RuntimeCommon/RoutingHelper.c | 15 +++++++++++++++ src/RuntimeCommon/RoutingHelper.h | 7 +++++++ src/RuntimeMocks/routing.c | 1 + src/RuntimeMocks/routing.h | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Packetizer/PassthroughPacketizer.c b/src/Packetizer/PassthroughPacketizer.c index c67276a..dd72ee4 100644 --- a/src/Packetizer/PassthroughPacketizer.c +++ b/src/Packetizer/PassthroughPacketizer.c @@ -38,7 +38,7 @@ PassthroughPacketizer_init(Packetizer* const self, const enum SystemBus busId, s *headerSize = 0; - if(bus_to_unique_port_map[busId] == INTERFACE_INVALID_ID) { + if(bus_to_unique_port_map[busId] == INTERFACE_INVALID_ID && bus_has_any_destination_port[busId] != 0) { // Passthrough Packetizer requires an unique interface on bus. abort(); } diff --git a/src/RuntimeCommon/RoutingHelper.c b/src/RuntimeCommon/RoutingHelper.c index 85ac4f0..5f7056a 100644 --- a/src/RuntimeCommon/RoutingHelper.c +++ b/src/RuntimeCommon/RoutingHelper.c @@ -44,3 +44,18 @@ find_unique_destination(const enum SystemBus bus) return (enum RemoteInterface)found_interface; } + +int +check_bus_has_any_destination_port(const enum SystemBus bus) +{ + size_t index; + int result = 0; + for(index = 0; index < INTERFACE_MAX_ID; ++index) { + if(port_to_partition_bus_map[index].partition != PARTITION_NAME + && port_to_partition_bus_map[index].bus == bus) { + result = 1; + } + } + + return result; +} diff --git a/src/RuntimeCommon/RoutingHelper.h b/src/RuntimeCommon/RoutingHelper.h index 66d7cca..0fbfd35 100644 --- a/src/RuntimeCommon/RoutingHelper.h +++ b/src/RuntimeCommon/RoutingHelper.h @@ -39,4 +39,11 @@ */ enum RemoteInterface find_unique_destination(const enum SystemBus bus); +/** @brief Check if bus has any destination port. + * + * @param[bus] system bus + * @return 0 if bus have not any destination port, otherwise non-zero value + */ +int check_bus_has_any_destination_port(const enum SystemBus bus); + #endif diff --git a/src/RuntimeMocks/routing.c b/src/RuntimeMocks/routing.c index 6e7a20c..eb22699 100644 --- a/src/RuntimeMocks/routing.c +++ b/src/RuntimeMocks/routing.c @@ -1,3 +1,4 @@ #include "routing.h" enum RemoteInterface bus_to_unique_port_map[] = { INTERFACE_INVALID_ID }; +int bus_has_any_destination_port[] = { 0 }; diff --git a/src/RuntimeMocks/routing.h b/src/RuntimeMocks/routing.h index 19e1255..8894a50 100644 --- a/src/RuntimeMocks/routing.h +++ b/src/RuntimeMocks/routing.h @@ -3,3 +3,4 @@ #define PARTITION_NAME X86_PARTITION extern enum RemoteInterface bus_to_unique_port_map[]; +extern int bus_has_any_destination_port[]; From cedddff9450fe637e9428780c22df33c40087071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Babski?= Date: Tue, 23 Jan 2024 11:45:46 +0000 Subject: [PATCH 2/2] RoutingHelper - docstring fix --- src/RuntimeCommon/RoutingHelper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RuntimeCommon/RoutingHelper.h b/src/RuntimeCommon/RoutingHelper.h index 0fbfd35..9514afe 100644 --- a/src/RuntimeCommon/RoutingHelper.h +++ b/src/RuntimeCommon/RoutingHelper.h @@ -42,7 +42,7 @@ enum RemoteInterface find_unique_destination(const enum SystemBus bus); /** @brief Check if bus has any destination port. * * @param[bus] system bus - * @return 0 if bus have not any destination port, otherwise non-zero value + * @return 0 if bus does not have any destination port, otherwise non-zero value */ int check_bus_has_any_destination_port(const enum SystemBus bus);