mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
Kernel: Use macros instead of hard-coded magic values
This commit is contained in:
parent
addddb4880
commit
fa434305a7
1 changed files with 8 additions and 6 deletions
|
@ -117,6 +117,8 @@ namespace Kernel {
|
||||||
#define INTERRUPT_TXD_LOW (1 << 15)
|
#define INTERRUPT_TXD_LOW (1 << 15)
|
||||||
#define INTERRUPT_SRPD (1 << 16)
|
#define INTERRUPT_SRPD (1 << 16)
|
||||||
|
|
||||||
|
#define PCI_VENDOR_INTEL 0x8086
|
||||||
|
|
||||||
// https://www.intel.com/content/dam/doc/manual/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf Section 5.2
|
// https://www.intel.com/content/dam/doc/manual/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf Section 5.2
|
||||||
static bool is_valid_device_id(u16 device_id)
|
static bool is_valid_device_id(u16 device_id)
|
||||||
{
|
{
|
||||||
|
@ -160,7 +162,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::detect()
|
||||||
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
|
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
|
||||||
if (address.is_null())
|
if (address.is_null())
|
||||||
return;
|
return;
|
||||||
if (id.vendor_id != 0x8086)
|
if (id.vendor_id != PCI_VENDOR_INTEL)
|
||||||
return;
|
return;
|
||||||
if (!is_valid_device_id(id.device_id))
|
if (!is_valid_device_id(id.device_id))
|
||||||
return;
|
return;
|
||||||
|
@ -223,16 +225,16 @@ void E1000NetworkAdapter::handle_irq(const RegisterState&)
|
||||||
|
|
||||||
m_entropy_source.add_random_event(status);
|
m_entropy_source.add_random_event(status);
|
||||||
|
|
||||||
if (status & 4) {
|
if (status & INTERRUPT_LSC) {
|
||||||
u32 flags = in32(REG_CTRL);
|
u32 flags = in32(REG_CTRL);
|
||||||
out32(REG_CTRL, flags | ECTRL_SLU);
|
out32(REG_CTRL, flags | ECTRL_SLU);
|
||||||
}
|
}
|
||||||
if (status & 0x80) {
|
if (status & INTERRUPT_RXDMT0) {
|
||||||
receive();
|
|
||||||
}
|
|
||||||
if (status & 0x10) {
|
|
||||||
// Threshold OK?
|
// Threshold OK?
|
||||||
}
|
}
|
||||||
|
if (status & INTERRUPT_RXT0) {
|
||||||
|
receive();
|
||||||
|
}
|
||||||
|
|
||||||
m_wait_queue.wake_all();
|
m_wait_queue.wake_all();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue