• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   BlockFront functions and types declarations.
3 
4   Copyright (C) 2014, Citrix Ltd.
5 
6   This program and the accompanying materials
7   are licensed and made available under the terms and conditions of the BSD License
8   which accompanies this distribution.  The full text of the license may be found at
9   http://opensource.org/licenses/bsd-license.php
10 
11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 #include "XenPvBlkDxe.h"
16 
17 #include <IndustryStandard/Xen/event_channel.h>
18 #include <IndustryStandard/Xen/io/blkif.h>
19 
20 typedef struct _XEN_BLOCK_FRONT_DEVICE XEN_BLOCK_FRONT_DEVICE;
21 typedef struct _XEN_BLOCK_FRONT_IO XEN_BLOCK_FRONT_IO;
22 
23 struct _XEN_BLOCK_FRONT_IO
24 {
25   XEN_BLOCK_FRONT_DEVICE  *Dev;
26   UINT8                   *Buffer;
27   UINTN                   Size;
28   UINTN                   Sector; ///< 512 bytes sector.
29 
30   grant_ref_t             GrantRef[BLKIF_MAX_SEGMENTS_PER_REQUEST];
31   INT32                   NumRef;
32 
33   EFI_STATUS              Status;
34 };
35 
36 typedef struct
37 {
38   UINT64    Sectors;
39   UINT32    SectorSize;
40   UINT32    VDiskInfo;
41   BOOLEAN   ReadWrite;
42   BOOLEAN   CdRom;
43   BOOLEAN   FeatureBarrier;
44   BOOLEAN   FeatureFlushCache;
45 } XEN_BLOCK_FRONT_MEDIA_INFO;
46 
47 #define XEN_BLOCK_FRONT_SIGNATURE SIGNATURE_32 ('X', 'p', 'v', 'B')
48 struct _XEN_BLOCK_FRONT_DEVICE {
49   UINT32                      Signature;
50   EFI_BLOCK_IO_PROTOCOL       BlockIo;
51   domid_t                     DomainId;
52 
53   blkif_front_ring_t          Ring;
54   grant_ref_t                 RingRef;
55   evtchn_port_t               EventChannel;
56   blkif_vdev_t                DeviceId;
57 
58   CONST CHAR8                 *NodeName;
59   XEN_BLOCK_FRONT_MEDIA_INFO  MediaInfo;
60 
61   VOID                        *StateWatchToken;
62 
63   XENBUS_PROTOCOL             *XenBusIo;
64 };
65 
66 #define XEN_BLOCK_FRONT_FROM_BLOCK_IO(b) \
67   CR (b, XEN_BLOCK_FRONT_DEVICE, BlockIo, XEN_BLOCK_FRONT_SIGNATURE)
68 
69 EFI_STATUS
70 XenPvBlockFrontInitialization (
71   IN  XENBUS_PROTOCOL  *XenBusIo,
72   IN  CONST CHAR8      *NodeName,
73   OUT XEN_BLOCK_FRONT_DEVICE **DevPtr
74   );
75 
76 VOID
77 XenPvBlockFrontShutdown (
78   IN XEN_BLOCK_FRONT_DEVICE *Dev
79   );
80 
81 VOID
82 XenPvBlockAsyncIo (
83   IN OUT XEN_BLOCK_FRONT_IO *IoData,
84   IN     BOOLEAN            IsWrite
85   );
86 
87 EFI_STATUS
88 XenPvBlockIo (
89   IN OUT XEN_BLOCK_FRONT_IO *IoData,
90   IN     BOOLEAN            IsWrite
91   );
92 
93 VOID
94 XenPvBlockAsyncIoPoll (
95   IN XEN_BLOCK_FRONT_DEVICE *Dev
96   );
97 
98 VOID
99 XenPvBlockSync (
100   IN XEN_BLOCK_FRONT_DEVICE *Dev
101   );
102