openbios.git
6 weeks ago40p: change residual data model name to IBM PPS Model 6015 master github/master
Mark Cave-Ayland [Mon, 1 Oct 2018 17:25:29 +0000 (18:25 +0100)] 
40p: change residual data model name to IBM PPS Model 6015

With the corresponding QEMU patches applied, it is now possible to change the
reported firmware name to that of a real 40p machine and boot to a working
userspace with the Linux sandalfoot zImage.

6 weeks ago40p: update interrupt routing code to match QEMU
Mark Cave-Ayland [Sun, 9 Sep 2018 12:32:58 +0000 (13:32 +0100)] 
40p: update interrupt routing code to match QEMU

Note that whilst guest OSs should be relying on residual data rather than the
OF device tree to determine the hardware, we still update the interrupt
properties to match the new code in QEMU for consistency.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months ago40p: fix up generation of interrupt properties
Mark Cave-Ayland [Mon, 27 Aug 2018 12:04:15 +0000 (13:04 +0100)] 
40p: fix up generation of interrupt properties

Since support for QEMU's 40p machine has been added there is now the possibility
of having a PPC architecture where !is_newworld() and !is_oldworld() are both
true.

Fix up a couple of instances in this logic that were preventing the generation
of interrupt properties in the device tree for 40p machines.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
2 months agoconfig: enable virtio-blk driver for default PPC and SPARC64 builds
Mark Cave-Ayland [Sun, 26 Aug 2018 14:38:29 +0000 (15:38 +0100)] 
config: enable virtio-blk driver for default PPC and SPARC64 builds

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months agodrivers: add virtio-1.0 virtio-blk driver
Mark Cave-Ayland [Sun, 26 Aug 2018 14:38:29 +0000 (15:38 +0100)] 
drivers: add virtio-1.0 virtio-blk driver

Note that as part of this commit we rename the legacy virtio-blk device node
from "virtio-blk" to "scsi" to match up with the QEMU fw path generator.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months agoSPARC64: add bootindex support
Mark Cave-Ayland [Sun, 26 Aug 2018 14:38:29 +0000 (15:38 +0100)] 
SPARC64: add bootindex support

This provides an alternative mechanism for supporting boot device order
information from QEMU compared with the legacy FW_CFG_BOOT_DEVICE
functionality specified via -boot.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months agoppc: add bootindex support
Mark Cave-Ayland [Sun, 26 Aug 2018 14:38:29 +0000 (15:38 +0100)] 
ppc: add bootindex support

This provides an alternative mechanism for supporting boot device order
information from QEMU compared with the legacy FW_CFG_BOOT_DEVICE
functionality specified via -boot.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months agoppc: make sure that we correctly map loader RAM at load-base
Mark Cave-Ayland [Sun, 26 Aug 2018 13:23:17 +0000 (14:23 +0100)] 
ppc: make sure that we correctly map loader RAM at load-base

An error in the logic related to FREE_BASE meant that instead of mapping the
RAM for the loader at load-base, a small section was being mapped at the
bottom of RAM instead.

Fix this by deferring the mapping of the load-base RAM to arch_init() when
we can access the load-base variable and map 8MB RAM with a 1:1 phys to
virt mapping.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months agoSPARC64: fix endian naming of architecture in_*() and out_*() functions
Mark Cave-Ayland [Sun, 26 Aug 2018 08:03:03 +0000 (09:03 +0100)] 
SPARC64: fix endian naming of architecture in_*() and out_*() functions

For reasons lost in the history of time, the SPARC64 endian accessors were
given the opposite names to their function i.e. out_le32() would use a
standard load whilst out_be32() would use a little-endian load. Switch
them around so that their implementation matches their name (and also that
of all other architectures).

Note that since the references in the inb/inw/inl and outb/outw/outl wrappers
are also swapped around then these accessors for legacy ioports (i.e. little
endian) will still behave exactly the same as before.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months agoSPARC64: fix up dma-* words
Mark Cave-Ayland [Sun, 19 Aug 2018 10:47:18 +0000 (11:47 +0100)] 
SPARC64: fix up dma-* words

