I’m a professional C programmer. I’m learning device drivers and want to write (and test) a simple serial port driver to send characters at a baud rate of 9600. I’ve started writing the code.
The problem is the function request_region fails (returns NULL) when I try to allocate the serial port registers with address range 03f8-03ff.
When I issue the command “cat /proc/ioports” I can see the following line
03f8-03ff : serial.
I thing this is because these ports are already allocated to already existing serial driver
Do I need to unload the already existing serial driver to test my driver?
If so, how can I do that?
You are right: there’s already a kernel driver using those ports. I assume you’re running on a Intel box so most probaby you’re using the 8250 driver. You can try to unload via:
but this will most probably fail if you’re using a kernel provided by a distro, since most of them have this module “built-in”. You can check this with
and you get
CONFIG_SERIAL_8250=ythen you need to compile your kernel where the 8250 driver is actually a loadable module.