CPU IO Ports on Non-x86 Architectures

In the world of alternative OS development, portability across multiple architectures is a challenging goal. Sometimes, it may be intrinsically hard to come up with hardware abstractions that work well everywhere, but many times the core problem is one of missing information. Here, I aim at learning more about the way non-x86 architectures deal with CPU IO ports, and in particular how they prevent user-mode software from accessing them.

First, let’s start by summing up what I know. IO ports are the conceptually simplest way for computer CPUs to communicate with external hardware in a bidirectional fashion. They work using standard CPU instructions that send and receive fixed-size integers to distant hardware. Unlike with memory-mapped IO, these instructions always work as expected, and aren’t moved anarchically by optimizing compilers if you forget a “volatile” keyword somewhere. IO ports are also as standard as communication with external hardware can get, but on the minus side they are probably the slowest IO mechanism available, and using them requires architecture-specific ASM snippets.

On architectures which supports hardware-enforced separation of kernel-mode and user-mode software, every CPU feature which is used to control external hardware must be kept under the control of privileged software, and IO ports are no exception. On x86, this is done by using so-called “IO permission bitmaps”, which allows kernel-mode software to control the way other software accesses IO ports at the individual port scale. This hardware feature, which is really nice for microkernel OSs, leads me to ask a first question : How do other architectures restrict user-mode software’s access to IO ports ?

Another thing worth noting about x86 IO ports is that they seem to be a thing of the past. For better and worse, x86 has apparently moved to memory-mapped IO, DMA, and nonstandard (“Model-specific”) CPU registers nowadays, and all uses which I’ve found so far for IO ports on this architecture are legacy IBM PC features : 8259 PIC, CMOS, PS/2-compatible keyboards… Which leads me to a second question : What are the main means of communication with external hardware on other architectures ?

Many thanks in advance for your answers.

75 Comments

  1. 2011-12-30 8:32 am
    • 2011-12-30 1:22 pm
      • 2011-12-31 5:32 pm
    • 2011-12-31 2:59 am
  2. 2011-12-30 9:54 am
    • 2011-12-30 11:02 am
    • 2011-12-30 12:33 pm
      • 2011-12-30 1:10 pm
      • 2011-12-30 2:16 pm
    • 2011-12-31 4:53 am
    • 2011-12-31 8:49 pm
    • 2012-01-02 12:27 am
  3. 2011-12-30 2:28 pm
    • 2011-12-30 4:22 pm
      • 2011-12-30 5:06 pm
        • 2011-12-30 6:48 pm
          • 2012-01-06 11:59 pm
        • 2011-12-31 1:24 pm
          • 2011-12-31 11:46 pm
          • 2012-01-01 3:24 am
          • 2012-01-01 2:04 pm
          • 2012-01-01 4:05 pm
          • 2012-01-01 4:16 pm
        • 2012-01-03 11:55 am
          • 2012-01-06 11:55 pm
  4. 2011-12-30 2:36 pm
  5. 2011-12-30 4:21 pm
  6. 2011-12-30 4:29 pm
    • 2011-12-30 5:08 pm
      • 2011-12-30 5:39 pm
      • 2011-12-30 6:38 pm
        • 2011-12-30 7:28 pm
          • 2011-12-30 8:06 pm
          • 2011-12-30 8:53 pm
          • 2011-12-30 10:08 pm
          • 2011-12-30 10:51 pm
          • 2011-12-30 11:21 pm
          • 2011-12-31 2:42 am
          • 2011-12-31 6:58 pm
          • 2011-12-31 7:22 pm
          • 2011-12-31 8:20 pm
          • 2011-12-31 9:01 pm
          • 2011-12-31 9:52 pm
          • 2012-01-02 3:04 am
          • 2012-01-03 3:14 pm
          • 2012-01-03 5:36 pm
          • 2012-01-03 7:31 pm
          • 2012-01-03 7:59 pm
          • 2012-01-03 10:00 pm
          • 2011-12-30 10:11 pm
          • 2011-12-30 11:11 pm
      • 2011-12-31 3:32 am
        • 2011-12-31 4:34 am
        • 2011-12-31 5:04 am
          • 2011-12-31 6:46 am
          • 2012-01-03 10:25 pm
          • 2012-01-03 11:19 pm
          • 2012-01-04 2:46 pm
          • 2012-01-03 10:21 pm
      • 2011-12-31 5:52 pm
        • 2011-12-31 6:42 pm
          • 2012-01-01 8:32 pm
  7. 2011-12-30 5:09 pm
  8. 2011-12-30 8:21 pm
  9. 2011-12-31 11:44 am
    • 2011-12-31 12:00 pm
      • 2012-01-01 4:53 pm
    • 2012-01-01 4:58 pm
  10. 2011-12-31 1:49 pm
    • 2011-12-31 3:17 pm
      • 2012-01-04 9:08 am
    • 2011-12-31 8:58 pm
      • 2012-01-02 6:38 pm
        • 2012-01-03 5:45 pm
    • 2012-01-04 9:33 am