VirtualBox

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

Last change on this file since 21321 was 21321, checked in by vboxsync, 15 years ago

OSE: export SCSI + SATA

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/* $Id: VBoxSCSI.h 21321 2009-07-07 12:31:37Z 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.virtualbox.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 *
47 * The register at port 0 receives the SCSI CDB issued from the driver when writing to it but
48 * before writing the actual CDB the first write gives the size of the CDB in bytes.
49 *
50 * Reading the port at offset 0 gives status information about the adapter.
51 * If the busy bit is set the adapter is processing a previous issued request if it is
52 * cleared the command finished and the adapter can process another request.
53 * The driver has to poll this bit because the adapter will not assert an IRQ for simplicity reasons.
54 *
55 * The register at offset 2 is to detect if a host adapter is available
56 * If the driver writes a value to this port and gets the same value after reading it
57 * again the adapter is available.
58 *
59 * This part has no R0 or GC components.
60 */
61
62#ifndef ___Storage_VBoxSCSI_h
63#define ___Storage_VBoxSCSI_h
64
65/*******************************************************************************
66* Header Files *
67*******************************************************************************/
68//#define DEBUG
69#include <VBox/pdmdev.h>
70
71typedef enum VBOXSCSISTATE
72{
73 VBOXSCSISTATE_NO_COMMAND = 0x00,
74 VBOXSCSISTATE_READ_TXDIR = 0x01,
75 VBOXSCSISTATE_READ_CDB_SIZE = 0x02,
76 VBOXSCSISTATE_READ_BUFFER_SIZE_LOW = 0x03,
77 VBOXSCSISTATE_READ_BUFFER_SIZE_HIGH = 0x04,
78 VBOXSCSISTATE_READ_COMMAND = 0x05,
79 VBOXSCSISTATE_COMMAND_READY = 0x06
80} VBOXSCSISTATE;
81
82#define VBOXSCSI_TXDIR_FROM_DEVICE 0
83#define VBOXSCSI_TXDIR_TO_DEVICE 1
84
85typedef struct VBOXSCSI
86{
87 /** The identify register. */
88 uint8_t regIdentify;
89 /** The target device. */
90 uint8_t uTargetDevice;
91 /** Transfer direction. */
92 uint8_t uTxDir;
93 /** The size of the CDB we are issuing. */
94 uint8_t cbCDB;
95 /** The command to issue. */
96 uint8_t aCDB[12];
97 /** Current position in the array. */
98 uint8_t iCDB;
99
100#if HC_ARCH_BITS == 64
101 uint32_t Alignment0;
102#endif
103
104 /** Pointer to the buffer holding the data. */
105 R3PTRTYPE(uint8_t *) pBuf;
106 /** Size of the buffer in bytes. */
107 uint32_t cbBuf;
108 /** Current position in the buffer. */
109 uint32_t iBuf;
110 /** Flag whether a request is pending. */
111 volatile bool fBusy;
112 /** The state we are in when fetching a command from the BIOS. */
113 VBOXSCSISTATE enmState;
114} VBOXSCSI, *PVBOXSCSI;
115
116#define VBOX_SCSI_BUSY RT_BIT(0)
117
118#ifdef IN_RING3
119RT_C_DECLS_BEGIN
120int vboxscsiInitialize(PVBOXSCSI pVBoxSCSI);
121int vboxscsiReadRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint32_t *pu32Value);
122int vboxscsiWriteRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint8_t uVal);
123int vboxscsiSetupRequest(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest, uint32_t *puTargetDevice);
124int vboxscsiRequestFinished(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest);
125int vboxscsiWriteString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
126 RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb);
127int vboxscsiReadString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
128 RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb);
129RT_C_DECLS_END
130#endif
131
132#endif /* ___Storage_VBoxSCSI_h */
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