blob: f891a189b11e5057c292a32e7470953a738e8c06 [file] [log] [blame]
// Copyright 2018 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.
@available(added=7)
library fuchsia.hardware.serialimpl;
using zx;
using fuchsia.hardware.serial;
type SerialState = strict enum : uint32 {
READABLE = 0x1;
WRITABLE = 0x2;
};
/// Callback for notification of readable/writeable state changes
/// This may be called from an interrupt thread it should just signal another thread
/// and return as soon as possible. In particular, it may not be safe to make protocol calls
/// from these callbacks.
@transport("Banjo")
@banjo_layout("ddk-callback")
closed protocol SerialNotify {
strict Callback(struct {
state SerialState;
}) -> ();
};
@transport("Banjo")
@banjo_layout("ddk-protocol")
closed protocol SerialImpl {
strict GetInfo() -> (struct {
s zx.Status;
info fuchsia.hardware.serial.SerialPortInfo;
});
/// Configures the given serial port.
strict Config(struct {
baud_rate uint32;
flags uint32;
}) -> (struct {
s zx.Status;
});
strict Enable(struct {
enable bool;
}) -> (struct {
s zx.Status;
});
strict Read() -> (struct {
s zx.Status;
@buffer
buf vector<uint8>:MAX;
});
strict Write(struct {
@buffer
buf vector<uint8>:MAX;
}) -> (struct {
s zx.Status;
actual uint64;
});
strict SetNotifyCallback(resource struct {
cb client_end:SerialNotify;
}) -> (struct {
s zx.Status;
});
};