fxos/fxos/main.cpp

80 lines
2.1 KiB
C++

#include <fxos/lang.h>
#include <fxos/load.h>
#include <fxos/errors.h>
#include <fxos/os.h>
#include <cstdio>
using namespace FxOS;
char const *info_str =
"Header information:\n"
" Bootcode timestamp (DateA) (0x8000ffb0) : %s\n"
" Serial number (0x8000ffd0) : %s\n"
" Bootcode checksum (0x8000fffc) : 0x%s\n"
" OS version (0x80010020) : %s\n";
char const *footer_str =
"\nFooter information:\n"
" Detected footer address : 0x8%07x\n"
" Langdata entries found : %d\n"
" OS date (DateO) (0x8%07x)" " : %s\n"
" OS checksum (0x8%07x)" " : 0x%s\n";
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";
char const *syscall_nonrom_str =
" %%%03x -> 0x%08x (%s memory)\n";
void info(std::string path)
{
File file(path);
OS os(file);
Target t;
t.bind_region(MemoryRegion::ROM, file);
t.bind_region(MemoryRegion::ROM_P2, file);
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");
}
int main(void)
{
try
{
FxOS::load("data/sh3.txt");
FxOS::load("data/sh4.txt");
}
catch(FxOS::SyntaxError &e)
{
std::cerr << e.file() << ":" << e.line() << ": " <<
e.what() << "\n" << std::flush;
return 1;
}
info("/home/lake/Documents/PC/Données/OS Graph 35+E II/3.10.bin");
return 0;
}