add tpmver detection

This commit is contained in:
kxtzownsu 2024-12-07 13:59:51 -05:00 committed by kxtz smith
parent a7f3965da6
commit 9a6415235d
4 changed files with 19 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include "tpm.h"
@ -39,4 +40,19 @@ const char* getFirmwareVersion(){
// uint32_t getKernelVersion(){
// }
// this is kinda shitty, but until the TPM2 API is done, this is how we have to do it
const char* getTpmVersion(){
char cmd[] = "tpmc tpmver";
static char output[5];
FILE* fp = popen(cmd, "r");
fgets(output, sizeof(output), fp);
fclose(fp);
trim_newline(output);
return output;
}
#endif

View File

@ -2,6 +2,6 @@
#define UI_H
void ui_flash(char* flashtype);
void ui_header(const char* fwver, char* kernver, char* tpmver, char* fwmp, char* gscver, char* gsctype);
void ui_header(const char* fwver, char* kernver, const char* tpmver, char* fwmp, char* gscver, char* gsctype);
#endif

View File

@ -14,7 +14,7 @@ int main(int argc, char **argv) {
// example values for testing
const char* fwver = getFirmwareVersion();
char* kernver = "0x00010001";
char* tpmver = "2.0";
const char* tpmver = getTpmVersion();
char* fwmp = "0x1";
char* gscver = "0.5.229";
char* gsctype = "Cr50";

View File

@ -75,7 +75,7 @@ void ui_flash(char* flashtype) {
}
}
void ui_header(const char* fwver, char* kernver, char* tpmver, char* fwmp, char* gscver, char* gsctype){
void ui_header(const char* fwver, char* kernver, const char* tpmver, char* fwmp, char* gscver, char* gsctype){
printf("KVS: Kernel Version Switcher (codename Maglev, bid: 2.0.0))\n");
printf("FW Version: %s\n", fwver);
printf("Kernel Version: %s\n", kernver);