SCO OpenServer


can_doio -- determine if current processor can do device I/O


#include <sys/ci/cidriver.h>

int can_doio(int bustype);


The can_doio routine determines if the current processor on a specified bus can perform device I/O.

Typically this routine is called from a driver strategy routine.


Possible values for bustype are defined in <sys/ci/cidriver.h>.

Return values

Zero (0) is returned if the current processor cannot do I/O to or from a device on the specified bus.

1 is returned if a processor can do I/O to or from a device on the specified bus.

1 will also be returned if only one processor is present in the system.


Context and synchronization

All contexts.

Hardware applicability

This function was created to support hardware that cannot access all supported busses. Current hardware does not have this limitation.

Version applicability

oddi: 2mp, 3mp, 4mp, 5mp, 6, 6mp

Future directions

Support for this function may be dropped in a future release.

SVR5 DDI compatibility

This function is not supported for DDI drivers.


disksort(D3oddi), intralloc(D3oddi), lockb(D3oddi), spl(D3oddi), splx(D3oddi), startio(D3oddi), unlockb(D3oddi)


The following example shows how can_doio is called from a driver strategy routine in line 4:
    1           s = lockb(&lock_xxtab);
    2           disksort(&xxtab, bp);
    3           if (xxtab.b_active == 0) {
    4                   if (can_doio(MP_ATBUS))
    5                           xxstart(xxstart_arg);
    6                   else {
    7                           unlockb(&lock_xxtab, -1);
    8                           startio(xxhandle, xxstart_arg);
    9                   }
   10                   splx(s);
   11           }
   12           else {
   13                   unlockb(&lock_xxtab, s);
   14                   return;
   15           }
In line 2, disksort(D3oddi) is called to sort and queue block driver I/O requests. Line 3 uses the b_active flag in the xxtab structure to determine if the driver is performing I/O. This flag is set in the driver's xxstart routine to indicate that it is active. If the processor is performing I/O, then the critical code section is unlocked in line 13, and the routine exits.

If the driver is not already performing I/O, can_doio is called in line 4 to see if the current processor can access the I/O bus. If it can, the xxstart routine is called directly in line 5. If access to the I/O bus from the current processor is not possible, the critical code section is unlocked in line 7. The ``-1'' argument to unlockb(D3oddi) indicates that the old spl value is not immediately restored: splx(D3oddi) is called by the driver after the call to unlockb, in line 10. Then startio(D3oddi) is called in line 8 to interrupt the processor that can access the I/O bus to run the xxstart routine. The first argument to the startio routine is the handle address returned from a previous call to intralloc(D3oddi). The second argument is that passed to the xxstart routine.

19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005