Home | History | Annotate | Download | only in Generic
      1 /** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
      2  * @{
      3  * @file
      4  *
      5  * MobiCore Driver Kernel Module Interface.
      6  *
      7  * <!-- Copyright Giesecke & Devrient GmbH 2009 - 2012 -->
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. The name of the author may not be used to endorse or promote
     18  *    products derived from this software without specific prior
     19  *    written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     22  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     27  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 #ifndef CMCKMOD_H_
     34 #define CMCKMOD_H_
     35 
     36 #include <stdint.h>
     37 
     38 #include "McTypes.h"
     39 #include "CKMod.h"
     40 
     41 
     42 /**
     43  * As this is also used by the ClientLib, we do not use exceptions.
     44  */
     45 class CMcKMod : public CKMod
     46 {
     47 public:
     48     /**
     49     * Map data.
     50     *
     51     * @param len
     52     * @param pHandle
     53     * @param pVirtAddr
     54     * @param pPhysAddr
     55     *
     56     * @return 0 if all went fine
     57     * @return MC_DRV_ERR_KMOD_NOT_OPEN
     58     * @return MC_DRV_ERR_KERNEL_MODULE or'ed with errno<<16
     59     */
     60     mcResult_t mapWsm(uint32_t  len,
     61                       uint32_t    *pHandle,
     62                       addr_t      *pVirtAddr,
     63                       addr_t      *pPhysAddr);
     64     /**
     65     * Map data.
     66     *
     67     * @param len
     68     * @param pHandle
     69     * @param pVirtAddr
     70     * @param pPhysAddr
     71     * @param pMciReuse [in|out] set to true [in] for reusing MCI buffer
     72     *                 is set to true [out] if MCI buffer has been reused
     73     * @return 0 if all went fine
     74     * @return MC_DRV_ERR_KMOD_NOT_OPEN
     75     * @return MC_DRV_ERR_KERNEL_MODULE or'ed with errno<<16
     76     */
     77     mcResult_t mapMCI(
     78         uint32_t    len,
     79         uint32_t    *pHandle,
     80         addr_t      *pVirtAddr,
     81         addr_t      *pPhysAddr,
     82         bool        *pReuse);
     83 
     84     /**
     85     * Map persistent WSM which will not be freed up once the calling process dies.
     86     */
     87     mcResult_t mapPersistent(
     88         uint32_t    len,
     89         uint32_t    *pHandle,
     90         addr_t      *pVirtAddr,
     91         addr_t      *pPhysAddr);
     92 
     93     int read(addr_t buffer, uint32_t len);
     94 
     95     bool waitSSIQ(uint32_t *pCnt);
     96 
     97     int fcInit(uint32_t nqOffset,
     98                uint32_t    nqLength,
     99                uint32_t    mcpOffset,
    100                uint32_t    mcpLength);
    101 
    102     int fcInfo(
    103         uint32_t    extInfoId,
    104         uint32_t    *pState,
    105         uint32_t    *pExtInfo);
    106 
    107     int fcYield(void);
    108 
    109     int fcNSIQ(void);
    110 
    111     mcResult_t free(uint32_t handle, addr_t buffer, uint32_t len);
    112 
    113     mcResult_t registerWsmL2(
    114         addr_t      buffer,
    115         uint32_t    len,
    116         uint32_t    pid,
    117         uint32_t    *pHandle,
    118         addr_t      *pPhysWsmL2);
    119 
    120     mcResult_t unregisterWsmL2(uint32_t handle);
    121 
    122     mcResult_t lockWsmL2(uint32_t handle);
    123 
    124     mcResult_t unlockWsmL2(uint32_t handle);
    125 
    126     mcResult_t cleanupWsmL2(void);
    127 
    128     addr_t findWsmL2(uint32_t handle);
    129 
    130     mcResult_t findContiguousWsm(uint32_t handle, addr_t *phys, uint32_t *len);
    131 
    132     /**
    133     * Tell stub to start MobiCore from given physical address
    134     */
    135     int fcExecute(addr_t startAddr, uint32_t areaLength);
    136 
    137     bool checkVersion(void);
    138 };
    139 
    140 typedef CMcKMod  *CMcKMod_ptr;
    141 
    142 #endif // CMCKMOD_H_
    143