fxos/include/fxos/load.h

52 lines
1.8 KiB
C++

//---
// fxos.load: Data file lexers and loaders
//---
#ifndef LIBFXOS_LOAD_H
#define LIBFXOS_LOAD_H
#include <fxos/util.h>
#include <fxos/target.h>
#include <fxos/symbols.h>
#include <string>
#include <map>
namespace FxOS {
using Header = std::map<std::string, std::string>;
/* Load the header of a data file.
@file Data file, assumed with an fxos header type-specific contents
@offset Will be set to the byte offset where content starts
@line Will be set to the liner number where content starts
This function is used when reading all data files for fxos. The header
indicates the file type, thus the syntax of the contents. Some metadata can
also be specified here.
The parameters [offset] and [line] are set to reflect the location in the
file where the raw content starts. These parameters are used to initialize
the lexers in all other load functions. */
Header load_header(Buffer const &file, size_t &offset, int &line);
/* Load an assembly instruction table for the disassembler. This function
directly feeds the disassembler and does not return anything.
@file Data file, presumably analyzed with lex_header()
@offset Offset of assembly data in the file (as set by load_header)
@line Line where assembly data starts in the file (idem) */
int load_asm(Buffer const &file, size_t offset, size_t line);
/* Load a target description into the target database. This function returns
the complete target description */
TargetDescription load_target(Buffer const &file, size_t offset, size_t line);
/* Load a symbol table. This function returns the full table, which may contain
duplicates or unused syscall numbers and addresses. */
SymbolTable load_symbols(Buffer const &file, size_t offset, size_t line);
} /* namespace FxOS */
#endif /* LIBFXOS_LOAD_H */