At work we have some embedded devices controlled by DOS software. I have been tasked with the responsibility of assessing the use of Linux as a replacement OS for DOS on a next generation of hardware. My research leads me to the conclusion that DOS is simply a totally different type of operating system that allows you to do potentially dangerous things if you want to. From my understanding if you wish to access hardware directly you would have to write a custom driver. What I need to know to satisfy the curiosity of my boss is the following: is it at all possible to access hardware directly from user space??

My guess is no, but I would like to request the opinion of those with knowledge far greater than mine.

  • How are the devices accessed from the OS? E.g. are they PCI cards? Jul 13, 2012 at 18:16
  • I believe so yes. Most hardware is wired into the board directly (like serial ports and ethernet adaptor). There are devices attached also - I am a simple desktop application developer so my in depth knowledge of hardware is very limited. Hence my asking here. Jul 13, 2012 at 18:21
  • If you are not using specialized hardware and are only looking to get serial-ports and ethernet working, you probably don't need to access the hardware directly ...
    – Bananguin
    Jul 13, 2012 at 18:38
  • This was my thought to be honest. However, I think because the old code uses stuff like hardware interrupts to access incoming TCP and serial transmissions my boss wants the same functionality. It's probably a real-time issue. I personally cant see the problem with using things like poll() or select() to get data. Jul 13, 2012 at 18:43

3 Answers 3


Yes, but it is rarely useful. On 32-bit x86 systems, you can use the ioperm(2) system call to set up the current process to allow it to perform port I/O directly. I believe this does not work on 64-bit systems. You can also do lseek/read/write combinations against /dev/port and I think this likewise is not very portable. See http://tldp.org/HOWTO/IO-Port-Programming-2.html for some more details. Both of these approaches are much slower and less flexible than writing a device driver of course (/dev/port slowest of all). None of tese userspace mechanisms allow you to handle interrupts or anything like that, of course. If performance is an issue you're going to end up writing a device driver.

  • But work with interrupts and DMA is still impossible in userspace (AFAIK) So device access from userspace is limited to communicate via ports or device mapped memory.
    – Netch
    Jul 15, 2012 at 10:33
  • Yes, which is why I mentioned that in my answer. Jul 15, 2012 at 22:18

Your guess is correct. The kernel is the only software that can send hardware requests. That does not only hold true for Linux. Virtually no operating system newer than DOS lets you access hardware directly, because, as you also suspect, it's quite quite dangerous.

However, there is no problem in writing your own driver and plenty of documentation is available. For example, this tutorial at xatlantis seems a recent (that's important!) and good source.


It is definitely possible to access hardware from user space. Especially if the hardware registers are memory mapped. Se e.g., UIO.

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.