⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dvd_ctl_pc.c

📁 wince host 和 target PCI驱动程序
💻 C
字号:
/*
 *  +-------------------------------------------------------------------+
 *  | Copyright (c) 1995,1996,1997 by Philips Semiconductors.           |
 *  |                                                                   |
 *  | This software  is furnished under a license  and may only be used |
 *  | and copied in accordance with the terms  and conditions of such a |
 *  | license  and with  the inclusion of this  copyright notice.  This |
 *  | software or any other copies of this software may not be provided |
 *  | or otherwise  made available  to any other person.  The ownership |
 *  | and title of this software is not transferred.                    |
 *  |                                                                   |
 *  | The information  in this software  is subject  to change  without |
 *  | any  prior notice  and should not be construed as a commitment by |
 *  | Philips Semiconductors.                                           |
 *  |                                                                   |
 *  | This  code  and  information  is  provided  "as is"  without  any |
 *  | warranty of any kind,  either expressed or implied, including but |
 *  | not limited  to the implied warranties  of merchantability and/or |
 *  | fitness for any particular purpose.                               |
 *  +-------------------------------------------------------------------+
 *
 *
 *  Module name              : DVD_Ctl_PC.c    1.1
 *
 *  Last update              : 11:47:14 - 98/11/06
 *
 *  Description              : (Authentication) Interface to DVD
 * 	
 */

/*----------------------------- includes ------------------------------------*/

#include "DVD_Interface.h"
#include "DVD_Ctl.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
 
/*------------------------- module state -------------------------------------*/
 
static DVDCtl_Command  state= DVDCtl_None;
static Int             the_drive;

/*------------------------- functions ----------------------------------------*/
 


static void print( String p, UInt8 *data, Int size )
{
    Int i;

    printf("%s : ", p);
    for (i=0; i<size; i++) { printf( " %02x", data[i] ); }
    printf("\n");
}




int dvdRead( Byte *buffer, Int size )
{
/* printf("dvdRead : state %d\n", state ); */

    switch (state) {
    case DVDCtl_PutOpenDrive:
              buffer[2] = dvdIntOpenDrive(&the_drive);
              buffer[1] = the_drive;
              buffer[0] = DVDCtl_GetOpenDrive;
              state     = DVDCtl_GetOpenDrive;
              return 3;

    case DVDCtl_PutDrvChallenge:
              buffer[1] = the_drive;
              buffer[0] = DVDCtl_GetDrvResponse;
              state     = DVDCtl_GetDrvResponse;
              if (dvdIntGetDrvResponse( the_drive, &buffer[2] )) {
                  return -1;
              } else {
                  return 7;
              }

    case DVDCtl_GetDrvResponse:
              buffer[1] = the_drive;
              buffer[0] = DVDCtl_GetDecChallenge;
              state     = DVDCtl_GetDecChallenge;
              if (dvdIntGetDecChallenge( the_drive, &buffer[2] )) {
                  return -1;
              } else {
                  return 12;
              }

    case DVDCtl_GetBedk:
              buffer[1] = the_drive;
              buffer[0] = DVDCtl_GetBedk;
              if (dvdIntGetEncDiscKey( the_drive, &buffer[2] )) {
                  return -1;
              } else {
                  return 2047;
              }

    case DVDCtl_GetBetk:
              buffer[1] = the_drive;
              buffer[0] = DVDCtl_GetBetk;
              if (dvdIntGetEncTitleKey( the_drive, &buffer[2] )) {
                  return -1;
              } else {
                  return 7;
              }

    default: assert(False);
    }
}





int dvdWrite( Byte *buffer, Int size)
{
    state= buffer[0];

/* printf("dvdWrite : state %d\n", state ); */

    switch (state) {
    case DVDCtl_PutOpenDrive:
    case DVDCtl_GetBedk:
    case DVDCtl_GetBetk:
              return 1;

    case DVDCtl_PutCloseDrive:
              dvdIntCloseDrive( the_drive );
              return 2;

    case DVDCtl_PutDrvChallenge:
              if (dvdIntPutDrvChallenge( the_drive, &buffer[2] )) {
                  return -1;
              } else {
                  return 12;
              }

    case DVDCtl_PutDecResponse:
              if (dvdIntPutDecResponse( the_drive, &buffer[2] )) {
                  return -1;
              } else {
                  return 7;
              }

    default: assert(False);
    }
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -