I have read that device drivers in Linux can run either in user mode or in kernel mode.
I also know that IO devices are accessed in one of two ways: using port-mapped IO, or using memory-mapped IO.
In port-mapped IO, we access an IO device using the instructions IN and OUT, and in memory-mapped IO, the registers of an IO device gets mapped to the kernel space memory (so we can access them using regular CPU instructions that accesses memory, like mov).
Now I suppose you can have a device driver running in user mode if the device driver accesses the IO device not directly, but rather by talking to the device driver of the IO port that the IO device is plugged into (for example: by talking to the serial port device driver if the IO device is plugged into a serial port).
But if the IO device is using port-mapped IO, the IN and OUT instructions are privileged instructions, so you need to be in kernel mode to use them. and if the IO device is using memory-mapped IO, the IO device registers will be mapped to the kernel space memory, and you need to be in kernel mode to access the kernel space memory.
So I don't think that a device driver that accesses an IO device directly can run in user mode.
Am I correct, or am I missing something?