Converting some exports to the new way.

This commit is contained in:
Ben Vanik 2015-06-01 20:56:57 -07:00
parent f634edb9eb
commit a91a754b24
17 changed files with 857 additions and 1325 deletions

View File

@ -388,7 +388,6 @@
<ClInclude Include="src\xenia\kernel\xboxkrnl_ordinals.h" />
<ClInclude Include="src\xenia\kernel\xboxkrnl_private.h" />
<ClInclude Include="src\xenia\kernel\xboxkrnl_rtl.h" />
<ClInclude Include="src\xenia\kernel\xboxkrnl_error.h" />
<ClInclude Include="src\xenia\kernel\xobject.h" />
<ClInclude Include="src\xenia\memory.h" />
<ClInclude Include="src\xenia\profiling.h" />

View File

@ -1341,9 +1341,6 @@
<ClInclude Include="third_party\xbyak\xbyak\xbyak.h">
<Filter>third_party\xbyak\xbyak</Filter>
</ClInclude>
<ClInclude Include="src\xenia\kernel\xboxkrnl_error.h">
<Filter>src\xenia\kernel</Filter>
</ClInclude>
<ClInclude Include="src\xenia\apu\audio_decoder.h">
<Filter>src\xenia\apu</Filter>
</ClInclude>

View File

@ -107,6 +107,7 @@ template <typename T>
class ParamBase : public Param {
public:
ParamBase() : Param(), value_(0) {}
ParamBase(T value) : Param(), value_(value) {}
ParamBase(Init& init) : Param(init) { LoadValue<T>(init); }
ParamBase& operator=(const T& other) {
value_ = other;
@ -206,6 +207,31 @@ class PrimitivePointerParam : public ParamBase<uint32_t> {
xe::be<T>* host_ptr_;
};
template <typename CHAR, typename STR>
class StringPointerParam : public ParamBase<uint32_t> {
public:
StringPointerParam(Init& init) : ParamBase(init) {
host_ptr_ = value_ ? reinterpret_cast<CHAR*>(
init.ppc_context->virtual_membase + value_)
: nullptr;
}
StringPointerParam(CHAR* host_ptr) : ParamBase(), host_ptr_(host_ptr) {}
StringPointerParam& operator=(const CHAR*& other) {
host_ptr_ = other;
return *this;
}
uint32_t guest_address() const { return value_; }
uintptr_t host_address() const {
return reinterpret_cast<uintptr_t>(host_ptr_);
}
STR value() const { return STR(host_ptr_); }
operator CHAR*() const { return host_ptr_; }
operator bool() const { return host_ptr_ != nullptr; }
protected:
CHAR* host_ptr_;
};
template <typename T>
class TypedPointerParam : public ParamBase<uint32_t> {
public:
@ -265,9 +291,11 @@ using lpdword_t = const shim::PrimitivePointerParam<uint32_t>&;
using lpqword_t = const shim::PrimitivePointerParam<uint64_t>&;
using lpfloat_t = const shim::PrimitivePointerParam<float>&;
using lpdouble_t = const shim::PrimitivePointerParam<double>&;
using lpstring_t = const shim::StringPointerParam<char, std::string>&;
using lpwstring_t = const shim::StringPointerParam<wchar_t, std::wstring>&;
using function_t = const shim::ParamBase<uint32_t>&;
using unknown_t = const shim::ParamBase<uint32_t>&;
using unknown_pointer_t = const shim::PointerParam&;
using lpunknown_t = const shim::PointerParam&;
template <typename T>
using pointer_t = const shim::TypedPointerParam<T>&;

View File

@ -65,13 +65,6 @@ SHIM_CALL XGetLanguage_shim(PPCContext* ppc_context,
SHIM_SET_RETURN_32(desired_language);
}
SHIM_CALL XamVoiceIsActiveProcess_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
XELOGD("XamVoiceIsActiveProcess()");
// Returning 0 here will short-circuit a bunch of voice stuff.
SHIM_SET_RETURN_32(0);
}
SHIM_CALL XamGetExecutionId_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t info_ptr = SHIM_GET_ARG_32(0);
@ -217,7 +210,6 @@ void xe::kernel::xam::RegisterInfoExports(
SHIM_SET_MAPPING("xam.xex", XGetGameRegion, state);
SHIM_SET_MAPPING("xam.xex", XGetLanguage, state);
SHIM_SET_MAPPING("xam.xex", XamVoiceIsActiveProcess, state);
SHIM_SET_MAPPING("xam.xex", XamGetExecutionId, state);
SHIM_SET_MAPPING("xam.xex", XamLoaderSetLaunchData, state);

View File

@ -29,8 +29,6 @@ XamModule::XamModule(Emulator* emulator, KernelState* kernel_state)
xam::RegisterNotifyExports(export_resolver_, kernel_state_);
xam::RegisterUIExports(export_resolver_, kernel_state_);
xam::RegisterUserExports(export_resolver_, kernel_state_);
xam::RegisterVideoExports(export_resolver_, kernel_state_);
xam::RegisterVoiceExports(export_resolver_, kernel_state_);
}
std::vector<xe::cpu::Export*> xam_exports;

View File

@ -38,10 +38,6 @@ void RegisterUIExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterUserExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterVideoExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterVoiceExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
} // namespace xam
} // namespace kernel

