Convert old-style kernel convention to new-style convention #631

Open
DrChat opened this Issue Nov 19, 2016 · 5 comments

Projects

None yet

4 participants

@DrChat
Collaborator
DrChat commented Nov 19, 2016 edited

Just rewrite exports using the old shim convention to the new convention.

E.g. XAudioGetSpeakerConfig

SHIM_CALL XAudioGetSpeakerConfig_shim(PPCContext* ppc_context,
                                      KernelState* kernel_state) {
  uint32_t config_ptr = SHIM_GET_ARG_32(0);

  XELOGD("XAudioGetSpeakerConfig(%.8X)", config_ptr);

  SHIM_SET_MEM_32(config_ptr, 0x00010001);

  SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
}

...

SHIM_SET_MAPPING("xboxkrnl.exe", XAudioGetSpeakerConfig, state);

Becomes

dword_result_t XAudioGetSpeakerConfig(lpdword_t config_ptr) {
  *config_ptr = 0x00010001;
  return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT(XAudioGetSpeakerConfig, ExportTag::kImplemented);

// (Call to SHIM_SET_MAPPING removed)

Fairly easy to do, just use others already converted as guidelines if you get lost. Be sure to add appropriate ExportTags and test the exports after conversion to make sure they still work!

Visual Studio can sometimes glitch out and cause you to hit an assert when starting Xenia after you convert an export. If that happens, clean and rebuild xenia-kernel.

Do not remove the Register*Exports functions, even if they become blank. They are still required for proper linkage.

@mmdanggg2

Hey, I was trying to do this but I'm just getting an exception after loading an iso. Not too sure how to debug it, It's crashing at shim_utils.h L423 and the string_buffer has got XAudioGetVoiceCategoryVolumeChangeMask in it so I assume that's where the problem is.

Unhandled exception at 0x00007FF622FB9F12 in xenia.exe: 0xC0000005: Access violation reading location 0x0000000241550000.

You can check the code https://github.com/mmdanggg2/xenia/blob/master/src/xenia/kernel/xboxkrnl/xboxkrnl_audio.cc

Thoughts/Suggestions?

@DrChat
Collaborator
DrChat commented Nov 25, 2016
@mmdanggg2

Don't think that's what's causing this problem, even with both lines commented out and just a return, it crashes the same.

@Nukem9
Contributor
Nukem9 commented Nov 25, 2016 edited

@mmdanggg2 I'd assume all instances of *driver_ptr need to be replaced like this or something similar(?):

assert_true((*driver_ptr & 0xFFFF0000) == 0x41550000);
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);

@maxton
Contributor
maxton commented Dec 2, 2016 edited

Just for reference, these are the kernel source files that still need updating, in descending order of number of functions

  • xboxkrnl_threading.cc
  • xboxkrnl_memory.cc
  • xboxkrnl_strings.cc
  • xboxkrnl_modules.cc
  • xboxkrnl_audio_xma.cc
  • xboxkrnl_ob.cc
  • xboxkrnl_rtl.cc
  • xboxkrnl_audio.cc
  • xboxkrnl_io.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment