home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cdrom.zip / DDK / BASE / SRC / DEV / DASD / CDROM / OS2CDROM / cdnec.c < prev    next >
C/C++ Source or Header  |  1996-06-18  |  5KB  |  129 lines

  1. /*static char *SCCSID = "@(#)cdnec.c  6.17 92/05/04";*/
  2. #define SCCSID  "@(#)cdnec.c  6.17 92/05/04"
  3.  
  4. /************************************************************************/
  5. /*                                                                      */
  6. /* Driver Name: OS2CDROM.DMD - OS/2 CD-ROM Device Manager               */
  7. /*              -----------------------------------------               */
  8. /*                                                                      */
  9. /* Source File Name: CDNEC.C                                            */
  10. /*                                                                      */
  11. /* Descriptive Name: Vendor unique command processing for NEC           */
  12. /*                   SCSI-2 CD-ROM Drives                               */
  13. /*                                                                      */
  14. /* Function:                                                            */
  15. /*                                                                      */
  16. /*                                                                      */
  17. /*----------------------------------------------------------------------*/
  18. /*                                                                      */
  19. /* Copyright (C) 1992 IBM Corporation                                   */
  20. /*                                                                      */
  21. /* DISCLAIMER OF WARRANTIES.  The following [enclosed] code is          */
  22. /* provided to you solely for the purpose of assisting you in           */
  23. /* the development of your applications. The code is provided           */
  24. /* "AS IS", without warranty of any kind. IBM shall not be liable       */
  25. /* for any damages arising out of your use of this code, even if        */
  26. /* they have been advised of the possibility of such damages.           */
  27. /*                                                                      */
  28. /*----------------------------------------------------------------------*/
  29. /*                                                                      */
  30. /* Change Log                                                           */
  31. /*                                                                      */
  32. /* Mark    Date      Programmer  Comment                                */
  33. /* ----    ----      ----------  -------                                */
  34. /* @nnnn   mm/dd/yy  NNN                                                */
  35. /*                                                                      */
  36. /*                                                                      */
  37. /************************************************************************/
  38.  
  39. #include "cdh.h"
  40. #include "necdb.h"
  41.  
  42.  
  43. /*------------------------------------------------------------------------
  44. ;
  45. ;** NEC_GetLastSessionAddr - Get address of last session on multisession
  46. ;                            disk
  47. ;
  48. ;   This routine returns the address of the last session of a multisession
  49. ;   photo CD disk.
  50. ;
  51. ;   USHORT NEC_GetLastSessionAddr(NPUNITCB pUnitCB, ULONG FAR * session_addr)
  52. ;
  53. ;   ENTRY:    pUnitCB          - Pointer to UnitCB
  54. ;             session_addr     - Pointer to returned session addr
  55. ;
  56. ;   RETURN:   USHORT           - Packet status word
  57. ;
  58. ;                                if the STERR bit is on, then the disk
  59. ;                                  is not a multisession disk and the
  60. ;                                  session_addr field is not valid
  61. ;
  62. ;                                if the STERR bit is NOT set, then the
  63. ;                                  disk is a multi-session disk and the
  64. ;                                  session addr field is valid
  65. ;
  66. ;
  67. ;   EFFECTS:
  68. ;
  69. ------------------------------------------------------------------------*/
  70. USHORT NEC_GetLastSessionAddr (pUnitCB, session_addr)
  71.  
  72. NPUNITCB pUnitCB;
  73. ULONG    FAR *session_addr;
  74.  
  75. {
  76.    USHORT rc;
  77.    NPIORB_CDB pIORB;
  78.    NEC_DATA_PointInfo NEAR *pCDBData;
  79.    union AddressType ul_LBA;
  80.    ULONG LBA;
  81.  
  82.    NEC_BuildCDB_GetLastSession (pUnitCB, (NPIORB_CDB FAR *) &pIORB);
  83.  
  84.    pCDBData = (NEC_DATA_PointInfo NEAR *) pIORB->CDB_data;
  85.  
  86.    rc = SubmitIORB_Wait(pUnitCB, pIORB);
  87.  
  88.    if (rc == STDON)
  89.    {
  90.  
  91.       rc = STDON + STERR;
  92.  
  93.       /* If type photo CD in both point entries, and address of last */
  94.       /* session not zero, then multisession disc.                   */
  95.  
  96.       if ( (pCDBData->point_data[0].control == NEC_PHOTO_CD) &&
  97.            (pCDBData->point_data[1].control == NEC_PHOTO_CD) )
  98.       {
  99.           if ( (pCDBData->point_data[1].imin != 0)  ||
  100.                (pCDBData->point_data[1].isec != 0)  ||
  101.                (pCDBData->point_data[1].iframe != 0) )
  102.           {
  103.              ul_LBA.ul_redbook.frame =
  104.                                   BCDtoBinary(pCDBData->point_data[1].iframe);
  105.              ul_LBA.ul_redbook.sec =
  106.                                   BCDtoBinary(pCDBData->point_data[1].isec);
  107.              ul_LBA.ul_redbook.min =
  108.                                   BCDtoBinary(pCDBData->point_data[1].imin);
  109.              ul_LBA.ul_redbook.zero = 0;
  110.  
  111.              LBA = (RedBookToHSG (ul_LBA.dword) ) + 150;
  112.  
  113.              *session_addr = LBA;
  114.  
  115.              rc = STDON;
  116.           }
  117.       }
  118.  
  119.    }
  120.    FreeIORB (pUnitCB, pIORB);
  121.    return (rc);
  122. }
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.