Commit 8584d42 "SPARC64: implement dma-* words" introduced the dma-* words
for SPARC64 but accidentally introduced an older prototype implementation
(probably introduced during a rebase) rather than using the correct defer
words.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2 months agoppc: move init-program client stack to 1:1 virt to phys mapped memory
Mark Cave-Ayland [Fri, 17 Aug 2018 09:35:48 +0000 (10:35 +0100)] 
ppc: move init-program client stack to 1:1 virt to phys mapped memory

The default context used by init-program is allocated from the OpenBIOS
heap which uses a different virt to phys mapping to avoid having to
physically relocate the PROM on startup for PPC machines.

It seems that the OpenBSD bootloader isn't happy with this change
introduced by the context rework, most likely because there is an
assumption that the client stack is mapped 1:1 virt to phys.

Fix this by overriding the default context stack during init-program
to a location just under the MMU hash table (SDR1) which was its
previous hard-coded location in 1:1 virt to phys mapped memory, and
allow OpenBSD to boot.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
3 months agopci: use absolute PCI IO addresses when programming bridge IO limits
Mark Cave-Ayland [Sun, 12 Aug 2018 12:55:12 +0000 (13:55 +0100)] 
pci: use absolute PCI IO addresses when programming bridge IO limits

The upper IO bridge limit was being calculated relative to the lower IO
bridge limit, rather than as an absolute address.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
3 months agolibopenbios: don't allow find_package_method() to push a NULL for empty strings
Mark Cave-Ayland [Sun, 12 Aug 2018 12:55:11 +0000 (13:55 +0100)] 
libopenbios: don't allow find_package_method() to push a NULL for empty strings

Instead push a valid address with zero length otherwise the Forth find-method
word can reference a NULL pointer.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
3 months agoide: don't use ioports as part of the controller node address
Mark Cave-Ayland [Sun, 12 Aug 2018 12:55:10 +0000 (13:55 +0100)] 
ide: don't use ioports as part of the controller node address

The problem with using the ioport as part of the controller node
address is that the address cannot be determined until after the PCI
BARs have been programmed.

This causes a problem when trying to generate fw bootpaths because by
definition they must be passed to the firmware before PCI initialisation.

Instead of using the controller ioport address, use the controller
index for the node address to provide a consistent device node
regardless of how the PCI BARs are programmed.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agousbhid: fix up keyboard alias for USB keyboards
Mark Cave-Ayland [Sat, 9 Jun 2018 15:46:58 +0000 (16:46 +0100)] 
usbhid: fix up keyboard alias for USB keyboards

A USB keyboard is not an ADB keyboard, so make sure that we set the keyboard
alias rather than the adb-keyboard alias.

This also enables us to simplify the alias logic in the PPC arch_of_init()
function.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoppc: add PMU driver
Mark Cave-Ayland [Sat, 9 Jun 2018 15:46:58 +0000 (16:46 +0100)] 
ppc: add PMU driver

The PMU hardware supercedes the CUDA hardware on more modern Macs providing
additional power management functionality which is required for more modern
Mac OSs.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoadb: set compatible property differently if PMU is present
Mark Cave-Ayland [Sat, 9 Jun 2018 15:46:58 +0000 (16:46 +0100)] 
adb: set compatible property differently if PMU is present

This matches the device tree from a real mac99 system.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoppc: add GPIO devices to the device tree when PMU hardware detected
Mark Cave-Ayland [Sat, 9 Jun 2018 15:46:58 +0000 (16:46 +0100)] 
ppc: add GPIO devices to the device tree when PMU hardware detected

PMU Mac models expose GPIOs via a separate address range at the start
of the via-pmu device.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoppc: add fw_cfg interface for passing VIA/ADB configuration from QEMU
Mark Cave-Ayland [Sat, 9 Jun 2018 15:46:58 +0000 (16:46 +0100)] 
ppc: add fw_cfg interface for passing VIA/ADB configuration from QEMU

This is in preparation for allowing OpenBIOS to detect the difference
between CUDA/PMU hardware and build the device tree accordingly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoprep: disable VBE extensions when executing client program
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
prep: disable VBE extensions when executing client program

PReP payloads such as Linux expect to be able to set standard VGA modes
on startup, but VBE prevents certain modes such as text-only.

