]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.h
MdeModulePkg: implement generic PCI I/O driver for non-discoverable devices
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NonDiscoverablePciDeviceDxe / NonDiscoverablePciDeviceIo.h
1 /** @file
2
3 Copyright (C) 2016, Linaro Ltd. All rights reserved.<BR>
4
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
11 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __NON_DISCOVERABLE_PCI_DEVICE_IO_H__
16 #define __NON_DISCOVERABLE_PCI_DEVICE_IO_H__
17
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/UefiLib.h>
23
24 #include <IndustryStandard/Pci.h>
25
26 #include <Protocol/ComponentName.h>
27 #include <Protocol/NonDiscoverableDevice.h>
28 #include <Protocol/PciIo.h>
29
30 #define NON_DISCOVERABLE_PCI_DEVICE_SIG SIGNATURE_32 ('P', 'P', 'I', 'D')
31
32 #define NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(PciIoPointer) \
33 CR (PciIoPointer, NON_DISCOVERABLE_PCI_DEVICE, PciIo, \
34 NON_DISCOVERABLE_PCI_DEVICE_SIG)
35
36 #define PCI_ID_VENDOR_UNKNOWN 0xffff
37 #define PCI_ID_DEVICE_DONTCARE 0x0000
38
39 #define PCI_MAX_BARS 6
40
41 typedef struct {
42 UINT32 Signature;
43 //
44 // The bound non-discoverable device protocol instance
45 //
46 NON_DISCOVERABLE_DEVICE *Device;
47 //
48 // The exposed PCI I/O protocol instance.
49 //
50 EFI_PCI_IO_PROTOCOL PciIo;
51 //
52 // The emulated PCI config space of the device. Only the minimally required
53 // items are assigned.
54 //
55 PCI_TYPE00 ConfigSpace;
56 //
57 // The first virtual BAR to assign based on the resources described
58 // by the non-discoverable device.
59 //
60 UINT32 BarOffset;
61 //
62 // The number of virtual BARs we expose based on the number of
63 // resources
64 //
65 UINT32 BarCount;
66 //
67 // The PCI I/O attributes for this device
68 //
69 UINT64 Attributes;
70 //
71 // Whether this device has been enabled
72 //
73 BOOLEAN Enabled;
74 } NON_DISCOVERABLE_PCI_DEVICE;
75
76 VOID
77 InitializePciIoProtocol (
78 NON_DISCOVERABLE_PCI_DEVICE *Device
79 );
80
81 extern EFI_COMPONENT_NAME_PROTOCOL gComponentName;
82 extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2;
83
84 #endif