Max OS 0.3
Loading...
Searching...
No Matches
amd_am79c973.h
Go to the documentation of this file.
1
9#ifndef MAXOS_DRIVERS_ETHERNET_AMD_AM79C973_H
10#define MAXOS_DRIVERS_ETHERNET_AMD_AM79C973_H
11
12#include <cstdint>
13#include <common/macros.h>
18
19namespace MaxOS::drivers::ethernet {
20
28 typedef struct PACKED InitializationBlock {
29
30 uint16_t mode;
31 unsigned reserved1 : 4;
32 unsigned num_send_buffers : 4;
33 unsigned reserved2 : 4;
34 unsigned num_recv_buffers : 4;
35 uint64_t physical_address : 48;
36 uint16_t reserved3;
37 uint64_t logical_address;
40
41 }
43
51 typedef struct PACKED BufferDescriptor {
52
53 uint64_t address;
54 uint32_t flags;
55 uint32_t flags2;
56 uint32_t avail;
57
58 }
60
66
67 private:
68
69 //Reading the media access control address (MAC address)
70 hardwarecommunication::Port16Bit mac_address_0_port;
71 hardwarecommunication::Port16Bit mac_address_2_port;
72 hardwarecommunication::Port16Bit mac_address_4_port;
73
74 //Register ports
75 hardwarecommunication::Port16Bit register_data_port;
76 hardwarecommunication::Port16Bit register_address_port;
77 hardwarecommunication::Port16Bit bus_control_register_data_port;
78
80
81 //The main purpose of the initialization block it to hold a pointer to the array of BufferDescriptors, which hold the pointers to the buffers
82 initialisation_block_t init_block { };
83
84
85 buffer_descriptor_t* send_buffer_descr; //Descriptor entry
86 uint8_t send_buffers[2 * 1024 + 15][8] { }; //8 Send Buffers, 2KB + 15 bytes
87 uint8_t current_send_buffer; //Which buffers are active
88
89 buffer_descriptor_t* recv_buffer_descr; //Descriptor entry
90 uint8_t recv_buffers[2 * 1024 + 15][8] { }; //8 Send Buffers, 2KB + 15 bytes
91 uint8_t current_recv_buffer; //Which buffers are active
92
93 //Ethernet Driver functions
94 MediaAccessControlAddress own_mac; //MAC address of the device
95 volatile bool active; //Is the device active
96 volatile bool init_done; //Is the device initialised
97
98 void fetch_data_received(); //Fetches the data from the buffer
99 void fetch_data_sent(); //Fetches the data from the buffer
100
101 public:
104
105 // Override driver default methods
106 uint32_t reset() final;
107 void activate() final;
108 void deactivate() final;
109
110 // Naming
111 string vendor_name() final;
112 string device_name() final;
113
114 //Override Interrupt default methods
115 void handle_interrupt() final;
116
117 //Ethernet Driver functions
118 void do_send(uint8_t* buffer, uint32_t size) final;
119 uint64_t get_media_access_control_address() final;
120 };
121
122
123}
124
125
126#endif //MAXOS_DRIVERS_ETHERNET_AMD_AM79C973_H
struct PACKED MaxOS::drivers::ethernet::InitializationBlock initialisation_block_t
Alias for InitializationBlock struct.
struct PACKED MaxOS::drivers::ethernet::BufferDescriptor buffer_descriptor_t
Alias for BufferDescriptor struct.
Driver for the AMD AM79C973 Ethernet Controller.
uint32_t reset() final
This function resets the device.
string vendor_name() final
Get who created the device.
string device_name() final
Get the device name of the driver.
void activate() final
This function activates the device and starts it (Runs when the driver-manger calls activateAll())
void handle_interrupt() final
This function handles the interrupt for the device.
uint64_t get_media_access_control_address() final
This function gets the MAC address.
void do_send(uint8_t *buffer, uint32_t size) final
This function sends a package.
void deactivate() final
Deactivate the driver.
Driver for the Ethernet Controller, manages the sending and receiving of data, the mac address,...
Definition ethernet.h:89
Handles a certain interrupt number.
Definition interrupts.h:30
Stores information about a PCI device.
Definition pci.h:54
Handles 16 bit ports.
Definition port.h:57
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
Defines a InterruptManager and InterruptHandler for managing hardware and software interrupts.
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)
Defines the layout of a buffer descriptor for the AMD AM79C973 Ethernet Controller.
uint32_t flags
Flags for the buffer.
uint32_t avail
Indicates whether the buffer is available to be used.
uint64_t address
Physical address of the buffer.
uint32_t flags2
Additional flags for the buffer (.
The initialization block for the AMD AM79C973 Ethernet Controller.
unsigned reserved2
Unused, must be zero.
uint64_t physical_address
The physical (MAC) address of the device (Not 64 bits but will be treated like it is)
unsigned num_send_buffers
How many buffers are used for sending.
uint64_t logical_address
The logical address filter for the device to use when deciding whether to accept a packet (0 = no fil...
unsigned num_recv_buffers
How many buffers are used for receiving.
unsigned reserved1
Unused, must be zero.
uint32_t recv_buffer_descr_address
Physical address of the first receive buffer descriptor.
uint32_t send_buffer_descr_address
Physical address of the first send buffer descriptor.
uint16_t reserved3
Unused, must be zero.