mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 07:23:43 +02:00
flashrom.c: Move print logic to print.c
This free's up flashrom.c from namespace pollution. BUG=b:242246291 TEST=builds Change-Id: I2724f7910fa3e01bcf49b8093260a4f1643df777 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/66652 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
This commit is contained in:
parent
f6d9a2847e
commit
0d4614777b
84
flashrom.c
84
flashrom.c
@ -26,9 +26,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#if HAVE_UTSNAME == 1
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#endif
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "flashchips.h"
|
#include "flashchips.h"
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
@ -1367,86 +1365,6 @@ void list_programmers_linebreak(int startcol, int cols, int paren)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_sysinfo(void)
|
|
||||||
{
|
|
||||||
#if IS_WINDOWS
|
|
||||||
SYSTEM_INFO si = { 0 };
|
|
||||||
OSVERSIONINFOEX osvi = { 0 };
|
|
||||||
|
|
||||||
msg_ginfo(" on Windows");
|
|
||||||
/* Tell Windows which version of the structure we want. */
|
|
||||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
||||||
if (GetVersionEx((OSVERSIONINFO*) &osvi))
|
|
||||||
msg_ginfo(" %lu.%lu", osvi.dwMajorVersion, osvi.dwMinorVersion);
|
|
||||||
else
|
|
||||||
msg_ginfo(" unknown version");
|
|
||||||
GetSystemInfo(&si);
|
|
||||||
switch (si.wProcessorArchitecture) {
|
|
||||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
|
||||||
msg_ginfo(" (x86_64)");
|
|
||||||
break;
|
|
||||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
|
||||||
msg_ginfo(" (x86)");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
msg_ginfo(" (unknown arch)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#elif HAVE_UTSNAME == 1
|
|
||||||
struct utsname osinfo;
|
|
||||||
|
|
||||||
uname(&osinfo);
|
|
||||||
msg_ginfo(" on %s %s (%s)", osinfo.sysname, osinfo.release,
|
|
||||||
osinfo.machine);
|
|
||||||
#else
|
|
||||||
msg_ginfo(" on unknown machine");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_buildinfo(void)
|
|
||||||
{
|
|
||||||
msg_gdbg("flashrom was built with");
|
|
||||||
#ifdef __clang__
|
|
||||||
msg_gdbg(" LLVM Clang");
|
|
||||||
#ifdef __clang_version__
|
|
||||||
msg_gdbg(" %s,", __clang_version__);
|
|
||||||
#else
|
|
||||||
msg_gdbg(" unknown version (before r102686),");
|
|
||||||
#endif
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
msg_gdbg(" GCC");
|
|
||||||
#ifdef __VERSION__
|
|
||||||
msg_gdbg(" %s,", __VERSION__);
|
|
||||||
#else
|
|
||||||
msg_gdbg(" unknown version,");
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
msg_gdbg(" unknown compiler,");
|
|
||||||
#endif
|
|
||||||
#if defined (__FLASHROM_LITTLE_ENDIAN__)
|
|
||||||
msg_gdbg(" little endian");
|
|
||||||
#elif defined (__FLASHROM_BIG_ENDIAN__)
|
|
||||||
msg_gdbg(" big endian");
|
|
||||||
#else
|
|
||||||
#error Endianness could not be determined
|
|
||||||
#endif
|
|
||||||
msg_gdbg("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_version(void)
|
|
||||||
{
|
|
||||||
msg_ginfo("flashrom %s", flashrom_version);
|
|
||||||
print_sysinfo();
|
|
||||||
msg_ginfo("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_banner(void)
|
|
||||||
{
|
|
||||||
msg_ginfo("flashrom is free software, get the source code at "
|
|
||||||
"https://flashrom.org\n");
|
|
||||||
msg_ginfo("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int selfcheck(void)
|
int selfcheck(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
89
print.c
89
print.c
@ -20,6 +20,15 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#if HAVE_UTSNAME == 1
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#endif
|
||||||
|
#if IS_WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
|
|
||||||
@ -505,6 +514,86 @@ int print_supported(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_sysinfo(void)
|
||||||
|
{
|
||||||
|
#if IS_WINDOWS
|
||||||
|
SYSTEM_INFO si = { 0 };
|
||||||
|
OSVERSIONINFOEX osvi = { 0 };
|
||||||
|
|
||||||
|
msg_ginfo(" on Windows");
|
||||||
|
/* Tell Windows which version of the structure we want. */
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||||
|
if (GetVersionEx((OSVERSIONINFO*) &osvi))
|
||||||
|
msg_ginfo(" %lu.%lu", osvi.dwMajorVersion, osvi.dwMinorVersion);
|
||||||
|
else
|
||||||
|
msg_ginfo(" unknown version");
|
||||||
|
GetSystemInfo(&si);
|
||||||
|
switch (si.wProcessorArchitecture) {
|
||||||
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||||
|
msg_ginfo(" (x86_64)");
|
||||||
|
break;
|
||||||
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||||
|
msg_ginfo(" (x86)");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
msg_ginfo(" (unknown arch)");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#elif HAVE_UTSNAME == 1
|
||||||
|
struct utsname osinfo;
|
||||||
|
|
||||||
|
uname(&osinfo);
|
||||||
|
msg_ginfo(" on %s %s (%s)", osinfo.sysname, osinfo.release,
|
||||||
|
osinfo.machine);
|
||||||
|
#else
|
||||||
|
msg_ginfo(" on unknown machine");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_buildinfo(void)
|
||||||
|
{
|
||||||
|
msg_gdbg("flashrom was built with");
|
||||||
|
#ifdef __clang__
|
||||||
|
msg_gdbg(" LLVM Clang");
|
||||||
|
#ifdef __clang_version__
|
||||||
|
msg_gdbg(" %s,", __clang_version__);
|
||||||
|
#else
|
||||||
|
msg_gdbg(" unknown version (before r102686),");
|
||||||
|
#endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
msg_gdbg(" GCC");
|
||||||
|
#ifdef __VERSION__
|
||||||
|
msg_gdbg(" %s,", __VERSION__);
|
||||||
|
#else
|
||||||
|
msg_gdbg(" unknown version,");
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
msg_gdbg(" unknown compiler,");
|
||||||
|
#endif
|
||||||
|
#if defined (__FLASHROM_LITTLE_ENDIAN__)
|
||||||
|
msg_gdbg(" little endian");
|
||||||
|
#elif defined (__FLASHROM_BIG_ENDIAN__)
|
||||||
|
msg_gdbg(" big endian");
|
||||||
|
#else
|
||||||
|
#error Endianness could not be determined
|
||||||
|
#endif
|
||||||
|
msg_gdbg("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_version(void)
|
||||||
|
{
|
||||||
|
msg_ginfo("flashrom %s", flashrom_version);
|
||||||
|
print_sysinfo();
|
||||||
|
msg_ginfo("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_banner(void)
|
||||||
|
{
|
||||||
|
msg_ginfo("flashrom is free software, get the source code at "
|
||||||
|
"https://flashrom.org\n");
|
||||||
|
msg_ginfo("\n");
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_INTERNAL == 1
|
#if CONFIG_INTERNAL == 1
|
||||||
|
|
||||||
#ifdef CONFIG_PRINT_WIKI
|
#ifdef CONFIG_PRINT_WIKI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user