diff options
author | Samuel Thibault <samuel.thibault@eu.citrix.com> | 2014-10-29 06:51:58 +0000 |
---|---|---|
committer | jljusten <jljusten@Edk2> | 2014-10-29 06:51:58 +0000 |
commit | 5cce85240450b4f878cc45b2eb16b7b4be74e511 (patch) | |
tree | bdf1817ff027d37f6bff6560816a0a6e302f1bb4 /OvmfPkg/XenPvBlkDxe/BlockFront.h | |
parent | de671da8e43c424ebdcf816c45fd06c43ff44aba (diff) | |
download | edk2-5cce85240450b4f878cc45b2eb16b7b4be74e511.zip edk2-5cce85240450b4f878cc45b2eb16b7b4be74e511.tar.gz edk2-5cce85240450b4f878cc45b2eb16b7b4be74e511.tar.bz2 |
OvmfPkg/XenPvBlkDxe: Add BlockFront client.
This is the code that will do the actual communication between OVMF and
a PV block backend, where the block device lives. The protocol used is
describe in the blkif.h header.
This implementation originally comes from Mini-OS, a part of the Xen
Project.
Change in V4:
- add file header to BlockFront.h (license, copyright, brief desc)
Change in V3:
- Improve comment of XenBusReadUint64.
- Moving blkif.h to this patch
with the necessary #pragma pack(4) applied for Ia32.
- Add a note about the license in the commit message
- Add "The protocol used is describe in the blkif.h header." in the
commit message
- Have a mandatory sector-size multiple of 512 or fail to initialize.
- use Sector instead of Offset for IO request.
with Sector been 512-byte unit.
- print something if EventChannelNotify return an error.
Change in V2:
- trigger CoW is probably not needed on OVMF (as opposed to Mini-OS),
removed the test.
- comments
- renamed XenbusReadInteger to XenBusReadUint64
- remove callback from IoData, use simple status instead
- return a status from the synchronus io
- Close protocol if blockfront init fail.
- fix few debug print
- Rename XenbusIo to XenBusIo
- XenPvBlkWaitForBackendState will return an error if the new backend
states is not the expected state.
- Add the license
License: This patch adds some files which are under the MIT license.
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16273 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/XenPvBlkDxe/BlockFront.h')
-rw-r--r-- | OvmfPkg/XenPvBlkDxe/BlockFront.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/OvmfPkg/XenPvBlkDxe/BlockFront.h b/OvmfPkg/XenPvBlkDxe/BlockFront.h new file mode 100644 index 0000000..867b39f --- /dev/null +++ b/OvmfPkg/XenPvBlkDxe/BlockFront.h @@ -0,0 +1,101 @@ +/** @file
+ BlockFront functions and types declarations.
+
+ Copyright (C) 2014, Citrix Ltd.
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include "XenPvBlkDxe.h"
+
+#include <IndustryStandard/Xen/event_channel.h>
+#include <IndustryStandard/Xen/io/blkif.h>
+
+typedef struct _XEN_BLOCK_FRONT_DEVICE XEN_BLOCK_FRONT_DEVICE;
+typedef struct _XEN_BLOCK_FRONT_IO XEN_BLOCK_FRONT_IO;
+
+struct _XEN_BLOCK_FRONT_IO
+{
+ XEN_BLOCK_FRONT_DEVICE *Dev;
+ UINT8 *Buffer;
+ UINTN Size;
+ UINTN Sector; ///< 512 bytes sector.
+
+ grant_ref_t GrantRef[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+ INT32 NumRef;
+
+ EFI_STATUS Status;
+};
+
+typedef struct
+{
+ UINT64 Sectors;
+ UINT32 SectorSize;
+ UINT32 VDiskInfo;
+ BOOLEAN ReadWrite;
+ BOOLEAN CdRom;
+ BOOLEAN FeatureBarrier;
+ BOOLEAN FeatureFlushCache;
+} XEN_BLOCK_FRONT_MEDIA_INFO;
+
+#define XEN_BLOCK_FRONT_SIGNATURE SIGNATURE_32 ('X', 'p', 'v', 'B')
+struct _XEN_BLOCK_FRONT_DEVICE {
+ UINT32 Signature;
+ EFI_BLOCK_IO_PROTOCOL BlockIo;
+ domid_t DomainId;
+
+ blkif_front_ring_t Ring;
+ grant_ref_t RingRef;
+ evtchn_port_t EventChannel;
+ blkif_vdev_t DeviceId;
+
+ CONST CHAR8 *NodeName;
+ XEN_BLOCK_FRONT_MEDIA_INFO MediaInfo;
+
+ VOID *StateWatchToken;
+
+ XENBUS_PROTOCOL *XenBusIo;
+};
+
+#define XEN_BLOCK_FRONT_FROM_BLOCK_IO(b) \
+ CR (b, XEN_BLOCK_FRONT_DEVICE, BlockIo, XEN_BLOCK_FRONT_SIGNATURE)
+
+EFI_STATUS
+XenPvBlockFrontInitialization (
+ IN XENBUS_PROTOCOL *XenBusIo,
+ IN CONST CHAR8 *NodeName,
+ OUT XEN_BLOCK_FRONT_DEVICE **DevPtr
+ );
+
+VOID
+XenPvBlockFrontShutdown (
+ IN XEN_BLOCK_FRONT_DEVICE *Dev
+ );
+
+VOID
+XenPvBlockAsyncIo (
+ IN OUT XEN_BLOCK_FRONT_IO *IoData,
+ IN BOOLEAN IsWrite
+ );
+
+EFI_STATUS
+XenPvBlockIo (
+ IN OUT XEN_BLOCK_FRONT_IO *IoData,
+ IN BOOLEAN IsWrite
+ );
+
+VOID
+XenPvBlockAsyncIoPoll (
+ IN XEN_BLOCK_FRONT_DEVICE *Dev
+ );
+
+VOID
+XenPvBlockSync (
+ IN XEN_BLOCK_FRONT_DEVICE *Dev
+ );
|