View File

@ -18,27 +18,14 @@ namespace kernel {
// TODO(benvanik): actually check to see if these are the same.
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode);
SHIM_CALL XGetVideoMode_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t video_mode_ptr = SHIM_GET_ARG_32(0);
X_VIDEO_MODE* video_mode = (X_VIDEO_MODE*)SHIM_MEM_ADDR(video_mode_ptr);
XELOGD("XGetVideoMode(%.8X)", video_mode_ptr);
VdQueryVideoMode(video_mode);
void XGetVideoMode(pointer_t<X_VIDEO_MODE> video_mode) {
VdQueryVideoMode(std::move(video_mode));
}
DECLARE_XAM_EXPORT(XGetVideoMode, ExportTag::kVideo | ExportTag::kStub);
SHIM_CALL XGetVideoCapabilities_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
XELOGD("XGetVideoCapabilities()");
SHIM_SET_RETURN_32(0);
}
dword_result_t XGetVideoCapabilities() { return 0; }
DECLARE_XAM_EXPORT(XGetVideoCapabilities, ExportTag::kVideo | ExportTag::kStub);
} // namespace kernel
} // namespace xe
void xe::kernel::xam::RegisterVideoExports(
xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {
SHIM_SET_MAPPING("xam.xex", XGetVideoCapabilities, state);
SHIM_SET_MAPPING("xam.xex", XGetVideoMode, state);
}

View File

@ -17,44 +17,26 @@
namespace xe {
namespace kernel {
SHIM_CALL XamVoiceCreate_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t unk1 = SHIM_GET_ARG_32(0); // 0
uint32_t unk2 = SHIM_GET_ARG_32(1); // 0xF
uint32_t out_voice_ptr = SHIM_GET_ARG_32(2);
XELOGD("XamVoiceCreate(%.8X, %.8X, %.8X)", unk1, unk2, out_voice_ptr);
dword_result_t XamVoiceIsActiveProcess() {
// Returning 0 here will short-circuit a bunch of voice stuff.
return 0;
}
DECLARE_XAM_EXPORT(XamVoiceIsActiveProcess, ExportTag::kStub);
dword_result_t XamVoiceCreate(unknown_t unk1, // 0
unknown_t unk2, // 0xF
lpdword_t out_voice_ptr) {
// Null out the ptr.
SHIM_SET_MEM_32(out_voice_ptr, 0);
SHIM_SET_RETURN_32(X_ERROR_ACCESS_DENIED);
out_voice_ptr.Zero();
return X_ERROR_ACCESS_DENIED;
}
DECLARE_XAM_EXPORT(XamVoiceCreate, ExportTag::kStub);
SHIM_CALL XamVoiceClose_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t voice_ptr = SHIM_GET_ARG_32(0);
dword_result_t XamVoiceClose(lpunknown_t voice_ptr) { return 0; }
DECLARE_XAM_EXPORT(XamVoiceClose, ExportTag::kStub);
XELOGD("XamVoiceClose(%.8X)", voice_ptr);
SHIM_SET_RETURN_32(0);
}
SHIM_CALL XamVoiceHeadsetPresent_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t voice_ptr = SHIM_GET_ARG_32(0);
XELOGD("XamVoiceHeadsetPresent(%.8X)", voice_ptr);
SHIM_SET_RETURN_32(0);
}
dword_result_t XamVoiceHeadsetPresent(lpunknown_t voice_ptr) { return 0; }
DECLARE_XAM_EXPORT(XamVoiceHeadsetPresent, ExportTag::kStub);
} // namespace kernel
} // namespace xe
void xe::kernel::xam::RegisterVoiceExports(
xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {
SHIM_SET_MAPPING("xam.xex", XamVoiceCreate, state);
SHIM_SET_MAPPING("xam.xex", XamVoiceClose, state);
SHIM_SET_MAPPING("xam.xex", XamVoiceHeadsetPresent, state);
}

View File

@ -17,210 +17,15 @@
namespace xe {
namespace kernel {
#define SHIM_GPR_32(n) (uint32_t)(ppc_context->r[n])
// TODO: clean me up!
SHIM_CALL DbgPrint_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(0);
if (format_ptr == 0) {
SHIM_SET_RETURN_32(-1);
return;
}
const char* format = (const char*)SHIM_MEM_ADDR(format_ptr);
int arg_index = 0;
char buffer[512]; // TODO: ensure it never writes past the end of the
// buffer...
char* b = buffer;
for (; *format != '\0'; ++format) {
const char* start = format;
if (*format != '%') {
*b++ = *format;
continue;
}
++format;
if (*format == '\0') {
break;
}
if (*format == '%') {
*b++ = *format;
continue;
}
const char* end;
end = format;
// skip flags
while (*end == '-' || *end == '+' || *end == ' ' || *end == '#' ||
*end == '0') {
++end;
}
if (*end == '\0') {
break;
}
int arg_extras = 0;
// skip width
if (*end == '*') {
++end;
arg_extras++;
} else {
while (*end >= '0' && *end <= '9') {
++end;
}
}
if (*end == '\0') {
break;
}
// skip precision
if (*end == '.') {
++end;
if (*end == '*') {
++end;
++arg_extras;
} else {
while (*end >= '0' && *end <= '9') {
++end;
}
}
}
if (*end == '\0') {
break;
}
// get length
int arg_size = 4;
if (*end == 'h') {
++end;
arg_size = 4;
if (*end == 'h') {
++end;
}
} else if (*end == 'l') {
++end;
arg_size = 4;
if (*end == 'l') {
++end;
arg_size = 8;
}
} else if (*end == 'j') {
arg_size = 8;
++end;
} else if (*end == 'z') {
arg_size = 4;
++end;
} else if (*end == 't') {
arg_size = 8;
++end;
} else if (*end == 'L') {
arg_size = 8;
++end;
}
if (*end == '\0') {
break;
}
if (*end == 'd' || *end == 'i' || *end == 'u' || *end == 'o' ||
*end == 'x' || *end == 'X' || *end == 'f' || *end == 'F' ||
*end == 'e' || *end == 'E' || *end == 'g' || *end == 'G' ||
*end == 'a' || *end == 'A' || *end == 'c') {
char local[512];
local[0] = '\0';
strncat(local, start, end + 1 - start);
assert_true(arg_size == 8 || arg_size == 4);
if (arg_size == 8) {
if (arg_extras == 0) {
uint64_t value =
arg_index < 7
? SHIM_GET_ARG_64(1 + arg_index)
: SHIM_MEM_32(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
int result = sprintf(b, local, value);
b += result;
arg_index++;
} else {
assert_true(false);
}
} else if (arg_size == 4) {
if (arg_extras == 0) {
uint64_t value =
arg_index < 7
? SHIM_GET_ARG_64(1 + arg_index)
: SHIM_MEM_32(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
int result = sprintf(b, local, (uint32_t)value);
b += result;
arg_index++;
} else {
assert_true(false);
}
}
} else if (*end == 'n') {
assert_true(arg_size == 4);
if (arg_extras == 0) {
uint32_t value = arg_index < 7
? SHIM_GET_ARG_32(1 + arg_index)
: (uint32_t)SHIM_MEM_64(SHIM_GPR_32(1) + 16 +
((1 + arg_index) * 8));
SHIM_SET_MEM_32(value, (uint32_t)((b - buffer) / sizeof(char)));
arg_index++;
} else {
assert_true(false);
}
} else if (*end == 's' || *end == 'p') {
char local[512];
local[0] = '\0';
strncat(local, start, end + 1 - start);
assert_true(arg_size == 4);
if (arg_extras == 0) {
uint32_t value = arg_index < 7
? SHIM_GET_ARG_32(1 + arg_index)
: (uint32_t)SHIM_MEM_64(SHIM_GPR_32(1) + 16 +
((1 + arg_index) * 8));
const void* pointer = (const void*)SHIM_MEM_ADDR(value);
int result = sprintf(b, local, pointer);
b += result;
arg_index++;
} else {
assert_true(false);
}
} else {
assert_true(false);
break;
}
format = end;
}
*b++ = '\0';
XELOGD("(DbgPrint) %s", buffer);
}
SHIM_CALL DbgBreakPoint_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
XELOGD("DbgBreakPoint()");
DebugBreak();
}
void DbgBreakPoint() { DebugBreak(); }
DECLARE_XBOXKRNL_EXPORT(DbgBreakPoint, ExportTag::kImportant);
// https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
typedef struct {
xe::be<uint32_t> type;
xe::be<uint32_t> name_ptr;
xe::be<uint32_t> thread_id;
xe::be<uint32_t> flags;
xe::be<uint32_t> type;
xe::be<uint32_t> name_ptr;
xe::be<uint32_t> thread_id;
xe::be<uint32_t> flags;
} X_THREADNAME_INFO;
static_assert_size(X_THREADNAME_INFO, 0x10);
@ -234,24 +39,24 @@ typedef struct {
xe::be<uint32_t> exception_information[15];
} X_EXCEPTION_RECORD;
static_assert_size(X_EXCEPTION_RECORD, 0x50);
void AppendParam(StringBuffer& string_buffer,
pointer_t<X_EXCEPTION_RECORD> record) {
string_buffer.AppendFormat("%.8X(%.8X)", record.guest_address(),
record->exception_code);
}
SHIM_CALL RtlRaiseException_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t record_ptr = SHIM_GET_ARG_32(0);
auto record = reinterpret_cast<X_EXCEPTION_RECORD*>(SHIM_MEM_ADDR(record_ptr));
XELOGD("RtlRaiseException(%.8X(%.8X))", record_ptr, record->exception_code);
void RtlRaiseException(pointer_t<X_EXCEPTION_RECORD> record) {
if (record->exception_code == 0x406D1388) {
// SetThreadName. FFS.
// https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
// TODO: check record->number_parameters to make sure it's a correct size
auto thread_info = reinterpret_cast<X_THREADNAME_INFO*>(&record->exception_information[0]);
auto thread_info =
reinterpret_cast<X_THREADNAME_INFO*>(&record->exception_information[0]);
assert_true(thread_info->type == 0x1000);
const char* name = (const char*)SHIM_MEM_ADDR(thread_info->name_ptr);
auto name =
kernel_memory()->TranslateVirtual<const char*>(thread_info->name_ptr);
object_ref<XThread> thread;
if (thread_info->thread_id == -1) {
@ -259,7 +64,7 @@ SHIM_CALL RtlRaiseException_shim(PPCContext* ppc_context,
thread = retain_object(XThread::GetCurrentThread());
} else {
// Lookup thread by ID.
thread = kernel_state->GetThreadByID(thread_info->thread_id);
thread = kernel_state()->GetThreadByID(thread_info->thread_id);
}
if (thread) {
@ -282,39 +87,20 @@ SHIM_CALL RtlRaiseException_shim(PPCContext* ppc_context,
// This is going to suck.
DebugBreak();
}
DECLARE_XBOXKRNL_EXPORT(RtlRaiseException, ExportTag::kImportant);
void xeKeBugCheckEx(uint32_t code, uint32_t param1, uint32_t param2,
uint32_t param3, uint32_t param4) {
void KeBugCheckEx(dword_t code, dword_t param1, dword_t param2, dword_t param3,
dword_t param4) {
XELOGD("*** STOP: 0x%.8X (0x%.8X, 0x%.8X, 0x%.8X, 0x%.8X)", code, param1,
param2, param3, param4);
fflush(stdout);
DebugBreak();
assert_always();
}
DECLARE_XBOXKRNL_EXPORT(KeBugCheckEx, ExportTag::kImportant);
SHIM_CALL KeBugCheck_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t code = SHIM_GET_ARG_32(0);
xeKeBugCheckEx(code, 0, 0, 0, 0);
}
SHIM_CALL KeBugCheckEx_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t code = SHIM_GET_ARG_32(0);
uint32_t param1 = SHIM_GET_ARG_32(1);
uint32_t param2 = SHIM_GET_ARG_32(2);
uint32_t param3 = SHIM_GET_ARG_32(3);
uint32_t param4 = SHIM_GET_ARG_32(4);
xeKeBugCheckEx(code, param1, param2, param3, param4);
}
void KeBugCheck(dword_t code) { KeBugCheckEx(code, 0, 0, 0, 0); }
DECLARE_XBOXKRNL_EXPORT(KeBugCheck, ExportTag::kImportant);
} // namespace kernel
} // namespace xe
void xe::kernel::xboxkrnl::RegisterDebugExports(
xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {
SHIM_SET_MAPPING("xboxkrnl.exe", DbgPrint, state);
SHIM_SET_MAPPING("xboxkrnl.exe", DbgBreakPoint, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlRaiseException, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeBugCheck, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeBugCheckEx, state);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_KERNEL_XBOXKRNL_ERROR_H_
#define XENIA_KERNEL_XBOXKRNL_ERROR_H_
#include "xenia/xbox.h"
namespace xe {
namespace kernel {
} // namespace kernel
} // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_ERROR_H_

View File

@ -16,12 +16,7 @@
namespace xe {
namespace kernel {
SHIM_CALL HalReturnToFirmware_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t routine = SHIM_GET_ARG_32(0);
XELOGD("HalReturnToFirmware(%d)", routine);
void HalReturnToFirmware(dword_t routine) {
// void
// IN FIRMWARE_REENTRY Routine
@ -33,11 +28,7 @@ SHIM_CALL HalReturnToFirmware_shim(PPCContext* ppc_context,
XELOGE("Game requested shutdown via HalReturnToFirmware");
exit(0);
}
DECLARE_XBOXKRNL_EXPORT(HalReturnToFirmware, ExportTag::kImportant);
} // namespace kernel
} // namespace xe
void xe::kernel::xboxkrnl::RegisterHalExports(
xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {
SHIM_SET_MAPPING("xboxkrnl.exe", HalReturnToFirmware, state);
}

View File

@ -30,9 +30,6 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
// Register all exported functions.
xboxkrnl::RegisterAudioExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterAudioXmaExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterDebugExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterErrorExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterHalExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterIoExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterMemoryExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterMiscExports(export_resolver_, kernel_state_);
@ -41,7 +38,6 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
xboxkrnl::RegisterRtlExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterStringExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterThreadingExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterUsbcamExports(export_resolver_, kernel_state_);
xboxkrnl::RegisterVideoExports(export_resolver_, kernel_state_);
// KeDebugMonitorData (?*)

View File

@ -25,12 +25,6 @@ void RegisterAudioExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterAudioXmaExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterDebugExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterErrorExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterHalExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterIoExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterMemoryExports(xe::cpu::ExportResolver* export_resolver,
@ -47,8 +41,6 @@ void RegisterStringExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterThreadingExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterUsbcamExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
void RegisterVideoExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state);
} // namespace xboxkrnl

View File

@ -961,6 +961,28 @@ SHIM_CALL _vscwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
SHIM_SET_RETURN_32(count);
}
SHIM_CALL DbgPrint_shim(PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t format_ptr = SHIM_GET_ARG_32(0);
if (!format_ptr) {
SHIM_SET_RETURN_32(X_STATUS_INVALID_PARAMETER);
return;
}
auto format = (const uint8_t*)SHIM_MEM_ADDR(format_ptr);
StackArgList args(ppc_context);
StringFormatData data(format);
int32_t count = format_core(ppc_context, data, args, false);
if (count <= 0) {
SHIM_SET_RETURN_32(X_STATUS_SUCCESS);
return;
}
XELOGD("(DbgPrint) %s", data.str().c_str());
SHIM_SET_RETURN_32(X_STATUS_SUCCESS);
}
} // namespace kernel
} // namespace xe
@ -971,4 +993,5 @@ void xe::kernel::xboxkrnl::RegisterStringExports(
SHIM_SET_MAPPING("xboxkrnl.exe", _vsnprintf, state);
SHIM_SET_MAPPING("xboxkrnl.exe", vswprintf, state);
SHIM_SET_MAPPING("xboxkrnl.exe", _vscwprintf, state);
SHIM_SET_MAPPING("xboxkrnl.exe", DbgPrint, state);
}

View File

@ -16,30 +16,19 @@
namespace xe {
namespace kernel {
SHIM_CALL XUsbcamCreate_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t unk1 = SHIM_GET_ARG_32(0); // E
uint32_t unk2 = SHIM_GET_ARG_32(1); // 0x4B000
uint32_t unk3_ptr = SHIM_GET_ARG_32(3);
XELOGD("XUsbcamCreate(%.8X, %.8X, %.8X)", unk1, unk2, unk3_ptr);
dword_result_t XUsbcamCreate(unknown_t unk1, // E
unknown_t unk2, // 0x4B000
lpunknown_t unk3_ptr) {
// 0 = success.
SHIM_SET_RETURN_32(X_ERROR_DEVICE_NOT_CONNECTED);
return X_ERROR_DEVICE_NOT_CONNECTED;
}
DECLARE_XBOXKRNL_EXPORT(XUsbcamCreate, ExportTag::kStub);
SHIM_CALL XUsbcamGetState_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
XELOGD("XUsbcamGetState()");
dword_result_t XUsbcamGetState() {
// 0 = not connected.
SHIM_SET_RETURN_32(0);
return 0;
}
DECLARE_XBOXKRNL_EXPORT(XUsbcamGetState, ExportTag::kStub);
} // namespace kernel
} // namespace xe
void xe::kernel::xboxkrnl::RegisterUsbcamExports(
xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {
SHIM_SET_MAPPING("xboxkrnl.exe", XUsbcamCreate, state);
SHIM_SET_MAPPING("xboxkrnl.exe", XUsbcamGetState, state);
}

View File

@ -115,8 +115,8 @@ DECLARE_XBOXKRNL_EXPORT(VdSetDisplayModeOverride,
ExportTag::kVideo | ExportTag::kStub);
dword_result_t VdInitializeEngines(unknown_t unk0, function_t callback,
unknown_t unk1, unknown_pointer_t unk2_ptr,
unknown_pointer_t unk3_ptr) {
unknown_t unk1, lpunknown_t unk2_ptr,
lpunknown_t unk3_ptr) {
// r3 = 0x4F810000
// r4 = function ptr (cleanup callback?)
// r5 = 0
@ -175,8 +175,7 @@ void VdEnableRingBufferRPtrWriteBack(lpvoid_t ptr, int_t block_size) {
}
DECLARE_XBOXKRNL_EXPORT(VdEnableRingBufferRPtrWriteBack, ExportTag::kVideo);
void VdGetSystemCommandBuffer(unknown_pointer_t p0_ptr,
unknown_pointer_t p1_ptr) {
void VdGetSystemCommandBuffer(lpunknown_t p0_ptr, lpunknown_t p1_ptr) {
p0_ptr.Zero(0x94);
xe::store_and_swap<uint32_t>(p0_ptr, 0xBEEF0000);
xe::store_and_swap<uint32_t>(p1_ptr, 0xBEEF0001);
@ -184,7 +183,7 @@ void VdGetSystemCommandBuffer(unknown_pointer_t p0_ptr,
DECLARE_XBOXKRNL_EXPORT(VdGetSystemCommandBuffer,
ExportTag::kVideo | ExportTag::kStub);
void VdSetSystemCommandBufferGpuIdentifierAddress(unknown_pointer_t unk) {
void VdSetSystemCommandBufferGpuIdentifierAddress(lpunknown_t unk) {
// r3 = 0x2B10(d3d?) + 8
}
DECLARE_XBOXKRNL_EXPORT(VdSetSystemCommandBufferGpuIdentifierAddress,
@ -196,16 +195,16 @@ DECLARE_XBOXKRNL_EXPORT(VdSetSystemCommandBufferGpuIdentifierAddress,
// no op?
dword_result_t VdInitializeScalerCommandBuffer(
unknown_t unk0, // 0?
unknown_t unk1, // 0x050002d0 size of ?
unknown_t unk2, // 0?
unknown_t unk3, // 0x050002d0 size of ?
unknown_t unk4, // 0x050002d0 size of ?
unknown_t unk5, // 7?
unknown_pointer_t unk6, // 0x2004909c <-- points to zeros?
unknown_t unk7, // 7?
lpvoid_t dest_ptr // Points to the first 80000000h where the memcpy
// sources from.
unknown_t unk0, // 0?
unknown_t unk1, // 0x050002d0 size of ?
unknown_t unk2, // 0?
unknown_t unk3, // 0x050002d0 size of ?
unknown_t unk4, // 0x050002d0 size of ?
unknown_t unk5, // 7?
lpunknown_t unk6, // 0x2004909c <-- points to zeros?
unknown_t unk7, // 7?
lpvoid_t dest_ptr // Points to the first 80000000h where the memcpy
// sources from.
) {
// We could fake the commands here, but I'm not sure the game checks for
// anything but success (non-zero ret).
@ -290,14 +289,13 @@ dword_result_t VdRetrainEDRAM(unknown_t unk0, unknown_t unk1, unknown_t unk2,
}
DECLARE_XBOXKRNL_EXPORT(VdRetrainEDRAM, ExportTag::kVideo | ExportTag::kStub);
void VdSwap(
lpvoid_t buffer_ptr, // ptr into primary ringbuffer
lpvoid_t fetch_ptr, // frontbuffer texture fetch
unknown_t unk2, //
unknown_pointer_t unk3, // buffer from VdGetSystemCommandBuffer
unknown_pointer_t unk4, // from VdGetSystemCommandBuffer (0xBEEF0001)
lpdword_t frontbuffer_ptr, // ptr to frontbuffer address
lpdword_t color_format_ptr, lpdword_t color_space_ptr) {
void VdSwap(lpvoid_t buffer_ptr, // ptr into primary ringbuffer
lpvoid_t fetch_ptr, // frontbuffer texture fetch
unknown_t unk2, //
lpunknown_t unk3, // buffer from VdGetSystemCommandBuffer
lpunknown_t unk4, // from VdGetSystemCommandBuffer (0xBEEF0001)
lpdword_t frontbuffer_ptr, // ptr to frontbuffer address
lpdword_t color_format_ptr, lpdword_t color_space_ptr) {
gpu::xenos::xe_gpu_texture_fetch_t fetch;
xe::copy_and_swap_32_unaligned(
reinterpret_cast<uint32_t*>(&fetch),