opentitanlib/transport/
errors.rs1use serde::{Deserialize, Serialize};
6use thiserror::Error;
7
8use super::Capability;
9use crate::impl_serializable_error;
10
11#[derive(Error, Debug, Serialize, Deserialize)]
15pub enum TransportError {
16 #[error("USB device did not match")]
17 NoMatch,
18 #[error("Found no USB device")]
19 NoDevice,
20 #[error("Found multiple USB devices, use --usb-serial")]
21 MultipleDevices,
22 #[error("USB error: {0}")]
23 UsbGenericError(String),
24 #[error("Error opening USB device: {0}")]
25 UsbOpenError(String),
26 #[error("Transport does not support {0:?}")]
27 InvalidInterface(TransportInterfaceType),
28 #[error("Transport does not support {0:?} instance {1}")]
29 InvalidInstance(TransportInterfaceType, String),
30 #[error("Encountered non-unicode device path")]
31 UnicodePathError,
32 #[error("Error opening {0}: {1}")]
33 OpenError(String, String),
34 #[error("Error reading from {0}: {1}")]
35 ReadError(String, String),
36 #[error("FPGA programming failed: {0}")]
37 FpgaProgramFailed(String),
38 #[error("Firmware programming failed: {0}")]
39 FirmwareProgramFailed(String),
40 #[error("Error clearing FPGA bitstream")]
41 ClearBitstreamFailed(),
42 #[error("PLL programming failed: {0}")]
43 PllProgramFailed(String),
44 #[error("Invalid pin strapping name \"{0}\"")]
45 InvalidStrappingName(String),
46 #[error("Invalid IO expander name \"{0}\"")]
47 InvalidIoExpanderName(String),
48 #[error("Invalid pin {1} for IO expander \"{0}\"")]
49 InvalidIoExpanderPinNo(String, u32),
50 #[error("Transport does not support the requested operation")]
51 UnsupportedOperation,
52 #[error("Requested operation invalid at this time")]
53 InvalidOperation,
54 #[error("Error communicating with FTDI: {0}")]
55 FtdiError(String),
56 #[error("Error communicating with debugger: {0}")]
57 CommunicationError(String),
58 #[error("Proxy unable to resolve `{0}`: {1}")]
59 ProxyLookupError(String, String),
60 #[error("Proxy unable to connect to `{0}`: {1}")]
61 ProxyConnectError(String, String),
62 #[error("Requested capabilities {0:?}, but capabilities {1:?} are supplied")]
63 MissingCapabilities(Capability, Capability),
64 #[error("Inconsistent configuration for {0:?} instance \"{1}\"")]
65 InconsistentConf(TransportInterfaceType, String),
66 #[error("Inconsistent configuration of transport interface \"{0}\" vs. \"{1}\"")]
67 InconsistentInterfaceConf(String, String),
68 #[error("Strapping \"{0}\" pin \"{1}\" cannot declare \"alias_of\"")]
69 InvalidConfStrapAlias(String, String),
70 #[error("Strapping \"{0}\" pin \"{1}\" cannot declare \"invert\"")]
71 InvalidConfStrapInvert(String, String),
72 #[error("Expected value \"{1}\" for key \"{0}\", found \"{2}\"")]
73 RequiresUnequal(String, String, String),
74 #[error("Expected value \"{1}\" for key \"{0}\", found none")]
75 RequiresMissing(String, String),
76}
77impl_serializable_error!(TransportError);
78
79#[derive(Debug, serde::Serialize, serde::Deserialize)]
81pub enum TransportInterfaceType {
82 Gpio,
83 Uart,
84 Spi,
85 I2c,
86 Jtag,
87 Emulator,
88 ProxyOps,
89 GpioMonitoring,
90 GpioBitbanging,
91 IoExpander,
92 Provides,
93}