qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] hw/ide: Add command to sync cache on ATAPI


From: Damien Zammit
Subject: [PATCH] hw/ide: Add command to sync cache on ATAPI
Date: Mon, 14 Mar 2022 01:24:04 +0000

Signed-off-by: Damien Zammit <damien@zamaudio.com>
---
 hw/ide/atapi.c            | 7 +++++++
 hw/ide/core.c             | 2 +-
 include/hw/ide/internal.h | 3 +++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index b626199e3d..a5fd849c56 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -1062,6 +1062,12 @@ static void cmd_seek(IDEState *s, uint8_t* buf)
     ide_atapi_cmd_ok(s);
 }

+static void cmd_sync_cache(IDEState *s, uint8_t* buf)
+{
+    ide_flush_cache(s);
+    ide_atapi_cmd_ok(s);
+}
+
 static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)
 {
     int sense;
@@ -1287,6 +1293,7 @@ static const struct AtapiCmd {
     [ 0x25 ] = { cmd_read_cdvd_capacity,            CHECK_READY },
     [ 0x28 ] = { cmd_read, /* (10) */               CHECK_READY },
     [ 0x2b ] = { cmd_seek,                          CHECK_READY | NONDATA },
+    [ 0x35 ] = { cmd_sync_cache,                    CHECK_READY | NONDATA },
     [ 0x43 ] = { cmd_read_toc_pma_atip,             CHECK_READY },
     [ 0x46 ] = { cmd_get_configuration,             ALLOW_UA },
     [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA },
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 3a5afff5d7..a548aef471 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1108,7 +1108,7 @@ static void ide_flush_cb(void *opaque, int ret)
     ide_set_irq(s->bus);
 }

-static void ide_flush_cache(IDEState *s)
+void ide_flush_cache(IDEState *s)
 {
     if (s->blk == NULL) {
         ide_flush_cb(s, 0);
diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h
index 97e7e59dc5..0c54a75493 100644
--- a/include/hw/ide/internal.h
+++ b/include/hw/ide/internal.h
@@ -654,4 +654,7 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, 
DriveInfo *drive);

 int ide_handle_rw_error(IDEState *s, int error, int op);

+/* hw/ide/core.c */
+void ide_flush_cache(IDEState *s);
+
 #endif /* HW_IDE_INTERNAL_H */
--
2.13.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]