[kernel] First pass at allowing multiple NIC device drivers in kernel #1338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First pass of request for multiple ethernet NIC device drivers compiled into kernel from discussion in #1312 (comment).
Implements "master" ethernet character device driver that passes ethernet I/O requests to subdrivers, which are currently ne2k.c, wd.c, and el3.c. Currently still implemented as /dev/eth for all drivers.
Only a single NIC sub driver may be compiled-in, however each now requests IRQ from kernel at open time, and frees IRQ at close time. This is tested by running
net stop
,net start
and works.NIC subdrivers need to have their kernel-boot-time init code moved to their open routine (@Mellvik) and tested. For the time being, the init code can fail if the NIC card is not found for the driver that is being opened, and return an appropriate errno from open. We need to eliminate the ne2k_drv_init, wd_drv_initm, and el3_drv_init routines. (Don't confuse the boot time xxx_drv_init routines with the driver-internal named xxx_init routines also!)
Next steps would be to commit this PR, then move init code to open routines for each subdriver, then allow multiple drivers to be compiled into kernel and implement multiple /dev/xxx char device names, then add
net start eth NIC
to pass the new /dev/ne2k etc char device to ktcp, and proceed with multiple NIC testing.Major issue is that IRQ, BASE and RAM addresses will need to be somehow kept separate for each driver. Not sure how to do that yet.
As long as only a single NIC subdriver is compiled into the kernel, we don't have to worry too much about some of the above difficulties, and we can proceed slowly as time permits in getting multiple NICs working. I figured it would be better to make this small jump now to get it out of the way, while still making it easy for ongoing NIC driver development already in process. In that way, the major kernel changes (which are mostly in this PR) are finished, and only the individual subdrivers will need updating.
Adds
free_irq
anddisable_irq
kernel routines for IBM PC (and PC-98). @cocus, we'll need to have you implement disable_irq(unsigned int irq), which I have stubbed out in irq-8018x.c for you. This routine should set the CPU to mask off interrupts for the passed irq; freeing the vector in low core is performed by free_irq and should work on 8018X already.All three drivers tested for compilation, but only NE2K tested on QEMU.