Commit graph

1635 commits

Author SHA1 Message Date
bunnie
6f8590e4e7 fixup config flags on keyboard option 2022-06-08 04:37:08 +08:00
bunnie
cb30edd8ab Merge branch 'main' into u2f 2022-06-08 04:35:37 +08:00
kelas
37d3e4973e don't block if the queue isn't empty 2022-06-07 19:21:43 +02:00
bunnie
0830513ef1 debugging for dynamic resize issue 2022-06-07 16:42:10 +08:00
bunnie
64f008b4fa add debugging facilities to gam 2022-06-07 16:28:26 +08:00
bunnie
741a6ab45e fix dynamic resize redraw bug
for some reason I was setting the state of a canvas to not drawable
when the clip rectangle was being reset, causing dynamic dialog boxes
to become static if the content inside changes size.

I think this is an artifact of a previous generation of this code,
so commenting that out, but left a breadcrumb is case I'm wrong.
2022-06-07 16:27:16 +08:00
bunnie
09a968ef09 remove debug-here dependency
this contains a dependency to `failure` two levels down that has a critical
vulnerability. Unfortunately no new versions of debug-here have been
published in a while. It's no longer used, so just stripping it out
altogether.
2022-06-07 14:00:25 +08:00
bunnie
ba874a653e make the rawserial path queue up to 128 characters if getchar() isn't live 2022-06-07 13:03:49 +08:00
bunnie
cc6382df10 revert rawserial feature on keyboard 2022-06-06 19:09:10 +08:00
bunnie
848df39d72 Merge branch 'u2f' into main 2022-06-06 19:04:58 +08:00
bunnie
6c94e61ab6 make hosted mode "happy" when running with HID calls 2022-06-06 19:00:19 +08:00
bunnie
66dc39c2a8 pddb sync does not require the handle to be mutable 2022-06-06 18:25:33 +08:00
bunnie
0d1244dc32 add a "rawserial" feature to the UART injection path 2022-06-06 14:10:31 +08:00
bunnie
62913a6560 meant to have keyboard injection as a feature. restore that. 2022-06-06 13:59:01 +08:00
bunnie
6e34659a33 Merge branch 'main' into u2f 2022-06-06 04:33:57 +08:00
bunnie
3e84e0e597 add some example code to FFI-test for implementing a getchar-like facility 2022-06-06 04:33:10 +08:00
bunnie
28a9d5bca7 add hooks so unsafe C-FFI calls can connect to the keyboard
- Opcodes are mapped to static IDs
- connection ID is now visible to someone who already owns
  the keyboard object. This can then be shared with the FFI
  interface to do calls to the keyboard server.
2022-06-06 03:56:05 +08:00
bunnie
ebd4e7a1ba improve dynamic notifications / kbhit reporting 2022-06-06 03:46:57 +08:00
bunnie
ffd8e3607d add a check that the write() has completed before initiating a new one 2022-06-06 03:46:30 +08:00
bunnie
72996bc453 add a facility for a simple blocking keyboard listener 2022-06-05 18:32:54 +08:00
bunnie
9bd39af684 Merge branch 'u2f' into main
Merge in the latest progress as it includes some fixes to the PDDB
(read_all() now works as expected), and to the keyboard listener
API on the dynamic notifications dialog box.
2022-06-05 01:53:41 +08:00
bunnie
2161771b09 fix keyboard listener on dynamic notifications 2022-06-05 01:45:25 +08:00
bunnie
17446588bb fix read_all bug in PDDB 2022-06-05 01:45:05 +08:00
bunnie
f4f6106b48 fix CI issues in github actions due to namespace collision of feature & package 2022-06-04 14:20:45 +08:00
bunnie
272abfd157 cleanup pass on spew and warnings 2022-06-04 00:56:47 +08:00
bunnie
6397aafb21 quiet down debug spew 2022-06-04 00:35:28 +08:00
bunnie
3ad70c711d add mjolnir; fix EP allocation bug
Spent the last couple days tracing down a dastardly bug, which was
slew only upon the creation of mjolnir.

The SpinalHDL USB core is unique in that it has a hardware
implementation of a linked list for its descriptors. This can
be very high performance because you can receive packets much
faster than software can keep up with it in short bursts --
assuming the stack can deal with it.

Unfortunately the poor Rust stack that we adopted from
the STM32 land only assumes single descriptors. Alas, we cannot
unlock the full power of linked list descriptors, and instead
we use "single entry lists" with static allocations, to match
the paradigm of the STM32.

Anyways. Early on, when creating the linked list allocator,
I contemplated doing it the Rusty way, and the C way. The Rusty
way would create a structure that mapped the descriptor headers
plus the variable-sized data chunk into some magical structure
that got us bounds checking and had proper accessors etc.
The C way would just be raw pointer manipulation using unsafes.

Unfortunately, my Rust-fu was no match for the linked list.
The problem is that the descriptors could be of any data size,
and they had to be mapped to a very specific piece of memory.
So I had to create a `repr (C)` struct that matched Rust's
alignment requirements and also somehow could deal with
a variable length array *but could not be a slice* because
the hardware implementation does not have the flexibility
to accommodate a fat pointer. I couldn't figure out how
to get const generics to work, and the size of the array
could be anything from 0 bytes to a couple kilobytes. So,
I ditched the safety of Rust and went with a C-style unsafe
pointer implementation.

