%I/O %Thadeu Cascardo # I/O Ports versus Memory Mapped Devices * Separate I/O space in x86 architecture * Other architectures emulate this I/O space access # Resource allocation * Different drivers must not conflict when using device resources, like I/O ports or memory space * They must request these resources and release them # I/O port allocation * linux/ioport.h * request\\_region(port, num, name) * release\\_region(port, num) * /proc/ioports # I/O ports access * asm/io.h * inb(port) * outb(data, port) * inw(port) * outw(data, port) * inl(port) * outl(port) * String operations * Pausing I/O * Platform Issues # Memory Region Allocation * request\\_mem\\_region(start, len, name) * release\\_mem\\_region(start, len) # Memory Mapping * ioremap(phys\\_addr, size) * iounmap(virt\\_addr) # Memory Access * ioread8(addr) * ioread16(addr) * ioread32(addr) * iowrite8(val, addr) * iowrite16(val, addr) * iowrite32(val, addr) * memset\\_io(addr, val, cnt) * memcpy\\_fromio(dst, src, cnt) * memcpy\\_toio(dst, src, cnt) # Mapping I/O Ports to Memory * ioport\\_map(port, cnt) * ioport\\_unmap(addr) # Memory Barries * linux/kernel.h * barrier() * asm/system.h * rmb() * wmb() * mb() * smp\\_rmb * smp\\_wmb * smp\\_mb