Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / pci.h
blobaaf0101f944d056f7377a775d0fff9b7df38518e
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008,2009 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_PCI_H
20 #define GRUB_PCI_H 1
22 #ifndef ASM_FILE
23 #include <grub/types.h>
24 #include <grub/symbol.h>
25 #endif
27 #define GRUB_PCI_ADDR_SPACE_MASK 0x01
28 #define GRUB_PCI_ADDR_SPACE_MEMORY 0x00
29 #define GRUB_PCI_ADDR_SPACE_IO 0x01
31 #define GRUB_PCI_ADDR_MEM_TYPE_MASK 0x06
32 #define GRUB_PCI_ADDR_MEM_TYPE_32 0x00 /* 32 bit address */
33 #define GRUB_PCI_ADDR_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
34 #define GRUB_PCI_ADDR_MEM_TYPE_64 0x04 /* 64 bit address */
35 #define GRUB_PCI_ADDR_MEM_PREFETCH 0x08 /* prefetchable */
37 #define GRUB_PCI_ADDR_MEM_MASK ~0xf
38 #define GRUB_PCI_ADDR_IO_MASK ~0x03
40 #define GRUB_PCI_REG_PCI_ID 0x00
41 #define GRUB_PCI_REG_VENDOR 0x00
42 #define GRUB_PCI_REG_DEVICE 0x02
43 #define GRUB_PCI_REG_COMMAND 0x04
44 #define GRUB_PCI_REG_STATUS 0x06
45 #define GRUB_PCI_REG_REVISION 0x08
46 #define GRUB_PCI_REG_CLASS 0x08
47 #define GRUB_PCI_REG_CACHELINE 0x0c
48 #define GRUB_PCI_REG_LAT_TIMER 0x0d
49 #define GRUB_PCI_REG_HEADER_TYPE 0x0e
50 #define GRUB_PCI_REG_BIST 0x0f
51 #define GRUB_PCI_REG_ADDRESSES 0x10
53 /* Beware that 64-bit address takes 2 registers. */
54 #define GRUB_PCI_REG_ADDRESS_REG0 0x10
55 #define GRUB_PCI_REG_ADDRESS_REG1 0x14
56 #define GRUB_PCI_REG_ADDRESS_REG2 0x18
57 #define GRUB_PCI_REG_ADDRESS_REG3 0x1c
58 #define GRUB_PCI_REG_ADDRESS_REG4 0x20
59 #define GRUB_PCI_REG_ADDRESS_REG5 0x24
61 #define GRUB_PCI_REG_CIS_POINTER 0x28
62 #define GRUB_PCI_REG_SUBVENDOR 0x2c
63 #define GRUB_PCI_REG_SUBSYSTEM 0x2e
64 #define GRUB_PCI_REG_ROM_ADDRESS 0x30
65 #define GRUB_PCI_REG_CAP_POINTER 0x34
66 #define GRUB_PCI_REG_IRQ_LINE 0x3c
67 #define GRUB_PCI_REG_IRQ_PIN 0x3d
68 #define GRUB_PCI_REG_MIN_GNT 0x3e
69 #define GRUB_PCI_REG_MAX_LAT 0x3f
71 #define GRUB_PCI_COMMAND_IO_ENABLED 0x0001
72 #define GRUB_PCI_COMMAND_MEM_ENABLED 0x0002
73 #define GRUB_PCI_COMMAND_BUS_MASTER 0x0004
74 #define GRUB_PCI_COMMAND_PARITY_ERROR 0x0040
75 #define GRUB_PCI_COMMAND_SERR_ENABLE 0x0100
77 #define GRUB_PCI_STATUS_CAPABILITIES 0x0010
78 #define GRUB_PCI_STATUS_66MHZ_CAPABLE 0x0020
79 #define GRUB_PCI_STATUS_FAST_B2B_CAPABLE 0x0080
81 #define GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT 9
82 #define GRUB_PCI_STATUS_DEVSEL_TIMING_MASK 0x0600
83 #define GRUB_PCI_CLASS_SUBCLASS_VGA 0x0300
85 #ifndef ASM_FILE
87 enum
89 GRUB_PCI_CLASS_NETWORK = 0x02
91 enum
93 GRUB_PCI_CAP_POWER_MANAGEMENT = 0x01
96 enum
98 GRUB_PCI_VENDOR_BROADCOM = 0x14e4
102 typedef grub_uint32_t grub_pci_id_t;
104 #ifdef GRUB_MACHINE_EMU
105 #include <grub/pciutils.h>
106 #else
107 typedef grub_uint32_t grub_pci_address_t;
108 struct grub_pci_device
110 int bus;
111 int device;
112 int function;
114 typedef struct grub_pci_device grub_pci_device_t;
115 static inline int
116 grub_pci_get_bus (grub_pci_device_t dev)
118 return dev.bus;
121 static inline int
122 grub_pci_get_device (grub_pci_device_t dev)
124 return dev.device;
127 static inline int
128 grub_pci_get_function (grub_pci_device_t dev)
130 return dev.function;
132 #include <grub/cpu/pci.h>
133 #endif
135 typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
136 (grub_pci_device_t dev, grub_pci_id_t pciid);
138 grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
139 int reg);
141 void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook);
143 struct grub_pci_dma_chunk;
145 struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align,
146 grub_size_t size);
147 void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch);
148 volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch);
149 grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch);
151 static inline void *
152 grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk)
154 return ((grub_uint8_t *) grub_dma_get_virt (chunk)
155 + (phys - grub_dma_get_phys (chunk)));
158 static inline grub_uint32_t
159 grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk)
161 return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk))
162 + grub_dma_get_phys (chunk));
165 grub_uint8_t
166 EXPORT_FUNC (grub_pci_find_capability) (grub_pci_device_t dev, grub_uint8_t cap);
168 #endif
170 #endif /* GRUB_PCI_H */