1612 Commits

Author SHA1 Message Date
af97fd7af5 arch/ppc/qemu: Add parse hex words for compatibility with Apple OF
Apple OF has parse-1hex, parse-2hex, parse-3hex words that may be used
by FCode ROMs so add these for compatibility

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2023-01-26 19:46:15 +00:00
c967b4c947 Use parse-nhex
Instead of reimplementing it several times use parse-nhex to decode
two hex numbers,

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2023-01-26 19:46:15 +00:00
9711c61be4 Generalise parse-hex
Add parse-nhex word reusing existing parse-ints and use that in
parse-hex instead of an independent implementation. The parse-nhex
name matches Apple OF, while SLOF calls the same operation
hex-decode-unit so adding this word increases compatibility with other
OF implementations.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2023-01-26 19:46:15 +00:00
1be046b641 Limit binary dump bytes in .properties output
Some device trees can contain large chunks of binary data that result
in .properties output to get lost in the dump of all binary bytes. Put
an upper limit of the bytes dumped.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2023-01-26 19:18:22 +00:00
0e0afae657 .github/workflows: add release.yml for generating an OpenBIOS release
This is a GitHub push action that builds OpenBIOS for all of the currently
supported architectures (amd64, sparc32, sparc64, ppc and x86) and a new
GitHub release consisting of an output zip file containing debug and release
binaries, along with the source in .tar.gz and .zip formats.

A release build is triggered by pushing a tag beginning with "v" indicating a
version number in contrast to pushing a branch.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-24 20:30:57 +00:00
5f20278340 .github/workflows: add main.yml for building OpenBIOS upon push
This is a GitHub push action that builds OpenBIOS for all of the currently
supported architectures (amd64, sparc32, sparc64, ppc and x86) and generates
an output zip file containing debug and release binaries.

The output zip file is stored both as a build artifact (which has a maximum
lifetime of 90 days) and for upstream OpenBIOS builds a "latest" release is
added to the repository.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-24 20:30:53 +00:00
7509205ce6 .github/workflows: add build-openbios-builder.yml action
This is a GitHub manual action that generates a container image from
docker/Dockerfile.builder and pushes the result to
ghcr.io/openbios/openbios-builder:master for public use.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-24 20:05:50 +00:00
1017e4adda docker: introduce Dockerfile.builder for openbios-builder container
This introduces a new Dockerfile.builder file that can be used by docker
build to generate a container that can build OpenBIOS based upon Debian
11.2 and the crosstool compilers from kernel.org.

The installed cross-compilers allow the building of SPARC32, SPARC64 and
PPC binaries.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-24 20:05:50 +00:00
0fbb6f73c1 ppc: Do not generate .stabs ELF sections to prevent GDB from choking on them
Recent versions of GDB (and probably older ones too, but not checked) crash
with and abort when loading the non-stripped 32-bit PPC QEMU build[1]. This
is due to a bug in GDB on reading stab symbols. The only place in OpenBIOS
where stab symbols are generated is in libgcc/crtsavres.S, which was copied
from the linux kernel[2].

Symbols that were defined in the stabs section are still able to be seen in
GDB after stabs removal. There does not appear to be a loss in debugging
functionality.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=28900
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/include/asm/ppc_asm.h?h=v5.17-rc4#n211

Signed-off-by: Glenn Washburn <development@efficientek.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-23 21:41:37 +00:00
88eb9291fc arch/unix/unix.c: fix build on x86 architecture with modern gcc compilers
Modern gcc compilers will fail to build x86 OpenBIOS failing with the error
message "libc/misc.c:20: multiple definition of `errno_int'" during link.

