Commit graph

4914 commits

Author SHA1 Message Date
bunnie
7be4a88a9b fix scheduler bug (credit: @xobs)
@xobs found a scheduler bug that would trigger a runnable process
search every time a scalar message returned. This fixes the problem,
causing the quantum to go back to the caller as intended.

Improves performance on the syscall by about 40%.
2023-01-17 02:11:48 +08:00
bunnie
aa48476937 Unroll loop for initializing memory in kernel
This also changes the initialization method from using `u8`
to `u32`.

The loop is unrolled to one iteration per cache line.
2023-01-17 02:10:46 +08:00
bunnie
8b5dfca749 chore: trim some unused comment-code that I forgot to clean before 2023-01-15 14:24:23 +08:00
bunnie
f66e53c54a respond to StartStop command with Done immediately
nothing to sync up on eject, since it's all already in RAM.
2023-01-15 02:39:03 +08:00
bunnie
0155306b85
Merge pull request #295 from gsora/fix/msc-macos
usb-device-xous: don't set device-wide class on mass-storage
2023-01-15 02:05:21 +08:00
Gianguido Sorà
b2494e92fc
usb-device-xous: don't set device-wide class on mass-storage
Setting it to zero (default if not set) makes mass-storage work under
macOS.
2023-01-14 18:53:48 +01:00
bunnie
c0d442f275 refactor reset() routine to be more comprehensive
The original implementation didn't keep around some key data,
so we had to read the old version of the record and update parameters
assuming that the USB descriptors didn't change too much.

Unfortunately with the mass storage option, the description can
change quite a bit, so we have to reconsitute it from scratch.
Basically, we re-do the `alloc()` call in the reset routine,
playing it reverse so that we setup all the higher-number
endpoints before doing ep0 last.