Disable VBE extensions when executing the client program to allow this
behaviour which also matches that of Open HackWare.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agolibopenbios: add PReP boot partition loader for PPC
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
libopenbios: add PReP boot partition loader for PPC

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agopc-parts: allow successful detection of PReP boot partitions
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
pc-parts: allow successful detection of PReP boot partitions

The PReP boot partition has its own separate layout, so if we detect a PReP
partition then assume success without attempting the filesystem probe (which
is always going to fail).

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoppc: use proper context when pre-loading kernels
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
ppc: use proper context when pre-loading kernels

Before the introduction of proper init-program contexts, OpenBIOS
used a simple assembler call_elf() function to execute the guest
kernel directly.

Switch over to using proper contexts via arch_init_program() which
enables us to remove the legacy call_elf() completely.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoppc: add PReP residual data block
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
ppc: add PReP residual data block

This is borrowed from OpenHackWare in order to provide hardware data to
the client OS.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agopci: add driver for LSI 53C810 SCSI controller
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
pci: add driver for LSI 53C810 SCSI controller

This is to enable booting PReP machines in OpenBIOS.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoppc: add PReP support to dma-map-in
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
ppc: add PReP support to dma-map-in

PReP machines have a separate iova address space mapped into the CPU address
space at 0x80000000, so add a new dma-map-in implementation that supports
this behaviour for the PReP machine.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agobootcode_load: ensure LOADER_NOT_SUPPORT is returned if no bootcode is present
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
bootcode_load: ensure LOADER_NOT_SUPPORT is returned if no bootcode is present

Otherwise we try unsucessfully to load the bootcode and fail rather than continuing
on to the next loader.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agopci: add AMD PCNET information to PCI database
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
pci: add AMD PCNET information to PCI database

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agopci: rename i82378 keyboard device from 8042 to keyboard
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
pci: rename i82378 keyboard device from 8042 to keyboard

This ensures the keyboard appears with a more sensible name in the device
tree.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agopc_kbd: ensure that we properly reset the 8042 controller and keyboard device
Mark Cave-Ayland [Sat, 26 May 2018 19:09:22 +0000 (20:09 +0100)] 
pc_kbd: ensure that we properly reset the 8042 controller and keyboard device

More recent versions of QEMU disable scanning until the controller and
keyboard device have been explicitly reset.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoesp: switch over to using dma-alloc/dma-map-in
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
esp: switch over to using dma-alloc/dma-map-in

Use the proper IEEE-1275 dma words to allocate and map DMA memory.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoesp: switch creation of esp device over to use new-device
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
esp: switch creation of esp device over to use new-device

Instead of using a C initialize function to create the esp device, switch over
to using the Forth "new-device" word so that all of the initialisation can be
done in place in ob_esp_init().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agosbus: add dma-* call-parent chain to all PCI devices and bridges
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
sbus: add dma-* call-parent chain to all PCI devices and bridges

This enables disk drivers to call the dma-* words as required by the
specification.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agopci: add dma-* call-parent chain to all PCI devices and bridges
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
pci: add dma-* call-parent chain to all PCI devices and bridges

This enables disk drivers to call the dma-* words as required by the
specification, and in particular fixes the failing dma-alloc warnings
emitted by NetBSD PPC on boot.

Note that we also add these methods to any partition/file packages via a
new is-call-parent helper word to ensure that the dma-* words are
available at all levels of interposition.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agomacio: add missing REGISTER_NODE for New World macio devices
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
macio: add missing REGISTER_NODE for New World macio devices

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoSPARC64: implement dma-* words
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
SPARC64: implement dma-* words

Implement the dma-* words in the root node using Forth, except for dma-alloc
and dma-sync which require C to use the in-built aligned memory allocator and
MMU flushing.

Note that as OpenBIOS doesn't enable the IOMMU for SPARC64 it is possible to
use the aligned memory allocator directly without any extra support code.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoPPC: implement dma-* words
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
PPC: implement dma-* words

Implement the dma-* words in the root node using Forth, except for dma-alloc
and dma-sync which require C to use the in-built aligned memory allocator and
I-cache and D-cache flushing.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoPPC: add flush_dcache_range() to start.S
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
PPC: add flush_dcache_range() to start.S

