Switching kernel files to the new style.

This commit is contained in:
Ben Vanik 2013-05-26 21:37:47 -07:00
parent fbe800aacd
commit 6e8828f843
20 changed files with 155 additions and 56 deletions

View File

@ -11,5 +11,6 @@
#define XENIA_KERNEL_KERNEL_H_
#include <xenia/kernel/runtime.h>
#include <xenia/kernel/modules/modules.h>
#endif // XENIA_KERNEL_KERNEL_H_

View File

@ -6,6 +6,7 @@
'xam_module.cc',
'xam_module.h',
'xam_ordinals.h',
'xam_private.h',
'xam_state.cc',
'xam_state.h',
'xam_table.inc',

View File

@ -10,8 +10,8 @@
#include <xenia/kernel/modules/xam/xam_info.h>
#include <xenia/kernel/shim_utils.h>
#include <xenia/kernel/xbox.h>
#include <xenia/kernel/modules/xam/xam_module.h>
#include <xenia/kernel/modules/xam/xam_private.h>
#include <xenia/kernel/modules/xam/xam_state.h>
using namespace xe;

View File

@ -10,8 +10,10 @@
#ifndef XENIA_KERNEL_MODULES_XAM_INFO_H_
#define XENIA_KERNEL_MODULES_XAM_INFO_H_
#include <xenia/kernel/modules/xam/xam_state.h>
#include <xenia/kernel/modules/xam/xam_ordinals.h>
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/xbox.h>
namespace xe {
@ -19,7 +21,6 @@ namespace kernel {
namespace xam {
void RegisterInfoExports(ExportResolver* export_resolver, XamState* state);
} // namespace xam

View File

@ -10,7 +10,8 @@
#include <xenia/kernel/modules/xam/xam_module.h>
#include <xenia/kernel/export.h>
#include <xenia/kernel/modules/xam/xam_info.h>
#include <xenia/kernel/modules/xam/xam_private.h>
#include <xenia/kernel/modules/xam/xam_state.h>
using namespace xe;
@ -18,6 +19,9 @@ using namespace xe::kernel;
using namespace xe::kernel::xam;
XamState* xe::kernel::xam::shared_xam_state_ = NULL;
XamModule::XamModule(Runtime* runtime) :
KernelModule(runtime) {
// Build the export table used for resolution.
@ -32,9 +36,15 @@ XamModule::XamModule(Runtime* runtime) :
// Setup the xam state instance.
xam_state = auto_ptr<XamState>(new XamState(memory_, export_resolver_));
// Setup the shared global state object.
XEASSERTNULL(shared_xam_state_);
shared_xam_state_ = xam_state.get();
// Register all exported functions.
RegisterInfoExports(export_resolver_.get(), xam_state.get());
}
XamModule::~XamModule() {
// Clear the shared XAM state.
shared_xam_state_ = NULL;
}

View File

@ -17,6 +17,9 @@
#include <xenia/kernel/kernel_module.h>
#include <xenia/kernel/modules/xam/xam_ordinals.h>
// All of the exported functions:
#include <xenia/kernel/modules/xam/xam_info.h>
namespace xe {
namespace kernel {

View File

@ -0,0 +1,41 @@
/**
******************************************************************************
* 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_MODULES_XAM_PRIVATE_H_
#define XENIA_KERNEL_MODULES_XAM_PRIVATE_H_
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/modules/xam/xam_ordinals.h>
namespace xe {
namespace kernel {
namespace xam {
class XamState;
// This is a global object initialized with the XamModule.
// It references the current xam state object that all xam methods should
// be using to stash their variables.
extern XamState* shared_xam_state_;
// Registration functions, one per file.
void RegisterInfoExports(ExportResolver* export_resolver, XamState* state);
} // namespace xam
} // namespace kernel
} // namespace xe
#endif // XENIA_KERNEL_MODULES_XAM_PRIVATE_H_

View File

@ -16,12 +16,6 @@
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_hal.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_module.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.h>
using namespace xe;
using namespace xe::kernel;

View File

@ -17,6 +17,13 @@
#include <xenia/kernel/kernel_module.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
// All of the exported functions:
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_hal.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_module.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.h>
namespace xe {
namespace kernel {

View File

@ -10,7 +10,8 @@
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_hal.h>
#include <xenia/kernel/shim_utils.h>
#include <xenia/kernel/xbox.h>
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
using namespace xe;

View File

@ -10,8 +10,10 @@
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_HAL_H_
#define XENIA_KERNEL_MODULES_XBOXKRNL_HAL_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/xbox.h>
namespace xe {
@ -19,7 +21,6 @@ namespace kernel {
namespace xboxkrnl {
void RegisterHalExports(ExportResolver* export_resolver, KernelState* state);
} // namespace xboxkrnl

View File

@ -10,7 +10,7 @@
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.h>
#include <xenia/kernel/shim_utils.h>
#include <xenia/kernel/xbox.h>
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
@ -113,14 +113,40 @@ SHIM_CALL NtAllocateVirtualMemory_shim(
SHIM_SET_RETURN(result);
}
SHIM_CALL NtFreeVirtualMemory_shim(
xe_ppc_state_t* ppc_state, KernelState* state) {
X_STATUS xeNtFreeVirtualMemory(
uint32_t* base_addr_ptr, uint32_t* region_size_ptr,
uint32_t free_type, uint32_t unknown) {
KernelState* state = shared_kernel_state_;
XEASSERTNOTNULL(state);
// NTSTATUS
// _Inout_ PVOID *BaseAddress,
// _Inout_ PSIZE_T RegionSize,
// _In_ ULONG FreeType
// ? handle?
// I've only seen zero.
XEASSERT(unknown == 0);
if (!*base_addr_ptr) {
return X_STATUS_MEMORY_NOT_ALLOCATED;
}
// Free.
uint32_t flags = 0;
uint32_t freed_size = xe_memory_heap_free(state->memory(), *base_addr_ptr,
flags);
if (!freed_size) {
return X_STATUS_UNSUCCESSFUL;
}
// Stash back.
*region_size_ptr = freed_size;
return X_STATUS_SUCCESS;
}
SHIM_CALL NtFreeVirtualMemory_shim(
xe_ppc_state_t* ppc_state, KernelState* state) {
uint32_t base_addr_ptr = SHIM_GET_ARG_32(0);
uint32_t base_addr_value = SHIM_MEM_32(base_addr_ptr);
uint32_t region_size_ptr = SHIM_GET_ARG_32(1);
@ -129,33 +155,21 @@ SHIM_CALL NtFreeVirtualMemory_shim(
uint32_t free_type = SHIM_GET_ARG_32(2);
uint32_t unknown = SHIM_GET_ARG_32(3);
// I've only seen zero.
XEASSERT(unknown == 0);
XELOGD(
"NtFreeVirtualMemory(%.8X(%.8X), %.8X(%.8X), %.8X, %.8X)",
base_addr_ptr, base_addr_value,
region_size_ptr, region_size_value,
free_type, unknown);
if (!base_addr_value) {
SHIM_SET_RETURN(X_STATUS_MEMORY_NOT_ALLOCATED);
return;
}
X_STATUS result = xeNtFreeVirtualMemory(
&base_addr_value, &region_size_value,
free_type, unknown);
// Free.
uint32_t flags = 0;
uint32_t freed_size = xe_memory_heap_free(state->memory(), base_addr_value,
flags);
if (!freed_size) {
SHIM_SET_RETURN(X_STATUS_UNSUCCESSFUL);
return;
if (XSUCCEEDED(result)) {
SHIM_SET_MEM_32(base_addr_ptr, base_addr_value);
SHIM_SET_MEM_32(region_size_ptr, region_size_value);
}
// Stash back.
SHIM_SET_MEM_32(base_addr_ptr, base_addr_value);
SHIM_SET_MEM_32(region_size_ptr, freed_size);
SHIM_SET_RETURN(X_STATUS_SUCCESS);
SHIM_SET_RETURN(result);
}

View File

@ -10,8 +10,10 @@
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_MEMORY_H_
#define XENIA_KERNEL_MODULES_XBOXKRNL_MEMORY_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/xbox.h>
namespace xe {
@ -24,8 +26,9 @@ X_STATUS xeNtAllocateVirtualMemory(
uint32_t allocation_type, uint32_t protect_bits,
uint32_t unknown);
void RegisterMemoryExports(ExportResolver* export_resolver, KernelState* state);
X_STATUS xeNtFreeVirtualMemory(
uint32_t* base_addr_ptr, uint32_t* region_size_ptr,
uint32_t free_type, uint32_t unknown);
} // namespace xboxkrnl

View File

@ -10,8 +10,9 @@
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_module.h>
#include <xenia/kernel/shim_utils.h>
#include <xenia/kernel/xbox.h>
#include <xenia/kernel/xex2.h>
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>

View File

@ -10,8 +10,10 @@
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_IMPL_H_
#define XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_IMPL_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/xbox.h>
namespace xe {
@ -19,7 +21,7 @@ namespace kernel {
namespace xboxkrnl {
void RegisterModuleExports(ExportResolver* export_resolver, KernelState* state);
} // namespace xboxkrnl

View File

@ -13,6 +13,8 @@
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
namespace xe {
namespace kernel {
@ -20,10 +22,22 @@ namespace xboxkrnl {
class KernelState;
// This is a global object initialized with the XboxkrnlModule.
// It references the current kernel state object that all kernel methods should
// be using to stash their variables.
extern KernelState* shared_kernel_state_;
// Registration functions, one per file.
void RegisterHalExports(ExportResolver* export_resolver, KernelState* state);
void RegisterMemoryExports(ExportResolver* export_resolver, KernelState* state);
void RegisterModuleExports(ExportResolver* export_resolver, KernelState* state);
void RegisterRtlExports(ExportResolver* export_resolver, KernelState* state);
void RegisterThreadingExports(ExportResolver* export_resolver,
KernelState* state);
} // namespace xboxkrnl
} // namespace kernel
} // namespace xe

View File

@ -10,8 +10,9 @@
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h>
#include <xenia/kernel/shim_utils.h>
#include <xenia/kernel/xbox.h>
#include <xenia/kernel/xex2.h>
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>

View File

@ -10,8 +10,10 @@
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_RTL_H_
#define XENIA_KERNEL_MODULES_XBOXKRNL_RTL_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/xbox.h>
namespace xe {
@ -19,7 +21,7 @@ namespace kernel {
namespace xboxkrnl {
void RegisterRtlExports(ExportResolver* export_resolver, KernelState* state);
} // namespace xboxkrnl

View File

@ -10,7 +10,8 @@
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.h>
#include <xenia/kernel/shim_utils.h>
#include <xenia/kernel/xbox.h>
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>

View File

@ -10,8 +10,10 @@
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_THREADING_H_
#define XENIA_KERNEL_MODULES_XBOXKRNL_THREADING_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/xbox.h>
namespace xe {
@ -19,8 +21,7 @@ namespace kernel {
namespace xboxkrnl {
void RegisterThreadingExports(ExportResolver* export_resolver,
KernelState* state);
} // namespace xboxkrnl