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>
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>
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>
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>
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>
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>
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>
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>
"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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>