Copy Link
Add to Bookmark
Report

Bootstrap Idea for Linux - 2

xbox's profile picture
Published in 
xbox
 · 20 Feb 2024

written by Michael Steil, 2 June 2002

My proposal for booting Linux from within the Xbox kernel uses many ideas of anonymous' ideas, but might be simpler, because we do not have to defragment the Linux kernel and we can stay in Protected Mode.

Using MmMapIoSpace, we can get a window in virtual memory straight through to physical memory. The Linux kernel needs to be at 1 MB in physical memory in order to get started, so we use this call to be able to copy it there directly without having to defragment it. But there are some problems:

  • we might overwrite parts of the NT kernel
  • we might overwrite parts of our own code
  • we might overwrite parts of the Linux kernel already in memory
  • we might overwrite parts of the NT pagetables

That's why we do the following:

  1. Keep allocating 4 KB pages of memory between 1 MB and 2 MB in physical memory using MmAllocateContiguousEx until all memory there is allocated.
  2. Allocate 1 MB or virtual memory and put the Linux kernel there. Overwriting Linux will not be possible any more.
  3. Disable interrupts. Overwriting NT will not matter any more.
  4. Create a window through to physical memory between 1 MB - 2 MB using MmMapIoSpace. (We must ensure that our bootloader code does not reside between 1 MB and 2 MB in virtual address space, but this is easy: We can put our address in virtual memory into the XBE header.)
  5. Copy the rest of our code into the last page of 1 MB - 2 MB and jump there. (Hopefully we will not overwrite our current pagetables - but this is very unprobable.)
  6. Copy the Linux kernel image to 1 MB (again: pagetables?)
  7. Turn off paging
  8. Load the new GDT and IDT Linux expects
  9. Jump to 0x10:0x100000, i.e. run Linux

If we want to use an initial RAM disk, we need a larger window, but the reat basically stays the same.

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT