Cleanup before kernel export refactor.

This commit is contained in:
Ben Vanik
2015-05-31 16:31:19 -07:00
parent fccab79a7a
commit 9c3d2b54fb
24 changed files with 2508 additions and 2502 deletions

View File

@@ -13,24 +13,51 @@
#include <string>
#include <vector>
#include "xenia/cpu/frontend/ppc_context.h"
namespace xe {
namespace cpu {
struct ExportTag {
typedef uint32_t type;
static const type kImplemented = 1 << 0;
static const type kSketchy = 1 << 1;
static const type kHighFrequency = 1 << 2;
static const type kImportant = 1 << 3;
static const type kThreading = 1 << 10;
static const type kInput = 1 << 11;
static const type kAudio = 1 << 12;
static const type kVideo = 1 << 13;
static const type kFileSystem = 1 << 14;
static const type kModules = 1 << 15;
static const type kUserProfiles = 1 << 16;
static const type kLog = 1 << 31;
};
// DEPRECATED
typedef void (*xe_kernel_export_shim_fn)(void*, void*);
class KernelExport {
class Export {
public:
enum ExportType {
Function = 0,
Variable = 1,
enum class Type {
kFunction = 0,
kVariable = 1,
};
uint32_t ordinal;
ExportType type;
uint32_t flags;
char name[96];
Type type;
std::string name;
ExportTag::type tags;
bool is_implemented;
void (*trampoline)(xe::cpu::frontend::PPCContext* ppc_context);
uint64_t call_count;
bool is_implemented() const {
return (tags & ExportTag::kImplemented) == ExportTag::kImplemented;
}
union {
// Variable data. Only valid when kXEKernelExportFlagVariable is set.
@@ -39,9 +66,6 @@ class KernelExport {
uint32_t variable_ptr;
struct {
// Second argument passed to the shim function.
void* shim_data;
// Shimmed implementation.
// This is called directly from generated code.
// It should parse args, do fixups, and call the impl.
@@ -55,25 +79,25 @@ class ExportResolver {
ExportResolver();
~ExportResolver();
void RegisterTable(const std::string& library_name, KernelExport* exports,
void RegisterTable(const std::string& library_name, Export* exports,
const size_t count);
KernelExport* GetExportByOrdinal(const std::string& library_name,
const uint32_t ordinal);
Export* GetExportByOrdinal(const std::string& library_name,
const uint32_t ordinal);
void SetVariableMapping(const std::string& library_name,
const uint32_t ordinal, uint32_t value);
void SetFunctionMapping(const std::string& library_name,
const uint32_t ordinal, void* shim_data,
const uint32_t ordinal,
xe_kernel_export_shim_fn shim);
private:
struct ExportTable {
std::string name;
std::string simple_name; // without extension
KernelExport* exports;
Export* exports;
size_t count;
ExportTable(const std::string& name, KernelExport* exports, size_t count)
ExportTable(const std::string& name, Export* exports, size_t count)
: name(name), exports(exports), count(count) {
auto dot_pos = name.find_last_of('.');
if (dot_pos != std::string::npos) {