Listing 3: From iohw.c.

extern unsigned int iord(_IOreg reg)
{
    switch (reg.type) {
      case _Port8:
        return inportb(reg.location.port);
      case _Port16:
        return inport(reg.location.port);
      case _Mem8:
        return *reg.location.ptr8;
      case _Mem16:
        return *reg.location.ptr16;
      default:
        abort();
    }
}