Implement flush_dcache_range() similar to flush_icache_range() in preparation
for adding dma command support.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoSPARC32: implement dma-* words
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
SPARC32: implement dma-* words

Use Forth wrappers around the existing C functions to implement all the dma-* words
in the root package.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoSPARC32: implement dvma_sync() function for synchronising DMA memory
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
SPARC32: implement dvma_sync() function for synchronising DMA memory

This is required for ensuring that CPU memory is coherent after DMA operations
have completed.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoSPARC32: move pgtsrmmu.h from arch/sparc32 to include/arch/sparc32
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
SPARC32: move pgtsrmmu.h from arch/sparc32 to include/arch/sparc32

This is to enable us to use its functions for the upcoming DMA functionality.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoSPARC32: implement dvma_map_in() for DMA IOVA to phys translation
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
SPARC32: implement dvma_map_in() for DMA IOVA to phys translation

Rather than have dvma_alloc() store the result of the physical translation
in the specified location, use the fact that we now have contiguous physical
DMA memory to implement dvma_map_in() to perform the translation separately.

This allows us to remove the pointer to the physical address parameter to
dvma_alloc() and instead perform the translation in esp.c by calling
dvma_map_in() separately.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoSPARC32: allocate contiguous physical memory for DVMA
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
SPARC32: allocate contiguous physical memory for DVMA

Currently we dynamically allocate physical memory for DVMA as required, however
that makes mapping between IOVA and physical addresses almost impossible since the
resulting regions are not contiguous.

Resolve this by allocating a contiguous physical memory block that we can use to
easily map between IOVA and physical addresses.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agoSPARC32: rename dvma_alloc()'s ba variable to iova
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
SPARC32: rename dvma_alloc()'s ba variable to iova

This makes it clearer that we are handling a virtual IO address.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agodma: add defers for the dma-* words
Mark Cave-Ayland [Sun, 20 May 2018 09:21:34 +0000 (10:21 +0100)] 
dma: add defers for the dma-* words

Whilst there is an existing implementation of dma-alloc, it is currently unused
so we can make this change now.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
5 months agopci: fix OHCI driver PCI address
Mark Cave-Ayland [Mon, 21 May 2018 20:36:42 +0000 (21:36 +0100)] 
pci: fix OHCI driver PCI address

Commit a1c2e4f "Add USB OHCI + HID driver" hardcoded the high order bit of
the PCI address to that used on PPC machines instead of using the correct
PCI_ADDR() macro.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
6 months agomacio: set correct UniNorth device revision
Mark Cave-Ayland [Sun, 6 May 2018 14:00:23 +0000 (15:00 +0100)] 
macio: set correct UniNorth device revision

Make sure that we set the device-rev property to 7 as found on a real Mac99
machine.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
6 months agoppc: don't hardcode the system bus frequency
Mark Cave-Ayland [Sun, 6 May 2018 14:00:23 +0000 (15:00 +0100)] 
ppc: don't hardcode the system bus frequency

The system bus frequency has been available from the QEMU fw_cfg interface for
some time, so let's use it rather than hard-coding the relevant values.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
6 months agoopenbios: compile fixes for GCC 7.3
Mark Cave-Ayland [Sat, 21 Apr 2018 16:01:58 +0000 (17:01 +0100)] 
openbios: compile fixes for GCC 7.3

This fixes additional warnings found when upgrading my compiler toolset from
GCC 5.x to 7.x.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agoofmem: restrict ofmem_claim() allocations to RAM size
Mark Cave-Ayland [Tue, 13 Feb 2018 22:24:21 +0000 (22:24 +0000)] 
ofmem: restrict ofmem_claim() allocations to RAM size

As OFMEM memory ranges don't provide an explicit upper limit, we must manually
check that CIF claim calls lie within a valid maxmimum range if attempting to
allocate a specific address. Since the claim method provides a 1:1 mapping between
physical and virtual addresses, the valid maximum address is therefore equivalent
to the machine RAM size.

This fixes booting yaboot 1.3.17 which implements a top-down search using claim to
find the next free memory region to locate its heap. Without this fix we blindly
accept a claim for physical addresses far above the available RAM which fails
silently when we try to use the mapping later.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agociface.fs: implement SUNW,power-off service
Mark Cave-Ayland [Mon, 15 Jan 2018 19:55:26 +0000 (19:55 +0000)] 
ciface.fs: implement SUNW,power-off service