Since the accompanying comment mentions that the reason for adding the
definition is to allow compilation to succeed on OS X, surround it with
suitable #if defined(__APPLE__) ... #endif guards.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-08 22:10:11 +00:00
edd14f40ab config/scripts/switch-arch: allow x86_64 prefix for x86 builds
Modern 64-bit compilers with a gcc multilib-capable toolchain are easily able
to build x86 OpenBIOS. If the build is not gcc multilib-capable then the
build typically fails with the message "fatal error: sys/cdefs.h: No such file
or directory".

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-08 22:10:11 +00:00
1aa242105a ppc: fix ciface_milliseconds using incorrect frequency for delay
Instead of using a constant frequency for all CPUs, use the processor timebase
frequency provided by QEMU. This fixes issues where delays from
ciface_milliseconds were not corresponding to elapsed time as given by the real
time clock on certain platforms, eg. QEMU's mac99 machine.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-02-08 21:26:31 +00:00
e2d6176ce9 cuda: fix get-time word
An extra byte is written after the CUDA_GET_TIME command causing the
command to return an incorrect time. Running QEMU with CUDA debug
messages on yields these messages:

  1177318@1642469573.070752:cuda_packet_receive length 3
  1177318@1642469573.070768:cuda_packet_receive_data [0] 0x01
  1177318@1642469573.070771:cuda_packet_receive_data [1] 0x03
  1177318@1642469573.070773:cuda_packet_receive_data [2] 0xfb
  1177318@1642469573.070776:cuda_receive_packet_cmd handling command
  GET_TIME CUDA: GET_TIME: wrong parameters 2

Fix the outgoing command length to remove the extra byte.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-01-27 15:24:45 +00:00
04dfc984ac ppc: Add PVRs for the MPC7450 family
This allows the processors from the 7450 family to pass the initial
PVR verification. Enables 7441, 7445, 7447, 7447a, 7450, 7451, 7455,
7457 and 7457a.

This should be used along with a QEMU that includes commit 1da666cd8e
("target/ppc: Disable software TLB for the 7450 family").

With Linux 5.15:

$ cd buildroot
$ make qemu_ppc_mac99_defconfig
$ make
$ qemu-system-ppc -m 1G -M mac99,via=pmu -cpu 7450 \
-kernel ./output/images/vmlinux \
-append root=/dev/sda \
-drive file=./output/images/rootfs.ext2,format=raw \
-net nic,model=sungem -net user -serial mon:stdio -nographic

>> =============================================================
>> OpenBIOS 1.1 [Jan 10 2022 13:27]
>> Configuration device id QEMU version 1 machine id 1
>> CPUs: 1
>> Memory: 1024M
>> UUID: 00000000-0000-0000-0000-000000000000
>> CPU type PowerPC,G4
(...)
Booting Linux via __start() @ 0x01000000 ...
(...)
Welcome to Buildroot
buildroot login:

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-01-14 19:32:07 +00:00
3f18ab37c6 drivers: Spell QEMU all caps
Replace Qemu -> QEMU.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-01-14 19:30:08 +00:00
cb7fd3ab7d drivers/usb: Fix building with gcc 10.x
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-01-14 19:19:55 +00:00
b9062deaae cuda: fix reset-all and power-off words
There is a long-standing bug in the CUDA implementation of the reset-all and
power-off words whereby an extra byte is written after the CUDA_RESET_SYSTEM
and CUDA_POWERDOWN commands.

