aboutsummaryrefslogtreecommitdiff
path: root/driver_library/src/ethosu.cpp
diff options
context:
space:
mode:
authorDavide Grohmann <davide.grohmann@arm.com>2021-06-01 15:03:51 +0200
committerKristofer Jonsson <kristofer.jonsson@arm.com>2021-06-10 14:58:49 +0000
commit35ce6c809ccf637c6bb8a00ad14b051b87d9884a (patch)
treee999250ca985ac5b00ba9162ee1782de02983c03 /driver_library/src/ethosu.cpp
parent0c79f896caf1a0ac16dd92810c4b15bfff00bdb3 (diff)
downloadethos-u-linux-driver-stack-35ce6c809ccf637c6bb8a00ad14b051b87d9884a.tar.gz
Add support for handling capabilities requests
Change-Id: Id5aa197312c88b0c448dc085d8477ed67da24724
Diffstat (limited to 'driver_library/src/ethosu.cpp')
-rw-r--r--driver_library/src/ethosu.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/driver_library/src/ethosu.cpp b/driver_library/src/ethosu.cpp
index 1768271..ea1f7f4 100644
--- a/driver_library/src/ethosu.cpp
+++ b/driver_library/src/ethosu.cpp
@@ -112,6 +112,43 @@ const char *Exception::what() const throw() {
}
/****************************************************************************
+ * Semantic Version
+ ****************************************************************************/
+
+bool SemanticVersion::operator==(const SemanticVersion &other) {
+ return other.major == major && other.minor == minor && other.patch == patch;
+}
+
+bool SemanticVersion::operator<(const SemanticVersion &other) {
+ if (other.major > major)
+ return true;
+ if (other.minor > minor)
+ return true;
+ return other.patch > patch;
+}
+
+bool SemanticVersion::operator<=(const SemanticVersion &other) {
+ return *this < other || *this == other;
+}
+
+bool SemanticVersion::operator!=(const SemanticVersion &other) {
+ return !(*this == other);
+}
+
+bool SemanticVersion::operator>(const SemanticVersion &other) {
+ return !(*this <= other);
+}
+
+bool SemanticVersion::operator>=(const SemanticVersion &other) {
+ return !(*this < other);
+}
+
+ostream &operator<<(ostream &out, const SemanticVersion &v) {
+ return out << "{ major=" << unsigned(v.major) << ", minor=" << unsigned(v.minor) << ", patch=" << unsigned(v.patch)
+ << " }";
+}
+
+/****************************************************************************
* Device
****************************************************************************/
@@ -130,6 +167,23 @@ int Device::ioctl(unsigned long cmd, void *data) {
return eioctl(fd, cmd, data);
}
+Capabilities Device::capabilities() {
+ ethosu_uapi_device_capabilities uapi;
+ (void)eioctl(fd, ETHOSU_IOCTL_CAPABILITIES_REQ, static_cast<void *>(&uapi));
+
+ Capabilities capabilities(
+ HardwareId(uapi.hw_id.version_status,
+ SemanticVersion(uapi.hw_id.version_major, uapi.hw_id.version_minor),
+ SemanticVersion(uapi.hw_id.product_major),
+ SemanticVersion(uapi.hw_id.arch_major_rev, uapi.hw_id.arch_minor_rev, uapi.hw_id.arch_patch_rev)),
+ HardwareConfiguration(uapi.hw_cfg.macs_per_cc,
+ uapi.hw_cfg.cmd_stream_version,
+ uapi.hw_cfg.shram_size,
+ bool(uapi.hw_cfg.custom_dma)),
+ SemanticVersion(uapi.driver_major_rev, uapi.driver_minor_rev, uapi.driver_patch_rev));
+ return capabilities;
+}
+
/****************************************************************************
* Buffer
****************************************************************************/