[OpenBIOS] usb driver to support usb keyboard
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Wed May 7 19:50:00 CEST 2014
On 07/05/14 17:54, BALATON Zoltan wrote:
> On Wed, 7 May 2014, Mark Cave-Ayland wrote:
>> First place I would look at is in drivers/pci.c and
>> drivers/pci-database.c to make sure that the USB host is detected in
>> the firmware tree - it should appear without any properties. Next
>> download the IEEE1275 PCI bindings and have a look at the words there.
>
> I've already looked at pci-database.c for the C driver from coreboot's
> libpayload. The USB controller was detected but printed "cannot manage"
> as there was no driver. I could add a callback to call the init function
> of the driver. I assume for a Forth driver should replace this to call
> into Forth like the vga driver does.
Yes, that's the one. You can add a dummy callback for testing that does
nothing to start with, but that should be enough for it to show up with
its device/vendor id when running "show-devs". Does Mac99 use OHCI or UHCI?
>> Probably the first place to start is getting the PCI config space
>> accesses working; for this you will probably need to implement some
>> Forth wrappers around C for the PCI config space access functions from
>> the PCI bindings.
>
> I don't see this yet. Can you give me some more details like which Forth
> words should be implemented by wrapping which C functions and an example
> of such implementation?
Okay: taking section 3.2.3 of the PCI bindings, as an example you'd need
to wrap the config-l@ and config-l! words so that they call OpenBIOS'
pci_config_read32() and pci_config_write32() functions to access PCI
configuration space.
>> In OpenBIOS, files are added into the build.xml file which generates a
>> set of Makefiles when running the switch-arch script.
>
> I've found this but I don't know how to add files for a driver. The vga
> driver is in build.xml like this:
>
> <fcode source="vga.fs" name="QEMU,VGA.bin" condition="DRIVER_VGA" />
>
> What should be the name? Can I just come up with something or are there
> some rules to follow?
Bear in mind that fcode is for compiled files, e.g. the above says take
vga.fs and output the binary QEMU,VGA.bin. To add a .fs to the Forth
dictionary you need to add them within the <dictionary> tags.
>> The .bth files are probably used to create FCode blobs, much in the
>> same way as the toke utility from the OpenBIOS fcode-utils does. Take
>> a look at drivers/build.xml and in particular the vga driver to see
>> how this is done, as this was a driver I converted over from C.
>>
>>> The ohci.bth file looks like this:
>>>
>>> ---begin---
>>> purpose: Load file for OHCI HCD
>>>
>>> command: &tokenize &this
>>> build-now
>>>
>>> silent on
>>>
>>> begin-tokenizing ohci.fc
>>>
>>> FCode-version2
>>>
>>> " ohci" encode-string " device_type" property
>>>
>>> fload ${BP}/dev/usb2/hcd/ohci/loadpkg.fth
>>>
>>> end0
>>>
>>> end-tokenizing
>>> ---end---
>>>
>>> and the hcd/ohci/loadpkg.fth referenced here contains more fload
>>> commands that load the other parts. What is the equivalent in OpenBIOS's
>>> Forth to do this?
>>
>> Instead of fload, you should be able to use include instead (see
>> forth/bootstrap/start.fs). And for tokenizing, you simply run the
>> Forth source code through fcode-utils' toke command.
>
> OK, I'll try to use include instead of fload and see what errors I get
> and if I can make sense of them.
Definitely start with a small set of files and get the basic PCI
configuration accesses working first, and then slowly add in the other
files until you get something that works.
>> Also once you start to get a feel for the work and think it's viable,
>> we should get Stefan to make sure he's okay with the OpenFirmware
>> license with respect to OpenBIOS' GPLv2.
>
> There's not much I can do about that licensing so feel free to ask now,
> it's better to know upfront if the patch cannot be accepted. (Although
> I've checked on gnu.org that the BSD style license should be compatible
> with GPLv2.)
Okay - would you like to email Stefan and CC me?
ATB,
Mark.
More information about the OpenBIOS
mailing list