Define DEBUG in debug builds
Also convert logging to use driver logging so it ignores the more
verbose logs that are now generated.
Change-Id: I65cb14b53a0e7d2da0034c23908a6713233d81e4
diff --git a/BUILD.gn b/BUILD.gn
index 4a255de..1904338 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -142,6 +142,10 @@
# According to Imagination, the kernel-esque driver should define this.
defines = [ "__KERNEL__" ]
+ if (is_debug) {
+ defines += [ "DEBUG" ]
+ }
+
cflags = [
"-include",
rebase_path("include/config_kernel_fuchsia_mt8167.h", root_build_dir),
diff --git a/services/server/env/fuchsia/osfunc.cc b/services/server/env/fuchsia/osfunc.cc
index 61df3fb..a76503a 100644
--- a/services/server/env/fuchsia/osfunc.cc
+++ b/services/server/env/fuchsia/osfunc.cc
@@ -418,8 +418,7 @@
IMG_CHAR *
OSGetCurrentProcessName(void)
{
- NOT_IMPLEMENTED();
- return 0;
+ return OSGetCurrentClientProcessNameKM();
}
uintptr_t
@@ -440,12 +439,14 @@
return connection->client_id();
}
-
IMG_CHAR *
OSGetCurrentClientProcessNameKM(void)
{
+ static char msd_name[] = "MSD";
MsdImgConnection *connection = MsdImgConnection::GetCurrentConnection();
- return connection->client_name();
+ // If there's no connection the current action is on the behalf of the
+ // MSD.
+ return connection ? connection->client_name() : msd_name;
}
uintptr_t
diff --git a/services/server/env/fuchsia/pvr_debug.cc b/services/server/env/fuchsia/pvr_debug.cc
index d6ac0c7..e781ba0 100644
--- a/services/server/env/fuchsia/pvr_debug.cc
+++ b/services/server/env/fuchsia/pvr_debug.cc
@@ -32,6 +32,8 @@
#include <stdarg.h>
#include <stdlib.h>
+#include <ddk/debug.h>
+
extern "C" {
#include "pvrversion.h"
#include "img_types.h"
@@ -52,8 +54,9 @@
{
va_list vl;
va_start(vl, pszFormat);
- vfprintf(stderr, pszFormat, vl);
- fprintf(stderr, "\n");
+ char data[512];
+ vsnprintf(data, sizeof(data), pszFormat, vl);
+ zxlogf(INFO, "msd-img-rgx-mtk: %s\n", data);
va_end(vl);
}
@@ -68,7 +71,12 @@
void
PVRSRVTrace(const IMG_CHAR *pszFormat, ...)
{
- NOT_IMPLEMENTED();
+ va_list vl;
+ va_start(vl, pszFormat);
+ char data[512];
+ vsnprintf(data, sizeof(data), pszFormat, vl);
+ zxlogf(TRACE, "msd-img-rgx-mtk: %s\n", data);
+ va_end(vl);
}
#endif /* defined(PVRSRV_NEED_PVR_TRACE) */
@@ -92,12 +100,29 @@
const IMG_CHAR *pszFormat,
...)
{
- va_list vl;
- va_start(vl, pszFormat);
- fprintf(stderr, "Error at %s:%d - ", pszFullFileName, ui32Line);
- vfprintf(stderr, pszFormat, vl);
- fprintf(stderr, "\n");
- va_end(vl);
+ uint32_t log_level;
+ if (ui32DebugLevel & (DBGPRIV_FATAL | DBGPRIV_ERROR))
+ {
+ log_level = DDK_LOG_ERROR;
+ }
+ else if (ui32DebugLevel & DBGPRIV_WARNING)
+ {
+ log_level = DDK_LOG_WARN;
+ }
+ else
+ {
+ log_level = DDK_LOG_TRACE;
+ }
+
+ if (zxlog_level_enabled_etc(log_level))
+ {
+ va_list vl;
+ va_start(vl, pszFormat);
+ char data[512];
+ vsnprintf(data, sizeof(data), pszFormat, vl);
+ driver_printf(log_level, "msd-img-rgx-mtk at %s:%d - %s\n", pszFullFileName, ui32Line, data);
+ va_end(vl);
+ }
}
IMG_EXPORT void IMG_CALLCONV __noreturn