I/O Devices as Files

The following Linux commands all perform the same operation on an I/O device(represented as a file)
– cp file > /dev/lp
– cat file > /dev/lp
– echo “Hello, world” > /dev/lp

Note: Please feel free to use the Internet

Direct Memory Access(DMA)
NIC, data == network packet
-write command to request packet transmission
-configure DMA controller with in-memory address and size of packet buffer

Typical Device Access
user process -> kernel -> driver -> device
-system call
-in-kernel stack
-driver invocation
-device request configuration

OS Bypass
-device regs/data
directly accessible
-OS configures then out-of-the way
“user-level driver”
-relies on device features
-sufficient registers

processes use fules => logical storage unit
kernel file system
– where, how to find and access file
– os specifies interface
generic block layer
– os standardized block interface
device driver

// ...
int fd;
unsigned long numblocks = 0;

fd = open(argv[1], 0_RDONLY);
ioctl(fd, BLKGETSIZE, &numblocks);
close(fd);
// ...