Skip to content

Commit

Permalink
prephv: cleanup, README
Browse files Browse the repository at this point in the history
I haven't written enough worth sharing, but I've written
enough that would be terrible to lose...so time to share it
away.

Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
  • Loading branch information
andreiw committed Apr 7, 2016
1 parent fe2c3ae commit b5f3ec4
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 570 deletions.
11 changes: 6 additions & 5 deletions Makefile
@@ -1,20 +1,19 @@
ENV_FILE=build_env
-include $(ENV_FILE)

SHELL := /bin/bash

OBJ = entry.o main.o console.o lib/string.o fdt.o fdt_strerror.o fdt_ro.o exc-vecs.o guest.o \
exc.o time.o mmu.o mem.o opal.o cache.o rom.o lib/ctype.o lib/vsprintf.o log.o lib/malloc.o \
fat/fat_cache.o fat/fat_format.o fat/fat_string.o fat/fat_write.o \
fat/fat_access.o fat/fat_filelib.o fat/fat_misc.o fat/fat_table.o

NAME = prephv

ifeq ($(CONFIG_MAMBO), 1)
BUILD_FLAGS = -DCONFIG_MAMBO
OBJ += mambo.o
endif

CROSS ?= ppc64le-linux
CC = $(CROSS)-gcc
PPC64QEMU ?= qemu-system-ppc64
FAT_IMAGE ?= ../image.fat # relative to skiboot

ARCH_FLAGS = -msoft-float -mpowerpc64 -mcpu=power8 -mtune=power8 -mabi=elfv2 \
-mlittle-endian -mno-strict-align -mno-multiple \
Expand Down Expand Up @@ -42,6 +41,8 @@ clean_env: log_clean_env clean
@echo OLD_BUILD_ENV=\"$(BUILD_ENV)\" > $(ENV_FILE)

test: $(NAME) skiboot/skiboot.lid
$(shell pushd skiboot && $(PPC64QEMU) -m 4G -M powernv -nographic -kernel ../prephv -initrd $(FAT_IMAGE) 1>&2 || 0)
$(shell reset)

skiboot/skiboot.lid:
git submodule update --init skiboot
Expand Down
92 changes: 92 additions & 0 deletions README.md
@@ -0,0 +1,92 @@
prephv - because I wasted my 90's playing with LEGOs.
=====================================================

This is mostly a huge ugly hack, derived from my
ppc64le_hello code. The running philosophy here is
to throw things together late at night with my family
asleep and see how far I get without a real design
or without a real desire to implement boring things
like IDE (*sigh*) emulation. PowerPC things though
are considered fun and crucial...anyway...

It's a 64-bit LE ``hypervisor'', running a single 32-bit
LE VM, with the intention of modelling some as of yet
unknown PReP machine...eventually hopefully enough to BSOD
inside the Windows NT 4.0 PowerPC kernel.

PReP is a long dead specification for consumer-ish PowerPC
servers and workstations, that basically amounted to a
pre-ACPI PC with a PowerPC CPU. Some PReP machines ran
Windows NT 4.0. Most ran AIX, an obscure Solaris port, or
gave Linux hackers many fun restless nights.

Relieve '96... I spent that July basking on the beaches of
Cagliari. Somewhere in a dusty office in Seattle people
were dealing with stuff like this:

Open Firmware ARC Interface Version 3.0 (Jul 12 1996 - 18:46:44)
Couldn't claim SYSTEM PARAMETER BLOCK
Program complete - please reboot.

Status
------

Today I fake out enough of OpenFirware client interface to
successfully run the VENEER.EXE ARC shim and hand off to
SETUPLDR. Not much else. Specifically, the CPU VM state is
not modelled quite well (or at all...?).

![ARC veneer image](/docs/veneer.png?raw=true "In ARC menu")
![setupldr image](/docs/setupldr.png?raw=true "In SETUPLDR")

The "disk" is passed as initrd. This is nowhere near
being able to run any portion of NT kernel.

Building
--------

You will need a LE 64-bit toolchain to build (i.e. ppc64le-linux).
A good source of toolchains is kernel.org. For building skiboot
(for testing) you will also need the BE 64-bit toolchain
(i.e. powerpc64-linux).

Skiboot is pulled-in as a submodule. Prephv is a skiboot payload.
So hypothetically it could run on a real Power8 box.

You will need Benjamin Herrenschmidt's PowerNV QEMU tree.

Good directions for QEMU/PowerNV:
https://www.flamingspork.com/blog/2015/08/28/running-opal-in-qemu-the-powernv-platform/

$ make

Running
-------

You now need an image.fat that contains at least the following
files from the NT 4.0 CD, which are obviously not distributable:
- \veneer.exe from /PPC/VENEER.EXE
- \osloader.exe from /PPC/SETUPLDR

I've used FAT16. Other FAT types are untested. Good luck.

$ PPC64QEMU=/path/to/BenH/powernv/qemu make test

TODO
----

- Everything
- Threads (+implement an interactive monitor/debugger)

Resources
---------

Useful stuff:
- PowerISA_V2.07_PUBLIC.pdf - Book 3S
- ABI53BitOpenPOWER_21July2014_pub.pdf - ELFv2 ABI used for PPC64LE
- P8_um_external_v1.1_2015JAN29_pub.pdf - POWER8 User Manual

Contact Info
------------

Andrei Warkentin (andrey.warkentin@gmail.com).
Binary file added docs/setupldr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/veneer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions entry.S
Expand Up @@ -112,9 +112,4 @@ _GLOBAL(_start)
* like, so we keep it.
*/
ori r0, r0, 0
#ifdef CONFIG_MAMBO
/*
* Stop sim.
*/
attn
#endif /* CONFIG_MAMBO */
never: b .
27 changes: 2 additions & 25 deletions exc.c
Expand Up @@ -62,8 +62,7 @@ exc_handler(eframe_t *frame)

/*
* Handle instruction storage faults within the HV address
* region (which is direct-mapped to 0). When the MMU is off,
* the translation happens automatically.
* region (which is direct-mapped to 0).
*/
if (frame->vec == EXC_ISI) {
if (frame->hsrr0 >= HV_ASPACE &&
Expand All @@ -78,8 +77,7 @@ exc_handler(eframe_t *frame)

/*
* Handle data storage faults within the HV address
* region (which is direct-mapped to 0). When the MMU is off,
* the translation happens automatically.
* region (which is direct-mapped to 0).
*/
if (frame->vec == EXC_DSI) {
if (get_DAR() >= HV_ASPACE &&
Expand All @@ -97,13 +95,6 @@ exc_handler(eframe_t *frame)
exc_rfi(frame);
}

if (frame->vec == EXC_HDEC) {
set_HDEC(DEC_DISABLE);
LOG("hypervisor decrementer, exception handler with MMU %s!",
(frame->hsrr1 & (MSR_IR | MSR_DR)) ? "on" : "off");
exc_rfi(frame);
}

if (frame->vec == EXC_SC) {
mtmsrd(MSR_RI, 1);
if (rom_call(frame) == ERR_NONE) {
Expand Down Expand Up @@ -174,20 +165,6 @@ exc_enable_ee(void)
}


void
exc_enable_hdec(void)
{
set_LPCR(get_LPCR() | LPCR_HDICE);
}


void
exc_disable_hdec(void)
{
set_LPCR(get_LPCR() & ~LPCR_HDICE);
}


void
exc_init(void)
{
Expand Down
26 changes: 0 additions & 26 deletions include/mambo.h

This file was deleted.

0 comments on commit b5f3ec4

Please sign in to comment.