Commit Graph

166 Commits

Author SHA1 Message Date
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
Thomas Huth 4f0a051873 Added PCI DMA functions
DMA transfers can only happen within a dedicated DMA window, so we need
special functions for allocating buffers and for mapping these buffers in and
out again.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 16:24:55 +02:00
Thomas Huth 904abb4a8f Add wrapper for H_PUT_TCE hypervisor call
H_PUT_TCE is needed for getting the DMA transfers working in the virtual
environment.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 16:24:55 +02:00
Thomas Huth c691959389 Set up PCI nodes on board-qemu
Populate the PCI device tree nodes with additional properties and words, and
provide enough of the SLOF PCI framework to be able to use the nodes with our
device specific drivers.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 16:21:48 +02:00
Thomas Huth c3ef350a8a Moved the PCI helper functions to a separate file
To be able to use some of the PCI helper functions for board-qemu, too, they
have to be separated from the original PCI-scan code.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 13:20:00 +02:00
Thomas Huth eecba74b38 Fixed unit address handling for PCI nodes
Added proper encode-unit and decode-unit functions for the PCI root node and
fixed the unit address handling for PCI nodes in the fdt to OF1275 device tree
conversion function.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 13:20:00 +02:00
Thomas Huth d38a1c54f5 Improved cache-inhibited access functions
Implemented the CI functions in cache.h (which are required by net-snk)
and fixed a bug in hv_logical_ci_store in libhvcall.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 13:20:00 +02:00
Benjamin Herrenschmidt c9d1203de0 Add RTAS config space accessors and skeletton PHB
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-10-12 13:20:00 +02:00
Benjamin Herrenschmidt 35fc16fee3 Move MMIO accessors to board-js2x and implement h-calls based ones for qemu
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-10-12 13:20:00 +02:00
Thomas Huth 32e3430c01 Improved node/instance handling.
The INSTANCE keyword can not be used while a node is opened (since it changes
the node>instance field that is also used for allocating the necessary amount
of memory for an instance). Since I experienced some bad and hard-to-debug
crashes when accidentially running into this problem, I now added a proper
error handling to the INSTANCE keyword.
Also improved my-space, my-address and my-unit a little bit so that these
node specific words now can also be used without an active instance.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth eec67511e1 Improved the way to detect some execution tokens for the debugger.
The debugger used an ugly hack to determine the execution tokens for
2CONSTANT, INSTANCE VALUE and INSTANCE VARIABLE. This hack used an faked
device node, which was quite error prone, e.g. when extending the node
structure in node.fs. Now the XTs are determined in a much more elegant way
at the places where the corresponding Forth words are defined.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth d823eb86d6 Removed obsolete types.h header files
Our "portable" types are defined in stdint.h, so there is no need for the
types.h header files anymore.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth f227b33012 Cleaned up Makefiles
Replaced "make" by "$(MAKE)" to be able to built in parallel, fixed
the indentation of some rules and removed some unused targets.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth 1645f050f8 Fixed get_puid function
The function for determining the PHB Unit ID had a bug - when translating the
address, it used the PCI child node for starting the translation. However,
since the PHB Unit ID is bound to the PCI bus root node, we've got to use that
node as starting point instead.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth 4f6e2c9efe Fix compiler warnings
GCC 4.6 complains about unused-but-set variables - which can safely be removed
in our cases.
Also fixed a strict-aliasing problem in rtas_flash.c of board-js2x.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth f90c45697b Fix for 8-byte wide local-mac-address properties
The /vdevice/l-lan device tree node from qemu uses a 8-byte wide
local-mac-address property instead of a normal 6-byte wide one.
According to a comments in the qemu code, this is necessary for backward
compatibility with old Linux kernels, so the problem is not going to be fixed
on the qemu side and we've got to take care about this in SLOF instead.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth 3be945997f Fixed net-snk Makefiles to only re-built client when something has changed
Due to some bad built rules, client has always been linked during each built.
This has been fixed now so that it only gets rebuild when something has changed.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth b6ec21f809 Fixed a bug in the "test" client interface command.
"test" was removing the wrong stack items, so the first stack item beyond
its parameters got corrupted.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth 7262e19eca Fixed a crash with early debug printf statements
printf does not work during rtas_init of snk yet, so the code has to use the
snk_kernel_interface instead.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth 4e4101fed2 JS2x: Detect the availability of biosemu automatically.
Since the biosemu code is optional, the config file now determines its
availability automatically.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 09:00:04 +02:00
Thomas Huth 399e16b3f7 Make net-snk and modules relocatable, too.
Cleaned up the toc-relative assembly of net-snk, fixed the Makefiles, save the
modules as ELF files instead of raw binaries, adjust the net-snk base address
and the load-base variable... a lot of changes were required to make the net-snk
and the snk modules relocatable, too. But now it should be possible to relocate
all files so that the firmware also runs with less than 256 MiB RAM.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 08:58:04 +02:00
Thomas Huth f06450c2e5 Removed redundant definition of load-base and flash-load-base.
These to Forth words are already defined in base.fs, so there is no need to
define them again.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 08:44:37 +02:00
Thomas Huth 98cdbf03c1 Got rid of the ELF loader functions written in Forth, using libelf instead.
It's cumbersome to maintain code twice, in Forth and in C, and now that libelf
has a new important feature (relocation), I removed most of the old Forth
functions for ELF loading and use the libelf everywhere instead.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 08:44:23 +02:00
Thomas Huth ad3238534f Pass IMA to Paflof and fix the memory regions which have to be CLAIMed
Provide a IMA (initially mapped area) value to Paflof so that the Forth code
can properly claim the memory regions which are used by Paflof.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 08:44:11 +02:00
Thomas Huth 7a3606eeb9 Reworked libelf to support relocation
Split elf.c into elf32.c and elf64.c for better readability. Added relocation
code to libelf for 64-bit ELF images, modified the Paflof Makefile to link
the executable with relocation information and load Paflof now to the upper
end of the memory.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 08:43:50 +02:00
Thomas Huth 2e2e4cae37 Move functions for byte-swapping into common header file.
The byte-swapping functions were scattered all over the source tree, now they
are merged into a new common header file called byteswap.h.

Signed-off-by: <thuth@linux.vnet.ibm.com>
2011-10-12 08:43:12 +02:00
Thomas Huth b94bde008b Fix vSCSI device addressing method
According to the "SCSI Architecture Model", there are multiple ways to specify
the 64-bit LUNs in the SRP_CMD structure. SLOF was using the "Peripheral device
addressing method" (00b) which did not match the rest of the source code that
is trying to scan for target IDs, not bus/channel numbers. Now the method has
been switched to "Logical unit addressing method" (10b) which matches the rest
of the code and which is also used by the Linux kernel in the same way.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-09-16 15:53:13 +02:00
Thomas Huth 3a3f3280e6 Workaround for the VSCSI problems with latest qemu version
The VSCSI behaviour of upstream qemu has changed a little bit, so that the
read-capacity command from SLOF failed. We now issue a test-unit-ready for
normal disks, too, and explicitly check whether read-capacity returned valid
values to work-around the problem.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-08-19 15:06:09 +02:00
Thomas Huth 1d41e8a29b Fixed some problems with libnvram
- On board-qemu, the logging partitions were too big (bigger than the total
  NVRAM size).
- Fixed a compiler warning about type-punned pointers in nvram.c
- When DISABLE_NVRAM is set, the fake buffer should not be accessed with
  cache-inhibited functions
- Makefile did not generate proper dependencies

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-08-19 14:57:32 +02:00