Device operations. Defines the functions to connect and disconnect any device
A potentially blocking I/O operation
The type representing the internal state of the device
An error signalled by the device, normally returned after a connection attempt
Type defining an identifier for this device that uniquely identifies it among a device tree.
Operations to generate entropy. This is currently a passthrough to the OCaml Random generator, and will be deprecated in V2 and turned into a proper DEVICE with blocking modes.
Initialize the generator with a random seed chosen in a system-dependent way.
int bound
returns a random integer between 0 (inclusive) and bound
(exclusive).
bound
must be greater than 0 and less than 230.
int32 bound
returns a random integer between 0 (inclusive) and bound
(exclusive).
bound
must be greater than 0.
A native entropy provider. *
Represents errors when attaching the entropy provider.
usually a cstruct
A handler
is called whenever the system has extra entropy to announce.
No guarantees are made about the entropy itself, other than it being
environmentally derived. In particular, the amount of entropy in the buffer
can be far lower than the size of the buffer
.
source
is a small integer, describing the provider but with no other
meaning.
handler
is expected to return quickly.
Clock operations. Currently read-only to retrieve the time in various formats.
#
tm_sec
| : int | ; | (* | Seconds 0..60 | *) |
#
tm_min
| : int | ; | (* | Minutes 0..59 | *) |
#
tm_hour
| : int | ; | (* | Hours 0..23 | *) |
#
tm_mday
| : int | ; | (* | Day of month 1..31 | *) |
#
tm_mon
| : int | ; | (* | Month of year 0..11 | *) |
#
tm_year
| : int | ; | (* | Year - 1900 | *) |
#
tm_wday
| : int | ; | (* | Day of week (Sunday is 0) | *) |
#
tm_yday
| : int | ; | (* | Day of year 0..365 | *) |
#
tm_isdst
| : bool | ; | (* | Daylight time savings in effect | *) |
The type representing wallclock time and calendar date.
Return the current time since 00:00:00 GMT, Jan. 1, 1970, in seconds.
A connection between endpoints.
A potentially blocking I/O operation
Abstract type for a memory buffer that may not be page aligned.
A flow represents the state of a single stream that is connected to an endpoint.
write flow buffer
will block until buffer
has been added to the
send queue. There is no indication when the buffer has actually been
read and, therefore, it must not be reused.
The contents may be transmitted in separate packets, depending on the
underlying transport. The result `Ok ()
indicates success, `Eof
indicates that the connection is now closed and `Error
indicates some
other error.
writev flow buffers
will block until the buffers have all been added
to the send queue. There is no indication when the buffers have actually
been read and, therefore, they must not be reused.
The result `Ok ()
indicates success, `Eof
indicates that the
connection is now closed and `Error
indicates some other error.
Text console input/output operations.
The type representing possible errors when attaching a console.
Operations on sector-addressible block devices, usually used for persistent storage
Abstract type for a page-aligned memory buffer
IO operation errors
read device sector_start buffers
returns a blocking IO operation which
attempts to fill buffers
with data starting at sector_start
.
Each of buffers
must be a whole number of sectors in length. The list
of buffers can be of any length.
write device sector_start buffers
returns a blocking IO operation which
attempts to write the data contained within buffers
to t
starting
at sector_start
. When the IO operation completes then all writes have been
persisted.
Once submitted, it is not possible to cancel a request and there is no timeout.
The operation may fail with
`Unimplemented
: the operation has not been implemented, no data has been written
`Is_read_only
: the device is read-only, no data has been written
`Disconnected
: the device has been disconnected at application request,
an unknown amount of data has been written
`Unknown
: some other permanent, fatal error (e.g. disk is on fire), where
an unknown amount of data has been written
Each of buffers
must be a whole number of sectors in length. The list
of buffers can be of any length.
The data will not be copied, so the supplied buffers must not be re-used until the IO operation completes.
A network interface that serves Ethernet frames.
Abstract type for a page-aligned memory buffer
Abstract type for a memory buffer that may not be page aligned
IO operation errors
Unique MAC identifier for the device
An Ethernet stack that parses frames from a network device and can associate them with IP address via ARP.
Abstract type for a memory buffer that may not be page aligned
Abstract type for an Ethernet network interface.
IO operation errors
Unique MAC identifier for the device
FIXME listen nf fn
is a blocking operation that calls fn buf
with
every packet that is read from the interface. It returns as soon
as it has initialised, and the function can be stopped by calling
disconnect
in the device layer.
An IP stack that parses Ethernet frames into IP packets
Abstract type for a memory buffer that may not be page aligned
Abstract type for an Ethernet device.
Abstract type for an IP address.
Abstract type for an IP prefix.
IO operation errors
An input continuation used by the parsing functions to pass on
an input packet down the stack.
callback ~src ~dst buf
will be called with src
and dst
containing the source and destination IP address respectively,
and buf
will be a buffer pointing at the start of the IP
payload.
input ~tcp ~udp ~default ip buf
demultiplexes an incoming buffer
that
contains an IP frame. It examines the protocol header and passes the result
onto either the tcp
or udp
function, or the default
function for
unknown IP protocols.
allocate_frame t ~dst ~proto
retrurns a pair (pkt, len)
such that
Cstruct.sub pkt 0 len
is the IP header (including the link layer part) of a
packet going to dst
for protocol proto
. The space in pkt
after the
first len
bytes can be used by the client.
A UDP stack that can send and receive datagrams.
Abstract type for a memory buffer that may not be page aligned.
Abstract type for an IPv4/6 stack for this stack to connect to.
Abstract type for an IP address representation.
An input function continuation to pass onto the underlying [root:ipv4] stack. This will normally be a NOOP for a conventional kernel, but a direct implementation will parse the buffer.
IO operation errors
A TCP stack that can send and receive reliable streams using the TCP protocol.
Abstract type for a memory buffer that may not be page aligned.
Abstract type for an IPv4 stack for this stack to connect to.
Abstract type for an IPv4 address representation.
An input function continuation to pass onto the underlying [root:ipv4] stack. This will normally be a NOOP for a conventional kernel, but a direct implementation will parse the buffer.
A flow represents the state of a single TCPv4 stream that is connected to an endpoint.
IO operation errors
write_nodelay flow
will block until the contents of buffer list
are all successfully transmitted to the remote endpoint. Buffering
within the stack is minimized in this mode. Note that this API will
change in a future revision to be a per-flow attribute instead of a
separately exposed function.
writev_nodelay flow
will block until the contents of buffer list
are all successfully transmitted to the remote endpoint. Buffering
within the stack is minimized in this mode. Note that this API will
change in a future revision to be a per-flow attribute instead of a
separately exposed function.
A complete TCP/IPv4 stack that can be used by applications to receive and transmit network traffic.
Abstract type of a console logger.
Abstract type of a network interface that is used to transmit and receive traffic associated with this stack.
Abstract type of the configuration modes associated with this interface. These can consist of the IPv4 address binding, or a DHCP interface.
Abstract type for the collection of user configuration specified to construct a stack.
Abstract type of an IPv4 address
Abstract type for a memory buffer that may not be page aligned.
Abstract type for a UDPv4 stack.
Abstract type for a TCPv4 stack.
Abstract type for a IPv4 stack
I/O operation errors
Type of a buffered byte-stream that is attached to an unbuffered flow (e.g. a TCPv4 connection).
Abstract type for a memory buffer that may not be page aligned.
Abstract type for an unbuffered network flow.
State associated with this channel, such as the inflight buffers.
Abstract type of a blocking IO monad.
Abstract type of a blocking stream of IO requests.
read_until t ch
will read from the channel until the given ch
character
is found. It returns a tuple indicating whether the character was found at
all (false
indicates that an EOF condition occurred before the character
was encountered), and the buffer
pointing to the position immediately
after the character (or the complete scanned buffer if the character was
never encountered).
write_string t buf off len
writes len
bytes from a string buf
,
starting from from offset off
.
write_line t buf
will write the string buf
to the output channel
and append a newline character afterwards.
A filesystem module.
Abstract type representing an error from the block layer
Abstract type for a page-aligned memory buffer
read t key offset length
reads up to length
bytes from the value
associated with key
. If less data is returned than requested, this
indicates the end of the value.
write t path offset data
writes data
at offset
in file path
on
filesystem t
Memory allocation interface.
Type of a C buffer (usually Cstruct)
get n
allocates and returns a memory block of n
pages. If
there is not enough memory, the unikernel will terminate.
pages n
allocates a memory block of n
pages and return the the
list of pages allocated.
string_blit src srcoff dst dstoff len
copies len
bytes from
string src
, starting at byte number srcoff
, to memory block
dst
, starting at byte number dstoff.
round_to_page_size n
returns the number of bytes that will be
allocated for storing n
bytes in memory
Static Key/value store.
Abstract type for a page-aligned memory buffer
read t key offset length
reads up to length
bytes from the value
associated with key
. If less data is returned than requested, this
indicates the end of the value.