diff options
author | John Snow <jsnow@redhat.com> | 2015-02-05 12:41:23 -0500 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2015-02-16 15:07:17 +0000 |
commit | 64a5a272e31c99cfb348f908d71c98d2eb83ba28 (patch) | |
tree | 088f9ca5577d6b19e58dbfb78b740610da2bd5e5 /tests/libqos/ahci.h | |
parent | 716b64079ceaa6fede724f8a24a24b0209fa5173 (diff) | |
download | qemu-64a5a272e31c99cfb348f908d71c98d2eb83ba28.tar.gz qemu-64a5a272e31c99cfb348f908d71c98d2eb83ba28.tar.bz2 qemu-64a5a272e31c99cfb348f908d71c98d2eb83ba28.zip |
libqos/ahci: add ahci command functions
This patch adds the AHCICommand structure, and a set of functions to
operate on the structure.
ahci_command_create - Initialize and create a new AHCICommand in memory
ahci_command_free - Destroy this object.
ahci_command_set_buffer - Set where the guest memory DMA buffer is.
ahci_command_commit - Write this command to the AHCI HBA.
ahci_command_issue - Issue the committed command synchronously.
ahci_command_issue_async - Issue the committed command asynchronously.
ahci_command_wait - Wait for an asynchronous command to finish.
ahci_command_slot - Get the number of the command slot we committed to.
Helpers:
size_to_prdtl - Calculate the required minimum PRDTL size from
a buffer size.
ahci_command_find - Given an ATA command mnemonic, look it up in the
properties table to obtain info about the command.
command_header_init - Initialize the command header with sane values.
command_table_init - Initialize the command table with sane values.
[Peter Maydell <peter.maydell@linaro.org> reported the following clang
warning:
tests/libqos/ahci.c:598:3: warning: redefinition
of typedef 'AHCICommand' is a C11 feature
[-Wtypedef-redefinition]
} AHCICommand;
I have replaced typedef struct ... AHCICommand; with struct ... ;
--Stefan]
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1423158090-25580-13-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/libqos/ahci.h')
-rw-r--r-- | tests/libqos/ahci.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index 83a62acf44..6ca1a6eb15 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -418,6 +418,9 @@ typedef struct PRD { uint32_t dbc; /* Data Byte Count (0-indexed) & Interrupt Flag (bit 2^31) */ } __attribute__((__packed__)) PRD; +/* Opaque, defined within ahci.c */ +typedef struct AHCICommand AHCICommand; + /*** Macro Utilities ***/ #define BITANY(data, mask) (((data) & (mask)) != 0) #define BITSET(data, mask) (((data) & (mask)) == (mask)) @@ -517,5 +520,20 @@ void ahci_set_command_header(AHCIQState *ahci, uint8_t port, void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot); void ahci_write_fis(AHCIQState *ahci, RegH2DFIS *fis, uint64_t addr); unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port); +unsigned size_to_prdtl(unsigned bytes, unsigned bytes_per_prd); + +/* Command Lifecycle */ +AHCICommand *ahci_command_create(uint8_t command_name); +void ahci_command_commit(AHCIQState *ahci, AHCICommand *cmd, uint8_t port); +void ahci_command_issue(AHCIQState *ahci, AHCICommand *cmd); +void ahci_command_issue_async(AHCIQState *ahci, AHCICommand *cmd); +void ahci_command_wait(AHCIQState *ahci, AHCICommand *cmd); +void ahci_command_free(AHCICommand *cmd); + +/* Command adjustments */ +void ahci_command_set_buffer(AHCICommand *cmd, uint64_t buffer); + +/* Command Misc */ +uint8_t ahci_command_slot(AHCICommand *cmd); #endif |