18using namespace MaxOS::common;
19using namespace MaxOS::hardwarecommunication;
20using namespace MaxOS::memory;
21using namespace MaxOS::drivers;
22using namespace MaxOS::drivers::ethernet;
23using namespace MaxOS::drivers::video;
24using namespace MaxOS::drivers::disk;
26PCIDeviceDescriptor::PCIDeviceDescriptor() =
default;
28PCIDeviceDescriptor::~PCIDeviceDescriptor() =
default;
45 return "IDE interface";
47 return "SATA controller";
79 return "Serial controller";
81 return "Communication controller";
89 return "System Management Bus";
101 m_command_port(0xCF8)
107PCIController::~PCIController() =
default;
123 | ((bus & 0xFF) << 16)
124 | ((device & 0x1F) << 11)
125 | ((function & 0x07) << 8)
127 m_command_port.
write(
id);
149 | ((bus & 0xFF) << 16)
150 | ((device & 0x1F) << 11)
151 | ((function & 0x07) << 8)
153 m_command_port.
write(
id);
168 return read(bus, device, 0, 0x0E) & (1 << 7);
178 for (
int bus = 0; bus < 8; ++bus) {
179 for (
int device = 0; device < 32; ++device) {
181 int num_functions = (device_has_functions(bus, device)) ? 8 : 1;
183 for (
int function = 0; function <
num_functions; ++function) {
195 if (
bar.address && (
bar.type == BARType::InputOutput))
230 result.function = function;
232 result.vendor_id = read(bus, device, function, 0x00);
233 result.device_id = read(bus, device, function, 0x02);
235 result.class_id = read(bus, device, function, 0x0B);
236 result.subclass_id = read(bus, device, function, 0x0A);
237 result.interface_id = read(bus, device, function, 0x09);
239 result.revision = read(bus, device, function, 0x8);
240 result.interrupt = read(bus, device, function, 0x3C);
253 switch (
dev.vendor_id) {
256 switch (
dev.device_id) {
268 switch (
dev.device_id) {
288 switch (
dev.class_id) {
292 switch (
dev.subclass_id) {
312 switch (
dev.vendor_id) {
318 switch (
dev.device_id) {
331 switch (
dev.device_id) {
349 switch (
dev.device_id) {
364 switch (
dev.device_id) {
406 switch (
dev.device_id) {
423 Logger::Out() <<
"Unknown (0x" <<
dev.vendor_id <<
":0x" <<
dev.device_id <<
")";
453 write(bus, device, function, 0x10 + 4 *
bar, 0xFFFFFFF0 | (
int)
result.type);
454 result.size = read(bus, device, function, 0x10 + 4 *
bar);
458 write(bus, device, function, 0x10 + 4 *
bar,
bar_value);
Driver for the AMD AM79C973 Ethernet Controller.
static Logger DEBUG()
Gets active logger set to DEBUG level.
static Logger & Out()
Gets the active logger.
Stores the left, top, width and height of a rectangle.
Event handler for the DriverSelector class, handles the event when a driver is selected.
base class for all drivers, handles the activation, deactivation, initialisation and reset of the dri...
Driver for the IDE controller, handles the creation and management of the IDE devices.
Driver for the AMD AM79C973 Ethernet Controller.
Driver for the Intel I217 Ethernet Controller.
Driver for the VGA graphics controller, handles the rendering of pixels to the screen.
Used to store the Base Address Register (BAR) of a PCI device.
static void list_known_device(const PCIDeviceDescriptor &dev)
Print the vednor and device id of known devices, or "Unknown" + their ids if not known.
PCIController()
Construct a new PCI Controller object.
static drivers::Driver * get_driver(PCIDeviceDescriptor dev)
Get the driver for the device.
void select_drivers(drivers::DriverSelectorEventHandler *handler) override
Select the driver for the device.
Stores information about a PCI device.
uint8_t class_id
The class type of the device.
uint8_t subclass_id
The subclass type of the device.
string get_type() const
Get the type of the device.
virtual uint32_t read()
read a double word from the port (32Bit)
virtual void write(uint32_t data)
write a double word to the port (32Bit)
Defines a driver for the Integrated Drive Electronics (IDE) controller.
Driver for the Intel I217 Ethernet Controller.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
Defines a Peripheral Component Interconnect (PCI) controller for managing PCI devices and loading the...
BARType
Determines whether the PCI device communicates via IO ports or memory.