Commit Graph

98 Commits

Author SHA1 Message Date
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 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 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 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 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
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 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 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 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 8765ceff79 Removed obsolete/unused code.
Cleaned up some remainders of SNK modules that have never been used in
production.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:09 +01:00
Thomas Huth c3cb339780 Fixed claim problem with accurately fitting areas
The third claim call in the following sequence failed though it should be
successful:
    5000 1000 0 claim
    7000 1000 0 claim
    6000 1000 0 claim
The problem was that "(?available-segment-#)" returned the wrong value when
the two areas (the one to be claimed and the one from the available list)
exactly matched.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:09 +01:00
Thomas Huth 5f1bef565c Fixed iso9660 package to be able to boot Debian and Ubuntu CD-ROM ISO images.
ISO9660 file names can have a semicolon followed by a revision number in the
file name. However, the code for cleaning these file names was broken, since
it removed the string pointer and length from the stack. Beside this bug,
there were two more problems: ISO9660 file names without extension can have a
trailing dot at the end, which must be stripped away. And the file names can
all be in uppercase letters (just like old MS-DOS file names), so we should use
case insensitive string compare here, too.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:09 +01:00
Thomas Huth 7a698c4734 Fixed a bug in the set-alias command
set-alias did not clean up the stack in case the "/aliases" node coud not be
found.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:09 +01:00
Thomas Huth f246a4c0a5 Some bugfixes in the boot functions
ABORT" needs a boolean value on the stack, but ABORT (without quotes at the end)
always aborts. In boot.fs, ABORT" has been used without the flag value on the
stack.
Also added a missing "disable-watchdog" before jumping to the operating system,
without this statement, the real JS2x blades rebooted in certain cases due to
the non-disarmed watchdog.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:09 +01:00
Thomas Huth eb28797799 Fixed paflof Makefile
Replaced the \t in the sed rules with real tabs since this is more portable
(\t only works with the GNU version of sed, not with the BSD version).
Also replaced the pushd and popd commands since they are not POSIX compliant,
they only work with bash but e.g. not with dash on Debian/Ubuntu systems.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:09 +01:00
Benjamin Herrenschmidt 39426bad55 Initial qemu/KVM board support
Added a new board for SLOF running on KVM/qemu.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:00 +01:00
Thomas Huth cf69a59a3e Use common timebase and delay code in all boards.
There is a file called timebase.fs in the common code folder already, so there
is no need to duplicate the delay functions in the board directories, too.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-21 15:02:47 +01:00
Benjamin Herrenschmidt aaad509cdc Initial import of slof-JX-1.7.0-4
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2010-12-01 09:51:44 +11:00