1// Copyright 2018 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5library ddk.protocol.serialimpl; 6 7using zx; 8using ddk.protocol.serial; 9 10enum SerialState : uint32 { 11 READABLE = 0x1; 12 WRITABLE = 0x2; 13}; 14 15/// Callback for notification of readable/writeable state changes 16/// This may be called from an interrupt thread it should just signal another thread 17/// and return as soon as possible. In particular, it may not be safe to make protocol calls 18/// from these callbacks. 19[Layout = "ddk-callback"] 20interface SerialNotify { 21 Callback(SerialState state) -> (); 22}; 23 24[Layout = "ddk-protocol"] 25interface SerialImpl { 26 GetInfo() -> (zx.status s, ddk.protocol.serial.SerialPortInfo info); 27 /// Configures the given serial port. 28 Config(uint32 baud_rate, uint32 flags) -> (zx.status s); 29 Enable(bool enable) -> (zx.status s); 30 Read() -> (zx.status s, vector<voidptr> buf); 31 Write(vector<voidptr> buf) -> (zx.status s, usize actual); 32 SetNotifyCallback(SerialNotify cb) -> (zx.status s); 33}; 34