DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SCO OpenServer

open(D2osdi)


open -- gain access to a device

Synopsis

See open(D2oddi) for synopsis, arguments, return values, and context.

Usage

SCSI peripheral driver

The open( ) routine in a SCSI peripheral driver opens the device for access and performs interrupt-driven initialization if required. The logic is as follows:

  1. Extract the Logical Unit Number (LUN) from the minor device number. If the device is not configured, use the cmn_err(D3oddi) function to issue an error message, set u.u_error to ENXIO, and return.

  2. Call scsi_getdev(D3osdi) to get device information from the SCSI configuration table. If information is not found, use the cmn_err(D3oddi) function to issue an error message, set u.u_error to ENODEV, and return.

  3. Verify that the device is configured by issuing a test command. In the sample driver, this command is coded in the Sflp_test_ready( ) subroutine. If all tests pass, issue the cdistributed(D3oddi) and/or bdistributed(D3oddi) function to register the SCSI peripheral driver as multithreaded.

    The sample driver registers only the strategy( ), read( ), and write( ) routines as multithreaded. Allowing other routines to run only on the base CPU does not significantly impact performance and simplifies multithreading from I/O assymetrical multiprocessor systems where some CPUs cannot access the I/O bus.

    If the test fails, wake up each device served by your driver by sending a command. The sample driver does this in its Sflpopen_exit( ) routine.

  4. Perform any additional setup tasks. For example, the sample SCSI peripheral driver sets up disk-specific information required by the diskinfo structure and other standard disk driver structures.

  5. Issue the printcfg(D3oddi) function tp display configuration information for the device. In particular, the name of the driver must be adapter, and the type of the driver must be the internal name as specified in column 1 of the mdevice(F) file. For example, the following call to printcfg(D3oddi) sets name=adapter and type=dpt:
       printcfg("adapter",base,end,vec,dma,"type=dpt");
    
    The output from this call will be similar to:
       adapter 0x5C80-0x5C90 14 - type=dpt
    
    See the sample driver to see how this information is gathered throughout the Sflpopen( ) routine.

  6. Exit the routine by releasing the last request block, turning off the flag to indicate that you are opening the device, and then calling splx(D3oddi) to restore any previously set interrupts.

Context and synchronization

context

Hardware applicability

All

Version applicability

osdi: 1, 2, 3, 4, 5 SCSI host adapter and peripheral drivers.

Differences between versions

External dependencies

Drivers that contain a open( ) routine must have a o in the second column of the mdevice(F) file.

References

close(D2osdi), close(S) open(S)

``OSDI SCSI driver interface version for SCO OpenServer 5'' in HDK Technical Reference


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