Presentation is loading. Please wait.

Presentation is loading. Please wait.

§4.4 Input and Output Devices Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario,

Similar presentations


Presentation on theme: "§4.4 Input and Output Devices Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario,"— Presentation transcript:

1 §4.4 Input and Output Devices Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada ece.uwaterloo.ca © 2012 by Douglas Wilhelm Harder. Some rights reserved. Based in part on Gary Nutt, Operating Systems, 3 rd ed.

2 Outline This topic looks at input and output devices –I/O Devices Categories –Device controllers –Direct Memory Access –Memory-mapped I/O I/O Devices 2

3 I/O devices communicate with a CPU through the system bus –Input devices signal the CPU that it is ready to transmit data The CPU retrieves and deals with that data Often the data is from registers into main memory –Similarly, the CPU can signal that it has data ready to transmit to output devices Devices retrieve the data Again, often the data that is being transmitted had to be copied from main memory into registers before it was sent on I/O Devices 3

4 4 Input keyboard mouse touch-sensitive screen microphone Output terminal graphical speaker printer Storage hard drives USB drives CD ROM Communication serial and parallel ports network cards (including wireless) infrared transmitter/receivers User: Bilby

5 I/O Devices Internal devices are connected directly to Communications connections usually pass through some port: –Ethernet –USB –Firewire (IEEE 1394) and thunderbolt –VGA and DVI –SCSI –Parallel, PS/2, Serial and TRS 5 I/O Devices

6 More and more common these days is to see devices with a network connection (wireless or landline) –Significantly greater costs –Significantly greater flexibility Its useful that were moving from IPv4 to IPv6 soon –2 32 IP addresses arent enough –IPv6 allows for IP addresses Again, the cost of quadrupling the IP address size is insignificant to the increase in hardware I/O Devices 6

7 Each device has a controller that connects it to the CPU via the system bus –Each controller provides the standard interface Most data buses today are either 32-bit or 64-bit –This means four or eight bytes can be loaded or read at once –The size of the data bus describes the length of a word I/O Devices 7

8 Device Controllers Applications communicate through a common interface presented by the device driver –The driver communicates with a device controller –The controller is doubly hardware dependent I/O Devices 8

9 Device Controllers Most device controllers will have hardware implementations for basic functionality –The controller must interface with the interface between devices –Examples: PSI Express I/O Devices 9

10 Device Controllers Each controller will have registers including: –A command register What the device should do next –Data registers Information passed to or copied from the device –Status register The current state of the device I/O Devices 10

11 Device Controllers Often, two flags within the command register are often busy and done –When both are 0 (false), data can be copied to the registers and a command can be sent to the device –A new command sets the busy flag to 1 : the device now either reads from or writes to the data registers –When the command is complete, the done flag is set to 1 and the busy flag is reset to 0 –If both are 1, the state is intermediate I/O Devices 11

12 Device Controllers If an unrecoverable error occurs during the command, an error code will be copied to a different part of the status register I/O Devices 12

13 Device Controllers Another common feature is a buffer –The CPU can continue reading data from an internal buffer while the controller is busy with the next command I/O Devices 13

14 Direct Memory Access Another common issue is copying data between a device and main memory –By default, all data must be copied through the CPU –This can be exceptionally expensive I/O Devices 14

15 Direct Memory Access Direct Memory Access (DMA) allows for direct transfer between a device and main memory –The device driver provides an address in main memory –The DMA controller facilitates the copy data to or from starting at this memory location –The CPU can now work in parallel so long as the system bus is not required I/O Devices 15

16 Memory-Mapped I/O Instructions for communicating with devices could be through CPU instructions –Copy status register to the CPU data register testCPU_register, device_address –Send commands to the command register inputdevice_address outputdevice_address –Copy values between data registers copy_inCPU_register, device_address, controller_register copy_outCPU_register, device_address, controller_register I/O Devices 16

17 Memory-Mapped I/O An alternate model is to explicitly associate specific memory locations with each device –Each register is associated with a memory location –Writes to those memory locations copies to the data to the corresponding –Changes to registers are copied to main memory Benefits: –This allows a smaller instruction set –Address registers can address device registers I/O Devices 17

18 Memory-Mapped I/O Consider the original MS DOS –It dedicated the top 384 KiB of memory available to an 8088 to system memory including memory-mapped I/O –In this case, the mapping is permanent I/O Devices 18

19 Summary This topic looks at input and output devices –I/O Devices Input, output, storage, communication –Device controllers –Direct Memory Access –Memory-mapped I/O I/O Devices 19


Download ppt "§4.4 Input and Output Devices Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario,"

Similar presentations


Ads by Google