[OpenBIOS] C bindings
samuel at ibrium.se
Thu Oct 30 13:03:56 CET 2003
Wouldn't it make sense to add some C-bindings to the forth
kernel? I have examined all the built-in tokens and as far
as far as I can tell there is currently no way to call an
external function (well, save abusing the inb/outb mechanism).
The forth kernel and the MOL OF loader are statically
linked as a single binary (the ROM image).
The MOL part of the code contains low-level support for
exceptions and similar things. It also contains filesystem
support, SCSI support, boot disk search algorithms, device
tree handling and the OF client interface (and some other stuff).
To make the C-code and the forth code interoperate, I would
like to be able to
1. Call C-functions from forth code by pushing the address
of the function on the stack. Something like
call ( function_addr -- <whatever> )
2. Be able to invoke the forth interpreter from C-code
(I think this can be implementable without modifying
the kernel code, but I haven't looked into it yet).
I can of course solve the first point be adding a primitive
to the words table, but wouldn't it make sense also for
other projects? I imagine that a real-world implementation
will implement some things in C (more people are familiar
with C and there are already plenty of code written in C
that can be reused; filesystems for instance...).
More information about the OpenBIOS