Initial check-in of LPC Snoop Broadcast Daemon
This is a simple daemon which reads a file interface
from an lpc-snoop driver and broadcasts the values read.
It presently assumes there's /dev/aspeed-lpc-snoop0, however
this could be made a command line parameter.
Change-Id: Ic8e7511de619d93bf1cffd9a096c92315f870946
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/lpcsnoop/snoop.hpp b/lpcsnoop/snoop.hpp
new file mode 100644
index 0000000..d1dd847
--- /dev/null
+++ b/lpcsnoop/snoop.hpp
@@ -0,0 +1,6 @@
+#pragma once
+
+/* The LPC snoop on port 80h is mapped to this dbus path. */
+#define SNOOP_OBJECTPATH "/xyz/openbmc_project/state/boot/raw"
+/* The LPC snoop on port 80h is mapped to this dbus service. */
+#define SNOOP_BUSNAME "xyz.openbmc_project.State.Boot.Raw"
diff --git a/lpcsnoop/snoop_listen.hpp b/lpcsnoop/snoop_listen.hpp
new file mode 100644
index 0000000..15b8c0f
--- /dev/null
+++ b/lpcsnoop/snoop_listen.hpp
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/message.hpp>
+#include <sdbusplus/server.hpp>
+
+#include "lpcsnoop/snoop.hpp"
+
+namespace lpcsnoop
+{
+
+using DbusSignalHandler = int (*)(sd_bus_message*, void*, sd_bus_error*);
+
+/* Returns matching string for what signal to listen on Dbus */
+static const std::string GetMatchRule()
+{
+ return "type='signal',"
+ "interface='org.freedesktop.DBus.Properties',"
+ "member='PropertiesChanged',"
+ "path='" SNOOP_OBJECTPATH "'";
+}
+
+class SnoopListen
+{
+ public:
+ SnoopListen(sdbusplus::bus::bus& busIn, DbusSignalHandler handler) :
+ bus(busIn), signal(busIn, GetMatchRule().c_str(), handler, this)
+ {
+ }
+
+ SnoopListen() = delete; // no default constructor
+ ~SnoopListen() = default;
+ SnoopListen(const SnoopListen&) = delete;
+ SnoopListen& operator=(const SnoopListen&) = delete;
+ SnoopListen(SnoopListen&&) = default;
+ SnoopListen& operator=(SnoopListen&&) = default;
+
+ private:
+ sdbusplus::bus::bus& bus;
+ sdbusplus::server::match::match signal;
+};
+
+} // namespace lpcsnoop