The virtio devices are preferred way of providing virtualized devices on
KVM/qemu. Here's now the basic support for virtio block devices.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Fixed network booting for device tree nodes that do not provide a
local-mac-address property by default.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The code for setting some of the device alias had a bug. When it was called
multiple times, for example because two or more hard disk images had been
configured, it left an item on the Forth stack, causing a crash or other
ugly side effects later.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
According to the PCI Bus Binding to IEEE 1275, the dma-alloc, dma-free,
dma-map-in, dma-map-out and dma-sync functions have to be provided by the
PCI bus node, not by the PCI device node, so I moved these functions to the
PHB node now. Since the "ibm,dma-window" property is still located in the
device node instead, I had to add a little hack to the $call-parent method
to remember the calling child, so that the parent node (the PHB node) can
access that property of the calling child.
Also added map-in and map-out functions now according the the PCI Bus Binding.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Refactored the ohci-scan function a little bit and use the new "extend-device"
function to extend the ohci node properly.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Fixed various bugs and added some improvements in the device tree node instance
handling code:
- The ">instance" word now checks whether access is beyond the allocated memory
- Check max-instance-size when creating new instance variables/values
- The arg point and the args-len were stored the wrong way round in the
instance header structure
- Free instance args buffer when closing an instance to avoid memory leaking
- finish-device destroyed the instance-template buffer, causing instance values
not to be initialized correctly anymore
- Added new command "extend-device" to be able to modify the instance template
of already existing nodes
- Added new command "unselect-dev" to undo the changes from select-dev
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Fixed two memory leaks:
- The PCI class file for network nodes did not properly close the obp-tftp
package
- The obp-tftp package used "select-dev" for setting a property in /chosen
which created some instances that were not closed anymore
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
According to IEEE 1275, the return stack commands may also be used in
"interpretation" FCODE mode (i.e. without a surrounding colon definition).
This did not work in SLOF yet since the commands were executed in one function
(called "exec"), but the main loop was done in another function (called
"evaluate-fcode"), so SLOF needed the return stack inbetween. When an FCODE
program put an additional item on the return stack, the FCODE interpreter
crashed. This has been fixed now by merging the exec function into the
evaluate-fcode function with the main loop.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
According to IEEE 1275, the b?branch instruction should jump "if all bits
of x are zero". However, our implementation also jumped already if x was not
equal to TRUE (i.e. 0xffffffff). It's fixed now by simply removing the odd
"?branch" function.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Since some FCODE programs use the normal memory access functions (like c@)
for accessing MMIO memory, we got to use a little hack to support them:
When address is bigger than MIN-RAM-SIZE, assume the FCODE is trying to
access MMIO memory and use the register based access functions (like rb@)
instead.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The "offset" function only worked for partitions starting within the first
4 GiB of the disk.
Also increased the amount of data to be read from a PReP partition since some
clients are certainly bigger than 2 MiB nowadays.
- Added support for double and tripple indirect blocks.
- For modern revision of ext2, the inode size is configurable
and thus has to be read out of the superblock
- The group descriptor table can be bigger than one block
- Free allocated memory when closing the package
According to PAPR, a firmware should support loading of Forth source code files.
Our "neteval" command provided a similar feature already, but only worked with
the "net" device and was not compliant to the "Recommended Practice" document.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
While reviewing our FCODE table, some missing FCODE tokens have been discovered.
According to the IEEE 1275 specification, some of them are marked as obsolete
and optional, but some of them are also marked as required.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
In 1275.fs there were some test code remainders from the early days that are
certainly not required anymore.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
According to IEEE 1275, the "pack" command converts a Forth string into a
packed counted string, i.e. it has to store the length of the string in the
destination memory buffer, too, so that the operation can be reverted with the
"count" command. Our current implementation did not save the length yet - this
has been fixed now.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Added comments about missing and obsolete FCODE tokens to shed a light on the
gaps in our FCODE token list. No functional change done.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
b(field) and b(buffer:) did not reveal the names of the corresponding
definitions so that external words could not be used.
Also replaced the "postpone exit" in b(field) by "<semicolon> compile," so that
these words now can be used with the debugger SEE command, too.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
When the biosemu has been enabled, there were some additional compiler warnings
showing up which have been silenced now.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The code did not check whether biosemu has been executed successfully - and
this of course caused problems when SLOF has been compiled without biosemu
enabled.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
While setting up the setsupbuff, the code wrote accidentially to memory
at address 3 instead of setsupbuff+3.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
According to IEEE 1275, the MMIO access functions rw@ etc. have to take care
of the byte-ordering of the corresponding bus. So some FCODE programs
(like the drivers from QLOGIC) seem not to support byte-swapping on their own,
but rely on the MMIO access functions from firmware to do the byte swapping.
Thus, to get these FCODE programs working, our MMIO access functions have to
do the byte-swapping when we run a PCI FCODE program!
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The map-in function must retriev the BAR address from the config space address
that is provided in the phys.hi parameter. We can not rely on the value in
phys.lo as we did before. This patch is needed to get the FCODE from QLOGIC
working, and it also revealed some bugs in the current version of our ATI rn50
driver (which uses map-in, too, to get the register base address).
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The +LOOP command needs a special treatment since it uses an additional cell
(with the jump offset) in the code area.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
According to IEEE 1275 Proposal 215 (Extensible Client Services Package),
the find-package method can be used to get the phandle of arbitrary nodes
(i.e. not only support packages) when the name starts with a slash.
Some FCODE programs depend on this behavior so we've got to support this, too!
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The named-token function evaluated the fcode-debug? variable the wrong way
round, and the "new-token" path did not work yet since it was not skipping
the fcode-string of the new function in that branch.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The SEE debugger word expects functions to end with a semicolon. However, b(;)
was using EXIT to mark the end of a function, so SEE failed with such Forth
words. Now b(;) is using the <semicolon> execution token so that FCODE functions
can be analyzed with SEE, too.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The Forth debug function "SEE" sometimes displayed wrong literal
values. This happened because the formatting of literal values was
prepared with the (u.) in (see-colon-body), but the formatted string
was then clobbered during (see-my-type) by another call to (u.).
To avoid this problem, (see-my-type) now copies the string to a
temporary pocket before calling (u.) again.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
INSTANCE VALUEs, VARIABLEs and DEFERs did not work at all for FCODE.
The opcode for INSTANCE was just doing the wrong thing, and the opcodes for
VALUE, VARIABLE and DEFER simply ignored whether they were used in context
of an INSTANCE or not. Now the opcodes are working right.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Fixed bad indentation and white space damages in the FCODE evaluator source
code. Also removed the redundant definitions of <value>, <variable>, etc. which
are defined in base.fs already.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
According to the IEEE 1275 PCI bus binding, the config space address for the
config-xx access functions should also always contain the bus-device-function
numbers (i.e. "my-space"). The SLOF code behaved different so far by adding
my-space during the config-xx words instead. This of course caused problems
when running FCODE that expects the IEEE 1275 behaviour.
The config-xx functions have now been changed to automatically detect the
required behaviour: If the caller supplied a bus-device-function number, we
do not add "my-space" in these functions anymore.
However, our pci-bridge code for the AMD 8111 abused the old behaviour by
accessing multiple devices+functions without specifying the full unit address.
So for this device, special config-xx functions have been added to work-around
this problem.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
When running more than one FCODE program, the second one was not executed
since fcode-end was not reset.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
There were several bugs in the pci-find-rom function that is used to detect
the FCODE in PCI Expansion ROMs. Due to these bugs, it was only able to find
the first image in the ROM. Now the function should also work fine if the
FCODE image is not the first image in the ROM.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Here are some useful debug functions that can be used for debugging problems
with memory allocation.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The bcm57xx driver is a normal part of the SLOF firmware, so it does not make
sense that it resides in the other-licence directory. Moved it to a new
directory called "drivers" now.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
For board-qemu, USB scan had to be triggered manually so far. Now it is run
automatically during each boot when an OHCI controller is available.
To determine the base address of the OHCI controller, we need translate-address.
However, this function does not work during the PCI scan on real hardware yet,
since the "assigned-addresses" properties might not be set up yet. Therefor the
translate-address is now done in the file usb-ohci.fs, which is now included
during the USB scan instead of the PCI scan.
For the real JS2x hardware there were also some words missing, like dma-alloc.
These are now provided, too, so the USB code now works on both again, emulated
and real hardware.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
QEMU only provides a 256 MiB DMA window. So when running with more than 256 MiB
RAM, we can not use a 1:1 mapping between physical and virtual DMA addresses
anymore -- the addresses have to be translated instead from physical to virtual
and vice versa.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
When running on QEMU, DMA can only happen with dedicated buffers that have to
be allocated and mapped in.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Size of the keyboard report descriptors is only 0x3f instead of 0x40...
...and qemu is picky about this right size.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The emulated OHCI controller on board-qemu behaves slightly different to the
controller that was used on JS2x. We've got to translate the PCI base address
to get the correct virtual base address of the HC. QEMU also does not like
mis-aligned accesses to registers, and after powering off the USB ports, we
must make sure to issue a reset to be able to detect devices again.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
The flattened device tree from QEMU contains some "phandle" and "linux,phandle"
properties which are referenced from the "interrupt-map" properties in the
pci root nodes. This is bad, since SLOF has a different concept of phandles.
Now the code patches the "interrupt-map" properties to contain the values
from SLOF and removes the "phandle" and "linux,phandle" properties from the
device tree.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>