Sample Pseudo-code for the ISA worker drivers

The example in this section shows a sample pseudo-code for the ISA worker drivers.


dd_initialization:

               determine bus type for device from configuration information
               call "handle = D_MAP_INIT(bid, DMA_SLAVE, bus_flags, channel)"
               if handle == DMA_FAIL
                              could not configure
               else
                              call "D_MAP_ENABLE(handle)" (if necessary)

dd_start_io:

               create dio list of virtual addresses involved in transfer
               call "result = D_MAP_SLAVE(handle, flags, minxfer, vlist, 
chan_flags)"
               if result == DMA_NORES
                       not enough resource, either initiate partial transfer
                       and leave remainder on queue or leave entire request
                       on the queue and call d_unmap_slave to unmap the
                              partial transfer.
               else if result == DMA_NOACC
                              use bytes_done to pinpoint failing buffer and
                              fail corresponding request
                              adjust virtual list and call d_map_slave again
               else
                              program device to initiate transfer

dd_finish_io:

               call "error = D_UNMAP_SLAVE(handle)"
               if error
                              log 
                              retry, or fail

dd_unconfigure:

               call "D_MAP_DISABLE(handle)" (if necessary)
               call "D_MAP_CLEAR(handle)"