lots of changes
diff --git a/objects/board_vpd_obj.c b/objects/board_vpd_obj.c
new file mode 100644
index 0000000..59eaca8
--- /dev/null
+++ b/objects/board_vpd_obj.c
@@ -0,0 +1,45 @@
+#include "interfaces/openbmc_intf.h"
+#include "openbmc.h"
+
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+gint
+main (gint argc, gchar *argv[])
+{
+ GMainLoop *loop;
+ GDBusConnection *c;
+ GDBusProxy *p;
+ GError *error;
+ GVariant *parm;
+ GVariant *result;
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ error = NULL;
+ c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+
+ error = NULL;
+ p = g_dbus_proxy_new_sync (c,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL, /* GDBusInterfaceInfo* */
+ "org.openbmc.managers.Frus", /* name */
+ "/org/openbmc/managers/Frus", /* object path */
+ "org.openbmc.managers.Frus", /* interface name */
+ NULL, /* GCancellable */
+ &error);
+ g_assert_no_error (error);
+ parm = g_variant_new("(isv)",21,"manufacturer",g_variant_new_string("ibmibm"));
+ result = g_dbus_proxy_call_sync (p,
+ "updateFruField",
+ parm,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ //g_main_loop_run (loop);
+ //g_bus_unown_name (id);
+ g_main_loop_unref (loop);
+ return 0;
+}
diff --git a/objects/button_power_obj.c b/objects/button_power_obj.c
index 6dbd5c3..4cd9b8d 100644
--- a/objects/button_power_obj.c
+++ b/objects/button_power_obj.c
@@ -1,10 +1,10 @@
-#include "interfaces/button.h"
+#include "interfaces/openbmc_intf.h"
#include "gpio.h"
#include "openbmc.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/buttons/ButtonPower";
-static const gchar* dbus_name = "org.openbmc.buttons.ButtonPower";
+static const gchar* dbus_object_path = "/org/openbmc/buttons";
+static const gchar* dbus_name = "org.openbmc.buttons.Power";
static GDBusObjectManagerServer *manager = NULL;
@@ -37,7 +37,7 @@
gpointer user_data)
{
ObjectSkeleton *object;
- g_print ("Acquired a message bus connection: %s\n",name);
+ //g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
{
@@ -81,7 +81,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+// g_print ("Acquired the name %s\n", name);
}
static void
@@ -89,7 +89,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+ // g_print ("Lost the name %s\n", name);
}
diff --git a/objects/chassis_identify_obj.c b/objects/chassis_identify_obj.c
index b8d50e0..a747d36 100644
--- a/objects/chassis_identify_obj.c
+++ b/objects/chassis_identify_obj.c
@@ -1,9 +1,9 @@
-#include "interfaces/led.h"
+#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
#include "gpio.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/leds/ChassisIdentify";
+static const gchar* dbus_object_path = "/org/openbmc/leds";
static const gchar* dbus_name = "org.openbmc.leds.ChassisIdentify";
static GDBusObjectManagerServer *manager = NULL;
@@ -46,7 +46,7 @@
{
ObjectSkeleton *object;
- g_print ("Acquired a message bus connection: %s\n",name);
+ //g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
{
@@ -95,7 +95,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+ //g_print ("Acquired the name %s\n", name);
}
static void
@@ -103,7 +103,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+ // g_print ("Lost the name %s\n", name);
}
diff --git a/objects/control_bmc_obj.c b/objects/control_bmc_obj.c
new file mode 100644
index 0000000..53e5c99
--- /dev/null
+++ b/objects/control_bmc_obj.c
@@ -0,0 +1,132 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include "interfaces/openbmc_intf.h"
+#include "openbmc.h"
+#include "gpio.h"
+
+/* ---------------------------------------------------------------------------------------------------- */
+static const gchar* dbus_object_path = "/org/openbmc/control";
+static const gchar* dbus_name = "org.openbmc.control.Bmc";
+
+
+static GDBusObjectManagerServer *manager = NULL;
+
+static gboolean
+on_init (Control *control,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ g_print("BMC init\n");
+ // BMC init done here
+ // must be blocking
+
+ control_complete_init(control,invocation);
+ control_emit_goto_system_state(control,"STANDBY");
+
+ return TRUE;
+}
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ ObjectSkeleton *object;
+ //g_print ("Acquired a message bus connection: %s\n",name);
+ cmdline *cmd = user_data;
+ if (cmd->argc < 2)
+ {
+ g_print("No objects created. Put object name(s) on command line\n");
+ return;
+ }
+ manager = g_dbus_object_manager_server_new (dbus_object_path);
+ int i=0;
+ for (i=1;i<cmd->argc;i++)
+ {
+ gchar *s;
+ s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ object = object_skeleton_new (s);
+ g_free (s);
+
+ ControlBmc* control_bmc = control_bmc_skeleton_new ();
+ object_skeleton_set_control_bmc (object, control_bmc);
+ g_object_unref (control_bmc);
+
+ Control* control = control_skeleton_new ();
+ object_skeleton_set_control (object, control);
+ g_object_unref (control);
+
+ EventLog* event_log = event_log_skeleton_new ();
+ object_skeleton_set_event_log (object, event_log);
+ g_object_unref (event_log);
+
+ //define method callbacks here
+ g_signal_connect (control,
+ "handle-init",
+ G_CALLBACK (on_init),
+ NULL); /* user_data */
+
+ /* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
+ g_object_unref (object);
+ }
+ /* Export all objects */
+ g_dbus_object_manager_server_set_connection (manager, connection);
+
+}
+
+static void
+on_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+// g_print ("Acquired the name %s\n", name);
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+// g_print ("Lost the name %s\n", name);
+}
+
+
+
+
+/*----------------------------------------------------------------*/
+/* Main Event Loop */
+
+gint
+main (gint argc, gchar *argv[])
+{
+ GMainLoop *loop;
+ cmdline cmd;
+ cmd.argc = argc;
+ cmd.argv = argv;
+
+ guint id;
+ loop = g_main_loop_new (NULL, FALSE);
+
+ id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ dbus_name,
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+ G_BUS_NAME_OWNER_FLAGS_REPLACE,
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ &cmd,
+ NULL);
+
+ g_main_loop_run (loop);
+
+ g_bus_unown_name (id);
+ g_main_loop_unref (loop);
+ return 0;
+}
diff --git a/objects/control_host_obj.c b/objects/control_host_obj.c
index 8722619..857f300 100644
--- a/objects/control_host_obj.c
+++ b/objects/control_host_obj.c
@@ -5,13 +5,13 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include "interfaces/control.h"
+#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
#include "gpio.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/control/Host";
+static const gchar* dbus_object_path = "/org/openbmc/control";
static const gchar* dbus_name = "org.openbmc.control.Host";
static GDBusObjectManagerServer *manager = NULL;
@@ -21,15 +21,22 @@
GPIO fsi_enable = (GPIO){ "FSI_ENABLE" };
GPIO cronus_sel = (GPIO){ "CRONUS_SEL" };
-
+static gboolean
+on_init (Control *control,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ control_complete_init(control,invocation);
+ return TRUE;
+}
static gboolean
on_boot (ControlHost *host,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- // TODO: Implement gpio toggling
+ // TODO: Add error checking
g_print("Boot\n");
-
+ Control* control = object_get_control((Object*)user_data);
control_host_complete_boot(host,invocation);
gpio_open(&fsi_clk);
@@ -76,6 +83,8 @@
gpio_close(&fsi_enable);
gpio_close(&cronus_sel);
+ control_emit_goto_system_state(control,"BOOTING");
+
control_host_emit_booted(host);
return TRUE;
}
@@ -86,7 +95,7 @@
gpointer user_data)
{
ObjectSkeleton *object;
- g_print ("Acquired a message bus connection: %s\n",name);
+ //g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
{
@@ -105,10 +114,19 @@
object_skeleton_set_control_host (object, control_host);
g_object_unref (control_host);
+ Control* control = control_skeleton_new ();
+ object_skeleton_set_control (object, control);
+ g_object_unref (control);
+
//define method callbacks here
g_signal_connect (control_host,
"handle-boot",
G_CALLBACK (on_boot),
+ object); /* user_data */
+
+ g_signal_connect (control,
+ "handle-init",
+ G_CALLBACK (on_init),
NULL); /* user_data */
/* Export the object (@manager takes its own reference to @object) */
@@ -130,7 +148,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+// g_print ("Acquired the name %s\n", name);
}
static void
@@ -138,7 +156,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+// g_print ("Lost the name %s\n", name);
}
gint
diff --git a/objects/fan_generic_obj.c b/objects/fan_generic_obj.c
index 4c2ca35..990a5e9 100644
--- a/objects/fan_generic_obj.c
+++ b/objects/fan_generic_obj.c
@@ -1,12 +1,11 @@
-#include "interfaces/fru.h"
+#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/frus/Fan";
-static const gchar* dbus_name = "org.openbmc.frus.Fan";
-static const guint poll_interval = 5000;
+static const gchar* dbus_object_path = "/org/openbmc/control";
+static const gchar* dbus_name = "org.openbmc.control.Fan";
static guint heartbeat = 0;
static GDBusObjectManagerServer *manager = NULL;
@@ -21,23 +20,23 @@
static gboolean
-on_set_speed (FruFan *fan,
+on_set_speed (Fan *fan,
GDBusMethodInvocation *invocation,
guint speed,
gpointer user_data)
{
- fru_fan_set_speed(fan,speed);
- fru_fan_complete_set_speed(fan,invocation);
+ fan_set_speed(fan,speed);
+ fan_complete_set_speed(fan,invocation);
return TRUE;
}
static gboolean
-on_get_speed (FruFan *fan,
+on_get_speed (Fan *fan,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
- guint reading = fru_fan_get_speed(fan);
- fru_fan_complete_get_speed(fan,invocation,reading);
+ guint reading = fan_get_speed(fan);
+ fan_complete_get_speed(fan,invocation,reading);
return TRUE;
}
@@ -46,7 +45,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired a message bus connection: %s\n",name);
+ //g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
@@ -63,13 +62,9 @@
ObjectSkeleton *object = object_skeleton_new (s);
g_free (s);
- FruFan *fan = fru_fan_skeleton_new ();
- object_skeleton_set_fru_fan (object, fan);
+ Fan *fan = fan_skeleton_new ();
+ object_skeleton_set_fan (object, fan);
g_object_unref (fan);
-
- Fru *fru = fru_skeleton_new ();
- object_skeleton_set_fru (object, fru);
- g_object_unref (fru);
//define method callbacks here
g_signal_connect (fan,
@@ -97,7 +92,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+ //g_print ("Acquired the name %s\n", name);
}
static void
@@ -105,7 +100,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+ //g_print ("Lost the name %s\n", name);
}
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index 04821f6..bb95d17 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -1,9 +1,9 @@
-#include "interfaces/flash.h"
+#include "interfaces/openbmc_intf.h"
#include "pflash/pflash.c"
#include "openbmc.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/flash/BIOS";
+static const gchar* dbus_object_path = "/org/openbmc/flash";
static const gchar* dbus_name = "org.openbmc.flash.BIOS";
static GDBusObjectManagerServer *manager = NULL;
@@ -47,7 +47,7 @@
gpointer user_data)
{
ObjectSkeleton *object;
- g_print ("Acquired a message bus connection: %s\n",name);
+// g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
{
@@ -93,7 +93,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+// g_print ("Acquired the name %s\n", name);
}
static void
@@ -101,7 +101,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+ //g_print ("Lost the name %s\n", name);
}
gint
diff --git a/objects/fru_board_obj.c b/objects/fru_board_obj.c
deleted file mode 100644
index 47683db..0000000
--- a/objects/fru_board_obj.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "interfaces/fru.h"
-#include "openbmc.h"
-
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static const gchar* dbus_object_path = "/org/openbmc/frus/Board";
-static const gchar* dbus_name = "org.openbmc.frus.Board";
-static const guint poll_interval = 5000;
-static guint heartbeat = 0;
-
-static GDBusObjectManagerServer *manager = NULL;
-
-static gboolean
-on_init (Fru *fru,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
-
- FruEeprom *eeprom = object_get_fru_eeprom((Object*)user_data);
-
- const gchar* dev_path = fru_eeprom_get_i2c_dev_path(eeprom);
- const gchar* addr = fru_eeprom_get_i2c_address(eeprom);
- g_print("Reading VPD EERPROM at: %s, %s\n",dev_path, addr);
- fru_complete_init(fru,invocation);
- fru_set_part_num(fru,"test part num");
-
- // add eeprom read code here
- fru_emit_cache_me(fru,dbus_name);
-
- return TRUE;
-}
-
-static void
-on_bus_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_print ("Acquired a message bus connection: %s\n",name);
-
- cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
- manager = g_dbus_object_manager_server_new (dbus_object_path);
- int i=0;
- for (i=1;i<cmd->argc;i++)
- {
- gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
- ObjectSkeleton *object = object_skeleton_new (s);
- g_free (s);
-
- Fru *fru = fru_skeleton_new ();
- object_skeleton_set_fru (object, fru);
- g_object_unref (fru);
-
- FruEeprom *eeprom = fru_eeprom_skeleton_new ();
- object_skeleton_set_fru_eeprom (object, eeprom);
- g_object_unref (eeprom);
-
- g_signal_connect (fru,
- "handle-init",
- G_CALLBACK (on_init),
- object); /* user_data */
-
-
- /* Export the object (@manager takes its own reference to @object) */
- g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
- g_object_unref (object);
- }
-
- /* Export all objects */
- g_dbus_object_manager_server_set_connection (manager, connection);
-}
-
-static void
-on_name_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_print ("Acquired the name %s\n", name);
-}
-
-static void
-on_name_lost (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_print ("Lost the name %s\n", name);
-}
-
-
-gint
-main (gint argc, gchar *argv[])
-{
- GMainLoop *loop;
- cmdline cmd;
- cmd.argc = argc;
- cmd.argv = argv;
- guint id;
- loop = g_main_loop_new (NULL, FALSE);
-
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
- dbus_name,
- G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
- G_BUS_NAME_OWNER_FLAGS_REPLACE,
- on_bus_acquired,
- on_name_acquired,
- on_name_lost,
- &cmd,
- NULL);
-
- g_main_loop_run (loop);
-
- g_bus_unown_name (id);
- g_main_loop_unref (loop);
- return 0;
-}
diff --git a/objects/fru_generic_obj.c b/objects/fru_generic_obj.c
deleted file mode 100644
index 742ec9e..0000000
--- a/objects/fru_generic_obj.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include "interfaces/fru.h"
-#include "openbmc.h"
-
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static const gchar* dbus_object_path = "/org/openbmc/frus/Fru";
-static const gchar* dbus_name = "org.openbmc.frus.Fru";
-static const guint poll_interval = 5000;
-static guint heartbeat = 0;
-
-static GDBusObjectManagerServer *manager = NULL;
-
-
-static void
-on_bus_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_print ("Acquired a message bus connection: %s\n",name);
-
- cmdline *cmd = user_data;
- if (cmd->argc < 2)
- {
- g_print("No objects created. Put object name(s) on command line\n");
- return;
- }
- manager = g_dbus_object_manager_server_new (dbus_object_path);
- int i=0;
- for (i=1;i<cmd->argc;i++)
- {
- gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
- ObjectSkeleton *object = object_skeleton_new (s);
- g_free (s);
-
- Fru *fru = fru_skeleton_new ();
- object_skeleton_set_fru (object, fru);
- g_object_unref (fru);
-
- /* Export the object (@manager takes its own reference to @object) */
- g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
- g_object_unref (object);
- }
-
- /* Export all objects */
- g_dbus_object_manager_server_set_connection (manager, connection);
-}
-
-static void
-on_name_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_print ("Acquired the name %s\n", name);
-}
-
-static void
-on_name_lost (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_print ("Lost the name %s\n", name);
-}
-
-
-gint
-main (gint argc, gchar *argv[])
-{
- GMainLoop *loop;
- cmdline cmd;
- cmd.argc = argc;
- cmd.argv = argv;
- guint id;
- loop = g_main_loop_new (NULL, FALSE);
-
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
- dbus_name,
- G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
- G_BUS_NAME_OWNER_FLAGS_REPLACE,
- on_bus_acquired,
- on_name_acquired,
- on_name_lost,
- &cmd,
- NULL);
-
- g_main_loop_run (loop);
-
- g_bus_unown_name (id);
- g_main_loop_unref (loop);
- return 0;
-}
diff --git a/objects/host_watchdog_obj.c b/objects/host_watchdog_obj.c
index 6396658..d038e15 100644
--- a/objects/host_watchdog_obj.c
+++ b/objects/host_watchdog_obj.c
@@ -1,11 +1,11 @@
-#include "interfaces/watchdog.h"
+#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/watchdog/HostWatchdog";
-static const gchar* dbus_name = "org.openbmc.watchdog.HostWatchdog";
+static const gchar* dbus_object_path = "/org/openbmc/watchdog";
+static const gchar* dbus_name = "org.openbmc.watchdog.Host";
static GDBusObjectManagerServer *manager = NULL;
@@ -20,7 +20,9 @@
if (count == 0)
{
+ //watchdog error, emit error and stop watchdog
watchdog_emit_watchdog_error(watchdog);
+ return FALSE;
}
//reset watchdog
@@ -33,6 +35,7 @@
GDBusMethodInvocation *invocation,
gpointer user_data)
{
+ watchdog_set_watchdog(wd,1);
guint poll_interval = watchdog_get_poll_interval(wd);
g_timeout_add(poll_interval, poll_watchdog, user_data);
watchdog_complete_start(wd,invocation);
@@ -56,7 +59,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired a message bus connection: %s\n",name);
+ // g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
@@ -106,7 +109,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+ //g_print ("Acquired the name %s\n", name);
}
static void
@@ -114,7 +117,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+ //g_print ("Lost the name %s\n", name);
}
diff --git a/objects/power_control_obj.c b/objects/power_control_obj.c
index ce9144b..0190fdf 100644
--- a/objects/power_control_obj.c
+++ b/objects/power_control_obj.c
@@ -6,12 +6,12 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include "interfaces/control.h"
+#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
#include "gpio.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/control/Power";
+static const gchar* dbus_object_path = "/org/openbmc/control";
static const gchar* dbus_name = "org.openbmc.control.Power";
GPIO power_pin = (GPIO){ "POWER_PIN" };
@@ -19,6 +19,9 @@
static GDBusObjectManagerServer *manager = NULL;
+guint tmp_pgood = 0;
+guint last_pgood = 0;
+
static gboolean poll_pgood(gpointer user_data)
{
ControlPower *control_power = object_get_control_power((Object*)user_data);
@@ -26,22 +29,32 @@
EventLog* event_log = object_get_event_log((Object*)user_data);
control_emit_heartbeat(control,dbus_name);
- //if (pgood.fd >= 0)
- //{
- uint8_t gpio = gpio_read(&pgood);
- //if changed, set property and emit signal
- if (gpio != control_power_get_pgood(control_power))
- {
- control_power_set_pgood(control_power,gpio);
- if (gpio==0)
- {
- control_power_emit_power_lost(control_power);
- }
- else
- {
- control_power_emit_power_good(control_power);
- }
+ //For simulation, remove
+ if (tmp_pgood!=last_pgood) {
+ if (tmp_pgood == 1) {
+ control_emit_goto_system_state(control,"POWERED_ON");
+ } else {
+ control_emit_goto_system_state(control,"POWERED_OFF");
}
+ }
+
+ last_pgood = tmp_pgood;
+ uint8_t gpio = gpio_read(&pgood);
+ //if changed, set property and emit signal
+ if (gpio != control_power_get_pgood(control_power))
+ {
+ control_power_set_pgood(control_power,gpio);
+ if (gpio==0)
+ {
+ control_power_emit_power_lost(control_power);
+ control_emit_goto_system_state(control,"POWERED_OFF");
+ }
+ else
+ {
+ control_power_emit_power_good(control_power);
+ control_emit_goto_system_state(control,"POWERED_ON");
+ }
+ }
return TRUE;
}
@@ -53,6 +66,7 @@
guint state,
gpointer user_data)
{
+ Control* control = object_get_control((Object*)user_data);
if (state > 1)
{
g_dbus_method_invocation_return_dbus_error (invocation,
@@ -69,10 +83,20 @@
else
{
g_print("Set power state: %d\n",state);
+ //temporary until real hardware works
+ tmp_pgood = state;
gpio_open(&power_pin);
gpio_write(&power_pin,!state);
gpio_close(&power_pin);
control_power_set_state(pwr,state);
+ if (state == 1)
+ {
+ control_emit_goto_system_state(control,"POWERING_ON");
+ }
+ else
+ {
+ control_emit_goto_system_state(control,"POWERING_OFF");
+ }
}
return TRUE;
}
@@ -104,7 +128,7 @@
gpointer user_data)
{
ObjectSkeleton *object;
- g_print ("Acquired a message bus connection: %s\n",name);
+ //g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
{
@@ -117,6 +141,7 @@
{
gchar *s;
s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ g_print("%s\n",s);
object = object_skeleton_new (s);
g_free (s);
@@ -136,7 +161,7 @@
g_signal_connect (control_power,
"handle-set-power-state",
G_CALLBACK (on_set_power_state),
- NULL); /* user_data */
+ object); /* user_data */
g_signal_connect (control_power,
"handle-get-power-state",
@@ -168,7 +193,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+ //g_print ("Acquired the name %s\n", name);
}
static void
@@ -176,7 +201,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+ //g_print ("Lost the name %s\n", name);
}
diff --git a/objects/sensor_host_status_obj.c b/objects/sensor_host_status_obj.c
index bd16935..57357d9 100644
--- a/objects/sensor_host_status_obj.c
+++ b/objects/sensor_host_status_obj.c
@@ -1,10 +1,10 @@
-#include "interfaces/sensor.h"
+#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
#define BOOTED 100
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/sensors/HostStatus";
+static const gchar* dbus_object_path = "/org/openbmc/sensors";
static const gchar* dbus_name = "org.openbmc.sensors.HostStatus";
static guint heartbeat = 0;
@@ -17,6 +17,8 @@
gpointer user_data)
{
SensorMatch *match = object_get_sensor_match((Object*)user_data);
+ Control* control = object_get_control((Object*)user_data);
+
sensor_value_set_value(sen,value);
sensor_value_emit_changed(sen,value,"");
// Important host status values
@@ -26,6 +28,7 @@
{
sensor_match_set_state(match,host_status);
sensor_match_emit_sensor_match(match,host_status);
+ control_emit_goto_system_state(control,"BOOTED");
}
sensor_value_complete_set_value(sen,invocation);
return TRUE;
@@ -40,12 +43,21 @@
return TRUE;
}
+static gboolean
+on_init_control (Control *control,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ control_complete_init(control,invocation);
+ return TRUE;
+}
+
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired a message bus connection: %s\n",name);
+// g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
@@ -69,6 +81,10 @@
SensorMatch *match = sensor_match_skeleton_new ();
object_skeleton_set_sensor_match (object, match);
g_object_unref (match);
+
+ Control* control = control_skeleton_new ();
+ object_skeleton_set_control (object, control);
+ g_object_unref (control);
//must init variant
GVariant* v = NEW_VARIANT_B(0);
@@ -77,13 +93,21 @@
// set units
sensor_value_set_units(sensor,"");
sensor_value_set_settable(sensor,TRUE);
+ //must emit change so sensor manager sees initial value
+ sensor_value_emit_changed(sensor,v,"");
//define method callbacks here
g_signal_connect (sensor,
"handle-init",
G_CALLBACK (on_init),
NULL); /* user_data */
- g_signal_connect (sensor,
+
+ g_signal_connect (control,
+ "handle-init",
+ G_CALLBACK (on_init_control),
+ NULL); /* user_data */
+
+ g_signal_connect (sensor,
"handle-set-value",
G_CALLBACK (on_set_value),
object); /* user_data */
@@ -102,7 +126,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+ //g_print ("Acquired the name %s\n", name);
}
static void
@@ -110,7 +134,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+ //g_print ("Lost the name %s\n", name);
}
diff --git a/objects/sensor_occ_obj.c b/objects/sensor_occ_obj.c
new file mode 100644
index 0000000..bd68382
--- /dev/null
+++ b/objects/sensor_occ_obj.c
@@ -0,0 +1,182 @@
+#include "interfaces/openbmc_intf.h"
+#include "openbmc.h"
+
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static const gchar* dbus_object_path = "/org/openbmc/sensors";
+static const gchar* dbus_name = "org.openbmc.sensors.Occ";
+static guint heartbeat = 0;
+
+static GDBusObjectManagerServer *manager = NULL;
+static gchar *instance_name = NULL;
+
+static gboolean poll_occ(gpointer user_data)
+{
+/*
+ gchar *s;
+ s = g_strdup_printf ("%s/Temperature/%d",g_dbus_object_get_object_path(G_DBUS_OBJECT(user_data)), 1);
+ g_print("%s\n",s);
+
+ GDBusInterface* interface = g_dbus_object_manager_get_interface((GDBusObjectManager*)manager,s,
+ "org.openbmc.SensorValue");
+
+ if (interface != NULL)
+ {
+ SensorValue* sensor = (SensorValue*) interface;
+ GVariant *value = NEW_VARIANT_U(10);
+ sensor_value_set_value(sensor,value);
+ const gchar* units = sensor_value_get_units(sensor);
+ sensor_value_emit_changed(sensor,sensor_value_get_value(sensor),units);
+ }
+ g_free (s);
+ //g_free(interface);
+*/
+ return TRUE;
+}
+
+
+
+static gboolean
+on_init (Occ *occ,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ guint poll_interval = occ_get_poll_interval(occ);
+ g_timeout_add(poll_interval, poll_occ, user_data);
+ occ_complete_init(occ,invocation);
+ return TRUE;
+}
+static gboolean
+on_init_sensor (SensorValue *sensor,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ //must implement init method
+ sensor_value_complete_init(sensor,invocation);
+ return TRUE;
+}
+
+
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ //g_print ("Acquired a message bus connection: %s\n",name);
+
+ cmdline *cmd = user_data;
+ if (cmd->argc < 2)
+ {
+ g_print("No objects created. Put object name(s) on command line\n");
+ return;
+ }
+ manager = g_dbus_object_manager_server_new (dbus_object_path);
+ int i=0;
+ for (i=1;i<cmd->argc;i++)
+ {
+ gchar *s;
+ s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ ObjectSkeleton *object = object_skeleton_new (s);
+ g_free (s);
+
+ Occ *occ = occ_skeleton_new ();
+ object_skeleton_set_occ (object, occ);
+ g_object_unref (occ);
+
+ SensorI2c *i2c = sensor_i2c_skeleton_new ();
+ object_skeleton_set_sensor_i2c (object, i2c);
+ g_object_unref (i2c);
+
+ g_signal_connect (occ,
+ "handle-init",
+ G_CALLBACK (on_init),
+ object); /* user_data */
+
+ //g_timeout_add(3000, poll_occ, object);
+
+ /* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
+ g_object_unref (object);
+
+ int c;
+ for (c=0;c<12;c++)
+ {
+ s = g_strdup_printf ("%s/Temperature/P8_%s_Core_%d",dbus_object_path,cmd->argv[i],c);
+ ObjectSkeleton *object = object_skeleton_new (s);
+ g_free (s);
+
+ SensorValue *sensor = sensor_value_skeleton_new ();
+ object_skeleton_set_sensor_value (object, sensor);
+ g_object_unref (sensor);
+ GVariant* v_new_value = NEW_VARIANT_U(c);
+ sensor_value_set_value(sensor,v_new_value);
+ sensor_value_set_units(sensor,"C");
+
+ g_signal_connect (sensor,
+ "handle-init",
+ G_CALLBACK (on_init_sensor),
+ NULL); /* user_data */
+
+ //emit changed signal so sensor manager sees initial value
+ sensor_value_emit_changed(sensor,sensor_value_get_value(sensor),sensor_value_get_units(sensor));
+ /* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
+ g_object_unref (object);
+
+ }
+ }
+
+ /* Export all objects */
+ g_dbus_object_manager_server_set_connection (manager, connection);
+}
+
+static void
+on_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+// g_print ("Acquired the name %s\n", name);
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ //g_print ("Lost the name %s\n", name);
+ g_print("shutting down: %s\n",name);
+ cmdline *cmd = user_data;
+ g_main_loop_quit(cmd->loop);
+}
+
+
+gint
+main (gint argc, gchar *argv[])
+{
+ GMainLoop *loop;
+ cmdline cmd;
+ cmd.argc = argc;
+ cmd.argv = argv;
+
+ guint id;
+ loop = g_main_loop_new (NULL, FALSE);
+ cmd.loop = loop;
+
+ id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ dbus_name,
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+ G_BUS_NAME_OWNER_FLAGS_REPLACE,
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ &cmd,
+ NULL);
+
+ g_main_loop_run (loop);
+
+ g_bus_unown_name (id);
+ g_main_loop_unref (loop);
+ return 0;
+}
diff --git a/objects/sensor_temperature_ambient_obj.c b/objects/sensor_temperature_ambient_obj.c
index 4f1b32a..fab2f1a 100644
--- a/objects/sensor_temperature_ambient_obj.c
+++ b/objects/sensor_temperature_ambient_obj.c
@@ -1,11 +1,11 @@
-#include "interfaces/sensor.h"
+#include "interfaces/openbmc_intf.h"
#include "openbmc.h"
#include "sensor_threshold.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/sensors/Temperature/Ambient";
+static const gchar* dbus_object_path = "/org/openbmc/sensors";
static const gchar* dbus_name = "org.openbmc.sensors.Temperature.Ambient";
static guint heartbeat = 0;
@@ -23,12 +23,12 @@
//TODO: Change to actually read sensor
double value = GET_VARIANT_D(v_value);
- g_print("Reading I2C = %s; Address = %s; %f\n",
- sensor_i2c_get_dev_path(i2c),sensor_i2c_get_address(i2c),value);
+ //g_print("Reading I2C = %s; Address = %s; %f\n",
+ // sensor_i2c_get_dev_path(i2c),sensor_i2c_get_address(i2c),value);
value = value+1;
- if (heartbeat > 10000)
+ if (heartbeat > 4000)
{
heartbeat = 0;
sensor_value_emit_heartbeat(sensor,dbus_name);
@@ -71,7 +71,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired a message bus connection: %s\n",name);
+ // g_print ("Acquired a message bus connection: %s\n",name);
cmdline *cmd = user_data;
if (cmd->argc < 2)
@@ -84,7 +84,7 @@
for (i=1;i<cmd->argc;i++)
{
gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ s = g_strdup_printf ("%s/Temperature/%s",dbus_object_path,cmd->argv[i]);
ObjectSkeleton *object = object_skeleton_new (s);
g_free (s);
@@ -145,7 +145,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Acquired the name %s\n", name);
+// g_print ("Acquired the name %s\n", name);
}
static void
@@ -153,7 +153,7 @@
const gchar *name,
gpointer user_data)
{
- g_print ("Lost the name %s\n", name);
+// g_print ("Lost the name %s\n", name);
}