PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1#pragma once
2
3#include <modules/acpi/acpi.h>
4
5#include <stdint.h>
6
7/**
8 * @brief PCI configuration space
9 * @defgroup modules_drivers_pci_config PCI Configuration Space
10 * @ingroup modules_drivers_pci
11 *
12 * Id like to use the PCI Firmware Specification as a reference for this, but unfortunately, its not freely available.
13 * So we use the OSDev Wiki instead.
14 *
15 * @see [OSDev PCI](https://wiki.osdev.org/PCI)
16 * @see [OSDev PCI Express](https://wiki.osdev.org/PCI_Express)
17 *
18 * @{
19 */
20
21/**
22 * @brief PCI Segment Group Type
23 */
25
26/**
27 * @brief PCI Bus Type
28 */
30
31/**
32 * @brief PCI Slot Type
33 */
35
36/**
37 * @brief PCI Function Type
38 */
40
41/**
42 * @brief PCI-e Configuration Space Base Address Allocation Structure
43 * @struct pci_config_bar_t
44 */
53
54/**
55 * @brief PCI Express Memory-mapped Configuration
56 * @struct mcfg_t
57 */
64
65/**
66 * @brief Read a byte from PCI configuration space
67 *
68 * @param segmentGroup Segment group number
69 * @param bus Bus number
70 * @param slot Slot number
71 * @param function Function number
72 * @param offset Offset within the configuration space
73 * @return Byte read from the configuration space
74 */
76 uint16_t offset);
77
78/**
79 * @brief Read a word from PCI configuration space
80 *
81 * @param segmentGroup Segment group number
82 * @param bus Bus number
83 * @param slot Slot number
84 * @param function Function number
85 * @param offset Offset within the configuration space
86 * @return Word read from the configuration space
87 */
89 uint16_t offset);
90
91/**
92 * @brief Read a dword from PCI configuration space
93 *
94 * @param segmentGroup Segment group number
95 * @param bus Bus number
96 * @param slot Slot number
97 * @param function Function number
98 * @param offset Offset within the configuration space
99 * @return DWord read from the configuration space
100 */
102 uint16_t offset);
103
104/**
105 * @brief Write a byte to PCI configuration space
106 *
107 * @param segmentGroup Segment group number
108 * @param bus Bus number
109 * @param slot Slot number
110 * @param function Function number
111 * @param offset Offset within the configuration space
112 * @param value Byte value to write
113 */
114void pci_config_write8(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function,
115 uint16_t offset, uint8_t value);
116
117/**
118 * @brief Write a word to PCI configuration space
119 *
120 * @param segmentGroup Segment group number
121 * @param bus Bus number
122 * @param slot Slot number
123 * @param function Function number
124 * @param offset Offset within the configuration space
125 * @param value Word value to write
126 */
127void pci_config_write16(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function,
128 uint16_t offset, uint16_t value);
129
130/**
131 * @brief Write a dword to PCI configuration space
132 *
133 * @param segmentGroup Segment group number
134 * @param bus Bus number
135 * @param slot Slot number
136 * @param function Function number
137 * @param offset Offset within the configuration space
138 * @param value DWord value to write
139 */
140void pci_config_write32(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function,
141 uint16_t offset, uint32_t value);
142
143/** @} */
#define PACKED
GCC packed attribute.
Definition defs.h:32
void pci_config_write8(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset, uint8_t value)
Write a byte to PCI configuration space.
Definition config.c:152
uint8_t pci_function_t
PCI Function Type.
Definition config.h:39
void pci_config_write16(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset, uint16_t value)
Write a word to PCI configuration space.
Definition config.c:162
uint8_t pci_config_read8(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset)
Read a byte from PCI configuration space.
Definition config.c:104
uint8_t pci_slot_t
PCI Slot Type.
Definition config.h:34
uint32_t pci_config_read32(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset)
Read a dword from PCI configuration space.
Definition config.c:136
void pci_config_write32(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset, uint32_t value)
Write a dword to PCI configuration space.
Definition config.c:177
uint8_t pci_bus_t
PCI Bus Type.
Definition config.h:29
uint16_t pci_segment_group_t
PCI Segment Group Type.
Definition config.h:24
uint16_t pci_config_read16(pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset)
Read a word from PCI configuration space.
Definition config.c:120
static start_entry_t entries[START_ENTRY_MAX]
Definition start_menu.c:21
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
__UINT16_TYPE__ uint16_t
Definition stdint.h:13
PCI Express Memory-mapped Configuration.
Definition config.h:59
sdt_header_t header
Definition config.h:60
uint64_t reserved
Definition config.h:61
PCI-e Configuration Space Base Address Allocation Structure.
Definition config.h:46
pci_segment_group_t segmentGroup
Definition config.h:48
uint32_t reserved
Definition config.h:51
pci_bus_t endBus
Definition config.h:50
uint64_t base
Definition config.h:47
pci_bus_t startBus
Definition config.h:49
System Description Table Header.
Definition acpi.h:90