Commit Graph

94 Commits

Author SHA1 Message Date
Thomas Huth c20f4bc8ac Support for virtio-net PCI devices
Added a driver for the "virtio-net" virtualized network devices from KVM/qemu.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-11-24 11:56:03 +01:00
Thomas Huth 008fe5610d Support for virtio-block PCI devices
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>
2011-11-24 11:32:35 +01:00
Thomas Huth 4737144db1 Check whether local-mac-address property exists before using its value
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>
2011-11-24 10:59:47 +01:00
Thomas Huth 7345fac3e5 Do not disassemble net-snk by default 2011-11-24 10:55:28 +01:00
Thomas Huth 7c33e22351 Fix stack problem during setup-alias functions
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>
2011-11-24 10:21:56 +01:00
Thomas Huth 2d3eabca48 Provide PCI memory mapping and dma memory handling in PHB node on board-qemu
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>
2011-11-24 10:21:56 +01:00
Thomas Huth 0be6560d65 OHCI: Reworked USB scan code a little bit
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>
2011-11-24 10:21:56 +01:00
Thomas Huth a5a2d44591 Improved instance handling
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>
2011-11-24 10:21:56 +01:00
Thomas Huth 05a2623c8c Fixed memory leak during network loading
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>
2011-11-24 10:21:56 +01:00
Thomas Huth 3124929fbf FCODE: Allow return stack commands to be used in "interpretation" mode.
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>
2011-11-24 10:21:56 +01:00
Thomas Huth 1b9c3f4ca5 FCODE: Fixed b?branch instruction
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>
2011-11-24 10:21:56 +01:00
Thomas Huth 559018d1cb FCODE: Support FCODE programs that access MMIO memory without the r-functions
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 7ea496223c Fixed bug in disk-label support package
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.
2011-11-17 12:10:37 +01:00
Thomas Huth 9e757c8c38 Improved ext2-files support package
- 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
2011-11-17 12:10:37 +01:00
Thomas Huth 75bf4f1f90 Allow "booting" of Forth source code files
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 5feccc2057 FCODE: Implemented missing tokens
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 4321b74de6 FCODE: Removed some unused test code and functions
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 46ac4818ad Fixed PACK command.
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>
2011-11-17 12:10:37 +01:00
Thomas Huth f332133c85 FCODE: Implemented the missing command "(cr"
According to IEEE 1275 the token 0x91 is used to emit a carret character.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-11-17 12:10:37 +01:00
Thomas Huth b44932581a FCODE: Reviewed token initialization sequence
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 3cab212e0b FCODE: Improved b(field) and b(buffer:)
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 047ef92897 Silenced some compiler warnings
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>
2011-11-17 12:10:37 +01:00
Thomas Huth e43f0673c4 JS2x: Check whether biosemu has been executed successfully
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 69cbb38fb5 JS2x: Fixed bug in Citrine code
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>
2011-11-17 12:10:37 +01:00
Thomas Huth 2cef4bbbc3 FCODE: Adjust MMIO access functions when running PCI FCODE programs
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>
2011-11-17 12:10:36 +01:00
Thomas Huth de5b143a1e Fixed the PCI map-in function.
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>
2011-11-17 12:10:36 +01:00
Thomas Huth ae0aaffc15 Fixed SEE command for words that contain a +LOOP
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>
2011-11-17 12:10:36 +01:00
Thomas Huth 16c43ff8de Enhance the behavior of find-package according to IEEE 1275 proposal 215
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>
2011-11-17 12:10:36 +01:00
Thomas Huth e32f09a2fb FCODE: Fixed named-token function
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>
2011-11-17 12:10:36 +01:00
Thomas Huth 43413964c9 FCODE: Fixed b(;) so that it also works with the debugger
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>
2011-11-17 12:10:36 +01:00
Thomas Huth 751edf326a Fixed bug in SEE debug function
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>
2011-11-17 12:10:36 +01:00
Thomas Huth a46b7e555a FCODE: Fixed instance handling
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>
2011-11-17 12:09:57 +01:00
Thomas Huth a02ee1cc21 FCODE evaluator source code beautification and clean-up
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>
2011-11-17 12:09:57 +01:00
Thomas Huth c140913ece Fixed config-xx PCI bus node functions
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>
2011-11-17 12:09:57 +01:00
Thomas Huth 8d9bb6b048 FCODE: Reset fcode-end flag before executing a new program
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>
2011-11-17 12:09:57 +01:00
Thomas Huth 174eecc55d FCODE: Fixed detection of images in PCI Expansion ROMs.
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>
2011-11-17 12:09:57 +01:00
Thomas Huth 9d63b7beb2 JS2x: Add some additional delays to takeover client.
These delays were needed to get the code running on the PowerStation again.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-11-17 12:09:56 +01:00
Thomas Huth 98f93f2a44 JS2x: Fixed x86 emu download script.
The script expects the folder include/x86emu. Create it if it is not existing
yet.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-11-17 12:09:56 +01:00
Thomas Huth 22bbcf2041 Code for debugging alloc-mem and free-mem calls
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>
2011-11-17 12:09:56 +01:00
Thomas Huth 51992a3da7 JS2x: Fixed takeover code to work with GCC 4.6
Fixed an "unused-but-set" warning and removed the obsolete "-a32" parameter.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-11-17 12:09:56 +01:00
Thomas Huth 72f942f1ac Added e1000 network driver
This driver can be used for downloading files via e1000 compatible NICs.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 16:24:55 +02:00
Thomas Huth beaa972b82 Moved bcm57xx driver to a new directory called "drivers".
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>
2011-10-12 16:24:55 +02:00
Thomas Huth 580d42015f Scan USB bus during boot.
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>
2011-10-12 16:24:55 +02:00
Thomas Huth b05d897663 USB: Removed unused code.
There was quite a lot of old and unused code in the usb files. This code has
been removed now.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 16:24:55 +02:00
Thomas Huth 391dab893c USB: Use physical addresses for OHCI controller
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>
2011-10-12 16:24:55 +02:00
Thomas Huth 6a257b0f57 USB: Reworked OHCI stack to use DMA-able buffers
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>
2011-10-12 16:24:55 +02:00
Thomas Huth f2bf58f8ec USB source code beautification
Fixed some white space damages and corrected some bad comments.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 16:24:55 +02:00
Thomas Huth 7c3b65d835 USB: Fixed the size of the keyboard report descriptors
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>
2011-10-12 16:24:55 +02:00
Thomas Huth 946628710f First fixes for the OHCI code on board-qemu.
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>
2011-10-12 16:24:55 +02:00
Thomas Huth 82954d4c10 Patch "interrupt-map" properties to contain the phandles from SLOF
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>
2011-10-12 16:24:55 +02:00