diff options
author | dzwdz | 2024-05-05 15:20:33 +0200 |
---|---|---|
committer | dzwdz | 2024-05-05 15:20:33 +0200 |
commit | 1e9887d904280c43c5a92570a07627689c89b48f (patch) | |
tree | 92a93a7e4bfd9da3ff7e9b09f83579f360340ce9 /src/kernel/arch/amd64/driver/rtl8139.c | |
parent | d7e389ae21685dda6ef6619cbd3c64ad2db149b4 (diff) |
net: expose the rtl mac to userland, make the netstack use it
Diffstat (limited to 'src/kernel/arch/amd64/driver/rtl8139.c')
-rw-r--r-- | src/kernel/arch/amd64/driver/rtl8139.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/kernel/arch/amd64/driver/rtl8139.c b/src/kernel/arch/amd64/driver/rtl8139.c index d1054a4..a005df5 100644 --- a/src/kernel/arch/amd64/driver/rtl8139.c +++ b/src/kernel/arch/amd64/driver/rtl8139.c @@ -85,7 +85,6 @@ void rtl8139_init(uint32_t bdf) { for (int i = 0; i < 6; i++) { mac[i] = port_in8(iobase + Mac + i); } - kprintf("%02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); vfs_root_register("/dev/eth/", accept); } @@ -174,6 +173,7 @@ static int try_tx(Proc *proc, const void __user *src, size_t slen) { enum { HandleRoot, HandleNet, + HandleMac, }; static void accept(VfsReq *req) { @@ -189,12 +189,13 @@ static void accept(VfsReq *req) { case VFSOP_OPEN: if (reqpathcmp(req, "")) ret = HandleRoot; else if (reqpathcmp(req, "net")) ret = HandleNet; + else if (reqpathcmp(req, "mac")) ret = HandleMac; else ret = -ENOENT; vfsreq_finish_short(req, ret); break; case VFSOP_READ: if (id == HandleRoot) { - const char data[] = "net"; + const char data[] = "mac\0net"; ret = req_readcopy(req, data, sizeof data); vfsreq_finish_short(req, ret); } else if (id == HandleNet) { @@ -205,6 +206,9 @@ static void accept(VfsReq *req) { } else { vfsreq_finish_short(req, ret); } + } else if (id == HandleMac) { + ret = req_readcopy(req, mac, sizeof mac); + vfsreq_finish_short(req, ret); } else panic_invalid_state(); break; case VFSOP_WRITE: |