Commit graph

56 commits

Author SHA1 Message Date
bunnie
4f14a67504 formatting changes due to changes in nightly rust
needed to get a clean check on gh
2025-02-01 22:26:40 +08:00
bunnie
043dfd84ae update formatting to latest nightly rules 2024-09-24 01:49:45 +08:00
bunnie
27a21e9112 format services/codec 2024-01-14 22:05:15 +08:00
bunnie
7e04357aba modernize codec debug 2023-12-24 23:50:50 +08:00
bunnie
af982aef30 add a static flag for interrupt hooking of the codec object
the init() function on this object may actually be called several
times within a single boot context because the codec is powered down
as a separate subsystem from the rest. however, the interrupt should
still only be hooked exactly once. This flag tracks that state.
2023-07-16 22:07:09 +08:00
bunnie
5055f1aad7 restore Box() around codec hardware structure 2023-07-16 17:33:26 +08:00
Sean Cross
1e07d94381 codec: install interrupt handler after ::new()
Signed-off-by: Sean Cross <sean@xobs.io>
2023-07-16 15:33:40 +08:00
bunnie
0b9199bc25 fix regression due to #366
Boxing the `Codec` object and sticking it on the heap causes
audio playback to hard-lock (no kp, no other explanation given).

Not sure what the issue is, but a cleaner fix is arguably to simply
increase the stack size so the objects can be allocated there.

I suspect the problem may have to do with how the FIFO structures
are memory-mapped and somehow this does not play nice with
Box (there are `unsafe` routines within it).
2023-04-21 13:43:50 +08:00
Sean Cross
ef077ed7de codec: place codec object into heap
The codec object contains a lot of data including a `FrameRing` buffer
as well as some other services. With the latest version of Rust, this
has grown large and no longer fits onto the stack. As a result, it
crashes with a stack overflow immediately upon boot.

Move the Codec onto the heap. This frees up stack and allows it to run
under Rust 1.69.0.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-20 13:06:33 +08:00
bunnie
16c48b4f5b minor tweak on debug levels 2023-03-23 21:20:17 +08:00
bunnie
f860f7bb33 add a mutex guard around I2C transactions
Individual I2C register reads and writes, even if to multiple bytes,
are atomic.

However, some i2c operations require multiple reads and writes
to be strung together without interruption for them to be valid.
A "mutex" is added, which if a program using I2C calls it prior
to their I2C operation, it will block if another program is
already using the I2C block for an uninterruptable series of
operations. The caller will automatically be unblocked once
the untinterruptable transactionts are completed.

Note that this is a collaborative exercise, a caller can still
try to initiate an I2C operation without getting a mutex first,
in which case it could interrupt another block that is doing something
uninterruptable. At the moment this merely generates a warning on
the console, but eventually, this will become a panic.
2023-01-31 18:22:10 +08:00
bunnie
04f700ac29 add headphone state polling to codec 2022-11-15 02:23:01 +08:00
bunnie
67fc21fbdd harmonize hosted mode selection, but retain an explicit hosted flag
In general, hosted mode is assumed "by default" if the target
is not Xous. This allows packages to be built cleanly on command
lines that don't know to pass a --feature flag to specify a target.

However, an explicit "hosted" flag is still retained so that we
can confirm the build system intent. This saves us from the failure
mode that we thought we were building for target A, but accidentally
ommitted the flag, and instead we've been silently building for
"hosted" mode without any warning. The main consumer of the "hosted"
flag is now just the build.rs script inside of the utralib.
2022-10-25 17:21:02 +08:00
bunnie
4e40ae6c5d move from target selectors to feature selectors for back-ends
This will allow for e.g. xous on riscv32-imac but not a precursor
target, for example: by using feature selectors we get to have
a bigger range of targets that we support, such as for implementations
that haven't been upstreamed or have official target-triples.

The downsides are:

- patch override libraries don't absorb feature flags. so, for
example, the AES crate that is used to patch other crates won't
be aware of the target features without modifying the referencing
crates.

- features are normally meant to be additive, but target features
are mutually exclusive. The mutex is enforced by a check in
utralib that throws a panic on build if two targets are accidentally
selected at the same time.
2022-10-02 02:56:44 +08:00
bunnie
d67c5d53fb reduce I2C chatter on resume 2022-06-28 03:24:59 +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
33d8275321 refactor I2C to use deferred message responses instead of busy waits
This is a start on issue #111, where instead of starting a throw-away
server and doing a "yield" loop to emulate blocking behavior, messages
are instead stored so they don't drop, thus keeping a blocking
message blocking.
2022-04-06 03:35:43 +08:00
bunnie
c503316c3d refactor suspend/resume ordering
Add a "Later" stage, and have exactly one "Last" stage.

"Last" to suspend is the ticktimer -- this is crucial for
basically everything else to work. The other really
low level stuff that needs to work to the last minute is
now in the "Later" bin.
2022-03-30 02:30:39 +08:00
bunnie
4044a1d2c1 unbreak hosted mode audio 2022-03-18 03:10:28 +08:00
bunnie
04f2e0fd2a restore headphone/speaker volume on resume 2022-03-17 17:56:27 +08:00
Jared Baldridge
f37df5b880 add drain and can_play stubs to hostaudio backend 2022-03-10 13:38:59 -08:00
bunnie
71d9cc38af fix (or at least improve) simultaneous tts initiation crash 2022-03-10 04:00:09 +08:00
bunnie
4440e61d02 fix short sample problems, add pause/abort API
pause API waits till the buffer drains to stop playback
abort causes playback to stop immediately, causing pending
frames to go empty.
2022-03-08 19:02:02 +08:00
bunnie
95b857feea refactor i2c interface to eliminate static mut unsafes
also remove async write callbacks: in practice, these aren't used

