xref: /haiku/headers/private/kernel/platform/efi/protocol/pci-root-bridge-io.h (revision 485b5cf8bc00ab5aaee5db81a91d135dc61d9cc3)
1 // Copyright 2016 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include <efi/boot-services.h>
8 #include <efi/types.h>
9 
10 #define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \
11     {0x2f707ebb, 0x4a1a, 0x11D4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d}}
12 extern efi_guid PciRootBridgeIoProtocol;
13 
14 typedef enum {
15     EfiPciWidthUint8,
16     EfiPciWidthUint16,
17     EfiPciWidthUint32,
18     EfiPciWidthUint64,
19     EfiPciWidthFifoUint8,
20     EfiPciWidthFifoUint16,
21     EfiPciWidthFifoUint32,
22     EfiPciWidthFifoUint64,
23     EfiPciWidthFillUint8,
24     EfiPciWidthFillUint16,
25     EfiPciWidthFillUint32,
26     EfiPciWidthFillUint64,
27     EfiPciWidthMaximum,
28 } efi_pci_root_bridge_io_width;
29 
30 struct efi_pci_root_bridge_io_protocol;
31 
32 typedef struct {
33     efi_status (*Read) (struct efi_pci_root_bridge_io_protocol* self,
34                         efi_pci_root_bridge_io_width   width,
35                         uint64_t addr, size_t count, void* buffer) EFIAPI;
36     efi_status (*Write) (struct efi_pci_root_bridge_io_protocol* self,
37                          efi_pci_root_bridge_io_width   width,
38                          uint64_t addr, size_t count, void* buffer) EFIAPI;
39 } efi_pci_root_bridge_io_access;
40 
41 #define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
42 #define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002
43 #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004
44 #define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008
45 #define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010
46 #define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
47 #define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
48 #define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
49 #define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800
50 #define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000
51 #define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
52 #define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000
53 #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
54 #define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000
55 
56 typedef enum {
57     EfiPciOperationBusMasterRead,
58     EfiPciOperationBusMasterWrite,
59     EfiPciOperationBusMasterCommonBuffer,
60     EfiPciOperationBusMasterRead64,
61     EfiPciOperationBusMasterWrite64,
62     EfiPciOperationBusMasterCommonBuffer64,
63     EfiPciOperationMaximum,
64 } efi_pci_root_bridge_io_operation;
65 
66 typedef struct efi_pci_root_bridge_io_protocol {
67     efi_handle ParentHandle;
68 
69     efi_status (*PollMem) (struct efi_pci_root_bridge_io_protocol *self,
70                            efi_pci_root_bridge_io_width width,
71                            uint64_t addr, uint64_t mask, uint64_t value, uint64_t delay,
72                            uint64_t* result) EFIAPI;
73 
74     efi_status (*PollIo) (struct efi_pci_root_bridge_io_protocol *self,
75                           efi_pci_root_bridge_io_width width,
76                           uint64_t addr, uint64_t mask, uint64_t value, uint64_t delay,
77                           uint64_t* result) EFIAPI;
78 
79     efi_pci_root_bridge_io_access Mem;
80     efi_pci_root_bridge_io_access Io;
81     efi_pci_root_bridge_io_access Pci;
82 
83     efi_status (*CopyMem) (struct efi_pci_root_bridge_io_protocol* self,
84                            efi_pci_root_bridge_io_width width,
85                            uint64_t dest_addr, uint64_t src_addr, size_t count) EFIAPI;
86 
87     efi_status (*Map) (struct efi_pci_root_bridge_io_protocol* self,
88                        efi_pci_root_bridge_io_operation operation,
89                        void* host_addr, size_t* num_bytes,
90                        efi_physical_addr* device_addr, void** mapping) EFIAPI;
91 
92     efi_status (*Unmap) (struct efi_pci_root_bridge_io_protocol* self,
93                          void* mapping) EFIAPI;
94 
95     efi_status (*AllocateBuffer) (struct efi_pci_root_bridge_io_protocol* self,
96                                   efi_allocate_type type, efi_memory_type memory_type,
97                                   size_t pages, void** host_addr, uint64_t attributes) EFIAPI;
98 
99     efi_status (*FreeBuffer) (struct efi_pci_root_bridge_io_protocol* self,
100                               size_t pages, void* host_addr) EFIAPI;
101 
102     efi_status (*Flush) (struct efi_pci_root_bridge_io_protocol* self) EFIAPI;
103 
104     efi_status (*GetAttributes) (struct efi_pci_root_bridge_io_protocol* self,
105                                  uint64_t* supports, uint64_t* attributes) EFIAPI;
106 
107     efi_status (*SetAttributes) (struct efi_pci_root_bridge_io_protocol* self,
108                                  uint64_t attributes, uint64_t* resource_base,
109                                  uint64_t* resource_len) EFIAPI;
110 
111     efi_status (*Configuration) (struct efi_pci_root_bridge_io_protocol* self,
112                                  void** resources) EFIAPI;
113 
114     uint32_t SegmentNumber;
115 } efi_pci_root_bridge_io_protocol;
116