From 2b3950912fde9dab1d051e100249d66e204f883b Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Tue, 30 Jan 2024 13:33:21 +0000 Subject: [PATCH 1/3] add submitter info to log from config file --- src/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.c b/src/main.c index 226fa6c..00ad4f4 100644 --- a/src/main.c +++ b/src/main.c @@ -26,6 +26,8 @@ static void init_default_values() output_video = TRUE; } +static char *submitter = NULL; + int load_conf_file(char *file_path) { print("Trying to open config file: %s", file_path); @@ -83,6 +85,12 @@ int load_conf_file(char *file_path) if (strcmp("disable-video", current_key) == 0) { output_video = !strtoul(strtok(NULL, "\n"), NULL, 16); } + if (strcmp("submitter", current_key) == 0) { + char *value = strtok(NULL, "\n"); + size_t length = strlen(value); + submitter = calloc(length + 1, sizeof(char)); + strncpy(submitter, value, length); + } } free(buffer); @@ -133,6 +141,11 @@ void main(void) print("Kernel Test Suite"); print("build: " GIT_VERSION); + print("submitter: %s", (submitter ? submitter : "")); + if (submitter) { + free(submitter); + submitter = NULL; + } run_tests(); vector_free(&tests_to_run); From 03ae7c91d08d3d7125f74c2fc952970648114c61 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Thu, 1 Feb 2024 13:44:49 +0000 Subject: [PATCH 2/3] add kernel version and hardware info --- src/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.c b/src/main.c index 00ad4f4..d3f75d2 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ #include #include +#include "util/hardware.h" #include "util/output.h" #include "util/misc.h" #include "util/vector.h" @@ -146,6 +147,15 @@ void main(void) free(submitter); submitter = NULL; } + print("kernel: %hu.%hu.%hu.%hu", + XboxKrnlVersion.Major, + XboxKrnlVersion.Minor, + XboxKrnlVersion.Build, + XboxKrnlVersion.Qfe); + print("hardware info: flags = 0x%08X, GPU rev = %hhu, MCPX rev = %hhu", + XboxHardwareInfo.Flags, + XboxHardwareInfo.GpuRevision, + XboxHardwareInfo.McpRevision); run_tests(); vector_free(&tests_to_run); From 5405dc31a4217c97c4f5c310998b12e425b7c722 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Thu, 1 Feb 2024 13:49:02 +0000 Subject: [PATCH 3/3] add pic version with console type prediction --- src/main.c | 3 ++ src/util/hardware.h | 77 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/util/hardware.h diff --git a/src/main.c b/src/main.c index d3f75d2..a11752c 100644 --- a/src/main.c +++ b/src/main.c @@ -156,6 +156,9 @@ void main(void) XboxHardwareInfo.Flags, XboxHardwareInfo.GpuRevision, XboxHardwareInfo.McpRevision); + char pic_version[4]; + getPICVersion(pic_version); + print("PIC version: %s (%s)", pic_version, getConsoleType(pic_version)); run_tests(); vector_free(&tests_to_run); diff --git a/src/util/hardware.h b/src/util/hardware.h new file mode 100644 index 0000000..768858f --- /dev/null +++ b/src/util/hardware.h @@ -0,0 +1,77 @@ +// SPDX-FileCopyrightText: none +// SPDX-License-Identifier: CC0-1.0 +#pragma once + +#include +#include +#include + +#include "util/output.h" + +static inline uint32_t inl(uint16_t port) +{ + uint32_t ret; + __asm__ __volatile__("inl %w1, %0" + : "=a"(ret) + : "Nd"(port)); + return ret; +} + +static void getPICVersion(char pic_version[4]) +{ + ULONG version; + HalWriteSMBusValue(0x20, 0x01, FALSE, 0); // reset index to 0 for reading + for (unsigned i = 0; i < 3; i++) { + HalReadSMBusValue(0x20, 0x01, 0, &version); + pic_version[i] = (char)version; + } + pic_version[3] = '\0'; +} + +static const char* getConsoleType(char pic_version[4]) +{ + // See https://xboxdevwiki.net/Xboxen_Info + if (pic_version[0] == 'A') { + return "PROTOTYPE (UNKNOWN)"; + } + else if (pic_version[0] == 'D' || pic_version[0] == 'B') { + if (XboxHardwareInfo.Flags & XBOX_HW_FLAG_DEVKIT_KERNEL) { + return "DEVKIT or DEBUGKIT"; + } + if (XboxHardwareInfo.Flags & XBOX_HW_FLAG_ARCADE) { + // Base on Cxbx-Reloaded's chihiro lpc reader function. + uint32_t type = inl(0x40F0); // Media Board Type reader + if (type == 0x0000) { + return "CHIHIRO (Type-1)"; + } + else if (type == 0x0100) { + return "CHIHIRO (Type-3)"; + } + + print("ERROR: Unknown return type from chihiro hardware: %08X", type); + return "CHIHIRO (UNKNOWN)"; + } + } + else if (pic_version[0] == 'P') { + if (strcmp(pic_version + 1, "01") == 0) { + return "Retail 1.0"; + } + if (strcmp(pic_version + 1, "05") == 0) { + return "Retail 1.1"; + } + if (strcmp(pic_version + 1, "11") == 0) { + // NOTE: 0xD4 is Focus (1.4) video encoder software address. + ULONG dummy_storage; + if (HalReadSMBusValue(0xD4, 0x00, 0, &dummy_storage) == STATUS_SUCCESS) { + return "Retail 1.4"; + } + // TODO: Find out how to tell the difference between 1.2 and 1.3 revisions... + return "Retail 1.2 or 1.3"; + } + if (strcmp(pic_version + 1, "2L") == 0) { + return "Retail 1.6"; + } + } + + return "UNKNOWN"; +}