In r0, 0x102 #Say 102 is a status resisterītbz r0, 7, _check_data #Test if bit7 of r0 is set, if not jump back If instead the IO is polling then the software must check periodically _check_data: #Done, myISR is called whenever new data arrives Out 0x100, r0 #Set bit7 to enable generation of interrupt If the device has just a status register that the software must periodically check, the type of IO is said polling IO.įor example to check if an UART has new data a software can use an interrupt #Setup isr If the device use an interrupt to notify the CPU of an event, the type of IO is said interrupt driven IO. The completion of an operation and the arrival of new data are two example of event that the software may want to be notified about. #Done, the software can do something else Movi r0, $0x21 #r0 = 0x21 (say it's READ_DMA_SECTORS command) With DMA the same read could be performed as #Setup read parameters omitted Movi r1, 512 / 4 #r1 = number of words in a sectorĭecbnz r1, _read #Decrement r1 and branch back if not zero Out 0x102, r0 #Tell the device to start reading Movi r0, $0x20 #r0 = 0x20 (say it's READ_SECTORS command) If the device can be told to initiate an operation and transfer the data to memory autonomously then the type of IO is Direct Memory Access IO.įor example to read a sector, say 512 bytes, from a disk the software could #Setup read parameters omitted If the software is forced to read each byte/word of data explicitly then the type of IO is programmed IO. This also applies to writing data into a device. Note that the ld type of instruction is the same used to access memory, so for example ld r1, 0x1000 could access memory instead of a device. In the example above the two addresses 0x34 generate two different bus addresses that are then handled differently. Ld r0, 0x34 #Read address 0x34 from memory address space in r0, 0x34 #Read address 0x34 from IO address space If the device is accessible as part of an unique address space, where memory is also located, then the type of IO is called memory-mapped IO.įor example some embedded controller and some mainstream architecture have special instructions to access the IO address space. If the device is accessible in a dedicated address space, separate from the address space or memory, then the type of IO is called port-mapped IO or isolated IO. Those terms are mostly independent and not mutually exclusive.īelow I'll use a pseudo-assembly code to make the examples clearer, it is a demonstrative code, not real code.
0 Comments
Leave a Reply. |