This hopefully fixes a stability issue for usb hid mode when
mass storage is enabled as a build option.
2023-01-15 01:00:53 +08:00
bunnie
af4b394e7d minor edit - make mass storage explicit in match option 2023-01-15 01:00:41 +08:00
bunnie
ee81c70018 refactor multi-view support
- use new SpinalUsbDevice::new() interface instead of cloning
- put the blank "key-up" event on keyboard events after the
core is switched to, instead of at boot.
- add some more appropriate debug statements to help track
view switching in debug logs
2023-01-14 19:10:21 +08:00
bunnie
df1b9d9f8d refactor SpinalUsbDevice new method
Instead of making it once and then cloning it (which is a bit
unclear what's going on), make it so that the shared memory
ranges are allocated in the caller's scope, and then create
the structure "clean".

Also add a static AtomicBool to track interrupt init state,
since that can be only called once.
2023-01-14 19:08:51 +08:00
bunnie
b13671b3bb add some debug output on asserts 2023-01-14 19:08:32 +08:00
bunnie
7021116a37 remove debug print 2023-01-14 19:07:56 +08:00
bunnie
f5a45bc017 cleanup some edge cases in handling poll events, suspend/resume
also fixes allocation ordering for EPs
2023-01-14 02:33:16 +08:00
bunnie
5faf7f50e6
Merge pull request #293 from gsora/fix/just-two-bulk
mass-storage: just use two bulk endpoints
2023-01-14 01:54:37 +08:00
Gianguido Sorà
96582fdf2a
mass-storage: just use two bulk endpoints
For some unknown reason, just adding a second bulk endpoint descriptor makes enumeration
fail on essentially all operating systems.

Adding three endpoints is no issue though, but since we want to avoid wasting resources around
here, writing 0x42 at the end of the last bulk endpoint... fixes everything.

Tested under Linux, Windows, OpenBSD, FreeBSD.
2023-01-13 18:15:05 +01:00
bunnie
0aae50fa82
Merge pull request #288 from plaurent/feat/shellchat-subcommand-pddb-copy
A "copy" subcommand for shellchat pddb
2023-01-14 00:31:37 +08:00
bunnie
26a3adcc01 integrate "chain" fully; use "chain" feature only for bulk endpoints
bulk endpoints have a different behavior now than interrupt
endpoints; bulk endpoints have chained descriptors so that the
hardware automatically responds to multiple USB packets quickly.

interrupt endpoints also have subtly different way of handling
data readiness, which is incompatible with the block device layer
as implemented.
2023-01-14 00:09:16 +08:00
bunnie
7d641641cd turn on mass-storage by default for app-image
this is to facilitate easier testing on bleeding-edge build
2023-01-14 00:08:42 +08:00
bunnie
02cd24e799 fix mass-storage feature missing in shellchat 2023-01-14 00:08:30 +08:00
bunnie
26f12990f1 change default disk size to 256kiB, mostly to economize on RAM
since we don't have a clear use case for this yet and it's just
for testing on bleeding-edge, make a very small disk just so it's
easier for people to do testing, but not so big that it's a burden
on the system.

later on we can make this dynamically sizeable/allocateable only
e.g., only when the disk is required
2023-01-14 00:07:11 +08:00
Patryk Laurent
0cd2010780 use closure/return to avoid deep indents 2023-01-12 21:12:56 -08:00
bunnie
c67a32b28c v2p table shouldn't be in the index
this is a temporary file related to performance profiling. added to .gitignore.
2023-01-13 03:01:39 +08:00
bunnie
afb2858eb5 Merge branch 'gsora-feat/usb-mass-storage' into main 2023-01-13 02:59:48 +08:00
bunnie
c631963a4b Merge branch 'feat/usb-mass-storage' of github.com:gsora/xous-core into gsora-feat/usb-mass-storage 2023-01-13 02:59:17 +08:00
Gianguido Sorà
65b02632c2
Merge pull request #3 from bunnie/feat/usb-mass-storage
Feat/usb mass storage
2023-01-12 19:11:45 +01:00
Patryk Laurent
fb5811ddc8 use MAIN_SEPARATOR instead of hardcoded ':' 2023-01-12 07:20:43 -08:00
bunnie
55b1addf59 add vendoring notice and original copyright to all files vendored in. 2023-01-12 02:10:41 +08:00
bunnie
1a00e3cc2f fix whitespace 2023-01-12 02:06:27 +08:00
bunnie
8aa1301d68 more cleanup 2023-01-12 01:51:50 +08:00
bunnie
bebf323798 some touch-up/cleanup; add a timeout on a blocking read 2023-01-12 01:45:51 +08:00
bunnie
1ec6bd7df4 remove some test files that aren't relevant to our build 2023-01-12 01:17:04 +08:00
bunnie
cd62caadcd fix paths and README 2023-01-12 01:13:21 +08:00
bunnie
ed23cdcc17 move crates to the libs/mass-storage directory 2023-01-12 01:12:56 +08:00
bunnie
88cdde4b9a remove unused files 2023-01-12 01:04:12 +08:00
bunnie
54467a75fc gate mass-storage behind a feature that is currently default off 2023-01-12 00:58:48 +08:00
bunnie
55b940fe74 tiny bit of cleanup & docs 2023-01-11 04:09:13 +08:00
bunnie
1f3c16aea8 add ReadFormatCapacities
this is required by Windows for the driver to work.
2023-01-11 03:55:04 +08:00
bunnie
93e3bc29b3 usb disk now working well without debugging messages 2023-01-11 02:00:32 +08:00
bunnie
d592bab121 head pointer offset is the most reliable way to determine transaction in progress
before we were looking at the amount of data transferred and
seeing if it matches the expected amount

I just realized that we can just look at the descriptor pointer in
the status region; if it is non-zero, then the descriptor set
is "live" and needs to be filled.

if it's zero, then a packet came in.

use this to fix the wait conditions for accepting new commands.
2023-01-11 01:59:13 +08:00
bunnie
f0d1c65c2a repair the minimal config for faster USB debugging 2023-01-11 01:58:15 +08:00
bunnie
921199b429 a cleaner version that works 2023-01-10 14:44:52 +08:00
bunnie
3355f3b5f4 writes now working, barely. 2023-01-10 05:21:11 +08:00
bunnie
5c1518cee6 block reads work. 2023-01-09 19:04:47 +08:00
bunnie
3d826ffbbe add bulk response chaining
IN descriptors now chain up to 512 bytes long

OUT descriptors still need to be worked up

However, there is an issue where the system is injecting the
ZLP/CSW immediately after the bulk response is queued up, and this
is getting sent before the bulk data is issued. Need to figure out
this race condition.
2023-01-09 04:14:59 +08:00
bunnie
10e605569f reduce InquiryResponse record 2023-01-07 00:22:26 +08:00
bunnie
d0afd80647 bump lockfile 2023-01-06 18:05:49 +08:00
bunnie
ce9accbfb8 revert accidental commit 2023-01-06 18:05:40 +08:00
bunnie
41d4837551 bump versions to absorb WDT change 2023-01-06 17:48:12 +08:00
bunnie
0f0b51c779 bump watchdog timer to a longer interval 2023-01-06 17:46:18 +08:00
bunnie
cf5b181b03 convert extra EP to interrupt 2023-01-06 17:44:04 +08:00