Operating Systems Memory-Mapped 1/0 c Each controller has a few registers that are used for communication with cpu g Write into these registers os can command the device to deliver data accept data, switch itselfon or off, or otherwise perform some action G Read from these registers: OS can learn what the devices state is whether it is prepared to accept a new command, and so on c In addition to the control registers, many devices have a data buffer that the os can read and write(e.g video ram) c Q: How the CPU communicates with the control registers and the device data buffer? Gao Haichang, Software School, Xidian University
Operating Systems Gao Haichang , Software School, Xidian University 8 Memory-Mapped I/O Each controller has a few registers that are used for communication with CPU. Write into these registers: OS can command the device to deliver data, accept data, switch itself on or off, or otherwise perform some action. Read from these registers: OS can learn what the device’s state is, whether it is prepared to accept a new command, and so on. In addition to the control registers, many devices have a data buffer that the OS can read and write (e.g. video RAM). Q: How the CPU communicates with the control registers and the device data buffer?
Operating Systems Memory-Mapped 1/0(2) Two address One address space Two address spaces OxFFFF Memory 1O ports 0 (a) (a)Separate 1o and memory space(IBM360) w Each control register is assigned an lo port number H Address spaces for memory and 1/O are different (b)Memory-mapped l/o(PDP-11) w Map all the control registers into the memory space H Each control register is assigned a unique memory address to which no memory is assigned (c) Hybrid(Pentium) H Memory-mapped 1/O data buffers, separate IO ports for the control registers
Operating Systems Gao Haichang , Software School, Xidian University 9 Memory-Mapped I/O (2) (a) Separate I/O and memory space (IBM 360) Each control register is assigned an I/O port number. Address spaces for memory and I/O are different (b) Memory-mapped I/O (PDP-11) Map all the control registers into the memory space. Each control register is assigned a unique memory address to which no memory is assigned. (c) Hybrid (Pentium) Memory-mapped I/O data buffers , separate I/O ports for the control registers
Operating Systems Memory-Mapped 1/0 Advantages G With memory-mapped 1O, a lo device driver can be written entirely in C. Otherwise, some assembly code is needed No special protection mechanism is needed to keep user processes from performing 10. G Every instructions that can reference memory can also reference control registers. Gao Haichang, Software School, Xidian University 10
Operating Systems Gao Haichang , Software School, Xidian University 10 Memory-Mapped I/O Advantages With memory-mapped I/O, a I/O device driver can be written entirely in C. Otherwise, some assembly code is needed. No special protection mechanism is needed to keep user processes from performing I/O. Every instructions that can reference memory can also reference control registers
Operating Systems Memory-Mapped 1/0 Disadvantages e Most computers nowadays have some form of caching of memory words. Caching a device control register would be disastrous(blind to device ready) Selective disable caching adds extra complexity. G If there is only one address space then all memory modules and all lo devices must examine all memory references to see which ones to response to. Most modern computers have a dedicated high-speed memory bus, so O device have no way of seeing memory addresses as they go by on the memory bus. Gao Haichang, Software School, Xidian University
Operating Systems Gao Haichang , Software School, Xidian University 11 Memory-Mapped I/O Disadvantages Most computers nowadays have some form of caching of memory words. Caching a device control register would be disastrous (blind to device ready). Selective disable caching adds extra complexity. If there is only one address space, then all memory modules and all I/O devices must examine all memory references to see which ones to response to. Most modern computers have a dedicated high-speed memory bus, so I/O device have no way of seeing memory addresses as they go by on the memory bus
Operating Systems Memory-Mapped 1/0 Disadvantages CPU reads and writes of memory go over this high-bandwidth bus CPU Memory CPU Memory O All addresses( memory This memory port is to allow l/o devices and / o)go here Bu access to memory (a)a single-bus architecture (b )a dual-bus memory architecture Gao Haichang, Software School, Xidian University 12
Operating Systems Gao Haichang , Software School, Xidian University 12 Memory-Mapped I/O Disadvantages (a) A single-bus architecture (b) A dual-bus memory architecture