Removing kernel_state and ppc_context from kernel export args.
This commit is contained in:
parent
23826fa957
commit
169ced8194
|
@ -15,17 +15,18 @@
|
||||||
#include "xenia/base/string.h"
|
#include "xenia/base/string.h"
|
||||||
#include "xenia/cpu/processor.h"
|
#include "xenia/cpu/processor.h"
|
||||||
#include "xenia/emulator.h"
|
#include "xenia/emulator.h"
|
||||||
#include "xenia/kernel/dispatcher.h"
|
|
||||||
#include "xenia/kernel/xam_module.h"
|
|
||||||
#include "xenia/kernel/xboxkrnl_module.h"
|
|
||||||
#include "xenia/kernel/xboxkrnl_private.h"
|
|
||||||
#include "xenia/kernel/xobject.h"
|
|
||||||
#include "xenia/kernel/apps/apps.h"
|
#include "xenia/kernel/apps/apps.h"
|
||||||
|
#include "xenia/kernel/dispatcher.h"
|
||||||
#include "xenia/kernel/objects/xevent.h"
|
#include "xenia/kernel/objects/xevent.h"
|
||||||
#include "xenia/kernel/objects/xmodule.h"
|
#include "xenia/kernel/objects/xmodule.h"
|
||||||
#include "xenia/kernel/objects/xnotify_listener.h"
|
#include "xenia/kernel/objects/xnotify_listener.h"
|
||||||
#include "xenia/kernel/objects/xthread.h"
|
#include "xenia/kernel/objects/xthread.h"
|
||||||
#include "xenia/kernel/objects/xuser_module.h"
|
#include "xenia/kernel/objects/xuser_module.h"
|
||||||
|
#include "xenia/kernel/util/shim_utils.h"
|
||||||
|
#include "xenia/kernel/xam_module.h"
|
||||||
|
#include "xenia/kernel/xboxkrnl_module.h"
|
||||||
|
#include "xenia/kernel/xboxkrnl_private.h"
|
||||||
|
#include "xenia/kernel/xobject.h"
|
||||||
|
|
||||||
DEFINE_bool(headless, false,
|
DEFINE_bool(headless, false,
|
||||||
"Don't display any UI, using defaults for prompts as needed.");
|
"Don't display any UI, using defaults for prompts as needed.");
|
||||||
|
@ -40,6 +41,8 @@ namespace kernel {
|
||||||
// be using to stash their variables.
|
// be using to stash their variables.
|
||||||
KernelState* shared_kernel_state_ = nullptr;
|
KernelState* shared_kernel_state_ = nullptr;
|
||||||
|
|
||||||
|
KernelState* kernel_state() { return shared_kernel_state_; }
|
||||||
|
|
||||||
KernelState::KernelState(Emulator* emulator)
|
KernelState::KernelState(Emulator* emulator)
|
||||||
: emulator_(emulator),
|
: emulator_(emulator),
|
||||||
memory_(emulator->memory()),
|
memory_(emulator->memory()),
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "xenia/base/string_buffer.h"
|
#include "xenia/base/string_buffer.h"
|
||||||
#include "xenia/cpu/export_resolver.h"
|
#include "xenia/cpu/export_resolver.h"
|
||||||
#include "xenia/cpu/frontend/ppc_context.h"
|
#include "xenia/cpu/frontend/ppc_context.h"
|
||||||
|
#include "xenia/kernel/kernel_state.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
@ -317,21 +318,16 @@ enum class KernelModuleId {
|
||||||
xam,
|
xam,
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename F, typename Tuple, std::size_t... I>
|
|
||||||
auto KernelTrampoline(F&& f, PPCContext* ppc_context, KernelState* kernel_state,
|
|
||||||
Tuple&& t, std::index_sequence<I...>) {
|
|
||||||
return std::forward<F>(f)(ppc_context, kernel_state,
|
|
||||||
std::get<I>(std::forward<Tuple>(t))...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t I = 0, typename... Ps>
|
template <size_t I = 0, typename... Ps>
|
||||||
typename std::enable_if<I == sizeof...(Ps)>::type AppendKernelCallParams(
|
typename std::enable_if<I == sizeof...(Ps)>::type AppendKernelCallParams(
|
||||||
StringBuffer& string_buffer, xe::cpu::Export* export, const std::tuple<Ps...>&) {}
|
StringBuffer& string_buffer, xe::cpu::Export* export,
|
||||||
|
const std::tuple<Ps...>&) {}
|
||||||
|
|
||||||
template <size_t I = 0, typename... Ps>
|
template <size_t I = 0, typename... Ps>
|
||||||
typename std::enable_if <
|
typename std::enable_if <
|
||||||
I<sizeof...(Ps)>::type AppendKernelCallParams(
|
I<sizeof...(Ps)>::type AppendKernelCallParams(
|
||||||
StringBuffer& string_buffer, xe::cpu::Export* export, const std::tuple<Ps...>& params) {
|
StringBuffer& string_buffer, xe::cpu::Export* export,
|
||||||
|
const std::tuple<Ps...>& params) {
|
||||||
if (I) {
|
if (I) {
|
||||||
string_buffer.Append(", ");
|
string_buffer.Append(", ");
|
||||||
}
|
}
|
||||||
|
@ -358,17 +354,18 @@ void PrintKernelCall(cpu::Export* export, const Tuple& params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename F, typename Tuple, std::size_t... I>
|
||||||
|
auto KernelTrampoline(F&& f, Tuple&& t, std::index_sequence<I...>) {
|
||||||
|
return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
|
||||||
|
}
|
||||||
|
|
||||||
template <KernelModuleId MODULE, uint16_t ORDINAL, typename R, typename... Ps>
|
template <KernelModuleId MODULE, uint16_t ORDINAL, typename R, typename... Ps>
|
||||||
xe::cpu::Export* RegisterExport(R (*fn)(PPCContext* ppc_context,
|
xe::cpu::Export* RegisterExport(R (*fn)(Ps&...), std::string name,
|
||||||
xe::kernel::KernelState* kernel_state,
|
|
||||||
Ps&...),
|
|
||||||
std::string name,
|
|
||||||
xe::cpu::ExportTag::type tags) {
|
xe::cpu::ExportTag::type tags) {
|
||||||
static const auto export =
|
static const auto export =
|
||||||
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||||
tags | ExportTag::kImplemented | ExportTag::kLog);
|
tags | ExportTag::kImplemented | ExportTag::kLog);
|
||||||
static R (*FN)(PPCContext* ppc_context, xe::kernel::KernelState* kernel_state,
|
static R (*FN)(Ps&...) = fn;
|
||||||
Ps&...) = fn;
|
|
||||||
struct X {
|
struct X {
|
||||||
static void Trampoline(PPCContext* ppc_context) {
|
static void Trampoline(PPCContext* ppc_context) {
|
||||||
++export->function_data.call_count;
|
++export->function_data.call_count;
|
||||||
|
@ -379,8 +376,8 @@ xe::cpu::Export* RegisterExport(R (*fn)(PPCContext* ppc_context,
|
||||||
if (export->tags & ExportTag::kLog) {
|
if (export->tags & ExportTag::kLog) {
|
||||||
PrintKernelCall(export, params);
|
PrintKernelCall(export, params);
|
||||||
}
|
}
|
||||||
auto result = KernelTrampoline(FN, ppc_context, ppc_context->kernel_state,
|
auto result =
|
||||||
std::forward<std::tuple<Ps...>>(params),
|
KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params),
|
||||||
std::make_index_sequence<sizeof...(Ps)>());
|
std::make_index_sequence<sizeof...(Ps)>());
|
||||||
result.Store(ppc_context);
|
result.Store(ppc_context);
|
||||||
if (export->tags & (ExportTag::kLog | ExportTag::kLogResult)) {
|
if (export->tags & (ExportTag::kLog | ExportTag::kLogResult)) {
|
||||||
|
@ -393,15 +390,12 @@ xe::cpu::Export* RegisterExport(R (*fn)(PPCContext* ppc_context,
|
||||||
}
|
}
|
||||||
|
|
||||||
template <KernelModuleId MODULE, uint16_t ORDINAL, typename... Ps>
|
template <KernelModuleId MODULE, uint16_t ORDINAL, typename... Ps>
|
||||||
xe::cpu::Export* RegisterExport(
|
xe::cpu::Export* RegisterExport(void (*fn)(Ps&...), std::string name,
|
||||||
void (*fn)(PPCContext* ppc_context, xe::kernel::KernelState* kernel_state,
|
xe::cpu::ExportTag::type tags) {
|
||||||
Ps&...),
|
|
||||||
std::string name, xe::cpu::ExportTag::type tags) {
|
|
||||||
static const auto export =
|
static const auto export =
|
||||||
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
new cpu::Export(ORDINAL, xe::cpu::Export::Type::kFunction, name,
|
||||||
tags | ExportTag::kImplemented | ExportTag::kLog);
|
tags | ExportTag::kImplemented | ExportTag::kLog);
|
||||||
static void (*FN)(PPCContext* ppc_context,
|
static void (*FN)(Ps&...) = fn;
|
||||||
xe::kernel::KernelState* kernel_state, Ps&...) = fn;
|
|
||||||
struct X {
|
struct X {
|
||||||
static void Trampoline(PPCContext* ppc_context) {
|
static void Trampoline(PPCContext* ppc_context) {
|
||||||
++export->function_data.call_count;
|
++export->function_data.call_count;
|
||||||
|
@ -412,8 +406,7 @@ xe::cpu::Export* RegisterExport(
|
||||||
if (export->tags & ExportTag::kLog) {
|
if (export->tags & ExportTag::kLog) {
|
||||||
PrintKernelCall(export, params);
|
PrintKernelCall(export, params);
|
||||||
}
|
}
|
||||||
KernelTrampoline(FN, ppc_context, ppc_context->kernel_state,
|
KernelTrampoline(FN, std::forward<std::tuple<Ps...>>(params),
|
||||||
std::forward<std::tuple<Ps...>>(params),
|
|
||||||
std::make_index_sequence<sizeof...(Ps)>());
|
std::make_index_sequence<sizeof...(Ps)>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -424,12 +417,20 @@ xe::cpu::Export* RegisterExport(
|
||||||
} // namespace shim
|
} // namespace shim
|
||||||
|
|
||||||
using xe::cpu::ExportTag;
|
using xe::cpu::ExportTag;
|
||||||
|
|
||||||
#define DECLARE_EXPORT(module_name, name, tags) \
|
#define DECLARE_EXPORT(module_name, name, tags) \
|
||||||
auto EXPORT_##module_name##_##name = \
|
auto EXPORT_##module_name##_##name = \
|
||||||
RegisterExport_##module_name(xe::kernel::shim::RegisterExport< \
|
RegisterExport_##module_name(xe::kernel::shim::RegisterExport< \
|
||||||
xe::kernel::shim::KernelModuleId::module_name, ordinals::##name>( \
|
xe::kernel::shim::KernelModuleId::module_name, ordinals::##name>( \
|
||||||
&name, std::string(#name), tags));
|
&name, std::string(#name), tags));
|
||||||
|
|
||||||
|
#define DECLARE_XAM_EXPORT(name, tags) DECLARE_EXPORT(xam, name, tags)
|
||||||
|
#define DECLARE_XBOXKRNL_EXPORT(name, tags) DECLARE_EXPORT(xboxkrnl, name, tags)
|
||||||
|
|
||||||
|
// Exported from kernel_state.cc.
|
||||||
|
KernelState* kernel_state();
|
||||||
|
inline Memory* kernel_memory() { return kernel_state()->memory(); }
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@ namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
// TODO(benvanik): actually check to see if these are the same.
|
// TODO(benvanik): actually check to see if these are the same.
|
||||||
void VdQueryVideoMode(PPCContext* ppc_context, KernelState* kernel_state,
|
void VdQueryVideoMode(typed_param_t<X_VIDEO_MODE> video_mode);
|
||||||
typed_param_t<X_VIDEO_MODE> video_mode);
|
|
||||||
SHIM_CALL XGetVideoMode_shim(PPCContext* ppc_context,
|
SHIM_CALL XGetVideoMode_shim(PPCContext* ppc_context,
|
||||||
KernelState* kernel_state) {
|
KernelState* kernel_state) {
|
||||||
uint32_t video_mode_ptr = SHIM_GET_ARG_32(0);
|
uint32_t video_mode_ptr = SHIM_GET_ARG_32(0);
|
||||||
|
@ -26,7 +25,7 @@ SHIM_CALL XGetVideoMode_shim(PPCContext* ppc_context,
|
||||||
|
|
||||||
XELOGD("XGetVideoMode(%.8X)", video_mode_ptr);
|
XELOGD("XGetVideoMode(%.8X)", video_mode_ptr);
|
||||||
|
|
||||||
VdQueryVideoMode(ppc_context, kernel_state, video_mode);
|
VdQueryVideoMode(video_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHIM_CALL XGetVideoCapabilities_shim(PPCContext* ppc_context,
|
SHIM_CALL XGetVideoCapabilities_shim(PPCContext* ppc_context,
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
using xe::gpu::GraphicsSystem;
|
|
||||||
|
|
||||||
// http://www.tweakoz.com/orkid/
|
// http://www.tweakoz.com/orkid/
|
||||||
// http://www.tweakoz.com/orkid/dox/d3/d52/xb360init_8cpp_source.html
|
// http://www.tweakoz.com/orkid/dox/d3/d52/xb360init_8cpp_source.html
|
||||||
// https://github.com/Free60Project/xenosfb/
|
// https://github.com/Free60Project/xenosfb/
|
||||||
|
@ -36,18 +34,14 @@ using xe::gpu::GraphicsSystem;
|
||||||
// http://www.microsoft.com/en-za/download/details.aspx?id=5313 -- "Stripped
|
// http://www.microsoft.com/en-za/download/details.aspx?id=5313 -- "Stripped
|
||||||
// Down Direct3D: Xbox 360 Command Buffer and Resource Management"
|
// Down Direct3D: Xbox 360 Command Buffer and Resource Management"
|
||||||
|
|
||||||
void VdGetCurrentDisplayGamma(PPCContext* ppc_context,
|
void VdGetCurrentDisplayGamma(lpdword_param_t arg0_ptr,
|
||||||
KernelState* kernel_state,
|
|
||||||
lpdword_param_t arg0_ptr,
|
|
||||||
lpfloat_param_t arg1_ptr) {
|
lpfloat_param_t arg1_ptr) {
|
||||||
*arg0_ptr = 2;
|
*arg0_ptr = 2;
|
||||||
*arg1_ptr = 2.22222233f;
|
*arg1_ptr = 2.22222233f;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdGetCurrentDisplayGamma, ExportTag::kVideo);
|
DECLARE_XBOXKRNL_EXPORT(VdGetCurrentDisplayGamma, ExportTag::kVideo);
|
||||||
|
|
||||||
void VdGetCurrentDisplayInformation(PPCContext* ppc_context,
|
void VdGetCurrentDisplayInformation(lpvoid_param_t info_ptr) {
|
||||||
KernelState* kernel_state,
|
|
||||||
lpvoid_param_t info_ptr) {
|
|
||||||
auto info = info_ptr.as_array<uint32_t>();
|
auto info = info_ptr.as_array<uint32_t>();
|
||||||
// Expecting a length 0x58 struct of stuff.
|
// Expecting a length 0x58 struct of stuff.
|
||||||
info[0 / 4] = (1280 << 16) | 720;
|
info[0 / 4] = (1280 << 16) | 720;
|
||||||
|
@ -73,10 +67,9 @@ void VdGetCurrentDisplayInformation(PPCContext* ppc_context,
|
||||||
info[80 / 4] = 0;
|
info[80 / 4] = 0;
|
||||||
info[84 / 4] = 1280; // display width
|
info[84 / 4] = 1280; // display width
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdGetCurrentDisplayInformation, ExportTag::kVideo);
|
DECLARE_XBOXKRNL_EXPORT(VdGetCurrentDisplayInformation, ExportTag::kVideo);
|
||||||
|
|
||||||
void VdQueryVideoMode(PPCContext* ppc_context, KernelState* kernel_state,
|
void VdQueryVideoMode(typed_param_t<X_VIDEO_MODE> video_mode) {
|
||||||
typed_param_t<X_VIDEO_MODE> video_mode) {
|
|
||||||
// TODO: get info from actual display
|
// TODO: get info from actual display
|
||||||
video_mode.Zero();
|
video_mode.Zero();
|
||||||
video_mode->display_width = 1280;
|
video_mode->display_width = 1280;
|
||||||
|
@ -92,12 +85,11 @@ void VdQueryVideoMode(PPCContext* ppc_context, KernelState* kernel_state,
|
||||||
video_mode->reserved[1] = 0;
|
video_mode->reserved[1] = 0;
|
||||||
video_mode->reserved[2] = 0;
|
video_mode->reserved[2] = 0;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdQueryVideoMode, ExportTag::kVideo);
|
DECLARE_XBOXKRNL_EXPORT(VdQueryVideoMode, ExportTag::kVideo);
|
||||||
|
|
||||||
dword_result_t VdQueryVideoFlags(PPCContext* ppc_context,
|
dword_result_t VdQueryVideoFlags() {
|
||||||
KernelState* kernel_state) {
|
|
||||||
X_VIDEO_MODE mode;
|
X_VIDEO_MODE mode;
|
||||||
VdQueryVideoMode(ppc_context, kernel_state, &mode);
|
VdQueryVideoMode(&mode);
|
||||||
|
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
flags |= mode.is_widescreen ? 1 : 0;
|
flags |= mode.is_widescreen ? 1 : 0;
|
||||||
|
@ -106,29 +98,26 @@ dword_result_t VdQueryVideoFlags(PPCContext* ppc_context,
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdQueryVideoFlags, ExportTag::kVideo);
|
DECLARE_XBOXKRNL_EXPORT(VdQueryVideoFlags, ExportTag::kVideo);
|
||||||
|
|
||||||
dword_result_t VdSetDisplayMode(PPCContext* ppc_context,
|
dword_result_t VdSetDisplayMode(dword_param_t mode) {
|
||||||
KernelState* kernel_state, dword_param_t mode) {
|
|
||||||
// Often 0x40000000.
|
// Often 0x40000000.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdSetDisplayMode,
|
DECLARE_XBOXKRNL_EXPORT(VdSetDisplayMode, ExportTag::kVideo | ExportTag::kStub);
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
|
||||||
|
|
||||||
dword_result_t VdSetDisplayModeOverride(
|
dword_result_t VdSetDisplayModeOverride(unknown_param_t unk0,
|
||||||
PPCContext* ppc_context, KernelState* kernel_state, unknown_param_t unk0,
|
unknown_param_t unk1,
|
||||||
unknown_param_t unk1, double_param_t refresh_rate, unknown_param_t unk3,
|
double_param_t refresh_rate,
|
||||||
|
unknown_param_t unk3,
|
||||||
unknown_param_t unk4) {
|
unknown_param_t unk4) {
|
||||||
// refresh_rate = 0, 50, 59.9, etc.
|
// refresh_rate = 0, 50, 59.9, etc.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdSetDisplayModeOverride,
|
DECLARE_XBOXKRNL_EXPORT(VdSetDisplayModeOverride,
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
dword_result_t VdInitializeEngines(PPCContext* ppc_context,
|
dword_result_t VdInitializeEngines(unknown_param_t unk0, fn_param_t callback,
|
||||||
KernelState* kernel_state,
|
|
||||||
unknown_param_t unk0, fn_param_t callback,
|
|
||||||
unknown_param_t unk1,
|
unknown_param_t unk1,
|
||||||
unknown_pointer_param_t unk2_ptr,
|
unknown_pointer_param_t unk2_ptr,
|
||||||
unknown_pointer_param_t unk3_ptr) {
|
unknown_pointer_param_t unk3_ptr) {
|
||||||
|
@ -138,93 +127,73 @@ dword_result_t VdInitializeEngines(PPCContext* ppc_context,
|
||||||
// r6/r7 = some binary data in .data
|
// r6/r7 = some binary data in .data
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdInitializeEngines,
|
DECLARE_XBOXKRNL_EXPORT(VdInitializeEngines,
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
void VdShutdownEngines(PPCContext* ppc_context, KernelState* kernel_state) {
|
void VdShutdownEngines() {
|
||||||
// Ignored for now.
|
// Ignored for now.
|
||||||
// Games seem to call an Initialize/Shutdown pair to query info, then
|
// Games seem to call an Initialize/Shutdown pair to query info, then
|
||||||
// re-initialize.
|
// re-initialize.
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdShutdownEngines,
|
DECLARE_XBOXKRNL_EXPORT(VdShutdownEngines,
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
dword_result_t VdGetGraphicsAsicID(PPCContext* ppc_context,
|
dword_result_t VdGetGraphicsAsicID() {
|
||||||
KernelState* kernel_state) {
|
|
||||||
// Games compare for < 0x10 and do VdInitializeEDRAM, else other
|
// Games compare for < 0x10 and do VdInitializeEDRAM, else other
|
||||||
// (retrain/etc).
|
// (retrain/etc).
|
||||||
return 0x11;
|
return 0x11;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdGetGraphicsAsicID, ExportTag::kVideo);
|
DECLARE_XBOXKRNL_EXPORT(VdGetGraphicsAsicID, ExportTag::kVideo);
|
||||||
|
|
||||||
dword_result_t VdEnableDisableClockGating(PPCContext* ppc_context,
|
dword_result_t VdEnableDisableClockGating(dword_param_t enabled) {
|
||||||
KernelState* kernel_state,
|
|
||||||
dword_param_t enabled) {
|
|
||||||
// Ignored, as it really doesn't matter.
|
// Ignored, as it really doesn't matter.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdEnableDisableClockGating, ExportTag::kVideo);
|
DECLARE_XBOXKRNL_EXPORT(VdEnableDisableClockGating, ExportTag::kVideo);
|
||||||
|
|
||||||
void VdSetGraphicsInterruptCallback(PPCContext* ppc_context,
|
void VdSetGraphicsInterruptCallback(fn_param_t callback,
|
||||||
KernelState* kernel_state,
|
|
||||||
fn_param_t callback,
|
|
||||||
lpvoid_param_t user_data) {
|
lpvoid_param_t user_data) {
|
||||||
// callback takes 2 params
|
// callback takes 2 params
|
||||||
// r3 = bool 0/1 - 0 is normal interrupt, 1 is some acquire/lock mumble
|
// r3 = bool 0/1 - 0 is normal interrupt, 1 is some acquire/lock mumble
|
||||||
// r4 = user_data (r4 of VdSetGraphicsInterruptCallback)
|
// r4 = user_data (r4 of VdSetGraphicsInterruptCallback)
|
||||||
auto gs = kernel_state->emulator()->graphics_system();
|
auto graphics_system = kernel_state()->emulator()->graphics_system();
|
||||||
if (gs) {
|
graphics_system->SetInterruptCallback(callback, user_data);
|
||||||
gs->SetInterruptCallback(callback, user_data);
|
|
||||||
}
|
}
|
||||||
}
|
DECLARE_XBOXKRNL_EXPORT(VdSetGraphicsInterruptCallback, ExportTag::kVideo);
|
||||||
DECLARE_EXPORT(xboxkrnl, VdSetGraphicsInterruptCallback, ExportTag::kVideo);
|
|
||||||
|
|
||||||
void VdInitializeRingBuffer(PPCContext* ppc_context, KernelState* kernel_state,
|
void VdInitializeRingBuffer(lpvoid_param_t ptr, int_param_t page_count) {
|
||||||
lpvoid_param_t ptr, int_param_t page_count) {
|
|
||||||
// r3 = result of MmGetPhysicalAddress
|
// r3 = result of MmGetPhysicalAddress
|
||||||
// r4 = number of pages? page size?
|
// r4 = number of pages? page size?
|
||||||
// 0x8000 -> cntlzw=16 -> 0x1C - 16 = 12
|
// 0x8000 -> cntlzw=16 -> 0x1C - 16 = 12
|
||||||
// Buffer pointers are from MmAllocatePhysicalMemory with WRITE_COMBINE.
|
// Buffer pointers are from MmAllocatePhysicalMemory with WRITE_COMBINE.
|
||||||
// Sizes could be zero? XBLA games seem to do this. Default sizes?
|
// Sizes could be zero? XBLA games seem to do this. Default sizes?
|
||||||
// D3D does size / region_count - must be > 1024
|
// D3D does size / region_count - must be > 1024
|
||||||
auto gs = kernel_state->emulator()->graphics_system();
|
auto graphics_system = kernel_state()->emulator()->graphics_system();
|
||||||
if (gs) {
|
graphics_system->InitializeRingBuffer(ptr, page_count);
|
||||||
gs->InitializeRingBuffer(ptr, page_count);
|
|
||||||
}
|
}
|
||||||
}
|
DECLARE_XBOXKRNL_EXPORT(VdInitializeRingBuffer, ExportTag::kVideo);
|
||||||
DECLARE_EXPORT(xboxkrnl, VdInitializeRingBuffer, ExportTag::kVideo);
|
|
||||||
|
|
||||||
void VdEnableRingBufferRPtrWriteBack(PPCContext* ppc_context,
|
void VdEnableRingBufferRPtrWriteBack(lpvoid_param_t ptr,
|
||||||
KernelState* kernel_state,
|
|
||||||
lpvoid_param_t ptr,
|
|
||||||
int_param_t block_size) {
|
int_param_t block_size) {
|
||||||
auto gs = kernel_state->emulator()->graphics_system();
|
|
||||||
if (!gs) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// r4 = 6, usually --- <=19
|
// r4 = 6, usually --- <=19
|
||||||
gs->EnableReadPointerWriteBack(ptr, block_size);
|
auto graphics_system = kernel_state()->emulator()->graphics_system();
|
||||||
|
graphics_system->EnableReadPointerWriteBack(ptr, block_size);
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdEnableRingBufferRPtrWriteBack, ExportTag::kVideo);
|
DECLARE_XBOXKRNL_EXPORT(VdEnableRingBufferRPtrWriteBack, ExportTag::kVideo);
|
||||||
|
|
||||||
void VdGetSystemCommandBuffer(PPCContext* ppc_context,
|
void VdGetSystemCommandBuffer(unknown_pointer_param_t p0_ptr,
|
||||||
KernelState* kernel_state,
|
|
||||||
unknown_pointer_param_t p0_ptr,
|
|
||||||
unknown_pointer_param_t p1_ptr) {
|
unknown_pointer_param_t p1_ptr) {
|
||||||
p0_ptr.Zero(0x94);
|
p0_ptr.Zero(0x94);
|
||||||
xe::store_and_swap<uint32_t>(p0_ptr, 0xBEEF0000);
|
xe::store_and_swap<uint32_t>(p0_ptr, 0xBEEF0000);
|
||||||
xe::store_and_swap<uint32_t>(p1_ptr, 0xBEEF0001);
|
xe::store_and_swap<uint32_t>(p1_ptr, 0xBEEF0001);
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdGetSystemCommandBuffer,
|
DECLARE_XBOXKRNL_EXPORT(VdGetSystemCommandBuffer,
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
void VdSetSystemCommandBufferGpuIdentifierAddress(PPCContext* ppc_context,
|
void VdSetSystemCommandBufferGpuIdentifierAddress(unknown_pointer_param_t unk) {
|
||||||
KernelState* kernel_state,
|
|
||||||
unknown_pointer_param_t unk) {
|
|
||||||
// r3 = 0x2B10(d3d?) + 8
|
// r3 = 0x2B10(d3d?) + 8
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdSetSystemCommandBufferGpuIdentifierAddress,
|
DECLARE_XBOXKRNL_EXPORT(VdSetSystemCommandBufferGpuIdentifierAddress,
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
// VdVerifyMEInitCommand
|
// VdVerifyMEInitCommand
|
||||||
|
@ -233,7 +202,7 @@ DECLARE_EXPORT(xboxkrnl, VdSetSystemCommandBufferGpuIdentifierAddress,
|
||||||
// no op?
|
// no op?
|
||||||
|
|
||||||
dword_result_t VdInitializeScalerCommandBuffer(
|
dword_result_t VdInitializeScalerCommandBuffer(
|
||||||
PPCContext* ppc_context, KernelState* kernel_state,
|
|
||||||
unknown_param_t unk0, // 0?
|
unknown_param_t unk0, // 0?
|
||||||
unknown_param_t unk1, // 0x050002d0 size of ?
|
unknown_param_t unk1, // 0x050002d0 size of ?
|
||||||
unknown_param_t unk2, // 0?
|
unknown_param_t unk2, // 0?
|
||||||
|
@ -257,7 +226,7 @@ dword_result_t VdInitializeScalerCommandBuffer(
|
||||||
// returns memcpy size >> 2 for memcpy(...,...,ret << 2)
|
// returns memcpy size >> 2 for memcpy(...,...,ret << 2)
|
||||||
return total_words >> 2;
|
return total_words >> 2;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdInitializeScalerCommandBuffer,
|
DECLARE_XBOXKRNL_EXPORT(VdInitializeScalerCommandBuffer,
|
||||||
ExportTag::kVideo | ExportTag::kSketchy);
|
ExportTag::kVideo | ExportTag::kSketchy);
|
||||||
|
|
||||||
// We use these to shuffle data to VdSwap.
|
// We use these to shuffle data to VdSwap.
|
||||||
|
@ -280,8 +249,7 @@ void AppendParam(StringBuffer& string_buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
dword_result_t VdCallGraphicsNotificationRoutines(
|
dword_result_t VdCallGraphicsNotificationRoutines(
|
||||||
PPCContext* ppc_context, KernelState* kernel_state, unknown_param_t unk0,
|
unknown_param_t unk0, typed_param_t<BufferScaling> args_ptr) {
|
||||||
typed_param_t<BufferScaling> args_ptr) {
|
|
||||||
assert_true(unk0 == 1);
|
assert_true(unk0 == 1);
|
||||||
|
|
||||||
// TODO(benvanik): what does this mean, I forget:
|
// TODO(benvanik): what does this mean, I forget:
|
||||||
|
@ -293,25 +261,23 @@ dword_result_t VdCallGraphicsNotificationRoutines(
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdCallGraphicsNotificationRoutines,
|
DECLARE_XBOXKRNL_EXPORT(VdCallGraphicsNotificationRoutines,
|
||||||
ExportTag::kVideo | ExportTag::kSketchy);
|
ExportTag::kVideo | ExportTag::kSketchy);
|
||||||
|
|
||||||
dword_result_t VdIsHSIOTrainingSucceeded(PPCContext* ppc_context,
|
dword_result_t VdIsHSIOTrainingSucceeded() {
|
||||||
KernelState* kernel_state) {
|
|
||||||
// Not really sure what this should be - code does weird stuff here:
|
// Not really sure what this should be - code does weird stuff here:
|
||||||
// (cntlzw r11, r3 / extrwi r11, r11, 1, 26)
|
// (cntlzw r11, r3 / extrwi r11, r11, 1, 26)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdIsHSIOTrainingSucceeded,
|
DECLARE_XBOXKRNL_EXPORT(VdIsHSIOTrainingSucceeded,
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
dword_result_t VdPersistDisplay(PPCContext* ppc_context,
|
dword_result_t VdPersistDisplay(unknown_param_t unk0,
|
||||||
KernelState* kernel_state, unknown_param_t unk0,
|
|
||||||
lpdword_param_t unk1_ptr) {
|
lpdword_param_t unk1_ptr) {
|
||||||
// unk1_ptr needs to be populated with a pointer passed to
|
// unk1_ptr needs to be populated with a pointer passed to
|
||||||
// MmFreePhysicalMemory(1, *unk1_ptr).
|
// MmFreePhysicalMemory(1, *unk1_ptr).
|
||||||
if (unk1_ptr) {
|
if (unk1_ptr) {
|
||||||
auto heap = kernel_state->memory()->LookupHeapByType(true, 16 * 1024);
|
auto heap = kernel_memory()->LookupHeapByType(true, 16 * 1024);
|
||||||
uint32_t unk1_value;
|
uint32_t unk1_value;
|
||||||
heap->Alloc(64, 32, kMemoryAllocationReserve | kMemoryAllocationCommit,
|
heap->Alloc(64, 32, kMemoryAllocationReserve | kMemoryAllocationCommit,
|
||||||
kMemoryProtectNoAccess, false, &unk1_value);
|
kMemoryProtectNoAccess, false, &unk1_value);
|
||||||
|
@ -320,28 +286,22 @@ dword_result_t VdPersistDisplay(PPCContext* ppc_context,
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdPersistDisplay,
|
DECLARE_XBOXKRNL_EXPORT(VdPersistDisplay,
|
||||||
ExportTag::kVideo | ExportTag::kSketchy);
|
ExportTag::kVideo | ExportTag::kSketchy);
|
||||||
|
|
||||||
dword_result_t VdRetrainEDRAMWorker(PPCContext* ppc_context,
|
dword_result_t VdRetrainEDRAMWorker(unknown_param_t unk0) { return 0; }
|
||||||
KernelState* kernel_state,
|
DECLARE_XBOXKRNL_EXPORT(VdRetrainEDRAMWorker,
|
||||||
unknown_param_t unk0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
DECLARE_EXPORT(xboxkrnl, VdRetrainEDRAMWorker,
|
|
||||||
ExportTag::kVideo | ExportTag::kStub);
|
ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
dword_result_t VdRetrainEDRAM(PPCContext* ppc_context,
|
dword_result_t VdRetrainEDRAM(unknown_param_t unk0, unknown_param_t unk1,
|
||||||
KernelState* kernel_state, unknown_param_t unk0,
|
unknown_param_t unk2, unknown_param_t unk3,
|
||||||
unknown_param_t unk1, unknown_param_t unk2,
|
unknown_param_t unk4, unknown_param_t unk5) {
|
||||||
unknown_param_t unk3, unknown_param_t unk4,
|
|
||||||
unknown_param_t unk5) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdRetrainEDRAM, ExportTag::kVideo | ExportTag::kStub);
|
DECLARE_XBOXKRNL_EXPORT(VdRetrainEDRAM, ExportTag::kVideo | ExportTag::kStub);
|
||||||
|
|
||||||
void VdSwap(
|
void VdSwap(
|
||||||
PPCContext* ppc_context, KernelState* kernel_state,
|
|
||||||
lpvoid_param_t buffer_ptr, // ptr into primary ringbuffer
|
lpvoid_param_t buffer_ptr, // ptr into primary ringbuffer
|
||||||
lpvoid_param_t fetch_ptr, // frontbuffer texture fetch
|
lpvoid_param_t fetch_ptr, // frontbuffer texture fetch
|
||||||
unknown_param_t unk2, //
|
unknown_param_t unk2, //
|
||||||
|
@ -379,14 +339,14 @@ void VdSwap(
|
||||||
dwords[3] = last_frontbuffer_width_;
|
dwords[3] = last_frontbuffer_width_;
|
||||||
dwords[4] = last_frontbuffer_height_;
|
dwords[4] = last_frontbuffer_height_;
|
||||||
}
|
}
|
||||||
DECLARE_EXPORT(xboxkrnl, VdSwap, ExportTag::kVideo | ExportTag::kImportant);
|
DECLARE_XBOXKRNL_EXPORT(VdSwap, ExportTag::kVideo | ExportTag::kImportant);
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
void xe::kernel::xboxkrnl::RegisterVideoExports(
|
void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||||
xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {
|
xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {
|
||||||
Memory* memory = kernel_state->memory();
|
auto memory = kernel_state->memory();
|
||||||
|
|
||||||
// VdGlobalDevice (4b)
|
// VdGlobalDevice (4b)
|
||||||
// Pointer to a global D3D device. Games only seem to set this, so we don't
|
// Pointer to a global D3D device. Games only seem to set this, so we don't
|
||||||
|
|
Loading…
Reference in New Issue