VirtualBox

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

最後變更 在這個檔案從28684是 28684,由 vboxsync 提交於 15 年 前

VBoxSCSI: Always reset the state if the protocol is violated and make it possible to reset the state from the BIOS

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.1 KB
 
1/* $Id: VBoxSCSI.h 28684 2010-04-24 14:22:22Z vboxsync $ */
2/** @file
3 *
4 * VBox storage devices:
5 * Simple SCSI interface for BIOS access
6 */
7
8/*
9 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.alldomusa.eu.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24/**
25 * This is a simple interface to access SCSI devices from the BIOS
26 * which is shared between the BusLogic and the LsiLogic
27 * SCSI host adapters to simplify the BIOS part.
28 *
29 * The BusLogic interface if available will be starting at port 0x330
30 * and the LsiLogic starts at 0x340 and each will have a size of 3 ports.
31 * The ports are used as described below:
32 *
33 * +--------+--------+----------+
34 * | Offset | Access | Purpose |
35 * +--------+--------+----------+
36 * | 0 | Write | Command |
37 * +--------+--------+----------+
38 * | 0 | Read | Status |
39 * +--------+--------+----------+
40 * | 1 | Write | Data in |
41 * +--------+--------+----------+
42 * | 1 | Read | Data out |
43 * +--------+--------+----------+
44 * | 2 | R/W | Detect |
45 * +--------+--------+----------+
46 * | 3 | Write | Reset |
47 * +--------+--------+----------+
48 *
49 * The register at port 0 receives the SCSI CDB issued from the driver when writing to it but
50 * before writing the actual CDB the first write gives the size of the CDB in bytes.
51 *
52 * Reading the port at offset 0 gives status information about the adapter.
53 * If the busy bit is set the adapter is processing a previous issued request if it is
54 * cleared the command finished and the adapter can process another request.
55 * The driver has to poll this bit because the adapter will not assert an IRQ for simplicity reasons.
56 *
57 * The register at offset 2 is to detect if a host adapter is available
58 * If the driver writes a value to this port and gets the same value after reading it
59 * again the adapter is available.
60 *
61 * This part has no R0 or GC components.
62 */
63
64#ifndef ___Storage_VBoxSCSI_h
65#define ___Storage_VBoxSCSI_h
66
67/*******************************************************************************
68* Header Files *
69*******************************************************************************/
70//#define DEBUG
71#include <VBox/pdmdev.h>
72
73typedef enum VBOXSCSISTATE
74{
75 VBOXSCSISTATE_NO_COMMAND = 0x00,
76 VBOXSCSISTATE_READ_TXDIR = 0x01,
77 VBOXSCSISTATE_READ_CDB_SIZE = 0x02,
78 VBOXSCSISTATE_READ_BUFFER_SIZE_LOW = 0x03,
79 VBOXSCSISTATE_READ_BUFFER_SIZE_HIGH = 0x04,
80 VBOXSCSISTATE_READ_COMMAND = 0x05,
81 VBOXSCSISTATE_COMMAND_READY = 0x06
82} VBOXSCSISTATE;
83
84#define VBOXSCSI_TXDIR_FROM_DEVICE 0
85#define VBOXSCSI_TXDIR_TO_DEVICE 1
86
87/** Maximum CDB size the BIOS driver sends. */
88#define VBOXSCSI_CDB_SIZE_MAX 10
89
90typedef struct VBOXSCSI
91{
92 /** The identify register. */
93 uint8_t regIdentify;
94 /** The target device. */
95 uint8_t uTargetDevice;
96 /** Transfer direction. */
97 uint8_t uTxDir;
98 /** The size of the CDB we are issuing. */
99 uint8_t cbCDB;
100 /** The command to issue. */
101 uint8_t aCDB[12];
102 /** Current position in the array. */
103 uint8_t iCDB;
104
105#if HC_ARCH_BITS == 64
106 uint32_t Alignment0;
107#endif
108
109 /** Pointer to the buffer holding the data. */
110 R3PTRTYPE(uint8_t *) pBuf;
111 /** Size of the buffer in bytes. */
112 uint32_t cbBuf;
113 /** Current position in the buffer. */
114 uint32_t iBuf;
115 /** Flag whether a request is pending. */
116 volatile bool fBusy;
117 /** The state we are in when fetching a command from the BIOS. */
118 VBOXSCSISTATE enmState;
119} VBOXSCSI, *PVBOXSCSI;
120
121#define VBOX_SCSI_BUSY RT_BIT(0)
122
123#ifdef IN_RING3
124RT_C_DECLS_BEGIN
125int vboxscsiInitialize(PVBOXSCSI pVBoxSCSI);
126int vboxscsiReadRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint32_t *pu32Value);
127int vboxscsiWriteRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint8_t uVal);
128int vboxscsiSetupRequest(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest, uint32_t *puTargetDevice);
129int vboxscsiRequestFinished(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest);
130int vboxscsiWriteString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
131 RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb);
132int vboxscsiReadString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
133 RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb);
134RT_C_DECLS_END
135#endif
136
137#endif /* ___Storage_VBoxSCSI_h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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