Context
Hacking the kernel: writing a full network stack. The LDD3 book is opened but not that helping after all.
破解内核:编写完整的网络堆栈。 LDD3的书已经打开但毕竟不是那么有用。
The whole userspace stack code is there already.
整个用户空间堆栈代码已经存在。
Now, I want to up my network driver. But before, I need to understand simple things, for my knowledge. I read the original driver for my card, obviously, and get no answer.
现在,我想要我的网络驱动程序。但在此之前,我需要了解简单的事情,据我所知。我显然读了我的卡的原始驱动程序,但没有得到答案。
Custom kernel 3.18.x
自定义内核3.18.x
x86_64
I don't want to only know how use the functions but understand the intrinsics as well.
我不想只知道如何使用函数,还要了解内在函数。
Question
I dig into the kernel meanderings and am not sure how the device_register function can grab the MAC address of a NIC.
我深入研究内核的蜿蜒,并且不确定device_register函数如何获取NIC的MAC地址。
In the function
在功能
int device_register(struct device *dev)
When have the mac been added ? Is it already allocated or will it be in device_add function ? So many indirections there..
什么时候添加mac?它已经分配了还是在device_add函数中?那里有如此多的间接......
How the kernel knows the mac address at the first place ? At boot ?
内核如何首先知道mac地址?在开机?
1 个解决方案
#1
0
OK,
device tree is my answer. Set at boot time.
设备树是我的答案。在启动时设置。
As I understood, the mac address is read in the ram where the motherboard gathers all the connected devices. Then the kernel reads that memory region according to the different offset that the motherboard set and retrieve the information it needs.
据我所知,在主板收集所有连接设备的RAM中读取mac地址。然后内核根据主板设置的不同偏移量读取该内存区域并检索所需的信息。
It appears in the /sys section as it seems.
它似乎出现在/ sys部分中。
Pfeww.. Now I can keep going :)
Pfeww ..现在我可以继续:)
#1
0
OK,
device tree is my answer. Set at boot time.
设备树是我的答案。在启动时设置。
As I understood, the mac address is read in the ram where the motherboard gathers all the connected devices. Then the kernel reads that memory region according to the different offset that the motherboard set and retrieve the information it needs.
据我所知,在主板收集所有连接设备的RAM中读取mac地址。然后内核根据主板设置的不同偏移量读取该内存区域并检索所需的信息。
It appears in the /sys section as it seems.
它似乎出现在/ sys部分中。
Pfeww.. Now I can keep going :)
Pfeww ..现在我可以继续:)