//--- // fxos.os: Operating system models and primitives //--- #ifndef LIBFXOS_OS_H #define LIBFXOS_OS_H #include #include #include #include namespace FxOS { class OS { public: /* Create an OS interface for this target. If the target does not have data loaded in ROM, this raises an exception. */ OS(Target &target); /* Type of OS, determined at construction */ enum Type { FX, CG }; Type type; /* Bootcode timestamp and checksum */ Addressable bootcode_timestamp; Addressable bootcode_checksum; /* OS version, serial number, timestamp and checksum */ Addressable version; Addressable serial_number; Addressable timestamp; Addressable checksum; /* Get number of syscalls */ int syscall_count() const noexcept; /* Get a syscall entry */ uint32_t syscall(int id) const; /* Find a syscall entry. Returns -1 if syscall is not found */ int find_syscall(uint32_t entry) const noexcept; /* Get address of syscall table */ uint32_t syscall_table_address() const noexcept; /* Footer address, or -1 if not found */ uint32_t footer; /* Number of langdata entries */ int langdata; private: /* Target being analyzed */ Target &m_target; /* Parse the OS header. This should be the first analysis function to be called, because it determines the type of model (ie. fx9860g vs fxcg50) thus the location of the syscall table and many more important parameters. */ void parse_header(); /* Locate and parse the syscall table. */ void parse_syscall_table(); /* Locate and parse the footer. */ void parse_footer(); //--- // OS information //--- /* Syscall table, in order of syscall IDs */ std::vector m_syscall_table; /* Bimap converse, syscalls sorted by address */ std::map m_syscall_addresses; }; } /* namespace FxOS */ #endif /* LIBFXOS_OS_H */