Git Product home page Git Product logo

xqemu-kernel's Introduction

xqemu-kernel

An open-source Xbox kernel alternative, designed for use with XQEMU.

Build Status

Introduction

XQEMU is a low-level machine emulator, which needs a copy of the Xbox system software to start and run games. Unfortunately, this system software cannot be freely distributed due to it being copyrighted material. This means that in order to run XQEMU, the user must dump the MCPX ROM and TSOP flash images from their own physical Xbox. This, of course, can be a significant barrier to entry for many users.

Though it is a goal for XQEMU to continue to maintain compatibility with the official Xbox system software, it is benificial to also have an open-source alternative path for multiple reasons, namely licensing and performance optimizations. Fortunately, the interface between title and the kernel (API) is simple, clean, and largely documented and can therefore be implemented by an open-source alternative kernel, maintaining binary compatibility with unmodified title code.

Please note: by design, this project contains no copyrighted code from the official Xbox kernel.

Current State

Currently able to boot nxdk samples with full 3D graphics! It'll be a little while before this can boot a real game.

In order to use this kernel, you'll need to use a development branch of XQEMU which facilitates loading an XBE.

What's Here

A very basic kernel that will:

  • Switch to protected mode
  • Enable the serial port (printk)
  • Perform barebones device init (PCI, VGA, etc)
  • Read the EEPROM
  • Poke XQEMU to load an XBE into memory
  • Patch XBE imports with stub functions
  • Jump to XBE entry point
  • Handle a handful of kernel function calls

What's Needed

High-level list of major things that need to be implemented next:

Core Stuff:

  • Proper kernel memory allocator (SLAB, SLOB might be fine)
  • Proper virtual memory allocator for title
  • Thread/DPC Scheduler
  • Interrupt stuff

HLE Interfaces:

  • XQEMU HLE File IO
  • etc.

Other Kernel things...

  • Rtl functions
  • Kernel data exports
  • Lots of other kernel stuff

Getting Started

How to Build

Standard build tools and NASM are needed, then make -C src.

How to Run

Check out run.sh to see how to use this with XQEMU. Please note that you'll need the dev branch of XQEMU (mentioned above). Also note that you should not provide a bootrom image when running this kernel.

xqemu-kernel's People

Contributors

mborgerson avatar

Stargazers

Jason Todd avatar  avatar Jamie Sparks avatar  avatar RadWolfie avatar James Young avatar Jevin Sweval avatar Stanislav Motylkov avatar  avatar  avatar Chris C. avatar Gnaghi avatar  avatar Mayeul Cantan avatar  avatar  avatar Alexandre Paillier avatar Taylor Genn avatar  avatar Ivan Roberto de Oliveira avatar  avatar

Watchers

 avatar Jevin Sweval avatar Jannik Vogel avatar  avatar James Cloos avatar cm avatar  avatar  avatar  avatar

xqemu-kernel's Issues

Implement proper threading

Currently the kernel just jumps right into the title's entry point, does not support any form of context switching/multi-threading (and associated synchronization objects, etc.).

  • Support context switching
  • Support all synchronization objects
    • See ReactOS before trying to implement any of this from scratch!
  • Support preemptive multitasking (use system timer interrupt to switch threads)
  • Support DPC queue/execution

Implement proper title memory allocation

Currently the memory allocation works by just giving out memory in increasing order. This works with most of the NXDK samples because they simply make a few allocations at startup and never free, but this would fail spectacularly if any title tried to actually free/alloc. Thus, a proper memory allocator is needed.

  • Support tracking of physical memory
  • Support allocation of contiguous and non-contiguous chunks of physical memory
  • Support mapping physical memory into the virtual address space

Implement associated functions:

  • MmAllocateContiguousMemory
  • MmAllocateContiguousMemoryEx (Partial)
  • MmAllocateSystemMemory
  • MmClaimGpuInstanceMemory
  • MmCreateKernelStack
  • MmDeleteKernelStack
  • MmFreeContiguousMemory
  • MmFreeSystemMemory
  • MmGetPhysicalAddress
  • MmIsAddressValid
  • MmLockUnlockBufferPages
  • MmLockUnlockPhysicalPage
  • MmMapIoSpace
  • MmPersistContiguousMemory
  • MmQueryAddressProtect
  • MmQueryAllocationSize
  • MmQueryStatistics
  • MmSetAddressProtect
  • MmUnmapIoSpace
  • NtAllocateVirtualMemory (Partial)
  • NtFreeVirtualMemory

It may be possible to leverage parts of the Linux kernel to implement this. Recommend an earlier kernel version for simplicity.

Implement HLE File I/O

Fortunately, DVD/HDD file access on Xbox is handled by the kernel, but this has not been implemented yet. QEMU already supports a paravirtualized filesystem interface via virtfs, and this project should try to leverage as much of that if possible. Otherwise a custom File I/O system will have to be setup. Assuming the virtfs route, this will tentatively include:

  • Adding a virtio PCI ring buffer driver
  • Adding a 9p driver
  • Implementing associated kernel API

In the end this will allow users to avoid creating any disk images and can simply point XQEMU at a directory (or current) which contains the necessary sub-folders (C, D, E, X, Y, Z ...).

Implement basic `Rtl*` functions

Many (but not all) of these functions are quite simple libc style routines that can be easily implemented.

Including:

  • RtlAnsiStringToUnicodeString
  • RtlAppendStringToString
  • RtlAppendUnicodeStringToString
  • RtlAppendUnicodeToString
  • RtlAssert
  • RtlCharToInteger
  • RtlCompareMemory
  • RtlCompareMemoryUlong
  • RtlCompareString
  • RtlCompareUnicodeString
  • RtlCopyString
  • RtlCopyUnicodeString
  • RtlCreateUnicodeString
  • RtlDowncaseUnicodeChar
  • RtlDowncaseUnicodeString
  • RtlEqualString
  • RtlEqualUnicodeString
  • RtlExtendedIntegerMultiply
  • RtlExtendedLargeIntegerDivide
  • RtlExtendedMagicDivide
  • RtlFillMemory
  • RtlFillMemoryUlong
  • RtlFreeAnsiString
  • RtlFreeUnicodeString
  • RtlInitAnsiString
  • RtlInitUnicodeString
  • RtlIntegerToChar
  • RtlIntegerToUnicodeString
  • RtlLowerChar
  • RtlMoveMemory
  • RtlMultiByteToUnicodeN
  • RtlMultiByteToUnicodeSize
  • RtlNtStatusToDosError
  • RtlTimeFieldsToTime
  • RtlTimeToTimeFields
  • RtlUlongByteSwap
  • RtlUnicodeStringToAnsiString
  • RtlUnicodeStringToInteger
  • RtlUnicodeToMultiByteN
  • RtlUnicodeToMultiByteSize
  • RtlUpcaseUnicodeChar
  • RtlUpcaseUnicodeString
  • RtlUpcaseUnicodeToMultiByteN
  • RtlUpperChar
  • RtlUpperString
  • RtlUshortByteSwap
  • RtlZeroMemory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.