77 lines
2.3 KiB
C++
77 lines
2.3 KiB
C++
#include "fxos-cli.h"
|
|
#include <fxos/target.h>
|
|
#include <fxos/os.h>
|
|
#include <fxos/util.h>
|
|
|
|
using namespace FxOS;
|
|
|
|
static char const *info_str =
|
|
"Header information:\n"
|
|
" Bootcode timestamp (DateA) (0x%000008x) : %s\n"
|
|
" Bootcode checksum (0x%000008x) : 0x%08x\n"
|
|
//" Serial number (0x%000008x) : %s\n"
|
|
" OS version (0x%000008x) : %s\n";
|
|
|
|
static char const *footer_str =
|
|
"\nFooter information:\n"
|
|
" Detected footer address : 0x%08x\n"
|
|
" Langdata entries found : %d\n"
|
|
" OS date (DateO) (0x%000008x) : %s\n"
|
|
" OS checksum (0x%000008x) : 0x%08x\n";
|
|
|
|
static char const *syscall_str =
|
|
"\nSyscall information:\n"
|
|
" Syscall table address (0x8001007c) : 0x%08x\n"
|
|
" Entries that point to valid memory : 0x%x\n"
|
|
" First seemingly invalid entry : 0x%08x\n"
|
|
" Syscall entries outside ROM:\n";
|
|
|
|
static char const *syscall_nonrom_str =
|
|
" %%%03x -> 0x%08x (%s memory)\n";
|
|
|
|
void os_info(std::string path)
|
|
{
|
|
/* Create an 8M buffer and load the ROM there */
|
|
Buffer romfile(path, MemoryRegion::ROM.size());
|
|
OS os(romfile);
|
|
|
|
/* There is some stuff we want to read directly */
|
|
Target &t = os.target;
|
|
|
|
printf(info_str,
|
|
&os.bootcode_timestamp, os.bootcode_timestamp.value.c_str(),
|
|
&os.bootcode_checksum, os.bootcode_checksum,
|
|
// &os.serial_number, os.serial_number,
|
|
&os.version, os.version.value.c_str());
|
|
|
|
if(os.footer == (uint32_t)-1)
|
|
{
|
|
printf("\nFooter could not be found.\n");
|
|
}
|
|
else
|
|
{
|
|
printf(footer_str, os.footer, os.langdata,
|
|
&os.timestamp, os.timestamp.value.c_str(),
|
|
&os.checksum, os.checksum);
|
|
}
|
|
|
|
uint32_t syscall_table = t.read_u32(0x8001007c);
|
|
uint32_t first_noncall = t.read_u32(syscall_table +
|
|
4 * os.syscall_count());
|
|
|
|
printf(syscall_str, syscall_table, os.syscall_count(), first_noncall);
|
|
|
|
int total = 0;
|
|
for(int i = 0; i < os.syscall_count(); i++)
|
|
{
|
|
uint32_t e = os.syscall(i);
|
|
MemoryRegion const *r = MemoryRegion::region_for(e);
|
|
if(!r || r->name == "ROM" || r->name == "ROM_P2") continue;
|
|
|
|
printf(syscall_nonrom_str, i, e, r->name.c_str());
|
|
total++;
|
|
}
|
|
|
|
if(!total) printf(" (none)\n");
|
|
}
|