VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/VBoxSCSI.h@ 102468

Last change on this file since 102468 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/* $Id: VBoxSCSI.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox storage devices - Simple SCSI interface for BIOS access.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/** @page pg_drv_scsi Simple SCSI interface for BIOS access.
29 *
30 * This is a simple interface to access SCSI devices from the BIOS which is
31 * shared between the BusLogic and the LsiLogic SCSI host adapters to simplify
32 * the BIOS part.
33 *
34 * The first interface (if available) will be starting at port 0x430 and
35 * each will occupy 4 ports. The ports are used as described below:
36 *
37 * +--------+--------+----------+
38 * | Offset | Access | Purpose |
39 * +--------+--------+----------+
40 * | 0 | Write | Command |
41 * +--------+--------+----------+
42 * | 0 | Read | Status |
43 * +--------+--------+----------+
44 * | 1 | Write | Data in |
45 * +--------+--------+----------+
46 * | 1 | Read | Data out |
47 * +--------+--------+----------+
48 * | 2 | R/W | Detect |
49 * +--------+--------+----------+
50 * | 3 | Read | SCSI rc |
51 * +--------+--------+----------+
52 * | 3 | Write | Reset |
53 * +--------+--------+----------+
54 *
55 * The register at port 0 receives the SCSI CDB issued from the driver when
56 * writing to it but before writing the actual CDB the first write gives the
57 * size of the CDB in bytes.
58 *
59 * Reading the port at offset 0 gives status information about the adapter. If
60 * the busy bit is set the adapter is processing a previous issued request if it is
61 * cleared the command finished and the adapter can process another request.
62 * The driver has to poll this bit because the adapter will not assert an IRQ
63 * for simplicity reasons.
64 *
65 * The register at offset 2 is to detect if a host adapter is available. If the
66 * driver writes a value to this port and gets the same value after reading it
67 * again the adapter is available.
68 *
69 * Any write to the register at offset 3 causes the interface to be reset. A
70 * read returns the SCSI status code of the last operation.
71 *
72 * This part has no R0 or RC components.
73 */
74
75#ifndef VBOX_INCLUDED_SRC_Storage_VBoxSCSI_h
76#define VBOX_INCLUDED_SRC_Storage_VBoxSCSI_h
77#ifndef RT_WITHOUT_PRAGMA_ONCE
78# pragma once
79#endif
80
81/*******************************************************************************
82* Header Files *
83*******************************************************************************/
84#include <VBox/vmm/pdmdev.h>
85#include <VBox/version.h>
86
87#ifdef IN_RING3
88RT_C_DECLS_BEGIN
89
90/**
91 * Helper shared by the LsiLogic and BusLogic device emulations to load legacy saved states
92 * before the removal of the VBoxSCSI interface.
93 *
94 * @returns VBox status code.
95 * @param pHlp Pointer to the Ring-3 device helper table.
96 * @param pSSM The SSM handle to operate on.
97 */
98DECLINLINE(int) vboxscsiR3LoadExecLegacy(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM)
99{
100 pHlp->pfnSSMSkip(pSSM, 4);
101
102 /*
103 * The CDB buffer was increased with r104155 in trunk (backported to 5.0
104 * in r104311) without bumping the SSM state versions which leaves us
105 * with broken saved state restoring for older VirtualBox releases
106 * (up to 5.0.10).
107 */
108 if ( ( pHlp->pfnSSMHandleRevision(pSSM) < 104311
109 && pHlp->pfnSSMHandleVersion(pSSM) < VBOX_FULL_VERSION_MAKE(5, 0, 12))
110 || ( pHlp->pfnSSMHandleRevision(pSSM) < 104155
111 && pHlp->pfnSSMHandleVersion(pSSM) >= VBOX_FULL_VERSION_MAKE(5, 0, 51)))
112 pHlp->pfnSSMSkip(pSSM, 12);
113 else
114 pHlp->pfnSSMSkip(pSSM, 20);
115
116 pHlp->pfnSSMSkip(pSSM, 1); /*iCDB*/
117 uint32_t cbBufLeft, iBuf;
118 pHlp->pfnSSMGetU32(pSSM, &cbBufLeft);
119 pHlp->pfnSSMGetU32(pSSM, &iBuf);
120 pHlp->pfnSSMSkip(pSSM, 2); /*fBusy, enmState*/
121
122 if (cbBufLeft + iBuf)
123 pHlp->pfnSSMSkip(pSSM, cbBufLeft + iBuf);
124
125 return VINF_SUCCESS;
126}
127
128
129RT_C_DECLS_END
130#endif /* IN_RING3 */
131
132#endif /* !VBOX_INCLUDED_SRC_Storage_VBoxSCSI_h */
133
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette