Commit Graph

22 Commits

Author SHA1 Message Date
Sam Leffler
88841cb7a7 DebugConsole: add autostart script support & make uart optional
- make kata-uart-client use dependent on a new "sparrow_uart_support"
  feature; this is needed for headless operation and for platforms
  without a working uart driver
- add a mechanism where an "autostart.repl" file is fetched  from the
  builtins (if present) and passed through the shell; output goes to
  the uart if configured, otherwise the kernel or /dev/nnull
- add a new "source" shell command that interprets the contents of a
  builtins file as console input
- rework the command interpreter to support autostart & source
- move the logging hookup to kata-debug-console so the system builds
  when no uart support is conffigured (need to add fallback to debug
  syscalls in case that works when no driver is present)

Change-Id: I5e6725c93488a48d212dfaca425ede37cbdb72e5
GitOrigin-RevId: 6f360cab71ea103af52e3c68ca240fc16e0f20bb
2022-10-18 15:36:33 -07:00
Sam Leffler
601e7f5c78 kata: compile-out debug & trace log calls in release builds
Change-Id: Ibde5a49141daa67c57e24340b73b436d08e68e7a
GitOrigin-RevId: 4a77833a6cd3e16850d2e4d90b7e7ed916770b50
2022-10-06 19:00:28 +00:00
June Tate-Gans
1a068b0143 kata: Prepend the Google copyright and Apache 2.0 license
This includes adding it to TOML files and CAmkES assembly files.

Change-Id: I263e7a566df91fccc04f9b2186edab13331290c5
GitOrigin-RevId: 48a35b06ca868a0a4d379f881068cc4dad491669
2022-10-06 18:59:16 +00:00
Sam Leffler
4ca13e9088 DebugConsole: add features to set initial logging level
Add features to control the log level used before reaching the shell
prompt (where the "loglevel" command can be used to control log
filtering).  The default log level is Info. LOG_DEBUG forces it to
Debug. LOG_TRACE forces it to Trace (max).

Change-Id: Ic55eaf3cd08fc101c53319b5a45a2c7de6f94a66
GitOrigin-RevId: 5500ac5d65186773d5304a75d03295e09b2e9a63
2022-10-06 18:54:19 +00:00
Cindy Liu
c9f36f4da8 Merge "Changes for updating the toolchain to nightly-1.58.0"
GitOrigin-RevId: 6eadbd3c3652d88b3079635f2649b43e370fe4bd
2022-10-06 18:54:11 +00:00
Sam Leffler
7a412467ac DebugConsole: reduce heap size to 16KB
Now that there's MemoryManager integration for zmodem uploads we no longer
need an outsized heap; make it 16KB for now (likely can be smaller).

Change-Id: I3b991ef794c0e718934d055e41aef9abc48b1d6b
GitOrigin-RevId: 7145b14fca96f59ff76497be29da6b1f447c15b0
2022-10-06 18:54:04 +00:00
Sam Leffler
ddacc3762e Add kata-os-common::camkes support.
Add a new "camkes" submodule that consolidates KataOS CAmkES component
integration boilerplate. Each component is expected to declare:

static mut CAMKES: Camkes = Camkes::new("ProcessManager");

and then (typically) use "pre_init" to setup the logger, heap, and the
slot allocator. More fine-grained control is provided by:

