blob: 4a52ebb64d02b2196a48a6c5c9bccb04d3c1f020 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library zx;
// port_packet_t::type ZX_PKT_TYPE_USER.
type PacketUser = strict union {
1: u64 array<uint64, 4>;
2: u32 array<uint32, 8>;
3: u16 array<uint16, 16>;
4: c8 array<int8, 32>;
};
// port_packet_t::type ZX_PKT_TYPE_SIGNAL_ONE.
type PacketSignal = struct {
trigger signals;
observed signals;
count uint64;
reserved0 uint64;
reserved1 uint64;
};
type PacketException = struct {
pid uint64;
tid uint64;
reserved0 uint64;
reserved1 uint64;
};
type PacketGuestBell = struct {
addr gpaddr;
reserved0 uint64;
reserved1 uint64;
reserved2 uint64;
};
// TODO(scottmg): Arch-specific definition.
type PacketGuestMem = struct {
addr gpaddr;
//#if __aarch64__
//uint8_t access_size;
//bool sign_extend;
//uint8_t xt;
//bool read;
//uint64_t data;
//uint64_t reserved;
//#elif __x86_64__
//// NOTE: x86 instructions are guaranteed to be 15 bytes or fewer.
//#define X86_MAX_INST_LEN 15u
//uint8_t inst_len;
//uint8_t inst_buf[X86_MAX_INST_LEN];
//// This is the default operand size as determined by the CS and EFER register (Volume 3,
//// Section 5.2.1). If operating in 64-bit mode then near branches and all instructions, except
//// far branches, that implicitly reference the RSP will actually have a default operand size of
//// 64-bits (Volume 2, Section 2.2.1.7), and not the 32-bits that will be given here.
//uint8_t default_operand_size;
//uint8_t reserved[7];
//#endif
};
type PacketGuestIo = struct {
port uint16;
access_size uint8;
input bool;
// TODO(scottmg): Unnamed union.
//union {
// uint8_t u8;
// uint16_t u16;
// uint32_t u32;
// uint8_t data[4];
//};
reserved0 uint64;
reserved1 uint64;
reserved2 uint64;
};
type PacketGuestVcpu = struct {
// TODO(scottmg): Unnamed union.
//union {
// struct {
// uint64_t mask;
// uint8_t vector;
// } interrupt;
// struct {
// uint64_t id;
// zx_gpaddr_t entry;
// } startup;
//};
type uint8;
reserved uint64;
};
type PacketInterrupt = struct {
timestamp time;
reserved0 uint64;
reserved1 uint64;
reserved2 uint64;
};
type PacketPageRequest = struct {
command uint16;
flags uint16;
reserved0 uint32;
offset uint64;
length uint64;
reserved1 uint64;
};
type PortPacket = struct {
key uint64;
type uint32;
status status;
// TODO(scottmg): Unnamed union.
// union {
user PacketUser;
signal PacketSignal;
exception PacketException;
guest_bell PacketGuestBell;
guest_mem PacketGuestMem;
guest_io PacketGuestIo;
guest_vcpu PacketGuestVcpu;
interrupt PacketInterrupt;
page_request PacketPageRequest;
// };
};
@transport("Syscall")
protocol port {
/// Create an IO port.
/// Rights: Caller job policy must allow ZX_POL_NEW_PORT.
port_create(struct {
options uint32;
}) -> (resource struct {
status status;
out handle:PORT;
});
/// Queue a packet to a port.
/// Rights: handle must be of type ZX_OBJ_TYPE_PORT and have ZX_RIGHT_WRITE.
port_queue(resource struct {
handle handle:PORT;
packet PortPacket;
}) -> (struct {
status status;
});
/// Wait for a packet arrival in a port.
/// Rights: handle must be of type ZX_OBJ_TYPE_PORT and have ZX_RIGHT_READ.
@blocking
port_wait(resource struct {
handle handle:PORT;
deadline time;
}) -> (struct {
status status;
packet optional_PortPacket;
});
/// Cancels async port notifications on an object.
/// Rights: handle must be of type ZX_OBJ_TYPE_PORT and have ZX_RIGHT_WRITE.
port_cancel(resource struct {
handle handle:PORT;
source handle;
key uint64;
}) -> (struct {
status status;
});
};