Merge remote-tracking branch 'origin'
diff --git a/bin/Palmetto.py b/bin/Palmetto.py
index ba0a321..286c9cf 100755
--- a/bin/Palmetto.py
+++ b/bin/Palmetto.py
@@ -107,7 +107,7 @@
'name' : 'HostWatchdog_0',
'properties' : {
'org.openbmc.Watchdog' : {
- 'poll_interval': 3000,
+ 'poll_interval': 30000,
}
}
}
@@ -152,13 +152,13 @@
'heartbeat' : 'no',
'instances' : [ { 'name' : 'Dummy' } ]
}
-SYSTEM_CONFIG['org.openbmc.flash.Bios'] = {
+SYSTEM_CONFIG['org.openbmc.control.Flash'] = {
'system_state' : 'BMC_STARTING',
'start_process' : True,
'monitor_process' : True,
'process_name' : 'flash_bios.exe',
'heartbeat' : 'no',
- 'instances' : [ { 'name' : 'Bios_0' } ]
+ 'instances' : [ { 'name' : 'dummy' } ]
}
SYSTEM_CONFIG['org.openbmc.manager.Download'] = {
diff --git a/bin/console b/bin/console
new file mode 100755
index 0000000..d3fa8bb
--- /dev/null
+++ b/bin/console
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+screen /dev/ttyS3 115200
+
diff --git a/bin/download_manager.py b/bin/download_manager.py
index 06e8773..35859a5 100755
--- a/bin/download_manager.py
+++ b/bin/download_manager.py
@@ -21,7 +21,7 @@
def __init__(self,bus,name):
dbus.service.Object.__init__(self,bus,name)
bus.add_signal_receiver(self.DownloadHandler,
- dbus_interface = "org.openbmc.Flash", signal_name = "Download")
+ dbus_interface = "org.openbmc.Flash", signal_name = "Download", path_keyword = "path")
@dbus.service.signal(DBUS_NAME,signature='ss')
def DownloadComplete(self,outfile,filename):
@@ -32,19 +32,22 @@
def DownloadError(self,filename):
pass
- def DownloadHandler(self,url,filename):
+ def DownloadHandler(self,url,filename,path = None):
try:
filename = str(filename)
client = tftpy.TftpClient(url, TFTP_PORT)
print "Downloading: "+filename+" from "+url
outfile = System.FLASH_DOWNLOAD_PATH+"/"+filename
client.download(filename,outfile)
- self.DownloadComplete(outfile,filename)
+ obj = bus.get_object("org.openbmc.control.Flash",path)
+ intf = dbus.Interface(obj,"org.openbmc.Flash")
+ intf.update(outfile)
except Exception as e:
print "ERROR DownloadManager: "+str(e)
- self.DownloadError(filename)
-
+ obj = bus.get_object("org.openbmc.control.Flash",path)
+ intf = dbus.Interface(obj,"org.openbmc.Flash")
+ intf.error("Download Error: "+filename)
if __name__ == '__main__':
diff --git a/bin/gpio2num b/bin/gpio2num
new file mode 100755
index 0000000..a176ec5
--- /dev/null
+++ b/bin/gpio2num
@@ -0,0 +1,18 @@
+#! /usr/bin/python
+
+import sys
+
+if (len(sys.argv) <2):
+ print "Usage: gpio2num [gpio1] [gpio2] ... [gpion]"
+ print "\tExample: gpio2num A2 B4"
+ exit(0)
+
+sys.argv.pop(0)
+for name in sys.argv:
+ c = name[0:1]
+ num = name[1:]
+ a = ord(c)-65
+ base = 480 - (int(a/4) * 32)
+ offset = a%4*8 + int(num)
+ gpio_num = base+offset
+ print name+" = " + str(gpio_num)
diff --git a/interfaces/openbmc_intf.c b/interfaces/openbmc_intf.c
index f1e0c95..b7d9501 100644
--- a/interfaces/openbmc_intf.c
+++ b/interfaces/openbmc_intf.c
@@ -19003,6 +19003,49 @@
FALSE
};
+static const _ExtendedGDBusArgInfo _flash_method_info_error_IN_ARG_message =
+{
+ {
+ -1,
+ (gchar *) "message",
+ (gchar *) "s",
+ NULL
+ },
+ FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _flash_method_info_error_IN_ARG_pointers[] =
+{
+ &_flash_method_info_error_IN_ARG_message,
+ NULL
+};
+
+static const _ExtendedGDBusMethodInfo _flash_method_info_error =
+{
+ {
+ -1,
+ (gchar *) "error",
+ (GDBusArgInfo **) &_flash_method_info_error_IN_ARG_pointers,
+ NULL,
+ NULL
+ },
+ "handle-error",
+ FALSE
+};
+
+static const _ExtendedGDBusMethodInfo _flash_method_info_done =
+{
+ {
+ -1,
+ (gchar *) "done",
+ NULL,
+ NULL,
+ NULL
+ },
+ "handle-done",
+ FALSE
+};
+
static const _ExtendedGDBusArgInfo _flash_method_info_update_via_tftp_IN_ARG_url =
{
{
@@ -19061,6 +19104,8 @@
static const _ExtendedGDBusMethodInfo * const _flash_method_info_pointers[] =
{
&_flash_method_info_update,
+ &_flash_method_info_error,
+ &_flash_method_info_done,
&_flash_method_info_update_via_tftp,
&_flash_method_info_init,
NULL
@@ -19176,12 +19221,26 @@
FALSE
};
+static const _ExtendedGDBusPropertyInfo _flash_property_info_status =
+{
+ {
+ -1,
+ (gchar *) "status",
+ (gchar *) "s",
+ G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+ NULL
+ },
+ "status",
+ FALSE
+};
+
static const _ExtendedGDBusPropertyInfo * const _flash_property_info_pointers[] =
{
&_flash_property_info_filename,
&_flash_property_info_flasher_path,
&_flash_property_info_flasher_name,
&_flash_property_info_flasher_instance,
+ &_flash_property_info_status,
NULL
};
@@ -19229,6 +19288,7 @@
g_object_class_override_property (klass, property_id_begin++, "flasher-path");
g_object_class_override_property (klass, property_id_begin++, "flasher-name");
g_object_class_override_property (klass, property_id_begin++, "flasher-instance");
+ g_object_class_override_property (klass, property_id_begin++, "status");
return property_id_begin - 1;
}
@@ -19243,6 +19303,8 @@
/**
* FlashIface:
* @parent_iface: The parent interface.
+ * @handle_done: Handler for the #Flash::handle-done signal.
+ * @handle_error: Handler for the #Flash::handle-error signal.
* @handle_init: Handler for the #Flash::handle-init signal.
* @handle_update: Handler for the #Flash::handle-update signal.
* @handle_update_via_tftp: Handler for the #Flash::handle-update-via-tftp signal.
@@ -19250,6 +19312,7 @@
* @get_flasher_instance: Getter for the #Flash:flasher-instance property.
* @get_flasher_name: Getter for the #Flash:flasher-name property.
* @get_flasher_path: Getter for the #Flash:flasher-path property.
+ * @get_status: Getter for the #Flash:status property.
* @download: Handler for the #Flash::download signal.
* @updated: Handler for the #Flash::updated signal.
*
@@ -19287,6 +19350,51 @@
G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
/**
+ * Flash::handle-error:
+ * @object: A #Flash.
+ * @invocation: A #GDBusMethodInvocation.
+ * @arg_message: Argument passed by remote caller.
+ *
+ * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-Flash.error">error()</link> D-Bus method.
+ *
+ * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call flash_complete_error() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+ *
+ * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+ */
+ g_signal_new ("handle-error",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (FlashIface, handle_error),
+ g_signal_accumulator_true_handled,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_BOOLEAN,
+ 2,
+ G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
+
+ /**
+ * Flash::handle-done:
+ * @object: A #Flash.
+ * @invocation: A #GDBusMethodInvocation.
+ *
+ * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-Flash.done">done()</link> D-Bus method.
+ *
+ * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call flash_complete_done() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+ *
+ * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+ */
+ g_signal_new ("handle-done",
+ G_TYPE_FROM_INTERFACE (iface),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (FlashIface, handle_done),
+ g_signal_accumulator_true_handled,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_BOOLEAN,
+ 1,
+ G_TYPE_DBUS_METHOD_INVOCATION);
+
+ /**
* Flash::handle-update-via-tftp:
* @object: A #Flash.
* @invocation: A #GDBusMethodInvocation.
@@ -19408,6 +19516,15 @@
*/
g_object_interface_install_property (iface,
g_param_spec_string ("flasher-instance", "flasher_instance", "flasher_instance", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ * Flash:status:
+ *
+ * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-Flash.status">"status"</link>.
+ *
+ * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("status", "status", "status", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
/**
@@ -19615,6 +19732,57 @@
}
/**
+ * flash_get_status: (skip)
+ * @object: A #Flash.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-Flash.status">"status"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * <warning>The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use flash_dup_status() if on another thread.</warning>
+ *
+ * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
+ */
+const gchar *
+flash_get_status (Flash *object)
+{
+ return FLASH_GET_IFACE (object)->get_status (object);
+}
+
+/**
+ * flash_dup_status: (skip)
+ * @object: A #Flash.
+ *
+ * Gets a copy of the <link linkend="gdbus-property-org-openbmc-Flash.status">"status"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_free().
+ */
+gchar *
+flash_dup_status (Flash *object)
+{
+ gchar *value;
+ g_object_get (G_OBJECT (object), "status", &value, NULL);
+ return value;
+}
+
+/**
+ * flash_set_status: (skip)
+ * @object: A #Flash.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-Flash.status">"status"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+flash_set_status (Flash *object, const gchar *value)
+{
+ g_object_set (G_OBJECT (object), "status", value, NULL);
+}
+
+/**
* flash_emit_updated:
* @object: A #Flash.
*
@@ -19743,6 +19911,196 @@
}
/**
+ * flash_call_error:
+ * @proxy: A #FlashProxy.
+ * @arg_message: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-Flash.error">error()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call flash_call_error_finish() to get the result of the operation.
+ *
+ * See flash_call_error_sync() for the synchronous, blocking version of this method.
+ */
+void
+flash_call_error (
+ Flash *proxy,
+ const gchar *arg_message,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+ "error",
+ g_variant_new ("(s)",
+ arg_message),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * flash_call_error_finish:
+ * @proxy: A #FlashProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to flash_call_error().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with flash_call_error().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+flash_call_error_finish (
+ Flash *proxy,
+ GAsyncResult *res,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * flash_call_error_sync:
+ * @proxy: A #FlashProxy.
+ * @arg_message: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-Flash.error">error()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See flash_call_error() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+flash_call_error_sync (
+ Flash *proxy,
+ const gchar *arg_message,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+ "error",
+ g_variant_new ("(s)",
+ arg_message),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * flash_call_done:
+ * @proxy: A #FlashProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-Flash.done">done()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call flash_call_done_finish() to get the result of the operation.
+ *
+ * See flash_call_done_sync() for the synchronous, blocking version of this method.
+ */
+void
+flash_call_done (
+ Flash *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+ "done",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * flash_call_done_finish:
+ * @proxy: A #FlashProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to flash_call_done().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with flash_call_done().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+flash_call_done_finish (
+ Flash *proxy,
+ GAsyncResult *res,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
+ * flash_call_done_sync:
+ * @proxy: A #FlashProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-Flash.done">done()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See flash_call_done() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+flash_call_done_sync (
+ Flash *proxy,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GVariant *_ret;
+ _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+ "done",
+ g_variant_new ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ cancellable,
+ error);
+ if (_ret == NULL)
+ goto _out;
+ g_variant_get (_ret,
+ "()");
+ g_variant_unref (_ret);
+_out:
+ return _ret != NULL;
+}
+
+/**
* flash_call_update_via_tftp:
* @proxy: A #FlashProxy.
* @arg_url: Argument to pass with the method invocation.
@@ -19957,6 +20315,42 @@
}
/**
+ * flash_complete_error:
+ * @object: A #Flash.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-Flash.error">error()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+flash_complete_error (
+ Flash *object,
+ GDBusMethodInvocation *invocation)
+{
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("()"));
+}
+
+/**
+ * flash_complete_done:
+ * @object: A #Flash.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-Flash.done">done()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+flash_complete_done (
+ Flash *object,
+ GDBusMethodInvocation *invocation)
+{
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("()"));
+}
+
+/**
* flash_complete_update_via_tftp:
* @object: A #Flash.
* @invocation: (transfer full): A #GDBusMethodInvocation.
@@ -20040,7 +20434,7 @@
{
const _ExtendedGDBusPropertyInfo *info;
GVariant *variant;
- g_assert (prop_id != 0 && prop_id - 1 < 4);
+ g_assert (prop_id != 0 && prop_id - 1 < 5);
info = _flash_property_info_pointers[prop_id - 1];
variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
if (info->use_gvariant)
@@ -20087,7 +20481,7 @@
{
const _ExtendedGDBusPropertyInfo *info;
GVariant *variant;
- g_assert (prop_id != 0 && prop_id - 1 < 4);
+ g_assert (prop_id != 0 && prop_id - 1 < 5);
info = _flash_property_info_pointers[prop_id - 1];
variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
g_dbus_proxy_call (G_DBUS_PROXY (object),
@@ -20229,6 +20623,21 @@
return value;
}
+static const gchar *
+flash_proxy_get_status (Flash *object)
+{
+ FlashProxy *proxy = FLASH_PROXY (object);
+ GVariant *variant;
+ const gchar *value = NULL;
+ variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "status");
+ if (variant != NULL)
+ {
+ value = g_variant_get_string (variant, NULL);
+ g_variant_unref (variant);
+ }
+ return value;
+}
+
static void
flash_proxy_init (FlashProxy *proxy)
{
@@ -20270,6 +20679,7 @@
iface->get_flasher_path = flash_proxy_get_flasher_path;
iface->get_flasher_name = flash_proxy_get_flasher_name;
iface->get_flasher_instance = flash_proxy_get_flasher_instance;
+ iface->get_status = flash_proxy_get_status;
}
/**
@@ -20744,7 +21154,7 @@
{
FlashSkeleton *skeleton = FLASH_SKELETON (object);
guint n;
- for (n = 0; n < 4; n++)
+ for (n = 0; n < 5; n++)
g_value_unset (&skeleton->priv->properties[n]);
g_free (skeleton->priv->properties);
g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
@@ -20762,7 +21172,7 @@
GParamSpec *pspec G_GNUC_UNUSED)
{
FlashSkeleton *skeleton = FLASH_SKELETON (object);
- g_assert (prop_id != 0 && prop_id - 1 < 4);
+ g_assert (prop_id != 0 && prop_id - 1 < 5);
g_mutex_lock (&skeleton->priv->lock);
g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
g_mutex_unlock (&skeleton->priv->lock);
@@ -20879,7 +21289,7 @@
GParamSpec *pspec)
{
FlashSkeleton *skeleton = FLASH_SKELETON (object);
- g_assert (prop_id != 0 && prop_id - 1 < 4);
+ g_assert (prop_id != 0 && prop_id - 1 < 5);
g_mutex_lock (&skeleton->priv->lock);
g_object_freeze_notify (object);
if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
@@ -20904,11 +21314,12 @@
g_mutex_init (&skeleton->priv->lock);
skeleton->priv->context = g_main_context_ref_thread_default ();
- skeleton->priv->properties = g_new0 (GValue, 4);
+ skeleton->priv->properties = g_new0 (GValue, 5);
g_value_init (&skeleton->priv->properties[0], G_TYPE_STRING);
g_value_init (&skeleton->priv->properties[1], G_TYPE_STRING);
g_value_init (&skeleton->priv->properties[2], G_TYPE_STRING);
g_value_init (&skeleton->priv->properties[3], G_TYPE_STRING);
+ g_value_init (&skeleton->priv->properties[4], G_TYPE_STRING);
}
static const gchar *
@@ -20955,6 +21366,17 @@
return value;
}
+static const gchar *
+flash_skeleton_get_status (Flash *object)
+{
+ FlashSkeleton *skeleton = FLASH_SKELETON (object);
+ const gchar *value;
+ g_mutex_lock (&skeleton->priv->lock);
+ value = g_value_get_string (&(skeleton->priv->properties[4]));
+ g_mutex_unlock (&skeleton->priv->lock);
+ return value;
+}
+
static void
flash_skeleton_class_init (FlashSkeletonClass *klass)
{
@@ -20990,6 +21412,7 @@
iface->get_flasher_path = flash_skeleton_get_flasher_path;
iface->get_flasher_name = flash_skeleton_get_flasher_name;
iface->get_flasher_instance = flash_skeleton_get_flasher_instance;
+ iface->get_status = flash_skeleton_get_status;
}
/**
diff --git a/interfaces/openbmc_intf.h b/interfaces/openbmc_intf.h
index ad4ea09..af80c89 100644
--- a/interfaces/openbmc_intf.h
+++ b/interfaces/openbmc_intf.h
@@ -2570,6 +2570,15 @@
+ gboolean (*handle_done) (
+ Flash *object,
+ GDBusMethodInvocation *invocation);
+
+ gboolean (*handle_error) (
+ Flash *object,
+ GDBusMethodInvocation *invocation,
+ const gchar *arg_message);
+
gboolean (*handle_init) (
Flash *object,
GDBusMethodInvocation *invocation);
@@ -2593,6 +2602,8 @@
const gchar * (*get_flasher_path) (Flash *object);
+ const gchar * (*get_status) (Flash *object);
+
void (*download) (
Flash *object,
const gchar *arg_url,
@@ -2614,6 +2625,14 @@
Flash *object,
GDBusMethodInvocation *invocation);
+void flash_complete_error (
+ Flash *object,
+ GDBusMethodInvocation *invocation);
+
+void flash_complete_done (
+ Flash *object,
+ GDBusMethodInvocation *invocation);
+
void flash_complete_update_via_tftp (
Flash *object,
GDBusMethodInvocation *invocation);
@@ -2654,6 +2673,40 @@
GCancellable *cancellable,
GError **error);
+void flash_call_error (
+ Flash *proxy,
+ const gchar *arg_message,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean flash_call_error_finish (
+ Flash *proxy,
+ GAsyncResult *res,
+ GError **error);
+
+gboolean flash_call_error_sync (
+ Flash *proxy,
+ const gchar *arg_message,
+ GCancellable *cancellable,
+ GError **error);
+
+void flash_call_done (
+ Flash *proxy,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+gboolean flash_call_done_finish (
+ Flash *proxy,
+ GAsyncResult *res,
+ GError **error);
+
+gboolean flash_call_done_sync (
+ Flash *proxy,
+ GCancellable *cancellable,
+ GError **error);
+
void flash_call_update_via_tftp (
Flash *proxy,
const gchar *arg_url,
@@ -2709,6 +2762,10 @@
gchar *flash_dup_flasher_instance (Flash *object);
void flash_set_flasher_instance (Flash *object, const gchar *value);
+const gchar *flash_get_status (Flash *object);
+gchar *flash_dup_status (Flash *object);
+void flash_set_status (Flash *object, const gchar *value);
+
/* ---- */
diff --git a/objects/control_bmc_obj.c b/objects/control_bmc_obj.c
index caba185..2aedd04 100644
--- a/objects/control_bmc_obj.c
+++ b/objects/control_bmc_obj.c
@@ -20,7 +20,6 @@
#define LPC_HICR6 0x80
#define LPC_HICR7 0x88
#define LPC_HICR8 0x8c
-
#define SPI_BASE (off_t)0x1e630000
#define SCU_BASE (off_t)0x1e780000
#define UART_BASE (off_t)0x1e783000
@@ -73,7 +72,7 @@
devmem(bmcreg+0x04,0x00000000); //Set Baud rate divisor -> 13 (Baud 115200)
devmem(bmcreg+0x08,0x000000c1); //Disable Parity, 1 stop bit, 8 bits
bmcreg = memmap(mem_fd,COM_BASE);
- devmem(bmcreg+0x9C,0x00000000); //Set routing UART1 -> COM 1
+ devmem(bmcreg+0x9C,0x08060000); //Set UART routing
bmcreg = memmap(mem_fd,SCU_BASE);
devmem(bmcreg+0x00,0x13008CE7);
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index ebc71aa..d9ad04d 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -5,15 +5,15 @@
#include "openbmc.h"
/* ---------------------------------------------------------------------------------------------------- */
-static const gchar* dbus_object_path = "/org/openbmc/flash";
-static const gchar* dbus_name = "org.openbmc.flash.Bios";
+static const gchar* dbus_object_path = "/org/openbmc/control/flash";
+static const gchar* dbus_name = "org.openbmc.control.Flash";
static const gchar* FLASHER_BIN = "flasher.exe";
static const gchar* DLOAD_BUS = "org.openbmc.managers.Download";
static const gchar* DLOAD_OBJ = "/org/openbmc/managers/Download";
static GDBusObjectManagerServer *manager = NULL;
-int update(Flash* flash)
+int update(Flash* flash, const char* obj_path)
{
pid_t pid;
int status=-1;
@@ -24,7 +24,7 @@
const gchar* name = flash_get_flasher_name(flash);
const gchar* inst = flash_get_flasher_instance(flash);
const gchar* filename = flash_get_filename(flash);
- status = execl(path, name, inst, filename, NULL);
+ status = execl(path, name, inst, filename, obj_path, NULL);
return status;
}
return 0;
@@ -38,11 +38,16 @@
flash_complete_init(f,invocation);
//tune flash
- flash_set_filename(f,"");
- int rc = update(f);
- if (rc==-1)
+ printf(" >>>>>>>>>> %s\n",flash_get_flasher_instance(f));
+ if (strcmp(flash_get_flasher_instance(f),"bios") == 0)
{
- printf("ERROR FlashControl_0: Unable to init\n");
+ flash_set_filename(f,"");
+ const gchar* obj_path = g_dbus_object_get_object_path((GDBusObject*)user_data);
+ int rc = update(f,obj_path);
+ if (rc==-1)
+ {
+ printf("ERROR FlashControl: Unable to init\n");
+ }
}
return TRUE;
}
@@ -110,15 +115,49 @@
else
{
printf("Flashing BIOS from TFTP: %s,%s\n",url,write_file);
- shared_resource_set_lock(lock,true);
- shared_resource_set_name(lock,dbus_object_path);
flash_set_filename(flash,write_file);
flash_emit_download(flash,url,write_file);
+ flash_set_status(flash,"Downloading");
}
return TRUE;
}
static gboolean
+on_error (Flash *flash,
+ GDBusMethodInvocation *invocation,
+ gchar* error_msg,
+ gpointer user_data)
+{
+ int rc = 0;
+ SharedResource *lock = object_get_shared_resource((Object*)user_data);
+ gboolean locked = shared_resource_get_lock(lock);
+ flash_set_status(flash, error_msg);
+ flash_complete_error(flash,invocation);
+ printf("ERROR: %s. Clearing locks\n",error_msg);
+ shared_resource_set_lock(lock,false);
+ shared_resource_set_name(lock,"");
+
+ return TRUE;
+}
+static gboolean
+on_done (Flash *flash,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ int rc = 0;
+ SharedResource *lock = object_get_shared_resource((Object*)user_data);
+ gboolean locked = shared_resource_get_lock(lock);
+ flash_set_status(flash, "Flash Done");
+ flash_complete_done(flash,invocation);
+ printf("Flash Done. Clearing locks\n");
+ shared_resource_set_lock(lock,false);
+ shared_resource_set_name(lock,"");
+
+ return TRUE;
+}
+
+
+static gboolean
on_update (Flash *flash,
GDBusMethodInvocation *invocation,
gchar* write_file,
@@ -127,6 +166,7 @@
int rc = 0;
SharedResource *lock = object_get_shared_resource((Object*)user_data);
gboolean locked = shared_resource_get_lock(lock);
+ flash_set_status(flash,"Flashing");
flash_complete_update(flash,invocation);
if (locked)
{
@@ -136,10 +176,12 @@
else
{
printf("Flashing BIOS from: %s\n",write_file);
+ flash_set_status(flash, "Flashing");
shared_resource_set_lock(lock,true);
shared_resource_set_name(lock,dbus_object_path);
flash_set_filename(flash,write_file);
- rc = update(flash);
+ const gchar* obj_path = g_dbus_object_get_object_path((GDBusObject*)user_data);
+ rc = update(flash,obj_path);
if (!rc)
{
shared_resource_set_lock(lock,false);
@@ -148,33 +190,6 @@
}
return TRUE;
}
-
-static void
-on_download_complete (GDBusConnection* connection,
- const gchar* sender_name,
- const gchar* object_path,
- const gchar* interface_name,
- const gchar* signal_name,
- GVariant* parameters,
- gpointer user_data)
-{
- Flash *flash = object_get_flash((Object*)user_data);
- SharedResource *lock = object_get_shared_resource((Object*)user_data);
-
- GVariantIter *iter = g_variant_iter_new(parameters);
- GVariant* v_fullname = g_variant_iter_next_value(iter);
- gsize size;
- const gchar* fullname = g_variant_get_string(v_fullname,&size);
- int rc;
- flash_set_filename(flash,fullname);
- rc = update(flash);
- if (!rc)
- {
- shared_resource_set_lock(lock,false);
- shared_resource_set_name(lock,"");
- }
-}
-
static void
on_flash_progress (GDBusConnection* connection,
const gchar* sender_name,
@@ -191,7 +206,11 @@
GVariant* v_progress = g_variant_iter_next_value(iter);
uint8_t progress = g_variant_get_byte(v_progress);
- printf("Progress: %d\n",progress);
+
+ gchar *s;
+ s = g_strdup_printf ("Flashing: %d%%",progress);
+ flash_set_status(flash,s);
+ g_free(s);
}
static void
@@ -208,6 +227,7 @@
printf("Flash succeeded; unlocking flash\n");
shared_resource_set_lock(lock,false);
shared_resource_set_name(lock,"");
+ flash_set_status(flash,"Flash Done");
}
static void
@@ -249,17 +269,31 @@
{
ObjectSkeleton *object;
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++)
+
+ //TODO: don't use fixed buffer
+ char flasher_path[512];
+ memset(flasher_path, '\0', sizeof(flasher_path));
+ bool found = false;
+ gchar *flasher_file;
+ int c = strlen(cmd->argv[0]);
+ while(c>0)
+ {
+ if (cmd->argv[0][c] == '/')
+ {
+ strncpy(flasher_path,cmd->argv[0],c);
+ flasher_file = g_strdup_printf ("%s/%s",flasher_path,FLASHER_BIN);
+ break;
+ }
+ c--;
+ }
+
+ const char* inst[] = {"bios","bmc"};
+ for (i=0;i<2;i++)
{
- gchar *s;
- s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ gchar* s;
+ s = g_strdup_printf ("%s/%s",dbus_object_path,inst[i]);
object = object_skeleton_new (s);
g_free (s);
@@ -274,33 +308,10 @@
shared_resource_set_lock(lock,false);
shared_resource_set_name(lock,"");
- int c = strlen(cmd->argv[0]);
-
- //TODO: don't use fixed buffer
- char buf[512];
- memset(buf, '\0', sizeof(buf));
- bool found = false;
- while(c>0)
- {
- if (cmd->argv[0][c] == '/')
- {
- strncpy(buf,cmd->argv[0],c);
- s = g_strdup_printf ("%s/%s",buf,FLASHER_BIN);
- break;
- }
- c--;
- }
- if (c==0)
- {
- printf("ERROR FlashBios: Invalid Path = %s\n",cmd->argv[0]);
- }
- else
- {
- flash_set_flasher_path(flash,s);
- flash_set_flasher_name(flash,FLASHER_BIN);
- flash_set_flasher_instance(flash,cmd->argv[i]);
- }
- g_free (s);
+ flash_set_flasher_path(flash,flasher_file);
+ flash_set_flasher_name(flash,FLASHER_BIN);
+ flash_set_flasher_instance(flash,inst[i]);
+ //g_free (s);
//define method callbacks here
@@ -321,6 +332,17 @@
"handle-update",
G_CALLBACK (on_update),
object); /* user_data */
+
+ g_signal_connect (flash,
+ "handle-error",
+ G_CALLBACK (on_error),
+ object); /* user_data */
+
+ g_signal_connect (flash,
+ "handle-done",
+ G_CALLBACK (on_done),
+ object); /* user_data */
+
g_signal_connect (flash,
"handle-update-via-tftp",
G_CALLBACK (on_update_via_tftp),
@@ -329,47 +351,9 @@
g_signal_connect (flash,
"handle-init",
G_CALLBACK (on_init),
- NULL); /* user_data */
+ object); /* user_data */
- g_dbus_connection_signal_subscribe(connection,
- DLOAD_BUS, DLOAD_BUS, "DownloadComplete",
- DLOAD_OBJ,NULL,G_DBUS_SIGNAL_FLAGS_NONE,
- (GDBusSignalCallback) on_download_complete,
- object,
- NULL );
- g_dbus_connection_signal_subscribe(connection,
- DLOAD_BUS, DLOAD_BUS, "DownloadError",
- DLOAD_OBJ,NULL,G_DBUS_SIGNAL_FLAGS_NONE,
- (GDBusSignalCallback) on_download_error,
- object,
- NULL );
-
- s = g_strdup_printf ("/org/openbmc/control/%s",cmd->argv[i]);
- g_dbus_connection_signal_subscribe(connection,
- NULL,
- "org.openbmc.FlashControl",
- "Done",
- s,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- (GDBusSignalCallback) on_flash_done,
- object,
- NULL );
- g_free(s);
- s = g_strdup_printf ("/org/openbmc/control/%s",cmd->argv[i]);
- g_dbus_connection_signal_subscribe(connection,
- NULL,
- "org.openbmc.FlashControl",
- "Error",
- s,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- (GDBusSignalCallback) on_flash_error,
- object,
- NULL );
-
- g_free(s);
- s = g_strdup_printf ("/org/openbmc/control/%s",cmd->argv[i]);
+ s = g_strdup_printf ("/org/openbmc/control/%s",inst[i]);
g_dbus_connection_signal_subscribe(connection,
NULL,
"org.openbmc.FlashControl",
@@ -389,7 +373,7 @@
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
g_object_unref (object);
}
-
+ g_free(flasher_file);
/* Export all objects */
g_dbus_object_manager_server_set_connection (manager, connection);
}
diff --git a/objects/flasher_obj.c b/objects/flasher_obj.c
index e951d63..53d62fd 100644
--- a/objects/flasher_obj.c
+++ b/objects/flasher_obj.c
@@ -51,6 +51,8 @@
static const char *fl_name;
static int32_t ffs_index = -1;
+static uint8_t FLASH_OK = 0;
+static uint8_t FLASH_ERROR = 1;
static int erase_chip(void)
{
@@ -69,6 +71,39 @@
return (rc);
}
+void flash_message(GDBusConnection* connection,char* obj_path,char* method, char* error_msg)
+{
+ GDBusProxy *proxy;
+ GError *error;
+ GVariant *parm = NULL;
+ GVariant *result;
+ error = NULL;
+ proxy = g_dbus_proxy_new_sync (connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL, /* GDBusInterfaceInfo* */
+ "org.openbmc.control.Flash", /* name */
+ obj_path, /* object path */
+ "org.openbmc.Flash", /* interface name */
+ NULL, /* GCancellable */
+ &error);
+ g_assert_no_error (error);
+
+ error = NULL;
+ if (strcmp(method,"error")==0) {
+ parm = g_variant_new("(s)",error_msg);
+ }
+ result = g_dbus_proxy_call_sync (proxy,
+ method,
+ parm,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ g_assert_no_error (error);
+}
+
+
static int program_file(FlashControl* flash_control, const char *file, uint32_t start, uint32_t size)
{
int fd, rc;
@@ -175,7 +210,7 @@
static void flash_access_setup_bmc(bool use_lpc, bool need_write)
{
int rc;
-
+ printf("Setting up BMC flash\n");
/* Open and map devices */
open_devs(use_lpc, true);
@@ -220,6 +255,7 @@
static void flash_access_setup_pnor(bool use_lpc, bool use_sfc, bool need_write)
{
int rc;
+ printf("Setting up BIOS flash\n");
/* Open and map devices */
open_devs(use_lpc, false);
@@ -260,13 +296,13 @@
atexit(flash_access_cleanup_pnor);
}
-int flash(FlashControl* flash_control,bool bmc_flash, char* write_file)
+uint8_t flash(FlashControl* flash_control,bool bmc_flash, char* write_file, char* obj_path)
{
bool has_sfc = false, has_ast = false, use_lpc = true;
bool erase = true, program = true;
uint32_t address = 0;
int rc;
-
+ printf("flasher: %s, BMC = %d\n",write_file,bmc_flash);
#ifdef __arm__
/* Check platform */
check_platform(&has_sfc, &has_ast);
@@ -275,15 +311,13 @@
if (bmc_flash) {
if (!has_ast) {
fprintf(stderr, "No BMC on this platform\n");
- flash_control_emit_error(flash_control,write_file);
- return;
+ return FLASH_ERROR;
}
flash_access_setup_bmc(use_lpc, erase || program);
} else {
if (!has_ast && !has_sfc) {
fprintf(stderr, "No BMC nor SFC on this platform\n");
- flash_control_emit_error(flash_control,write_file);
- return;
+ return FLASH_ERROR;
}
flash_access_setup_pnor(use_lpc, has_sfc, erase || program);
}
@@ -292,8 +326,7 @@
&fl_total_size, &fl_erase_granule);
if (rc) {
fprintf(stderr, "Error %d getting flash info\n", rc);
- flash_control_emit_error(flash_control,write_file);
- return;
+ return FLASH_ERROR;
}
#endif
if (strcmp(write_file,"")!=0)
@@ -302,32 +335,27 @@
struct stat stbuf;
if (stat(write_file, &stbuf)) {
perror("Failed to get file size");
- flash_control_emit_error(flash_control,write_file);
- return;
+ return FLASH_ERROR;
}
uint32_t write_size = stbuf.st_size;
#ifdef __arm__
rc = erase_chip();
if (rc) {
- flash_control_emit_error(flash_control,write_file);
- return;
+ return FLASH_ERROR;
}
rc = program_file(flash_control, write_file, address, write_size);
if (rc) {
- flash_control_emit_error(flash_control,write_file);
- return;
+ return FLASH_ERROR;
}
#endif
- flash_control_emit_done(flash_control,write_file);
- //flash_control_emit_error(flash_control,write_file);
printf("Flash done\n");
}
else
{
- flash_control_emit_done(flash_control,write_file);
printf("Flash tuned\n");
}
+ return FLASH_OK;
}
static void
@@ -337,12 +365,12 @@
{
cmdline *cmd = user_data;
- if (cmd->argc < 2)
+ if (cmd->argc < 4)
{
- g_print("No objects created. Put object name and filename on command line\n");
+ g_print("flasher [flash name] [filename] [source object]\n");
return;
}
- printf("Starting flasher\n");
+ printf("Starting flasher: %s,%s,%s,\n",cmd->argv[1],cmd->argv[2],cmd->argv[3]);
ObjectSkeleton *object;
manager = g_dbus_object_manager_server_new (dbus_object_path);
gchar *s;
@@ -361,7 +389,16 @@
/* Export all objects */
g_dbus_object_manager_server_set_connection (manager, connection);
- flash(flash_control,false,cmd->argv[2]);
+ bool bmc_flash = false;
+ if (strcmp(cmd->argv[1],"bmc")==0) {
+ bmc_flash = true;
+ }
+ int rc = flash(flash_control,bmc_flash,cmd->argv[2],cmd->argv[3]);
+ if (rc == FLASH_ERROR) {
+ flash_message(connection,cmd->argv[3],"error","Flash Error");
+ } else {
+ flash_message(connection,cmd->argv[3],"done","");
+ }
//Object exits when done flashing
g_main_loop_quit(cmd->loop);
diff --git a/xml/openbmc_intf.xml b/xml/openbmc_intf.xml
index 2ba627b..4a2398f 100644
--- a/xml/openbmc_intf.xml
+++ b/xml/openbmc_intf.xml
@@ -144,6 +144,11 @@
<method name="update">
<arg name="filename" type="s" direction="in"/>
</method>
+ <method name="error">
+ <arg name="message" type="s" direction="in"/>
+ </method>
+ <method name="done"/>
+
<method name="updateViaTftp">
<arg name="url" type="s" direction="in"/>
<arg name="filename" type="s" direction="in"/>
@@ -158,6 +163,7 @@
<property name="flasher_path" type="s" access="read"/>
<property name="flasher_name" type="s" access="read"/>
<property name="flasher_instance" type="s" access="read"/>
+ <property name="status" type="s" access="read"/>
</interface>
<interface name="org.openbmc.FlashControl">
<method name="flash">