Max OS 0.3
Loading...
Searching...
No Matches
intel_i217.h
Go to the documentation of this file.
1
9#ifndef MAXOS_DRIVERS_ETHERNET_INTEL_I127_H
10#define MAXOS_DRIVERS_ETHERNET_INTEL_I127_H
11
12#include <cstddef>
13#include <common/outputStream.h>
14#include <common/macros.h>
15#include <drivers/driver.h>
19#include <memory/memoryIO.h>
22
23
24namespace MaxOS::drivers::ethernet {
25
33 typedef struct PACKED ReceiveDescriptor {
34 uint64_t buffer_address;
35 uint16_t length;
36 uint16_t checksum;
37 uint8_t status;
38 uint8_t errors;
39 uint16_t special;
40 } receive_descriptor_t;
41
49 typedef struct PACKED SendDescriptor {
50 uint64_t buffer_address;
51 uint16_t length;
52 uint8_t cso;
53 uint8_t cmd;
54 uint8_t status;
55 uint8_t css;
56 uint16_t special;
57 } send_descriptor_t;
58
59
65
66 uint8_t bar_type = { 0 };
67 uint16_t port_base = { 0 };
68 uint64_t mem_base = { 0 };
69 uint8_t mac_address[6] = { 0 };
70
71
72 //Registers Addresses (Main Registers)
73 uint16_t control_register; // The control register
74 uint16_t status_register; // The status register
75 uint16_t eprom_register; // The address of the eeprom register
76 uint16_t control_ext_register; // The control extension register
77 uint16_t interrupt_mask_register; // The interrupt mask register
78
79 //Registers Addresses (Receive Registers)
80 uint16_t receive_control_register; // The receive control register
81 uint16_t receive_descriptor_low_register; // The receive descriptor low register
82 uint16_t receive_descriptor_high_register; // The receive descriptor high register
83 uint16_t receive_descriptor_length_register;// The receive descriptor length register
84 uint16_t receive_descriptor_head_register; // The receive descriptor head register
85 uint16_t receive_descriptor_tail_register; // The receive descriptor tail register
86
87 //Registers Addresses (Send Registers)
88 uint16_t send_control_register; // The send control register
89 uint16_t send_descriptor_low_register; // The send descriptor low register
90 uint16_t send_descriptor_high_register; // The send descriptor high register
91 uint16_t send_descriptor_length_register; // The send descriptor length register
92 uint16_t send_descriptor_head_register; // The send descriptor head register
93 uint16_t send_descriptor_tail_register; // The send descriptor tail register
94
95
96
97
98 //Buffers
99 receive_descriptor_t* receive_dsrctrs[32]; // The receive descriptors
100 uint16_t current_receive_buffer; // The current receive buffer
101
102 send_descriptor_t* send_dsrctrs[8]; // The send descriptors
103 uint16_t current_send_buffer; // The current send buffer
104
105
106 // write Commands and read results From NICs either using MemIO or IO Ports
107 void write(uint16_t address, uint32_t data) const;
108 [[nodiscard]] uint32_t read(uint16_t address) const;
109
110 //EPROM (Device Memory)
111 bool eprom_present = false; // Whether the EPROM is present
112 bool detect_ee_prom(); // Return true if EEProm exist, else it returns false and set the error_exists data member
113 uint32_t eeprom_read(uint8_t addr); // read 4 bytes from a specific EEProm Address
114
115
116 bool read_mac_address(); // read MAC Address
117
118 void receive_init(); // Initialise receive descriptors buffers
119 void send_init(); // Initialise transmit descriptors buffers
120
121 //Ethernet Driver functions
122 MediaAccessControlAddress own_mac; //MAC address of the device
123 volatile bool active; //Is the device active
124 volatile bool init_done; //Is the device initialised
125
126 void fetch_data_received(); //Fetches the data from the buffer
127
128 public:
129
130 explicit IntelI217(hardwarecommunication::PCIDeviceDescriptor* device_descriptor);
131 ~IntelI217();
132
133
134 //Override driver default methods
135 uint32_t reset() final;
136 void activate() final;
137 void deactivate() final;
138
139 //Override Interrupt default methods
140 void handle_interrupt() final;
141
142
143 //Ethernet Driver functions
144 string vendor_name() final;
145 string device_name() final;
146
147 void do_send(uint8_t* buffer, uint32_t size) final;
148 uint64_t get_media_access_control_address() final;
149 };
150
151}
152
153
154#endif //MAXOS_DRIVERS_ETHERNET_INTEL_I127_H
Driver for the Ethernet Controller, manages the sending and receiving of data, the mac address,...
Definition ethernet.h:89
Driver for the Intel I217 Ethernet Controller.
Definition intel_i217.h:64
void deactivate() final
Deactivate the driver.
void do_send(uint8_t *buffer, uint32_t size) final
(Device Side) send the data
uint64_t get_media_access_control_address() final
Get the MAC address.
void activate() final
Activate the driver.
uint32_t reset() final
Reset the driver.
string device_name() final
Get the device name of the driver.
string vendor_name() final
Get who created the device.
void handle_interrupt() final
Handles an interrupt.
Handles a certain interrupt number.
Definition interrupts.h:30
Stores information about a PCI device.
Definition pci.h:54
Defines a base Driver class and DriverManager for managing drivers.
Defines an EthernetDriver class for managing Ethernet communication, including sending and receiving ...
uint64_t MediaAccessControlAddress
Used to make MAC addresses more readable.
Definition ethernet.h:21
struct PACKED MaxOS::drivers::ethernet::SendDescriptor send_descriptor_t
Alias for SendDescriptor struct.
struct PACKED MaxOS::drivers::ethernet::ReceiveDescriptor receive_descriptor_t
Alias for ReceiveDescriptor struct.
Defines a InterruptManager and InterruptHandler for managing hardware and software interrupts.
Defines classes for memory input and output operations of various bit widths (8, 16,...
Defines a MemoryManager class for handling memory allocation and deallocation.
Defines OutputStream and GenericOutputStream classes for writing data to streams.
Defines a Peripheral Component Interconnect (PCI) controller for managing PCI devices and loading the...
Defines classes for handling hardware communication ports (8, 16, and 32 bit)
The receive descriptor for the Intel I217 Ethernet Controller.
Definition intel_i217.h:33
uint16_t length
The length of the received frame.
Definition intel_i217.h:35
uint8_t errors
Any errors that occurred.
Definition intel_i217.h:38
uint64_t buffer_address
The address of the receive buffer.
Definition intel_i217.h:34
uint16_t checksum
The checksum of the received frame.
Definition intel_i217.h:36
uint8_t status
The status of the received frame.
Definition intel_i217.h:37
The send descriptor for the Intel I217 Ethernet Controller.
Definition intel_i217.h:49
uint8_t cso
The checksum offset.
Definition intel_i217.h:52
uint8_t css
The checksum start.
Definition intel_i217.h:55
uint16_t length
The length of the send frame.
Definition intel_i217.h:51
uint64_t buffer_address
The address of the send buffer.
Definition intel_i217.h:50