fn init_logger(self: &Cmakes, level: Log::LevelFilter);
fn init_allocator(self: &Camkes, heap: &'static mut [u8]);
fn init_slot_allocator(self: &Camkes, first_slot: seL4_CPtr, last_slot: seL4_CPtr);

When receiving capabilities use "init_recv_path" to setup the IPCBuffer
receive path and "assert_recv_path" & "check_recv_path" calls to verify
noting has clobbered the setting.

The debug_assert_slot_* macros are wrapped in Camkes:: functions and a
"top_level_path" function for constructing seL4_CPath objects. Altogether
this normally allows a component to be written without direct use of the
CAmkES global static identifiers SELF_CNODE*.

Change-Id: Ia1351e411a5355789cf74bc0fcfe0e41a418b7d4
GitOrigin-RevId: fb81a8e0687ed9321c9961410edd5dbd54093ce5
2022-10-06 18:48:10 +00:00
Sam Leffler
b8dfe92451 DebugConsole: clippy findings
Change-Id: I8e93e5441e5762171b4e32baa253ceba6d96855b
GitOrigin-RevId: 90106f4f236c27f88a59ea6286612bb6db378cfc
2022-10-06 18:47:07 +00:00
Sam Leffler
746616b6d6 DebugConsole: add cpio archive of builtin bundle objects
- replace the memory-mapped elf file by a cpio archive of bundle
  objects (BundleImages until we fill in what a bundle is)
- add a new "builtins" command to list the contents of the cpio
  archive (similar to cpio -t)
- extend the "install" command to load from the builtins archive
- switch the connection to ProcessManager to support the larger
  ObjDescBundle's coming from the cpio archive

Change-Id: I5d7c195b58937df3921f925de3637f325f53fa2f
GitOrigin-RevId: 410813e62ae8f38685a1b32deb2e80de538085a4
2022-10-06 18:45:35 +00:00
Sam Leffler
0a51bd8b59 DebugConsole: hookup zmodem to MemoryManager
- change zmodem uploads to get memory from the MemoryManager
- add a "-z" option to the "install" command to start a zmodem upload
  to generate the package contents to send to ProcessManager
- increase CNode headroom for loading package contents

Change-Id: I5f329cdd044368e5568ad891245d67a4a13f8468
GitOrigin-RevId: 2853cde48cb8232f3ba75fe7e8efdbd3032bcb66
2022-10-06 18:44:59 +00:00
June Tate-Gans
57a4ee2f13 cargo: Bump to 2021 edition
Change-Id: Icb2deaff58da7f92970d8f57f7853349769323f5
GitOrigin-RevId: f8303df543a9d84c066b9a4a1bd1c0239eb75857
2022-10-06 18:42:30 +00:00
Sam Leffler
9188a29bd4 Move common crates to kata-os-common and shorten names.
- kata-allocator, kata-kata-logger, kata-panic, and kata-slot-allocator
  are now submodules of kata-os-common
- be more consistent on use stmts (and remove unneeded deps)
- cleanup various deps on kata-panic that no longer seem to be needed
  (likely due to using resolver=2)

Change-Id: I5d3f4b399e3be66c09c2f97c75d5e3053993ebdd
GitOrigin-RevId: 393e28fbb975959cba35388bab749b256cda0095
2022-10-06 18:42:22 +00:00
Matt Harvey
4faa2e4c82 Implements BufRead in kata_io
Reading one byte at a time in a loop causes excessive syscalls. For
example, ZMODEM needs to do this when finding the end of each frame.
This change copies parts of std::io needed to wrap a Read in a BufReader
so that the read will be done eagerly.

It enables buffered UART reads for the whole DebugConsole at the point
where its single Read object is initialized.

Change-Id: I19935ca02333bc74d9b581d384a1854968ac5329
GitOrigin-RevId: 1aa80e036561a6a18e79dbf28bcab240efe80cd1
2022-10-06 18:32:11 +00:00
Matt Harvey
d70003982c Merge "Aligns UART API with Rust Read and Write"
GitOrigin-RevId: df407ae4bddb75b1bc43c35062947679c2b10c3a
2022-10-06 18:31:59 +00:00
Matt Harvey
251c907f49 Increases DebugConsole heap to 1MB
There is a temporary desire to keep ZMODEM uploads as state in
DebugConsole. Since realistic package ZIP files might be larger than
16KB, this change increases the heap size to have a lot of excess.

Change-Id: Iabb5014cb77cf828f77d4553b7f304248c085114
GitOrigin-RevId: 2ae49570a887d5bd2d4672fb3e134c8a1394190e
2022-10-06 18:13:32 +00:00
Sam Leffler
36677807e8 Merge "Improve unit test usability."
GitOrigin-RevId: 25772f196da92291383369a233f71f1335cb7cc1
2022-10-06 18:13:21 +00:00
Sam Leffler
d97a78316e Misc cleanups.
- change early logging (pre kata-shell prompt) to trace level so by
  default nothing shows up unless kata-debug-console::pre_init sets
  log::set_max_level to Trace (default is Debug)
- log allocator init's in caller so log msgs identify per-component heap
  setups (all the same for now but at some point may diverge)
- shorten kata-shell prompt to "KATA> " - remove unused camkes control's
  and consolidate other early work in pre_init and <component>__init hooks
- cargo fmt components

Change-Id: I010eb5cc5af2e379691cb2e62d82dbab32a06bc3
GitOrigin-RevId: badddf46f5ba50fa60e9cbead9f6d99d5ff3808b
2022-10-06 18:03:53 +00:00
Sam Leffler
64da97a4a6 Merge "Add kata-panic support."
GitOrigin-RevId: 86b4cf1b25c2796fff0b2f90da6ef76d773c80a9
2022-10-06 17:59:05 +00:00
Sam Leffler
c5e8722a24 Merge "Add LoggerInterface for logging msgs on the console."
GitOrigin-RevId: 256da9ba28b31f1ac3a87cce0098a52ac918de13
2022-10-06 17:58:54 +00:00
Sam Leffler
94358ffec7 Switch to purpose-built global allocator.
Replace LockedHeap with a purpose-built equivalent. This works around
issues where rust_oom was undefined for certain build configs and
facilitates future sel4 integration (e.g. to use dynamically allocated
memory instead of bss).

Change-Id: I54f779ef794104ad1ae95590812d1cd49b4a3734
GitOrigin-RevId: 83474c02e6b6957946fbca4a9aa090bf3c4dbfdc
2022-10-06 17:58:08 +00:00
Sam Leffler
8d7e4bf44a Add a simple rust global allocator to each component.
- add a linked_list_allocator::LockedHeap instance to each component that
  might want to allocate memory and init the allocator with a fixed-size
  memory block in the component post_init hook
- add an alloc_test shell command that exercises the allocator

This does not dynamically add memory or support sharing memory between
components; this is an intermediate step to simplify bringing in crates
that want to allocate memory (e.g. hashbrown)..

Change-Id: Idaf11fb5d4999218c75bf932133df24de35e3053
GitOrigin-RevId: 7c9b14bf9463239ce030c374b58a140f0835759e
2022-10-06 17:57:56 +00:00
Matt Harvey
fd2bebb81f Replaces processmanager with a one-app CAmkES assembly for the entire Kata OS
This also adds a skeleton for the DebugConsole CLI taking IO from a UART
via some Rust wrapper functions, also defined in this change
(kata-uart-client).

Change-Id: I56856c14992010483da58c45f6550c0a4c9987b0
GitOrigin-RevId: e1b2d65ed3a7f627a9f7377caa407151fc943864
2022-10-06 17:54:23 +00:00