This is a Sun-specific service which is only enabled for the SPARC64
architecture.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agoSPARC64: implement power-off word
Mark Cave-Ayland [Mon, 15 Jan 2018 19:55:26 +0000 (19:55 +0000)] 
SPARC64: implement power-off word

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agoSPARC64: add power device under the ebus device
Mark Cave-Ayland [Mon, 15 Jan 2018 19:55:25 +0000 (19:55 +0000)] 
SPARC64: add power device under the ebus device

Due to limitations in the current QEMU PCI IO BAR layout, it isn't possible
to use the offset of 0x7240000 as used in a real Ultra 5.

For the moment locate the power device at offset 0x7240 as a reminder of its
true origin.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agoSPARC32: implement power-off word
Mark Cave-Ayland [Mon, 15 Jan 2018 19:55:25 +0000 (19:55 +0000)] 
SPARC32: implement power-off word

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agoadmin: add power.fs with initial dummy power-off implementation
Mark Cave-Ayland [Mon, 15 Jan 2018 19:55:25 +0000 (19:55 +0000)] 
admin: add power.fs with initial dummy power-off implementation

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agox86: remove static declaration from multiboot_header definition
Mark Cave-Ayland [Sat, 13 Jan 2018 21:21:05 +0000 (21:21 +0000)] 
x86: remove static declaration from multiboot_header definition

Newer versions of gcc fail to compile OpenBIOS giving a
"error: ‘multiboot_header’ defined but not used" message when the default
build with -Werror enabled is used.

Remove the static declaration to enable compilation to succeed, which
incidentally matches the other copies of multiboot.c in the OpenBIOS
source tree.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9 months agopci: fix compilation for architectures where OFMEM isn't available
Mark Cave-Ayland [Sat, 13 Jan 2018 21:21:05 +0000 (21:21 +0000)] 
pci: fix compilation for architectures where OFMEM isn't available

Commit 0d3345f9 "pci: add ob_pci_unmap() to unmap PCI memory" accidentally
broke compilation for architectures where OFMEM is unavailable such as x86.

Add the appropriate #if defined(CONFIG_OFMEM)...#endif block to ob_pci_unmap()
so that compilation can at least succeed for these architectures.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
13 months agopci: set sunhme name to "network"
Mark Cave-Ayland [Sun, 15 Oct 2017 08:06:08 +0000 (09:06 +0100)] 
pci: set sunhme name to "network"

This brings the device tree in agreement with a real Ultra 5.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
13 months agopci: set cmd646 name and device_type properties to "ide"
Mark Cave-Ayland [Sun, 15 Oct 2017 08:06:08 +0000 (09:06 +0100)] 
pci: set cmd646 name and device_type properties to "ide"

This is because some OSs (noticeably NetBSD) look up devices by device_type
in order to establish an interrupt mapping.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
13 months agoSPARC64: switch to simba PCI bridge machine configuration
Mark Cave-Ayland [Sun, 15 Oct 2017 08:06:08 +0000 (09:06 +0100)] 
SPARC64: switch to simba PCI bridge machine configuration

Fix up the ebus device interrupt parents, plus remove deprecated code for
mapping PCI devices to the PCI root bus as this is no longer possible.

Now that the transition to a simba configuration is complete, make sure
that we update mem_base and io_base to match the start address of each
simba module, and update pci_mem_base accordingly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
13 months agopci: add PCI bridge support for 32-bit PCI IO address spaces
Mark Cave-Ayland [Fri, 22 Sep 2017 12:02:06 +0000 (13:02 +0100)] 
pci: add PCI bridge support for 32-bit PCI IO address spaces

Make sure that we set the upper 16-bits of the IO address for both the
PCI IO base and PCI IO limit registers.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
13 months agopackage.fs: don't reveal interposed packages
Mark Cave-Ayland [Wed, 13 Sep 2017 18:24:43 +0000 (19:24 +0100)] 
package.fs: don't reveal interposed packages

The IEEE-1275 interpose specification suggests that interposed packages should
not be visible unless an interpose-aware Forth word is used.

