3 ms·
General tips: 1. Start with a QEMU emulated device. QEMU is more forgiving than real hardware and you can study, understand, and debug the "hardware impersonat
by breckinloggins 5y ago
General tips:
1. Start with a QEMU emulated device. QEMU is more forgiving than real hardware and you can study, understand, and debug the "hardware impersonation side" of the QEMU code to see what happens when you set a bit in some register.
2. Pick a simple device. Don't start with the USB stack or Ethernet. Maybe try to reimplement the UART driver first.
3. Don't freak out about "device driver architecture" stuff like whether you need lock-free queues or allocation-free algorithms or ring buffers or... whatever. Just get it working.
4. Write a userspace program that uses the driver you'd like to see working. That'll motivate you to finish it.
5. Repeat. Until eventually you know how to write device drivers. :)
- toast0 5y ago> 2. Pick a simple device. Don't start with the USB stack or Ethernet. Maybe try to reimplement the UART driver first. A UART driver is great; then if you want to do Ethernet, virtio-net is a good start, and then carefully pick your physical ethernet card; something descriptor based will let you reuse the descriptor concepts you already learned. Realtek cards get a lot of shade, but aren't too bad to interface with and they're very popular; if you've got a bunch of computers, you've probably got at least a few realtek nics. Ethernet is cool, because then you can start communicating with the world (although there's a lot of stuff to get tcp going)