0

Based on what I know so far, if I want to create a driver, and want the driver to send data on some port (for example: serial/parallel/USB), my driver will communicate with the port driver, and the port driver is the one that will access the port directly.

Assume that my driver will run in kernel mode.

Now my question is, can my driver access the port directly instead of telling the port driver to do that? I am guessing that the answer is yes since my driver is running in kernel mode, and so it can do anything (I mean if the port driver can do it, then my driver should be able to do it also!).

3

Let's define "access the port" first.

A serial/USB port will have a special IC on the mother board. It will be connected by electrical traces to a peripheral controller or other ICs, all eventually wired to the CPU.

So, when we say "access the port" to mean "control the electrical signals on those traces wired to that USB controller", then yes a kernel mode driver can make that happen.

The problem is when we define "access the port" to mean "make the port do something useful". A USB controller is a very complex chip, the USB protocol is a huge pain to implement. You're not going to be able to guess the right way to talk to it, you're not going to guess how the chip interprets the electrical signals applied to its pins. Sometimes the makers of the IC will keep those details secret, and even if they publish them, it can be a lot of work.

In the case of USB, there exists a company, FTDI, where its entire reason for existence is to allow people to make USB connected hardware and simultaneously avoid the hassle of writing drivers for it.

So the answer to your question is probably no, because while your written question is in the context of the first definition, you're thinking and your goals are of the second.

  • 1
    And if you do manage to correctly signal the USB controller, the real USB controller driver is going to interfere with the signals by trying to send its own at the same time. – immibis May 29 '17 at 5:20
  • @whatsisname "So, when we say "access the port" to mean "control the electrical signals on those traces wired to that USB controller", then yes a kernel mode driver can make that happen." Yes, this is what I mean. And I am only asking this question to see if it is technically possible to do it, I am not thinking of actually doing it :) – John May 29 '17 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.