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/source/profiler/Profiler.cc b/source/profiler/Profiler.cc
index 7e10097..64edcf2 100644
--- a/source/profiler/Profiler.cc
+++ b/source/profiler/Profiler.cc
@@ -21,28 +21,27 @@
 
 namespace arm {
 namespace app {
-    Profiler::Profiler(hal_platform* platform, const char* name = "Unknown")
-    : m_name(name)
-    {
-        if (platform && platform->inited) {
-            this->m_pPlatform = platform;
-            this->Reset();
-        } else {
-            printf_err("Profiler %s initialised with invalid platform\n",
-                this->m_name.c_str());
-        }
-    }
+    Profiler::Profiler()
+        : Profiler("Unknown")
+    {}
+
+    Profiler::Profiler(const char* name)
+        : m_name(name)
+    {}
 
     bool Profiler::StartProfiling(const char* name)
     {
         if (name) {
             this->SetName(name);
         }
-        if (this->m_pPlatform && !this->m_started) {
-            this->m_pPlatform->timer->reset();
-            this->m_tstampSt = this->m_pPlatform->timer->get_counters();
-            this->m_started = true;
-            return true;
+        if (!this->m_started) {
+            hal_pmu_reset();
+            this->m_tstampSt.initialised = false;
+            hal_pmu_get_counters(&this->m_tstampSt);
+            if (this->m_tstampSt.initialised) {
+                this->m_started = true;
+                return true;
+            }
         }
         printf_err("Failed to start profiler %s\n", this->m_name.c_str());
         return false;
@@ -50,13 +49,17 @@
 
     bool Profiler::StopProfiling()
     {
-        if (this->m_pPlatform && this->m_started) {
-            this->m_tstampEnd = this->m_pPlatform->timer->get_counters();
+        if (this->m_started) {
+            this->m_tstampEnd.initialised = false;
+            hal_pmu_get_counters(&this->m_tstampEnd);
             this->m_started = false;
-
-            this->AddProfilingUnit(this->m_tstampSt, this->m_tstampEnd, this->m_name);
-
-            return true;
+            if (this->m_tstampEnd.initialised) {
+                this->AddProfilingUnit(
+                    this->m_tstampSt,
+                    this->m_tstampEnd,
+                    this->m_name);
+                return true;
+            }
         }
         printf_err("Failed to stop profiler %s\n", this->m_name.c_str());
         return false;
@@ -160,11 +163,6 @@
     void Profiler::AddProfilingUnit(pmu_counters start, pmu_counters end,
                                     const std::string& name)
     {
-        if (!this->m_pPlatform) {
-            printf_err("Invalid platform\n");
-            return;
-        }
-
         struct ProfilingUnit unit = {
             .counters = end
         };