summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/XenPvBlkDxe/BlockFront.h
blob: 3651a6c8cdb99e341345cd4dd3f6e411c32ca90a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/** @file
  BlockFront functions and types declarations.

  Copyright (C) 2014, Citrix Ltd.

  SPDX-License-Identifier: BSD-2-Clause-Patent

**/
#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
  );