fxos/include/fxos/os.h

70 lines
1.5 KiB
C++

//---
// fxos.os: Operating system models and primitives
//---
#ifndef LIBFXOS_OS_H
#define LIBFXOS_OS_H
#include <fxos/target.h>
#include <fxos/util.h>
#include <vector>
#include <map>
namespace FxOS {
class OS
{
public:
/* Load an OS from a file. */
OS(File &file);
/* Get OS version */
std::string version() const noexcept;
/* 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 the footer address. Returns -1 if not found */
uint32_t footer() const noexcept;
private:
/* Determine the OS version. This should be the first analysis function
to be called, because it determines the type of model (ie. fx9860g
versus fxcg50) thus the location of the syscall table and many more
important parameters. */
void parse_version();
/* Locate and parse the syscall table. */
void parse_syscall_table();
/* Locate the footer */
void parse_footer();
/* Working target which is a simulated memory with just the OS */
Target m_target;
//---
// OS information
//---
/* Version */
std::string m_version;
/* Syscall table, in order of syscall IDs */
std::vector<uint32_t> m_syscall_table;
/* Bimap converse, syscalls sorted by address */
std::map<uint32_t,int> m_syscall_addresses;
/* Footer address */
uint32_t m_footer;
};
} /* namespace FxOS */
#endif /* LIBFXOS_OS_H */