From 1e9887d904280c43c5a92570a07627689c89b48f Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 5 May 2024 15:20:33 +0200 Subject: net: expose the rtl mac to userland, make the netstack use it --- src/kernel/arch/amd64/driver/rtl8139.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/kernel/arch/amd64/driver') 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: -- cgit v1.2.3