summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/Storage/ATAPIPassthrough.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
commitf8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch)
tree26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/Devices/Storage/ATAPIPassthrough.h
parentInitial commit. (diff)
downloadvirtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.tar.xz
virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.zip
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Devices/Storage/ATAPIPassthrough.h')
-rw-r--r--src/VBox/Devices/Storage/ATAPIPassthrough.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/VBox/Devices/Storage/ATAPIPassthrough.h b/src/VBox/Devices/Storage/ATAPIPassthrough.h
new file mode 100644
index 00000000..ee4e86f7
--- /dev/null
+++ b/src/VBox/Devices/Storage/ATAPIPassthrough.h
@@ -0,0 +1,100 @@
+/* $Id: ATAPIPassthrough.h $ */
+/** @file
+ * VBox storage devices: ATAPI passthrough helpers (common code for DevATA and DevAHCI).
+ */
+
+/*
+ * Copyright (C) 2012-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef VBOX_INCLUDED_SRC_Storage_ATAPIPassthrough_h
+#define VBOX_INCLUDED_SRC_Storage_ATAPIPassthrough_h
+#ifndef RT_WITHOUT_PRAGMA_ONCE
+# pragma once
+#endif
+
+#include <VBox/cdefs.h>
+#include <VBox/vmm/pdmifs.h>
+#include <VBox/vmm/pdmstorageifs.h>
+
+RT_C_DECLS_BEGIN
+
+/**
+ * Opaque media track list.
+ */
+typedef struct TRACKLIST *PTRACKLIST;
+
+/**
+ * Creates an empty track list handle.
+ *
+ * @returns VBox status code.
+ * @param ppTrackList Where to store the track list handle on success.
+ */
+DECLHIDDEN(int) ATAPIPassthroughTrackListCreateEmpty(PTRACKLIST *ppTrackList);
+
+/**
+ * Destroys the allocated task list handle.
+ *
+ * @returns nothing.
+ * @param pTrackList The track list handle to destroy.
+ */
+DECLHIDDEN(void) ATAPIPassthroughTrackListDestroy(PTRACKLIST pTrackList);
+
+/**
+ * Clears all tracks from the given task list.
+ *
+ * @returns nothing.
+ * @param pTrackList The track list to clear.
+ */
+DECLHIDDEN(void) ATAPIPassthroughTrackListClear(PTRACKLIST pTrackList);
+
+/**
+ * Updates the track list from the given CDB and data buffer.
+ *
+ * @returns VBox status code.
+ * @param pTrackList The track list to update.
+ * @param pCDB The CDB buffer.
+ * @param pvBuf The data buffer.
+ */
+DECLHIDDEN(int) ATAPIPassthroughTrackListUpdate(PTRACKLIST pTrackList, const uint8_t *pCDB, const void *pvBuf);
+
+/**
+ * Return the sector size from the track matching the LBA in the given track list.
+ *
+ * @returns Sector size.
+ * @param pTrackList The track list to use.
+ * @param iAtapiLba The start LBA to get the sector size for.
+ */
+DECLHIDDEN(uint32_t) ATAPIPassthroughTrackListGetSectorSizeFromLba(PTRACKLIST pTrackList, uint32_t iAtapiLba);
+
+/**
+ * Parses the given CDB and returns whether it is safe to pass it through to the host drive.
+ *
+ * @returns Flag whether passing the CDB through to the host drive is safe.
+ * @param pbCdb The CDB to parse.
+ * @param cbCdb Size of the CDB in bytes.
+ * @param cbBuf Size of the guest buffer.
+ * @param pTrackList The track list for the current medium if available (optional).
+ * @param pbSense Pointer to the sense buffer.
+ * @param cbSense Size of the sense buffer.
+ * @param penmTxDir Where to store the transfer direction (guest to host or vice versa).
+ * @param pcbXfer Where to store the transfer size encoded in the CDB.
+ * @param pcbSector Where to store the sector size used for the transfer.
+ * @param pu8ScsiSts Where to store the SCSI status code.
+ */
+DECLHIDDEN(bool) ATAPIPassthroughParseCdb(const uint8_t *pbCdb, size_t cbCdb, size_t cbBuf,
+ PTRACKLIST pTrackList, uint8_t *pbSense, size_t cbSense,
+ PDMMEDIATXDIR *penmTxDir, size_t *pcbXfer,
+ size_t *pcbSector, uint8_t *pu8ScsiSts);
+
+RT_C_DECLS_END
+
+#endif /* !VBOX_INCLUDED_SRC_Storage_ATAPIPassthrough_h */