Downside of this refactor is that threads for handling the
callbacks are not spawned on demand, they are spawned at boot,
leading to about an extra 68k of RAM used (most of it being
consumed in the codec block, actually). Some of this is also
probably extra object code because we're using more of the stdlib
primitives, which carry some weight.
2022-02-19 00:31:25 +08:00
bunnie
827888ccbb fix up the REFCOUNT on connections
Was doing disjoint loads and stores on an Atomic, really, should
be using the fetch_add, fetch_sub variants to be proper.

Didn't seem to impact anything but maybe there's a future version
of me that high fives me for doing this.
2022-01-31 23:13:10 +08:00
bunnie
617fc3b8f6 bug fixes in the REPL demo 2022-01-25 01:57:16 +08:00
bunnie
994e3d7cfb refactor llio crate (phase 1): organize files into sub-systems 2022-01-11 12:02:27 +08:00
bunnie
b275b1d3c2 move some low-level hardware facing services to "Late" suspend status
So far it's been no problem to suspend these in any order, but as
more services come to rely upon them it's better if they suspend after
any client applications have been suspended.
2022-01-10 13:48:49 +08:00
bunnie
c5fe1bc99b add sequencing to suspend/resume order of operations
this is necessary because we want to make sure that the SPINOR
service does not shut down before the PDDB service finishes syncing
its disks.
2022-01-10 13:45:56 +08:00
bunnie
489a26dd11 fix an issue where we don't decrement the connection counter on drop 2022-01-05 20:01:54 +08:00
bunnie
5c33e84858 fix hosted mode missing audio dummy functions 2021-09-10 22:58:03 +08:00
bunnie
beed5c395a add volume control functions to the codec 2021-09-10 22:53:41 +08:00
Sean Cross
b86e0a65cd services: recognize xous as a hardware OS
Support `xous` as a valid OS. This allows us to build the entire kernel
under this target.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-02 18:11:48 +08:00
bunnie
aa967a5a17 quiet up hosted mode build warnings 2021-06-18 22:37:08 +08:00
bunnie
8cd84d3be0 Merge branch 'bunnie-dev' into ux-refactor
incorporates the upstreamed xous-names connection count patch
2021-06-15 17:45:07 +08:00
bunnie
eee9f4e765 refactor xous-names to permit only a fixed number of connections
this prevents less trusted processes from connecting to servers
after the kernel initializations are done.

this works so long as we don't have disconnects from the kernel
servers. In order to support disconnects we will also need a
way to re-enumerate the SID to guarantee that we don't have a re-use
problem. But for now, the kernel is not designed with any practical
disconnect mechanism; there is no code that calls the Quit mechanism
on any server.
2021-06-15 17:41:14 +08:00
bunnie
4058b56aae intermediate checkin of UX refactor 2021-06-15 12:50:29 +08:00
bunnie
fadc9c29ab Merge remote-tracking branch 'origin/master' into bunnie-dev 2021-06-02 03:59:25 +08:00
bunnie
9f3647f3a3 have audio off by default on power-on to save power 2021-06-01 00:44:33 +08:00
bunnie
30aa794f30 add reference counting on connections between servers
the connection number is re-used for all objects created
within a process space, so you can't `Drop` the connection
immediately when an object goes out of scope. You have to
make sure all instance of the object go out of scope. This
patch adds reference counting to all the objects so that
the `Drop` function works as intended.
2021-05-21 16:24:30 +08:00
Sean Cross
eb7895d601 xous: add a return code to TerminateProcess
As part of this refactor, make `terminate_process()` a divergent call.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-20 11:01:00 +08:00
bunnie
08a86749fe fix hosted mode bugs 2021-05-09 01:13:16 +08:00
bunnie
15fc4a6c36 audio working, trying out longer samples 2021-05-08 03:14:14 +08:00
bunnie
fe6b417643 checkpoint 2021-05-08 01:13:30 +08:00
bunnie
b3a60faec2 audio checkpoint 2021-05-07 15:09:51 +08:00
bunnie
7dd66a4c18 playback is mostly working and stable 2021-05-07 05:42:39 +08:00
bunnie
adc7f8e98d cleanup the i2c API
condense async/sync methods into a single one and decide which
is which based upon the presence of an Option<callback>
2021-05-06 14:03:06 +08:00
bunnie
bc82dbd157 transition i2c api on codec, finally found the damn race condition 2021-05-06 05:05:17 +08:00
bunnie
b596c40dd6 refactor I2C to have work queue, cleaner (but untested) APIs 2021-05-06 03:40:04 +08:00
bunnie
bb5bc1d212 refactor i2c to break out the i2c machine to a separate server
the concurrency issues on I2C are getting hairy, and it was probably a
dubious decision from the start to merge I2C into the LLIO block; but
originally this was motivated by the idea of keeping all the
"miscellaneous slow stuff" in one process to keep the memory footprint
small and make code a bit more readable.

Keeping I2C in the same process space as the LLIO but splitting it
into its own thread and server splits the difference, by giving us
more options to deal with the concurrency, without inflating the size
of the kernel binary and allocating a lot of extra static data.
2021-05-06 00:45:14 +08:00