diff options
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 1 | ||||
-rw-r--r-- | Kernel/Net/E1000NetworkAdapter.cpp | 16 | ||||
-rw-r--r-- | Kernel/Net/E1000NetworkAdapter.h | 1 | ||||
-rw-r--r-- | Kernel/Net/NetworkAdapter.h | 1 |
4 files changed, 19 insertions, 0 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index cc6a1d0f8a..9833bfdc9a 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -318,6 +318,7 @@ Optional<KBuffer> procfs$net_adapters(InodeIdentifier) obj.set("bytes_in", adapter.bytes_in()); obj.set("packets_out", adapter.packets_out()); obj.set("bytes_out", adapter.bytes_out()); + obj.set("link_up", adapter.link_up()); json.append(obj); }); return json.serialized<KBufferBuilder>(); diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp index 3ceb0d7e0e..43bae8c074 100644 --- a/Kernel/Net/E1000NetworkAdapter.cpp +++ b/Kernel/Net/E1000NetworkAdapter.cpp @@ -80,6 +80,17 @@ #define TSTA_LC (1 << 2) // Late Collision #define LSTA_TU (1 << 3) // Transmit Underrun +// STATUS Register + +#define STATUS_FD 0x01 +#define STATUS_LU 0x02 +#define STATUS_TXOFF 0x08 +#define STATUS_SPEED 0xC0 +#define STATUS_SPEED_10MB 0x00 +#define STATUS_SPEED_100MB 0x40 +#define STATUS_SPEED_1000MB1 0x80 +#define STATUS_SPEED_1000MB2 0xC0 + OwnPtr<E1000NetworkAdapter> E1000NetworkAdapter::autodetect() { static const PCI::ID qemu_bochs_vbox_id = { 0x8086, 0x100e }; @@ -215,6 +226,11 @@ void E1000NetworkAdapter::read_mac_address() } } +bool E1000NetworkAdapter::link_up() +{ + return (in32(REG_STATUS) & STATUS_LU); +} + void E1000NetworkAdapter::initialize_rx_descriptors() { auto ptr = (u32)kmalloc_eternal(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16); diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h index c2eec037b4..1c74a995cd 100644 --- a/Kernel/Net/E1000NetworkAdapter.h +++ b/Kernel/Net/E1000NetworkAdapter.h @@ -17,6 +17,7 @@ public: virtual ~E1000NetworkAdapter() override; virtual void send_raw(const u8*, int) override; + virtual bool link_up() override; private: virtual void handle_irq() override; diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index 4860e8b647..f0e0ec3e3f 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -25,6 +25,7 @@ public: const String& name() const { return m_name; } MACAddress mac_address() { return m_mac_address; } IPv4Address ipv4_address() const { return m_ipv4_address; } + virtual bool link_up() { return false; } void set_ipv4_address(const IPv4Address&); |