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