Commit 247c6169 "Fix for interpose problem" realised this by converting the romvec
obp_inst2pkg() function over to use ihandle>non-interposed-phandle but didn't make
the same change to the equivalent CIF call instance-to-path (which is presumably
correct since the interpose specification also states that interposed packages are
only visible to a new instance-to-interposed-path CIF call).

Here we add a new instance-to-package word as a wrapper to
ihandle>non-interposed-phandle and update obp_inst2pkg() and instance-to-path to
use it accordingly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
14 months agopci: add Intel e1000 network device to PCI database
Mark Cave-Ayland [Tue, 5 Sep 2017 22:02:54 +0000 (23:02 +0100)] 
pci: add Intel e1000 network device to PCI database

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
14 months agopci: add SUN hme network device
Mark Cave-Ayland [Thu, 20 Jul 2017 21:23:55 +0000 (22:23 +0100)] 
pci: add SUN hme network device

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
14 months agopci: add ob_pci_unmap() to unmap PCI memory
Mark Cave-Ayland [Tue, 5 Sep 2017 21:42:40 +0000 (22:42 +0100)] 
pci: add ob_pci_unmap() to unmap PCI memory

This can now be used in sungem_config_cb() to unmap the PCI BAR
used to configure the MAC address.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
14 months agopci: add basic support for Apple SunGEM
Mark Cave-Ayland [Tue, 5 Sep 2017 21:35:37 +0000 (22:35 +0100)] 
pci: add basic support for Apple SunGEM

No driver, but we read the MAC address from the chip and write
it into the device-tree where Linux and MacOS look for it. We
also set the right compatible property for MacOS to pick it up.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
14 months agopci: split the PCI mapping code out of ob_pci_bus_map_in() into ob_pci_map()
Mark Cave-Ayland [Tue, 5 Sep 2017 21:31:05 +0000 (22:31 +0100)] 
pci: split the PCI mapping code out of ob_pci_bus_map_in() into ob_pci_map()

This is so that it can be called directly from C rather than just the
pci-map-in Forth binding.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
14 months agopci: move pci_decode_pci_addr() towards the top of pci.c
Mark Cave-Ayland [Tue, 5 Sep 2017 21:27:58 +0000 (22:27 +0100)] 
pci: move pci_decode_pci_addr() towards the top of pci.c

This is in anticipation of using in several other places.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: map Simba PCI bus A on-board devices to fixed interrupts
Mark Cave-Ayland [Sat, 8 Jul 2017 20:36:00 +0000 (21:36 +0100)] 
pci: map Simba PCI bus A on-board devices to fixed interrupts

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: use ob_pci_bus_set_interrupt_map() to configure interrupts for Simba PCI bus B
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:59 +0000 (21:35 +0100)] 
pci: use ob_pci_bus_set_interrupt_map() to configure interrupts for Simba PCI bus B

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@iande.co.uk>
16 months agopci: alter ob_configure_pci_device() to return its device phandle
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:58 +0000 (21:35 +0100)] 
pci: alter ob_configure_pci_device() to return its device phandle

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: rename SUN4U_INTERRUPT to SUN4U_PCIAINTERRUPT
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:57 +0000 (21:35 +0100)] 
pci: rename SUN4U_INTERRUPT to SUN4U_PCIAINTERRUPT

The current interrupt mapping is only correct for PCI bus A (QEMU
currently alters its PCI mappings to handle that PCI devices are
plugged into the PCI root bus and not behind a Simba bridge).

Add a comment to point out that the existing mapping is deprecated
and should be removed once the QEMU PCI topology has been updated.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: don't set interrupt-map and interrupt-map-mask properties if empty
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:56 +0000 (21:35 +0100)] 
pci: don't set interrupt-map and interrupt-map-mask properties if empty

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: update interrupt-map-mask to include the bus during interrupt comparisons
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:55 +0000 (21:35 +0100)] 
pci: update interrupt-map-mask to include the bus during interrupt comparisons

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: implement simba_config_cb() for programming device ranges
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:54 +0000 (21:35 +0100)] 
pci: implement simba_config_cb() for programming device ranges

The SUN,simba device doesn't have a ranges properties and so Linux will
calculate the PCI memory/IO ranges by probing the PBM "Memory Address Map"
and "I/O Address Map" registers (see apb_fake_ranges()).

Set sensible default values for both SUNW,simba devices during PCI
configuration and document accordingly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoSPARC64: add custom sabre reg property to sabre_config_cb()
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:53 +0000 (21:35 +0100)] 
SPARC64: add custom sabre reg property to sabre_config_cb()

Sabre has a slightly different reg property than that of other PCI host
bridges. Hardcode the correct value as taken from a real Ultra 5 device
tree.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoSPARC64: implement custom PCI bus scan for sabre
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:52 +0000 (21:35 +0100)] 
SPARC64: implement custom PCI bus scan for sabre

The sabre on-board devices are located at devfn (1,1) which means that in a
standard PCI bus scan the bus at devfn (1, 0) is enumerated first. This
doesn't play well with OpenBIOS which assumes that the ebus (with legacy
ioports) is mapped starting from io_base == 0x0.

Perform a custom scan to ensure that OpenBIOS doesn't crash when additional
devices are added to the bus at devfn (1, 0).

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoSPARC64: fix PCI configuration space size
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:51 +0000 (21:35 +0100)] 
SPARC64: fix PCI configuration space size

Make the PCI configuration space size match that of a real Ultra5 machine.

Currently the declared PCI configuration space is too large and actually
overlaps PCI memory space.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoSPARC64: fix PCI memory base in host ranges
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:50 +0000 (21:35 +0100)] 
SPARC64: fix PCI memory base in host ranges

Previously the address of the PCI memory base in the host ranges property was
offset by pci_mem_base. While technically correct, Linux incorrectly calculates
the start of the Simba window based upon this address.

Change the memory base to APB_MEM_BASE to match a real Ultra 5 which prevents
Linux from outputting warnings about incorrect window sizes.

Signed-off-by: Mark Cave-ayland <mark.cave-ayland@ilande.co.uk>
16 months agoSPARC64: increase size of PCI IO space
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:49 +0000 (21:35 +0100)] 
SPARC64: increase size of PCI IO space

This is required to ensure that we can fit both SUNW,simba devices within
the available space.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoSPARC64: increase size of PCI memory space
Mark Cave-Ayland [Sat, 8 Jul 2017 20:35:48 +0000 (21:35 +0100)] 
SPARC64: increase size of PCI memory space

On a real machine the PCI memory space should be 10 times as large, however that
takes us to a 64-bit value which isn't directly supported by OpenBIOS. Increase
the PCI memory space by an amount which allows Linux to allocate the IOMMU correctly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoarch: remove rbase and rlen from pci_arch_t for all PCI architectures
Mark Cave-Ayland [Sat, 8 Jul 2017 19:36:59 +0000 (20:36 +0100)] 
arch: remove rbase and rlen from pci_arch_t for all PCI architectures

This is now handled by the host_ranges property so remove all remaining
references.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: update pci_set_host_ranges() to use the new pci_arch_t host_ranges
Mark Cave-Ayland [Sat, 8 Jul 2017 19:36:58 +0000 (20:36 +0100)] 
pci: update pci_set_host_ranges() to use the new pci_arch_t host_ranges

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoarch: update pci_host_t host_ranges with values for each architecture
Mark Cave-Ayland [Sat, 8 Jul 2017 19:36:57 +0000 (20:36 +0100)] 
arch: update pci_host_t host_ranges with values for each architecture

As derived from the current logic in pci_host_set_ranges().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: move memory type enum from drivers/pci.c to include/drivers/pci.h
Mark Cave-Ayland [Sat, 8 Jul 2017 19:36:56 +0000 (20:36 +0100)] 
pci: move memory type enum from drivers/pci.c to include/drivers/pci.h

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: define pci_range_t typedef and add it to pci_arch_t struct
Mark Cave-Ayland [Sat, 8 Jul 2017 19:36:55 +0000 (20:36 +0100)] 
pci: define pci_range_t typedef and add it to pci_arch_t struct

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopc_kbd: add optional mouse device support for 8042 devices
Mark Cave-Ayland [Sat, 8 Jul 2017 19:25:51 +0000 (20:25 +0100)] 
pc_kbd: add optional mouse device support for 8042 devices

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopc_kbd: place keyboard device under 8042 controller device
Mark Cave-Ayland [Sat, 8 Jul 2017 19:25:50 +0000 (20:25 +0100)] 
pc_kbd: place keyboard device under 8042 controller device

