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

📄 oem_func.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
字号:
/* <LIC_AMD_STD> * Copyright (C) 2003-2005 Advanced Micro Devices, Inc.  All Rights Reserved. *  * Unless otherwise designated in writing, this software and any related  * documentation are the confidential proprietary information of AMD.  * THESE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY * UNLESS OTHERWISE NOTED IN WRITING, EXPRESS OR IMPLIED WARRANTY OF ANY  * KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,  * NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE AND IN NO  * EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER.  *  * AMD does not assume any responsibility for any errors which may appear  * in the Materials nor any responsibility to support or update the * Materials.  AMD retains the right to modify the Materials at any time,  * without notice, and is not obligated to provide such modified  * Materials to you. AMD is not obligated to furnish, support, or make * any further information available to you. * </LIC_AMD_STD>  *//* <CTL_AMD_STD> * </CTL_AMD_STD>  *//* <DOC_AMD_STD> * This is a security udp server which provide: *  * 1.  encoded serial number string for clients. * 2.  consistency checks for serial number files * 3.  hostid consistency check * 4.  obfuscate client serial number file access * 5.  recovers damaged serial number files *  * In some ways this is just a glorified file read. * </DOC_AMD_STD>  */#define  NEED_FILES#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/resource.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/ioctl.h>#include "base64.h"#include "secure_serial.h"#include "secure_serial_priv.h"#include "sfiles.h"#include "oemkeys.h"#include "linux/nvram.h"int                  nvramfd=-1;/*//------------------------------------------------------------------------------------------Attention OEM:This file contains an working example API.There is three OEM fucntion which OEMs can customize to meet the requirements andneeds of their enviroment.1.  oemSecurityAlertCB - This is a callback which will be invoked when an error occursand in some cases to report success.2.  oemGetSerialNum - This function is called by secserv to retrieve ther PMP serial number.The provided code implements the signed serial number files and symlinks.  This functioncan be replaced with OEM supplied fuction.3.  oemSerialCheck any checks to insure the integrity of the system.  The suppliedroute rewrites the signed serial number files and symlinks.Suggestions:  If you have an firmware solution for serial number, then have thesecserv sign the files.  Then compare to make sure there is no tampering has taken place.//------------------------------------------------------------------------------------------*/int oemOpenNVRam(){  nvramfd = open("/dev/nvram",O_RDONLY);  if (nvramfd < 0)    {      return(SERIAL_NVRAM_OPEN);    }  return(SERIAL_STATUS_OK);}  // oem_securityAlert callback function.  This callback is called by the secserv when// an security error occurs.void oemSecurityAlertCB(int alertCode, char *msg){  if (SEC_ALERT_OK == alertCode)    return;  if (NULL == msg )    fprintf(stderr,"OEM needs to put correct security alert action %d\n",alertCode);  else    fprintf(stderr,"OEM needs to put correct security alert action %d [%s]\n",            alertCode,msg);}//// OEM function to return model number of the//char * oemGetModelStr(int *error_code){  int rc;    static char modelStr[MODEL_ID_SIZE+1];  memset(modelStr,MODEL_ID_SIZE+1,0);    rc = ioctl(nvramfd,NVRAM_GET_MODEL_ID,modelStr);  if (rc < 0)  {    *error_code = SERIAL_IOCTL_ERROR;    fprintf(stderr,"Model Id String Error\n");    return("Model Id String Error");  }    *error_code = SERIAL_STATUS_OK;  return(modelStr);  }//// OEM function to write DivX dataint oemWriteDivxData(char *data){  int rc;  rc = ioctl(nvramfd,NVRAM_SET_DIVX_DATA,data);  return(rc);  }//// OEM function to read DivX dataint oemReadDivxData(char *data){  int rc;  memset(data,DIVX_STORE_SIZE,0);  rc = ioctl(nvramfd,NVRAM_GET_DIVX_DATA,data);  return(rc);}//// return Manufacturer String for the device//char *oemGetManufStr(int *errorCode){  int rc;    static char manufStr[MODEL_ID_SIZE+1];  memset(manufStr,MANUF_SIZE+1,0);  rc = ioctl(nvramfd,NVRAM_GET_MANUFACTURER,manufStr);  if (rc < 0)  {    *errorCode = SERIAL_IOCTL_ERROR;        printf("Manufacturer String Error\n");    return("Manufacturer String Error");  }    *errorCode = SERIAL_STATUS_OK;  return(manufStr);  }// OEM function to aquire serial number of the PMP device.//// This function must return a unique serial number of the device ranging between 20-32 characters// char *oemGetSerialNum(int *errorCode){  int rc;    static char serialNum[SERIAL_NUM_SIZE+1];  serialNum[SERIAL_NUM_SIZE]='\0';  rc = ioctl(nvramfd,NVRAM_GET_SERIAL,serialNum);  if (rc < 0)  {    *errorCode = SERIAL_IOCTL_ERROR;    perror("Invalid-Serial-Number\n");    return("Invalid-Serial-Number");  }    *errorCode = SERIAL_STATUS_OK;	return(serialNum);}

⌨️ 快捷键说明

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