seperated flash download
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index 2a5471b..cb3f70a 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -8,6 +8,26 @@
static GDBusObjectManagerServer *manager = NULL;
+void update(Flash *flash, const gchar* write_file)
+{
+ printf("Flashing: %s\n",write_file);
+ // get size from file
+ struct stat stbuf;
+ uint32_t address = 0, read_size = 0, write_size = 0;
+
+#ifdef __arm__
+ if (stat(write_file, &stbuf))
+ {
+ printf("ERROR: Invalid flash file: %s\n",write_file);
+ }
+ write_size = stbuf.st_size;
+ // TODO: need to change pflash to return error instead of exit
+ erase_chip();
+ program_file(write_file, address, write_size);
+#endif
+ flash_emit_updated(flash);
+}
+
static gboolean
on_init (Flash *f,
GDBusMethodInvocation *invocation,
@@ -24,32 +44,51 @@
}
static gboolean
-on_update (Flash *f,
+on_update_via_tftp (Flash *flash,
+ GDBusMethodInvocation *invocation,
+ gchar* url,
+ gchar* write_file,
+ gpointer user_data)
+{
+ printf("Flashing BIOS from TFTP: %s,%s\n",url,write_file);
+ flash_emit_download(flash,url,write_file);
+ flash_complete_update_via_tftp(flash,invocation);
+ return TRUE;
+}
+
+static gboolean
+on_update (Flash *flash,
GDBusMethodInvocation *invocation,
gchar* write_file,
gpointer user_data)
{
printf("Flashing BIOS from file\n");
- flash_complete_update(f,invocation);
- // get size from file
- struct stat stbuf;
- uint32_t address = 0, read_size = 0, write_size = 0;
-
-#ifdef __arm__
- if (stat(write_file, &stbuf))
- {
- printf("ERROR: Invalid flash file: %s\n",write_file);
- }
- write_size = stbuf.st_size;
- // TODO: need to change pflash to return error instead of exit
- erase_chip();
- program_file(write_file, address, write_size);
-#endif
-
- flash_emit_updated(f);
+ flash_complete_update(flash,invocation);
+ update(flash,write_file);
+ flash_emit_updated(flash);
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);
+
+ GVariantIter *iter = g_variant_iter_new(parameters);
+ GVariant* value = g_variant_iter_next_value(iter);
+ const gchar* write_file;
+ gsize size;
+ write_file = g_variant_get_string(value,&size);
+ update(flash,write_file);
+
+}
+
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
@@ -81,12 +120,27 @@
"handle-update",
G_CALLBACK (on_update),
NULL); /* user_data */
-
+ g_signal_connect (flash,
+ "handle-update-via-tftp",
+ G_CALLBACK (on_update_via_tftp),
+ NULL); /* user_data */
+
g_signal_connect (flash,
"handle-init",
G_CALLBACK (on_init),
NULL); /* user_data */
+ g_dbus_connection_signal_subscribe(connection,
+ "org.openbmc.managers.Download",
+ "org.openbmc.managers.Download",
+ "DownloadComplete",
+ "/org/openbmc/managers/Download",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ (GDBusSignalCallback) on_download_complete,
+ object,
+ NULL );
+
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));