mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:27:35 +00:00
E1000: Use a WaitQueue to sleep while waiting for a transmit IRQ
This commit is contained in:
parent
bcffe31d3a
commit
39246fb621
2 changed files with 12 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <Kernel/IO.h>
|
#include <Kernel/IO.h>
|
||||||
#include <Kernel/Net/E1000NetworkAdapter.h>
|
#include <Kernel/Net/E1000NetworkAdapter.h>
|
||||||
#include <Kernel/PCI.h>
|
#include <Kernel/PCI.h>
|
||||||
|
#include <Kernel/Thread.h>
|
||||||
|
|
||||||
#define REG_CTRL 0x0000
|
#define REG_CTRL 0x0000
|
||||||
#define REG_STATUS 0x0008
|
#define REG_STATUS 0x0008
|
||||||
|
@ -167,6 +168,8 @@ void E1000NetworkAdapter::handle_irq()
|
||||||
if (status & 0x80) {
|
if (status & 0x80) {
|
||||||
receive();
|
receive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_wait_queue.wake_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void E1000NetworkAdapter::detect_eeprom()
|
void E1000NetworkAdapter::detect_eeprom()
|
||||||
|
@ -321,6 +324,7 @@ u32 E1000NetworkAdapter::in32(u16 address)
|
||||||
|
|
||||||
void E1000NetworkAdapter::send_raw(const u8* data, int length)
|
void E1000NetworkAdapter::send_raw(const u8* data, int length)
|
||||||
{
|
{
|
||||||
|
disable_irq();
|
||||||
u32 tx_current = in32(REG_TXDESCTAIL);
|
u32 tx_current = in32(REG_TXDESCTAIL);
|
||||||
#ifdef E1000_DEBUG
|
#ifdef E1000_DEBUG
|
||||||
kprintf("E1000: Sending packet (%d bytes)\n", length);
|
kprintf("E1000: Sending packet (%d bytes)\n", length);
|
||||||
|
@ -336,8 +340,12 @@ void E1000NetworkAdapter::send_raw(const u8* data, int length)
|
||||||
#endif
|
#endif
|
||||||
tx_current = (tx_current + 1) % number_of_tx_descriptors;
|
tx_current = (tx_current + 1) % number_of_tx_descriptors;
|
||||||
out32(REG_TXDESCTAIL, tx_current);
|
out32(REG_TXDESCTAIL, tx_current);
|
||||||
while (!descriptor.status)
|
enable_irq();
|
||||||
;
|
for (;;) {
|
||||||
|
if (descriptor.status)
|
||||||
|
break;
|
||||||
|
current->wait_on(m_wait_queue);
|
||||||
|
}
|
||||||
#ifdef E1000_DEBUG
|
#ifdef E1000_DEBUG
|
||||||
kprintf("E1000: Sent packet, status is now %b!\n", descriptor.status);
|
kprintf("E1000: Sent packet, status is now %b!\n", descriptor.status);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -72,4 +72,6 @@ private:
|
||||||
|
|
||||||
e1000_rx_desc* m_rx_descriptors;
|
e1000_rx_desc* m_rx_descriptors;
|
||||||
e1000_tx_desc* m_tx_descriptors;
|
e1000_tx_desc* m_tx_descriptors;
|
||||||
|
|
||||||
|
WaitQueue m_wait_queue;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue