mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[6s] Add 6s shell, make channels full-duplex
This commit adds the 6s shell, and a bunch of supporting work for it. Major changes include: - New shell.yaml manifest to give 6s control of the TTY instead of srv.logger - Changes to mailbox syscalls to add max handles array size separate from input size. Also reversed the meaning of the similar data size argument in those syscalls. (Using the second arg as the max array size and the first as the current valid size allows for the auto verify code to verify handles properly, and simplifies user-side code.) - New util::unique_ptr smart pointer class similar to std::unique_ptr - New ipc::message format that uses util::unique_ptr to manage ownership and lifetimes and avoid extra copying. - The service locator protocol now supports multiple handles per entry - Channels got a major overhaul. They are now split into two VMAs, each containing a mutex, a condition, and a util::bip_buffer. The order of the VMAs determines which end of the pipe you're on. (ie, the creator swaps them before handing them to the other thread.) Their API also changed to be similar to that of util::bip_buffer, to avoid extra copies. - util::bip_buffer now keeps its state and its buffer together, so that there are no pointers. This allows multiple processes to share them in shared memory, like in channels. - The UART driver changed from keeping buffers for the serial ports to just keeping a channel, and the serial port objects read/write directly from/to the channel. Known issues: - The shell doesn't actually do anything yet. It echos its input back to the serial line and injects a prompt on new lines. - The shell is one character behind in printing back to the serial line.
This commit is contained in:
@@ -5,14 +5,29 @@
|
||||
#include <stdint.h>
|
||||
#include <j6/types.h>
|
||||
#include <util/counted.h>
|
||||
#include <util/pointers.h>
|
||||
|
||||
namespace ipc {
|
||||
|
||||
static constexpr size_t message_size = 64;
|
||||
|
||||
struct message
|
||||
{
|
||||
uint64_t tag;
|
||||
util::buffer data;
|
||||
util::counted<j6_handle_t> handles;
|
||||
uint16_t data_size;
|
||||
|
||||
uint16_t handle_count : 4;
|
||||
uint16_t out_of_band : 1;
|
||||
|
||||
uint32_t _reserved;
|
||||
|
||||
uint8_t content[ message_size - 8 ];
|
||||
|
||||
util::buffer data();
|
||||
util::const_buffer data() const;
|
||||
|
||||
util::counted<j6_handle_t> handles();
|
||||
util::counted<const j6_handle_t> handles() const;
|
||||
|
||||
message();
|
||||
message(uint64_t in_tag, const util::buffer &in_data, const util::counted<j6_handle_t> &in_handles);
|
||||
@@ -20,6 +35,13 @@ struct message
|
||||
~message();
|
||||
|
||||
message & operator=(message &&other);
|
||||
|
||||
void set(uint64_t in_tag, const util::buffer &in_data, const util::counted<j6_handle_t> &in_handles);
|
||||
|
||||
private:
|
||||
void clear_oob();
|
||||
};
|
||||
|
||||
} // namespace ipc
|
||||
using message_ptr = util::unique_ptr<message>;
|
||||
|
||||
} // namespace ipc
|
||||
|
||||
Reference in New Issue
Block a user