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

📄 sec2_ioctl.c

📁 freescale ppc sec2加解密单元驱动
💻 C
字号:
/**************************************************************************** * sec2_ioctl.c - Driver service hooks for the SEC2.x security core **************************************************************************** * Copyright (c) Certicom Corp. 1996-2002.  All rights reserved * Copyright (c) 2003-2005 Freescale Semiconductor * All Rights Reserved. Proprietary and Confidential. * * NOTICE: The information contained in this file is proprietary * to Freescale Semiconductor, and is being made available to * Freescale's customers under strict license agreements. * Use or disclosure of this information is permissible only * under the terms of the existing license agreement. ***************************************************************************//* Revision History: * 1.0   Aug 24,2003 dgs - adapted from the final version of mpc18x * 1.1.0 Nov 22,2003 sec - merge in changes from Linux fork * 1.1.1 Dev 15,2004 sec - remove old diagnostics * 1.2   Jan 27,2005 sec - fix minor compiler warnings */#include "sec2_const.h"#include "Sec2Driver.h"#if 0#ifdef __KERNEL__int SEC2Open(struct inode *nd, struct file *fil){    SEC2Dump(DBGTXT_SETRQ, ("SEC2Open() called, inode 0x%08x, file 0x%08x\n", (unsigned int)nd, (unsigned int)fil));        MOD_INC_USE_COUNT;    return 0;}#endif#ifdef VXWORKSint SEC2Open(DEV_HDR *pDevHdr, int mode, int flags){    return((int)pDevHdr);}#endif#ifdef __KERNEL__int SEC2Close(struct inode *nd, struct file *fil)#elseint SEC2Close(int devDesc)#endif{    int     channel;    QUEUE_ENTRY *QueueEntry;    int     callingTaskId = (int)taskIdSelf();    SEC2Dump(DBGTXT_SETRQ, ("SEC2Close() called\n"));    QueueEntry = sec2_ProcessQueueTop;    while (QueueEntry->pReq != NULL)    {        if (QueueEntry->requestingTaskId == callingTaskId)        {            ((GENERIC_REQ*)QueueEntry->pReq)->status = SEC2_CANCELLED_REQUEST;            QueueEntry->pReq =  (GENERIC_REQ *)NULL; /*20060920*/        }        QueueEntry = QueueEntry->next;    }    IOLockChannelAssignment();    /* release any leftover reserved channels associated with this descriptor */    for (channel=0; channel<SEC2_NUM_CHANNELS; channel++)        if (Sec2_ChannelAssignments[channel].ownerTaskId == callingTaskId)            /* release this channel */            sec2_ReleaseChannel((unsigned long)(channel+1), callingTaskId, TRUE);    IOUnLockChannelAssignment();    Sec2_ScheduleNext();#ifdef __KERNEL__    MOD_DEC_USE_COUNT;#endif    return SEC2_SUCCESS;}#endifint SEC2_ioctl(register int ioctlCode, register void *param){    int status = 0;#ifdef __KERNEL__    MALLOC_REQ *mem;#endif    switch (ioctlCode)    {    case IOCTL_PROC_REQ:        if (param == (void *)NULL)        {            status = SEC2_INVALID_ADDRESS;            break;        }        status = Sec2_ProcessRequest((GENERIC_REQ *)param, (int)taskIdSelf());        break;    case IOCTL_GET_STATUS:        sec2_GetStatus((SEC2_STATUS_REQ *)param, (int)taskIdSelf());        break;#ifdef __KERNEL__    case IOCTL_MALLOC:        if ((((MALLOC_REQ *)param)->ptr = malloc(((MALLOC_REQ *)param)->sz)) == 0) {            status = SEC2_MALLOC_FAILED;            break;        }        memset(((MALLOC_REQ *)param)->ptr, 0, ((MALLOC_REQ *)param)->sz);        status = SEC2_SUCCESS;        break;    case IOCTL_COPYFROM:        mem = (MALLOC_REQ *)param;        mem->pid = current->pid;        copy_from_user(mem->to, mem->from, mem->sz);        status = SEC2_SUCCESS;        break;    case IOCTL_COPYTO:        mem = (MALLOC_REQ *)param;        mem->pid = current->pid;        copy_to_user(mem->to, mem->from, mem->sz);        status = SEC2_SUCCESS;        break;    case IOCTL_FREE:        free((void *)param);        break;#endif    default:        /* invalide IOCTL code, return an error */        /* need OS-specific error value here */        return (S_ioLib_UNKNOWN_REQUEST);    } /* end switch (ioctlCode) */    return (status);}

⌨️ 快捷键说明

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