~sircmpwn/mercury

f2c8f806a306b4f5e7043fc389b87d97816c6ceb — Drew DeVault 2 months ago 7801d3a
proto: initial commit

Note that ipcgen does not yet support most of this so.
4 files changed, 114 insertions(+), 0 deletions(-)

A proto/dev/serial.ipc
A proto/errors.ipc
A proto/io.ipc
A proto/sys.ipc
A proto/dev/serial.ipc => proto/dev/serial.ipc +44 -0
@@ 0,0 1,44 @@
namespace dev;
use errors;
use io;

# Note: TWO is interpreted as 1.5 for some char lengths (5)
enum stop_bits {
	ONE,
	TWO,
};

enum parity {
	NONE,
	ODD,
	EVEN,
	MARK,
	SPACE,
};

# Defines the interface for a serial device.
interface serial :: io::iodev {
	# Returns the configured baud rate in hertz.
	call get_baud() uint;

	# Returns the configured number of bits per character.
	call get_charlen() uint;

	# Returns the configured number of stop bits.
	call get_stopbits() stop_bits;

	# Returns the configured parity setting.
	call get_parity() parity;

	# Sets the baud rate for this serial device.
	call set_baud(hz: uint) (void | errors::unsupported);

	# Sets the number of bits per character. Must be 5, 6, 7, or 8.
	call set_charlen(bits: uint) (void | errors::invalid);

	# Configures the number of stop bits to use.
	call set_stopbits(bits: stop_bits) void;

	# Configures the desired parity.
	call set_parity(parity: parity) void;
};

A proto/errors.ipc => proto/errors.ipc +41 -0
@@ 0,0 1,41 @@
# The errors namespace defines common error cases for all interfaces.
namespace errors;

# The requested resource is not available.
error busy;

# An attempt was made to create a resource which already exists.
error exists;

# A function was called with an invalid combination of arguments.
error invalid;

# The user does not have permission to use this resource.
error noaccess;

# An entry was requested which does not exist.
error noentry;

# The requested operation caused a numeric overflow condition.
error overflow;

# The requested operation is not supported.
error unsupported;

# The requested operation timed out.
error timeout;

# The requested operation was cancelled.
error cancelled;

# A connection attempt was refused.
error refused;

# Unable to allocate sufficient memory for the requested operation.
error nomem;

# An operation was interrupted.
error interrupted;

# The user should attempt an operation again.
error again;

A proto/io.ipc => proto/io.ipc +22 -0
@@ 0,0 1,22 @@
use errors;

# Indicates an end-of-file condition.
unit EOF;

# An object which implements I/O operations.
interface iodev {
	# Reads data from an I/O object. Returning the number of bytes read or
	# EOF.
	#
	# "buf" is treated as an offset into the first page among the provided
	# pages to write the data to, and len is the upper limit on the number
	# of bytes that should be read.
	call read{pages: page...}(buf: uintptr, len: size) (size | EOF | errors::*);

	# Writes data to an I/O object.
	#
	# "buf" is treated as an offset into the first page among the provided
	# pages to read the data from, and len is the upper limit on the number
	# of bytes that should be read.
	call write{pages: page...}(buf: uintptr, len: size) (size | errors::*);
};

A proto/sys.ipc => proto/sys.ipc +7 -0
@@ 0,0 1,7 @@
namespace sys;

# The drivermgr interface is used by drivers to install their devices into the
# running system.
interface drivermgr {
	call serial_new{, out: dev::serial}() void;
};