VirtualBox

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

Last change on this file since 40257 was 35346, checked in by vboxsync, 14 years ago

VMM reorg: Moving the public include files from include/VBox to include/VBox/vmm.

  • 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 35346 2010-12-27 16:13:13Z vboxsync $ */
2/** @file
3 *
4 * VBox storage devices:
5 * Simple SCSI interface for BIOS access
6 */
7
8/*
9 * Copyright (C) 2006-2009 Oracle Corporation
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
20/**
21 * This is a simple interface to access SCSI devices from the BIOS
22 * which is shared between the BusLogic and the LsiLogic
23 * SCSI host adapters to simplify the BIOS part.
24 *
25 * The BusLogic interface if available will be starting at port 0x330
26 * and the LsiLogic starts at 0x340 and each will have a size of 3 ports.
27 * The ports are used as described below:
28 *
29 * +--------+--------+----------+
30 * | Offset | Access | Purpose |
31 * +--------+--------+----------+
32 * | 0 | Write | Command |
33 * +--------+--------+----------+
34 * | 0 | Read | Status |
35 * +--------+--------+----------+
36 * | 1 | Write | Data in |
37 * +--------+--------+----------+
38 * | 1 | Read | Data out |
39 * +--------+--------+----------+
40 * | 2 | R/W | Detect |
41 * +--------+--------+----------+
42 * | 3 | Write | Reset |
43 * +--------+--------+----------+
44 *
45 * The register at port 0 receives the SCSI CDB issued from the driver when writing to it but
46 * before writing the actual CDB the first write gives the size of the CDB in bytes.
47 *
48 * Reading the port at offset 0 gives status information about the adapter.
49 * If the busy bit is set the adapter is processing a previous issued request if it is
50 * cleared the command finished and the adapter can process another request.
51 * The driver has to poll this bit because the adapter will not assert an IRQ for simplicity reasons.
52 *
53 * The register at offset 2 is to detect if a host adapter is available
54 * If the driver writes a value to this port and gets the same value after reading it
55 * again the adapter is available.
56 *
57 * This part has no R0 or GC components.
58 */
59
60#ifndef ___Storage_VBoxSCSI_h
61#define ___Storage_VBoxSCSI_h
62
63/*******************************************************************************
64* Header Files *
65*******************************************************************************/
66//#define DEBUG
67#include <VBox/vmm/pdmdev.h>
68
69typedef enum VBOXSCSISTATE
70{
71 VBOXSCSISTATE_NO_COMMAND = 0x00,
72 VBOXSCSISTATE_READ_TXDIR = 0x01,
73 VBOXSCSISTATE_READ_CDB_SIZE = 0x02,
74 VBOXSCSISTATE_READ_BUFFER_SIZE_LOW = 0x03,
75 VBOXSCSISTATE_READ_BUFFER_SIZE_HIGH = 0x04,
76 VBOXSCSISTATE_READ_COMMAND = 0x05,
77 VBOXSCSISTATE_COMMAND_READY = 0x06
78} VBOXSCSISTATE;
79
80#define VBOXSCSI_TXDIR_FROM_DEVICE 0
81#define VBOXSCSI_TXDIR_TO_DEVICE 1
82
83/** Maximum CDB size the BIOS driver sends. */
84#define VBOXSCSI_CDB_SIZE_MAX 10
85
86typedef struct VBOXSCSI
87{
88 /** The identify register. */
89 uint8_t regIdentify;
90 /** The target device. */
91 uint8_t uTargetDevice;
92 /** Transfer direction. */
93 uint8_t uTxDir;
94 /** The size of the CDB we are issuing. */
95 uint8_t cbCDB;
96 /** The command to issue. */
97 uint8_t aCDB[12];
98 /** Current position in the array. */
99 uint8_t iCDB;
100
101#if HC_ARCH_BITS == 64
102 uint32_t Alignment0;
103#endif
104
105 /** Pointer to the buffer holding the data. */
106 R3PTRTYPE(uint8_t *) pBuf;
107 /** Size of the buffer in bytes. */
108 uint32_t cbBuf;
109 /** Current position in the buffer. */
110 uint32_t iBuf;
111 /** Flag whether a request is pending. */
112 volatile bool fBusy;
113 /** The state we are in when fetching a command from the BIOS. */
114 VBOXSCSISTATE enmState;
115} VBOXSCSI, *PVBOXSCSI;
116
117#define VBOX_SCSI_BUSY RT_BIT(0)
118
119#ifdef IN_RING3
120RT_C_DECLS_BEGIN
121int vboxscsiInitialize(PVBOXSCSI pVBoxSCSI);
122int vboxscsiReadRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint32_t *pu32Value);
123int vboxscsiWriteRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint8_t uVal);
124int vboxscsiSetupRequest(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest, uint32_t *puTargetDevice);
125int vboxscsiRequestFinished(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest);
126void vboxscsiSetRequestRedo(PVBOXSCSI pVBoxSCSI, PPDMSCSIREQUEST pScsiRequest);
127int vboxscsiWriteString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
128 RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb);
129int vboxscsiReadString(PPDMDEVINS pDevIns, PVBOXSCSI pVBoxSCSI, uint8_t iRegister,
130 RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb);
131RT_C_DECLS_END
132#endif
133
134#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