Split the keyboard device into an 8042 controller device and a child keyboard
device as indicated in some SPARC and PReP device trees.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agoSPARC64: fix up PCI-EBus interrupt map and ino for PS/2 keyboard device
Mark Cave-Ayland [Sat, 8 Jul 2017 19:19:41 +0000 (20:19 +0100)] 
SPARC64: fix up PCI-EBus interrupt map and ino for PS/2 keyboard device

This allows the PS/2 keyboard device to be detected and used under *BSD
for SPARC64.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: always use devfn 0 for PCI host bridge ranges
Mark Cave-Ayland [Sat, 8 Jul 2017 19:19:40 +0000 (20:19 +0100)] 
pci: always use devfn 0 for PCI host bridge ranges

Always use devfn 0 for PCI host bridge ranges, regardless of the devfn of the
bridge itself. This generates a PCI host bridge ranges property matching that
of real hardware for PPC machines.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agovga.fs: do not attempt to map MMIO registers more than once
Mark Cave-Ayland [Sat, 8 Jul 2017 19:19:39 +0000 (20:19 +0100)] 
vga.fs: do not attempt to map MMIO registers more than once

The FreeBSD PPC bootloader attempts to reset the console causing an error
because the MMIO registers are already mapped. Add a check to ensure that
we only map them once.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
16 months agopci: fix accidental io_base reset for PCI host bridge
Mark Cave-Ayland [Sun, 9 Jul 2017 17:48:50 +0000 (18:48 +0100)] 
pci: fix accidental io_base reset for PCI host bridge

Commit c80a58b added a workaround to allow ioport access through the first PCI
bridge found until its base and limits were programmed, so that on-board devices
not directly attached to the PCI host bus could be used during OpenBIOS
initialisation.

Unfortunately the logic was broken, and in fact the reset should only occur if
we're the first PCI bridge that isn't the host bridge - otherwise we end up
resetting io_base for the PCI host bus causing its devices to be mapped over
existing in-built ioports causing strange behaviour.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: allow ob_pci_bus_set_interrupt_map() to take a callback function
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: allow ob_pci_bus_set_interrupt_map() to take a callback function

This serves 2 purposes: firstly it means that each PCI bridge can set its
own custom interrupt-map and interrupt-mask if required, and secondly the
interrupt properties can be split into per-architecure sections.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: split PCI bus interrupt maps from PCI host bridge interrupt maps
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: split PCI bus interrupt maps from PCI host bridge interrupt maps

This is to allow us to generate interrupt maps for any PCI bus, not just the
PCI host bridge.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: configure base and limit registers during PCI bridge configuration
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: configure base and limit registers during PCI bridge configuration

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: implement ob_pci_bridge_map_in() for PCI-PCI bridge nodes
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: implement ob_pci_bridge_map_in() for PCI-PCI bridge nodes

As indicated by the IEEE-1275 PCI bindings, PCI-PCI bridges should call
call the map-in method of the parent.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: rename ob_pci_map_in() to ob_pci_bus_map_in()
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: rename ob_pci_map_in() to ob_pci_bus_map_in()

This is in preparation for separating out the behaviour between host bridges
and PCI bridges.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: create new ob_pci_bridge_node based upon ob_pci_bus_node
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: create new ob_pci_bridge_node based upon ob_pci_bus_node

These two types of node will need to have slightly differing behaviours moving
forwards.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: include PCI bus id in ob_pci_decode_unit()
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: include PCI bus id in ob_pci_decode_unit()

Instead of hard-coding the bus id to 0, grab the bus id from the first word
of the "bus-range" property. In particular this allows us to correctly
navigate the DT when trying to access a node with a unit id.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
17 months agopci: add temporary bus-range property to PCI bridge devices
Mark Cave-Ayland [Sun, 11 Jun 2017 09:49:02 +0000 (10:49 +0100)] 
pci: add temporary bus-range property to PCI bridge devices

This enables the bridge (and also any children) to determine their bus number
during the secondary PCI bus scan.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>