[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/23] ide: Convert read/write multiple commands to
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 06/23] ide: Convert read/write multiple commands to ide_cmd_table handler |
Date: |
Mon, 24 Jun 2013 11:10:18 +0200 |
From: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/ide/core.c | 119 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 60 insertions(+), 59 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index bf2007a..e6cd7b8 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1056,6 +1056,60 @@ static bool cmd_verify(IDEState *s, uint8_t cmd)
return true;
}
+static bool cmd_set_multiple_mode(IDEState *s, uint8_t cmd)
+{
+ if (s->drive_kind == IDE_CFATA && s->nsector == 0) {
+ /* Disable Read and Write Multiple */
+ s->mult_sectors = 0;
+ } else if ((s->nsector & 0xff) != 0 &&
+ ((s->nsector & 0xff) > MAX_MULT_SECTORS ||
+ (s->nsector & (s->nsector - 1)) != 0)) {
+ ide_abort_command(s);
+ } else {
+ s->mult_sectors = s->nsector & 0xff;
+ }
+
+ return true;
+}
+
+static bool cmd_read_multiple(IDEState *s, uint8_t cmd)
+{
+ bool lba48 = (cmd == WIN_MULTREAD_EXT);
+
+ if (!s->bs || !s->mult_sectors) {
+ ide_abort_command(s);
+ return true;
+ }
+
+ ide_cmd_lba48_transform(s, lba48);
+ s->req_nb_sectors = s->mult_sectors;
+ ide_sector_read(s);
+ return false;
+}
+
+static bool cmd_write_multiple(IDEState *s, uint8_t cmd)
+{
+ bool lba48 = (cmd == WIN_MULTWRITE_EXT);
+ int n;
+
+ if (!s->bs || !s->mult_sectors) {
+ ide_abort_command(s);
+ return true;
+ }
+
+ ide_cmd_lba48_transform(s, lba48);
+
+ s->req_nb_sectors = s->mult_sectors;
+ n = MIN(s->nsector, s->req_nb_sectors);
+
+ s->status = SEEK_STAT | READY_STAT;
+ ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write);
+
+ s->media_changed = 1;
+
+ return false;
+}
+
#define HD_OK (1u << IDE_HD)
#define CD_OK (1u << IDE_CD)
#define CFA_OK (1u << IDE_CFATA)
@@ -1081,13 +1135,13 @@ static const struct {
[WIN_READ_EXT] = { NULL, HD_CFA_OK },
[WIN_READDMA_EXT] = { NULL, HD_CFA_OK },
[WIN_READ_NATIVE_MAX_EXT] = { NULL, HD_CFA_OK },
- [WIN_MULTREAD_EXT] = { NULL, HD_CFA_OK },
+ [WIN_MULTREAD_EXT] = { cmd_read_multiple, HD_CFA_OK },
[WIN_WRITE] = { NULL, HD_CFA_OK },
[WIN_WRITE_ONCE] = { NULL, HD_CFA_OK },
[WIN_WRITE_EXT] = { NULL, HD_CFA_OK },
[WIN_WRITEDMA_EXT] = { NULL, HD_CFA_OK },
[CFA_WRITE_SECT_WO_ERASE] = { NULL, CFA_OK },
- [WIN_MULTWRITE_EXT] = { NULL, HD_CFA_OK },
+ [WIN_MULTWRITE_EXT] = { cmd_write_multiple, HD_CFA_OK },
[WIN_WRITE_VERIFY] = { NULL, HD_CFA_OK },
[WIN_VERIFY] = { cmd_verify, HD_CFA_OK | SET_DSC },
[WIN_VERIFY_ONCE] = { cmd_verify, HD_CFA_OK | SET_DSC },
@@ -1107,14 +1161,14 @@ static const struct {
[WIN_SMART] = { NULL, HD_CFA_OK },
[CFA_ACCESS_METADATA_STORAGE] = { NULL, CFA_OK },
[CFA_ERASE_SECTORS] = { NULL, CFA_OK },
- [WIN_MULTREAD] = { NULL, HD_CFA_OK },
- [WIN_MULTWRITE] = { NULL, HD_CFA_OK },
- [WIN_SETMULT] = { NULL, HD_CFA_OK },
+ [WIN_MULTREAD] = { cmd_read_multiple, HD_CFA_OK },
+ [WIN_MULTWRITE] = { cmd_write_multiple, HD_CFA_OK },
+ [WIN_SETMULT] = { cmd_set_multiple_mode, HD_CFA_OK |
SET_DSC },
[WIN_READDMA] = { NULL, HD_CFA_OK },
[WIN_READDMA_ONCE] = { NULL, HD_CFA_OK },
[WIN_WRITEDMA] = { NULL, HD_CFA_OK },
[WIN_WRITEDMA_ONCE] = { NULL, HD_CFA_OK },
- [CFA_WRITE_MULTI_WO_ERASE] = { NULL, CFA_OK },
+ [CFA_WRITE_MULTI_WO_ERASE] = { cmd_write_multiple, CFA_OK },
[WIN_STANDBYNOW1] = { cmd_nop, ALL_OK },
[WIN_IDLEIMMEDIATE] = { cmd_nop, ALL_OK },
[WIN_STANDBY] = { cmd_nop, ALL_OK },
@@ -1181,22 +1235,6 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val)
}
switch(val) {
- case WIN_SETMULT:
- if (s->drive_kind == IDE_CFATA && s->nsector == 0) {
- /* Disable Read and Write Multiple */
- s->mult_sectors = 0;
- s->status = READY_STAT | SEEK_STAT;
- } else if ((s->nsector & 0xff) != 0 &&
- ((s->nsector & 0xff) > MAX_MULT_SECTORS ||
- (s->nsector & (s->nsector - 1)) != 0)) {
- ide_abort_command(s);
- } else {
- s->mult_sectors = s->nsector & 0xff;
- s->status = READY_STAT | SEEK_STAT;
- }
- ide_set_irq(s->bus);
- break;
-
case WIN_READ_EXT:
lba48 = 1;
/* fall through */
@@ -1232,43 +1270,6 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val)
s->media_changed = 1;
break;
- case WIN_MULTREAD_EXT:
- lba48 = 1;
- /* fall through */
- case WIN_MULTREAD:
- if (!s->bs) {
- goto abort_cmd;
- }
- if (!s->mult_sectors) {
- goto abort_cmd;
- }
- ide_cmd_lba48_transform(s, lba48);
- s->req_nb_sectors = s->mult_sectors;
- ide_sector_read(s);
- break;
-
- case WIN_MULTWRITE_EXT:
- lba48 = 1;
- /* fall through */
- case WIN_MULTWRITE:
- case CFA_WRITE_MULTI_WO_ERASE:
- if (!s->bs) {
- goto abort_cmd;
- }
- if (!s->mult_sectors) {
- goto abort_cmd;
- }
- ide_cmd_lba48_transform(s, lba48);
- s->error = 0;
- s->status = SEEK_STAT | READY_STAT;
- s->req_nb_sectors = s->mult_sectors;
- n = s->nsector;
- if (n > s->req_nb_sectors)
- n = s->req_nb_sectors;
- ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write);
- s->media_changed = 1;
- break;
-
case WIN_READDMA_EXT:
lba48 = 1;
/* fall through */
--
1.8.1.4
- [Qemu-devel] [PULL 00/23] Block patches, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 02/23] ide: Convert WIN_DSM to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 01/23] ide: Add handler to ide_cmd_table, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 03/23] ide: Convert WIN_IDENTIFY to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 04/23] ide: Convert cmd_nop commands to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 05/23] ide: Convert verify commands to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 06/23] ide: Convert read/write multiple commands to ide_cmd_table handler,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 09/23] ide: Convert READ NATIVE MAX ADDRESS to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 10/23] ide: Convert CHECK POWER MDOE to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 08/23] ide: Convert DMA read/write commands to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 07/23] ide: Convert PIO read/write commands to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 11/23] ide: Convert SET FEATURES to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 12/23] ide: Convert FLUSH CACHE to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 13/23] ide: Convert SEEK to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 14/23] ide: Convert ATAPI commands to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 15/23] ide: Convert CF-ATA commands to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH 16/23] ide: Convert SMART commands to ide_cmd_table handler, Stefan Hajnoczi, 2013/06/24