This extra byte used to be ignored in QEMU until commits 017da0b568 ("cuda:
port POWERDOWN command to new framework") and 54e894442e ("cuda: port
RESET_SYSTEM command to new framework") added a check which rejects the
command if the command length is incorrect.

Fix the outgoing command length to remove the extra byte which allows the
reset-all and power-off words to work in QEMU once again.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/624
2021-10-30 19:50:43 +01:00
d657b65318 escc: send software reset command before configuring the port
According to the ESCC datasheet all register values are undetermined until an
explicit reset command is sent. This is required to fix an issue with QEMU's
ESCC device to ensure that the registers are set to default values if the
default power-on values are changed.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-09-02 10:17:46 +01:00
9cd695aa3c escc: add port index to uart_init_line()
This will be needed to allow uart_init_line() to reset the correct port.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-09-02 10:17:43 +01:00
4a0041107b pci: Rename pci_xbox_blacklisted() as pci_xbox_ignore_device()
In order to use inclusive terminology, rename pci_xbox_blacklisted()
as pci_xbox_ignore_device(), and remove an obvious comment.

Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-15 21:41:33 +00:00
42d77fb767 40p: simplify IRQ swizzling
LSI SCSI on PReP is the unique particular case where we use
fixed IRQ routing. All other cases use regular IRQ swizzling.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-15 21:41:33 +00:00
30df4a912f 40p: use is_apple() macro
Simplify using the is_apple() macro.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-15 21:39:17 +00:00
feda9d5de9 40p: Allow Raven controller to handle all IRQs
In commit ce7fa4d29b we adapted to match QEMU (invalid) code.
Now than QEMU has been fixed and handle the 4 IRQs, update the
OF device tree again.

Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-15 21:39:17 +00:00
7f28286f5c PPC: mark first 4 pages of physical and virtual memory as unavailable
The Debian ports images have now switched from using yaboot to grub as their
bootloader. Recent versions of these images will hang rather than boot under
QEMU despite there being no obvious changes to the boot process.

Further investigation reveals that the second stage grub bootloader appears
to use low memory whilst loading the kernel/initrd from disk: unfortunately
the OpenBIOS vector table lives within the first few pages of physical RAM
and so grub writes over the vector table (in particular overwriting the MMU
fault handlers) causing them to fail next time they are executed which
causes the hang.

Fortunately just before this stage of the bootloader executes, it uses the
CIF to request the contents of the /memory node "available" property. It
seems that the low memory locations used by grub are taken from the start
of the available range, so we can simply increase the number of RAM pages
reserved at the bottom of RAM to ensure that the area chosen by the bootloader
doesn't conflict with the vector table.

This patch raises the start of available memory from 0x1000 to 0x4000 which
allows grub to boot successfully in my tests. According to dumps of device trees
taken from real PPC Macs there are already several examples where the start of
available memory is set to 0x3000 or 0x4000, so as this is already present on
real hardware it should not cause any regressions.

Finally it is worth noting that even in the earlier grub images I could see
write accesses to low memory that would overwrite the vector table: I think
that until recently we were lucky that they happened to avoid anything that
was critical to allow the kernel to load and boot.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-07-25 10:00:22 +01:00
75fbb41d28 SPARC: add implementation of addr word
OpenBSD uses the addr word to retrieve the address of several framebuffer
variables during initialisation. Provide an implementation of addr which
allows OpenBSD to initialise the framebuffer correctly on SPARC32 and SPARC64.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-07-02 20:39:17 +01:00
4704d9eba6 virtio: limit ring size to a maximum of 128 descriptor entries
QEMU commit c9b7d9ec21 "virtio: increase virtqueue size for virtio-scsi and
virtio-blk" increased the number of queue descriptors from 128 to 256 which
caused OpenBIOS to fail when booting from a virtio-blk device under
qemu-system-ppc due to a memory overflow.

Update the virtio-blk driver so that it uses a maximum of 128 descriptor
entries (the previous value) to fix the issue, and also ensure that any
further increases in virtqueue size will not cause the same failure.

Note that this commit also fixes the vring_area size calculation which was
incorrectly based upon the number of virtqueues, and not the number of
descriptor entries.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-05-16 14:42:22 +01:00
9b8c30c6db pci: Enable bus-master on virtio_blk
In qemu 9d7bd0826f2d19f88631ad7078662668148f7b5f, the behavior of vring
processing was changed to not run whenever bus-mastering is disabled.

Since we were never enabling it in the first place, OpenBIOS was no longer
able to access virtio disks on qemu.

Fix this by enabling bus-mastering before initializing.

Signed-off-by: Brandon Bergren <git@bdragon.rtk0.net>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-05-16 14:09:11 +01:00
01069e6610 SPARC32: fix kernel and initrd mapping to match SILO
The previous attempt to fix this was wrong in that I misinterpreted what SILO was
doing: whilst it detects a free region of memory for the kernel/initrd, it simply
maps the areas at fixed addresses rather than allocating them.

Fixes: f633f31 "SPARC32: mark initrd memory as mapped and in use before booting kernel"
Fixes: c87d0eb "SPARC32: mark kernel memory as mapped"
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-04-26 12:31:34 +01:00
2e2ff674df SPARC64: fix kernel and initrd mapping to match SILO
The previous attempt to fix this was wrong in that I misinterpreted what SILO was
doing: whilst it detects a free region of memory for the kernel/initrd, it simply
maps the areas at fixed addresses rather than allocating them.

Fixes: 3464681 "SPARC64: mark initrd memory as mapped and in use before booting kernel"
Fixes: c21c366 "SPARC64: mark kernel memory as mapped and in use before booting kernel"
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-04-26 12:27:59 +01:00
7e5b89e429 ide: locate drives by iterating over the device tree during ob_ide_quiesce()
It is now possible to locate IDE drives by searching the device tree for "block"
type devices containing a C drive instance variable. Rewrite ob_ide_quiesce() to
locate and quiesce IDE drives using this method which finally enables us to
remove the global IDE channels list and its remaining ide_add_channel() function.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-10-22 19:00:24 +01:00
1c63d13a1f ide: use instance values to hold C drive and channel structures
Rather than iterate over the global IDE channels list, use instance variables to
hold the relevant pointers. This allows us to remove ide_seek_channel() since
it is no longer necessary for each IDE device to iterate over the global list
in order to locate the drive/channel information.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-10-22 19:00:24 +01:00
a7ca34d425 escc: explicitly mark variable containing incoming keyboard character as volatile
Otherwise the compiler may not understand that a read from the assigned buffer
is comming from memory-mapped IO space and fail to update accordingly.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-10-17 18:27:44 +01:00
f28e16f9aa admin/devices.fs: Format assigned-addresses property
To help reading property listing also format assigned-addresses
property the same way as reg was already formatted.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
2019-10-12 10:06:28 +01:00
412fc43324 virtio: use instance value to initialise C instance parameter
This simplifies the open word by avoiding having to locate and read the value
of the _vdev property.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
5a2ec0dcd0 lsi: use instance value to hold sd_private_t pointer
It is also possible to remove the global_lsi variable by adding a pointer to
the parent lsi_private_t instance within sd_private_t.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
4660d881aa pc_kbd: use instance value to initialise C instance parameter
This simplifies the open word by avoiding having to locate and read the value
of the address property.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
175271be92 pc_serial: remove separate init word
Instead use an instance value and initialise the C instance parameter within
the open word.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
8878220797 pci: call set-args before configuring PCI device nodes
This is to ensure that the my-space and my-address words are set correctly
for any PCI devices that wish to execute FCode.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
c8afd6a9f9 pci: remove explicit setting of my-self from PCI devices
Since the correct current instance is now being set during probe, there is no
need to explicitly set it whilst creating the device.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
c79f534243 pci: remove explicit find-device from PCI devices
Since the correct active package is now being set during probe, there is no
need to explicitly find the parent node before creating the device.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
81b1da3a74 x86: set active package and current instance to root device node before probe
Now that all PCI devices have been converted to new-device...finish-device we can
set both the active package and current instance to the root device node before
probe, giving all child devices a correct active package and instance chain during
creation.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
538ededddd SPARC64: set active package and current instance to root device node before probe
Now that all PCI devices have been converted to new-device...finish-device we can
set both the active package and current instance to the root device node before
probe, giving all child devices a correct active package and instance chain during
creation.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
d9273b7a9d ppc: set active package and current instance to root device node before probe
Now that all PCI devices have been converted to new-device...finish-device we can
set both the active package and current instance to the root device node before
probe, giving all child devices a correct active package and instance chain during
creation.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
71743ba29d ppc: move New World uninorth and nvram device node creation to the root device
Whilst the NVRAM device node exists under the mac-io device node for Old World
Macs, both itself and the Uninorth device node exist under the root device node
on New World Macs.

Move creation of both device nodes to arch_of_init() for New World machines to
enable the active package and current instance to be set correctly during device
tree construction.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
f4d68d907a nvram: ensure that NVRAM configuration is separate from NVRAM node creation
As part of this separation we can also move "update-nvram" directly to the
NVRAM node bindings.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
29c8d2c339 libopenbios: remove REGISTER_NAMED_NODE and REGISTER_NAMED_NODE_PHANDLE macros
Now that we've removed all references to these binding macros they can be removed
completely.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
80f2b4833e pci: remove ob_pci_initialize() and ob_pci_empty_node
The ob_pci_initialize() function can be removed as it is empty, whilst
ob_pci_empty_node is no longer required since the existing fallback code
will always apply the ob_pci_simple_node bindings if no callback is
configured.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
d5c86af027 pci: convert to use BIND_NODE_METHODS() macro
Moving the setup of PCI devices to within a new-device...finish-device sequence
as part of the conversion further enables us to move the PCI host bridge
configuration logic from ob_pci_init() to ob_configure_pci_device() where it
belongs.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
add8a184fb virtio: convert to use BIND_NODE_METHODS() macro
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00
2dfafd921f lsi: convert to use BIND_NODE_METHODS() macro
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18 21:16:50 +01:00