MLECO-3070: Further HAL cleanup.

Cleaning up HAL sources by removing unnecessary redirections
with function pointers. The "platform packages" under HAL are
now streamlined enough to not need any major HAL wrapping (as
was the case before).

This allows us to have a very thin HAL layer that sits on top
of the platform and compnent packs. Also helps in getting rid
of "hal platform" pointer being passed around in the code to
use any HAL functionality.

Change-Id: I04b2057f972aad7a5cfb4a396bcdf147c9f9ef1c
Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
diff --git a/tests/common/ProfilerTests.cc b/tests/common/ProfilerTests.cc
index 889e2f2..91ac973 100644
--- a/tests/common/ProfilerTests.cc
+++ b/tests/common/ProfilerTests.cc
@@ -25,22 +25,16 @@
 
 TEST_CASE("Common: Test Profiler")
 {
-    hal_platform    platform;
-    platform_timer  timer {};
+    hal_platform_init();
 
-    /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
-
-    /* An invalid profiler shouldn't be of much use */
-    SECTION("Test invalid profiler") {
-        arm::app::Profiler profilerInvalid{nullptr, "test_invalid"};
-        REQUIRE(false == profilerInvalid.StartProfiling());
-        REQUIRE(false == profilerInvalid.StopProfiling());
+    SECTION("Test default construction") {
+        arm::app::Profiler profiler{};
+        REQUIRE(true == profiler.StartProfiling());
+        REQUIRE(true == profiler.StopProfiling());
     }
 
     SECTION("Test valid profiler") {
-        arm::app::Profiler profilerValid{&platform, "test_valid"};
+        arm::app::Profiler profilerValid{"test_valid"};
         REQUIRE(true == profilerValid.StartProfiling());
         REQUIRE(true == profilerValid.StopProfiling());
         std::vector<arm::app::ProfileResult> results;
@@ -57,7 +51,7 @@
     }
 
     SECTION("Test multiple profilers") {
-        arm::app::Profiler profilerValid{&platform, "one"};
+        arm::app::Profiler profilerValid{"one"};
         REQUIRE(true == profilerValid.StartProfiling());
         REQUIRE(true == profilerValid.StopProfiling());
 
@@ -78,7 +72,7 @@
 #if defined (CPU_PROFILE_ENABLED)
     SECTION("Test CPU profiler") {
 
-        arm::app::Profiler profilerCPU{&platform, "test cpu"};
+        arm::app::Profiler profilerCPU{"test cpu"};
         std::vector<arm::app::ProfileResult> results;
         profilerCPU.StartProfiling();
         profilerCPU.StopProfiling();
diff --git a/tests/use_case/img_class/ImgClassificationUCTest.cc b/tests/use_case/img_class/ImgClassificationUCTest.cc
index 62d8eb8..b9caf61 100644
--- a/tests/use_case/img_class/ImgClassificationUCTest.cc
+++ b/tests/use_case/img_class/ImgClassificationUCTest.cc
@@ -43,12 +43,8 @@
 
 TEST_CASE("Inference by index", "[.]")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::MobileNetModel model;
@@ -59,9 +55,8 @@
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
 
-    arm::app::Profiler profiler{&platform, "img_class"};
+    arm::app::Profiler profiler{"img_class"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<uint32_t>("imgIndex", 0);
     arm::app::Classifier classifier;    /* Classifier wrapper object. */
@@ -81,12 +76,8 @@
 
 TEST_CASE("Inference run all images", "[.]")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::MobileNetModel model;
@@ -97,9 +88,8 @@
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
 
-    arm::app::Profiler profiler{&platform, "img_class"};
+    arm::app::Profiler profiler{"img_class"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<uint32_t>("imgIndex", 0);
     arm::app::Classifier classifier;    /* classifier wrapper object. */
@@ -115,12 +105,8 @@
 
 TEST_CASE("List all images")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::MobileNetModel model;
@@ -130,8 +116,6 @@
 
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
-
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
 
     REQUIRE(arm::app::ListFilesHandler(caseContext));
diff --git a/tests/use_case/kws/KWSHandlerTest.cc b/tests/use_case/kws/KWSHandlerTest.cc
index 3013611..d0a8a3f 100644
--- a/tests/use_case/kws/KWSHandlerTest.cc
+++ b/tests/use_case/kws/KWSHandlerTest.cc
@@ -43,12 +43,8 @@
 
 TEST_CASE("Inference by index")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::MicroNetKwsModel model;
@@ -59,9 +55,8 @@
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
 
-    arm::app::Profiler profiler{&platform, "kws"};
+    arm::app::Profiler profiler{"kws"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<int>("frameLength", g_FrameLength);  /* 640 sample length for MicroNetKws. */
     caseContext.Set<int>("frameStride", g_FrameStride);  /* 320 sample stride for MicroNetKws. */
@@ -120,12 +115,8 @@
 
 TEST_CASE("Inference run all clips")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::MicroNetKwsModel model;
@@ -136,9 +127,8 @@
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
 
-    arm::app::Profiler profiler{&platform, "kws"};
+    arm::app::Profiler profiler{"kws"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<uint32_t>("clipIndex", 0);
     caseContext.Set<int>("frameLength", g_FrameLength);  /* 640 sample length for MicroNet. */
@@ -156,12 +146,8 @@
 
 TEST_CASE("List all audio clips")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
-    /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+   /* Initialise the HAL and platform. */
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::MicroNetKwsModel model;
@@ -172,7 +158,6 @@
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
 
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
 
     REQUIRE(arm::app::ListFilesHandler(caseContext));
diff --git a/tests/use_case/noise_reduction/RNNNoiseUCTests.cc b/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
index a376dd5..cc1b4d7 100644
--- a/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
+++ b/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
@@ -24,17 +24,12 @@
 #include <hal.h>
 #include <Profiler.hpp>
 
-#define PLATFORM \
-hal_platform    platform; \
-platform_timer  timer;    \
-hal_init(&platform, &timer); \
-hal_platform_init(&platform);
+#define PLATFORM    hal_platform_init();
 
 #define CONTEXT \
 arm::app::ApplicationContext caseContext; \
-arm::app::Profiler profiler{&platform, "noise_reduction"}; \
+arm::app::Profiler profiler{"noise_reduction"}; \
 caseContext.Set<arm::app::Profiler&>("profiler", profiler); \
-caseContext.Set<hal_platform&>("platform", platform); \
 caseContext.Set<arm::app::RNNoiseModel&>("model", model);
 
 TEST_CASE("Verify output tensor memory dump")
diff --git a/tests/use_case/object_detection/ObjectDetectionUCTest.cc b/tests/use_case/object_detection/ObjectDetectionUCTest.cc
index 79e76bd..a7e4f33 100644
--- a/tests/use_case/object_detection/ObjectDetectionUCTest.cc
+++ b/tests/use_case/object_detection/ObjectDetectionUCTest.cc
@@ -42,12 +42,8 @@
 
 TEST_CASE("Inference by index")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::YoloFastestModel model;
@@ -58,9 +54,8 @@
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
 
-    arm::app::Profiler profiler{&platform, "object_detection"};
+    arm::app::Profiler profiler{"object_detection"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<uint32_t>("imgIndex", 0);
     arm::app::object_detection::DetectorPostprocessing postp;
@@ -72,12 +67,8 @@
 
 TEST_CASE("Inference run all images")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::YoloFastestModel model;
@@ -88,9 +79,8 @@
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
 
-    arm::app::Profiler profiler{&platform, "object_detection"};
+    arm::app::Profiler profiler{"object_detection"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<uint32_t>("imgIndex", 0);
     arm::app::object_detection::DetectorPostprocessing postp;
@@ -102,12 +92,8 @@
 
 TEST_CASE("List all images")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform. */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     /* Model wrapper object. */
     arm::app::YoloFastestModel model;
@@ -117,8 +103,6 @@
 
     /* Instantiate application context. */
     arm::app::ApplicationContext caseContext;
-
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
 
     REQUIRE(arm::app::ListFilesHandler(caseContext));
diff --git a/tests/use_case/vww/VisualWakeWordUCTests.cc b/tests/use_case/vww/VisualWakeWordUCTests.cc
index 16bd5a6..531764b 100644
--- a/tests/use_case/vww/VisualWakeWordUCTests.cc
+++ b/tests/use_case/vww/VisualWakeWordUCTests.cc
@@ -41,12 +41,7 @@
 
 TEST_CASE("Inference by index")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
-    /* Initialise the HAL and platform */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     arm::app::VisualWakeWordModel model;    /* model wrapper object */
 
@@ -55,9 +50,8 @@
 
     /* Instantiate application context */
     arm::app::ApplicationContext caseContext;
-    arm::app::Profiler profiler{&platform, "pd"};
+    arm::app::Profiler profiler{"pd"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<uint32_t>("imgIndex", 0);
     arm::app::Classifier classifier;    /* classifier wrapper object */
@@ -76,12 +70,8 @@
 
 TEST_CASE("Inference run all images")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     arm::app::VisualWakeWordModel model;    /* model wrapper object */
 
@@ -90,9 +80,8 @@
 
     /* Instantiate application context */
     arm::app::ApplicationContext caseContext;
-    arm::app::Profiler profiler{&platform, "pd"};
+    arm::app::Profiler profiler{"pd"};
     caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
     caseContext.Set<uint32_t>("imgIndex", 0);
     arm::app::Classifier classifier;    /* classifier wrapper object */
@@ -107,12 +96,8 @@
 
 TEST_CASE("List all images")
 {
-    hal_platform    platform;
-    platform_timer  timer;
-
     /* Initialise the HAL and platform */
-    hal_init(&platform, &timer);
-    hal_platform_init(&platform);
+    hal_platform_init();
 
     arm::app::VisualWakeWordModel model;    /* model wrapper object */
 
@@ -122,7 +107,6 @@
     /* Instantiate application context */
     arm::app::ApplicationContext caseContext;
 
-    caseContext.Set<hal_platform&>("platform", platform);
     caseContext.Set<arm::app::Model&>("model", model);
 
     REQUIRE(arm::app::ListFilesHandler(caseContext));