Sure enough, it came to haunt me. When I wrote the allocator,
I forgot to allocate space for the descriptor headers. This
worked fine for the keyboard, because the keyboard asks for
32-byte descriptors but only ever does a 25-byte report. That's
just enough to fit the descriptor headers, ironically.

When implementing FIDO/U2F, it asks for 64-byte descriptors
and uses exactly 64-byte messages for everything. This caused
a bug where I could receive one incoming packet, but when
responding with an outgoing packet we'd overwrite the descriptors
of the receiving packet, zeroing it out, causing the the descriptor
to fail in the hardware state machine. Of course I never saw
this because I would print the descriptors of the individual
endpoints upon creating them, but the pointer-overflow problem
only occurs later.

Thus mjolnir was created, it is basically a tool that gives me
a raw hex dump of the endpoint and descriptor banks, which I
can then analyze and diff. It's very powerful, but also very
unweildy -- if invoked indiscriminantly, the overhead of
all the prints would cause other failures due to timing problems.
Thus mjolnir exists as a feature that introduces special
locks around the USB endpoints so that they NAK while mjolnir
does its analysis, disallowing concurrent mutation of the
memory state.

Upon deploying mjolnir, the problem became obvious, and it is
now fixed.

Thus, while on the one hand, it's a great story of how maybe
we should avoid unsafe Rust, it's also a story of how hardware
structures like a hardware linked list may be fundamentally
incompatible with Rust. I think if the hardware USB descriptor
linked list was modified to allow for a fat pointer to track
a data slice, the implementation would almost be trivial. But,
rewriting HDL to fit Rust also has its hazards, as the exact
layout of a fat pointer in RAM is not guaranteed and it would
probably foolhardy to commit to something not guaranteed in
hardware.
2022-06-03 23:53:37 +08:00
bunnie
4dca789d22 make keyboard composite device optional
just to make debugging a bit easier
2022-06-03 18:17:39 +08:00
bunnie
6ff5924cea fix issue with in_progress being set on init for writes
also try to wait for transactions in progress on write before
re-initiating
2022-06-03 16:49:36 +08:00
bunnie
8914dad705 remove redundant nack overhead, and the mystery delay
looks like after solving the redundant interrupt problem,
the mystery delay is no longer needed.
2022-06-03 03:11:35 +08:00
bunnie
f7a01693fe fix interrupts for USB; fix issue #170
this fixes two things:

1. writes no longer generate a spurious interrupt on completion
that also triggers a "non-read".

2. writes are not automatically set to send on allocation. this
solves issue #170. they are only set to send after a write.
2022-06-03 02:26:08 +08:00
bunnie
48f3b36875 stuck at getting FIDO stack to respond to second OUT packet. 2022-06-03 01:08:25 +08:00
bunnie
52e6071265 update FidoMsg api and fix opcode bug 2022-06-02 00:58:13 +08:00
bunnie
6f1bbb49d1 cleanup whitespace issues 2022-06-01 22:33:04 +08:00
bunnie
27c4d5e01d return the key hit to the listener of the notification 2022-06-01 22:32:03 +08:00
bunnie
da06d95acd add a deferred listener for keyboard events from a dynamic notification 2022-06-01 22:31:44 +08:00
bunnie
740c3a8572 Merge branch 'main' into u2f 2022-06-01 00:33:31 +08:00
bunnie
5337d34d45 fix warnings in hosted mode 2022-06-01 00:32:49 +08:00
bunnie
2eee81b218 fix another errant mut that wasn't needed in pddb 2022-06-01 00:21:30 +08:00
bunnie
3b1629744c fix warnings that result from the PDDB mutability change 2022-06-01 00:21:22 +08:00
bunnie
a1fc015541 use interior mutability to handle callbacks
this eases a mutability requirement for the PDDB object
2022-06-01 00:21:15 +08:00
bunnie
21116a1693 fix another errant mut that wasn't needed in pddb 2022-06-01 00:06:55 +08:00
bunnie
9ee306315e fix warnings that result from the PDDB mutability change 2022-05-31 23:55:12 +08:00
bunnie
bf535bd0e1 use interior mutability to handle callbacks
this eases a mutability requirement for the PDDB object
2022-05-31 23:54:16 +08:00
bunnie
b20514e87d cleanup hosted mode warnings 2022-05-31 14:48:09 +08:00
bunnie
376d7a713b Merge branch 'main' into u2f 2022-05-31 14:39:08 +08:00
bunnie
98289b1405 fix warnings that have cropped up for transition to 2021 edition 2022-05-31 14:38:41 +08:00
Sean Cross
3ae9d8abf0 apps/services: remove xous::xous_main macro usage
This macro will be removed, since it is no longer necessary. Remove this
macro across the project and replace it with a standard `main()`
function.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-05-31 13:33:30 +08:00
bunnie
647a3a26dd port to composite format 2022-05-30 18:52:03 +08:00
bunnie
372c2cb680 Merge branch 'main' into u2f 2022-05-30 17:41:27 +08:00