|
@@ -652,6 +652,7 @@ static void do_next_command(struct ctl_state *state)
|
|
|
}
|
|
|
|
|
|
static FATFS sd_fs;
|
|
|
+static bool sd_mounted;
|
|
|
|
|
|
static int mount_disk(void)
|
|
|
{
|
|
@@ -668,6 +669,7 @@ static int mount_disk(void)
|
|
|
set_led(LED_DISKIO, false);
|
|
|
return -1;
|
|
|
}
|
|
|
+ sd_mounted = true;
|
|
|
|
|
|
label[0] = '\0';
|
|
|
volid = 0;
|
|
@@ -827,3 +829,26 @@ void abcdisk_config(void)
|
|
|
abc_register(&state->iodev, devsel);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/*
|
|
|
+ * Shut down the disk subsystem for reboot
|
|
|
+ */
|
|
|
+void abcdisk_shutdown(void)
|
|
|
+{
|
|
|
+ if (!sd_mounted)
|
|
|
+ return; /* Nothing to do */
|
|
|
+
|
|
|
+ for (int i = 0; i < CONTROLLER_TYPES; i++) {
|
|
|
+ struct ctl_state * const state = &controllers[i];
|
|
|
+ if (state->initialized)
|
|
|
+ unmount_drives(state);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Unmount the SD card filesystem */
|
|
|
+ f_unmount("");
|
|
|
+
|
|
|
+ /* Check one last time to see if anything needs to be written out */
|
|
|
+ disk_ioctl(0, CTRL_SYNC, NULL);
|
|
|
+
|
|
|
+ sd_mounted = false;
|
|
|
+}
|