aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gud/MobiCoreKernelApi/device.h
blob: c348eb5cfc69f14a5fe1b868141d9b4a5d1a2eb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/** @addtogroup MCD_IMPL_LIB
 * @{
 * @file
 *
 * Client library device management.
 *
 * Device and Trustlet Session management Functions.
 *
 * <!-- Copyright Giesecke & Devrient GmbH 2009 - 2011 -->
 */
#ifndef DEVICE_H_
#define DEVICE_H_

#include <linux/list.h>

#include "connection.h"
#include "session.h"
#include "wsm.h"


typedef struct {
    sessionVector_t sessionVector; /**< MobiCore Trustlet session associated with the device */
    wsmVector_t     wsmL2Vector; /**< WSM L2 Table  */

    uint32_t        deviceId; /**< Device identifier */
    connection_t    *connection; /**< The device connection */
    struct mcInstance  *pInstance; /**< MobiCore Driver instance */

    struct list_head list; /**< The list param for using the kernel lists*/
} mcore_device_t;

mcore_device_t *mcore_device_create(
    uint32_t      deviceId,
    connection_t  *connection
);

void mcore_device_cleanup(
    mcore_device_t * dev
);

/**
  * Open the device.
  * @param deviceName Name of the kernel modules device file.
  * @return true if the device has been opened successfully
  */
bool mcore_device_open(
    mcore_device_t   *dev,
    const char *deviceName
);

/**
  * Closes the device.
  */
void mcore_device_close(
    mcore_device_t *dev
);

/**
  * Check if the device has open sessions.
  * @return true if the device has one or more open sessions.
  */
bool mcore_device_hasSessions(
    mcore_device_t *dev
);

/**
  * Add a session to the device.
  * @param sessionId session ID
  * @param connection session connection
  */
bool mcore_device_createNewSession(
    mcore_device_t      *dev,
    uint32_t      sessionId,
    connection_t  *connection
);

/**
  * Remove the specified session from the device.
  * The session object will be destroyed and all resources associated with it will be freed.
  *
  * @param sessionId Session of the session to remove.
  * @return true if a session has been found and removed.
  */
bool mcore_device_removeSession(
    mcore_device_t *dev,
    uint32_t sessionId
);

/**
  * Get as session object for a given session ID.
  * @param sessionId Identified of a previously opened session.
  * @return Session object if available or NULL if no session has been found.
  */
session_t *mcore_device_resolveSessionId(
    mcore_device_t *dev,
    uint32_t sessionId
);

/**
  * Allocate a block of contiguous WSM.
  * @param len The virtual address to be registered.
  * @return The virtual address of the allocated memory or NULL if no memory is available.
  */
wsm_ptr mcore_device_allocateContiguousWsm(
    mcore_device_t *dev,
    uint32_t len
);

/**
  * Unregister a vaddr from a device.
  * @param vaddr The virtual address to be registered.
  * @param paddr The physical address to be registered.
  */
bool mcore_device_freeContiguousWsm(
    mcore_device_t  *dev,
    wsm_ptr   pWsm
);

/**
  * Get a WSM object for a given virtual address.
  * @param vaddr The virtual address which has been allocate with mcMallocWsm() in advance.
  * @return the WSM object or NULL if no address has been found.
  */
wsm_ptr mcore_device_findContiguousWsm(
    mcore_device_t *dev,
    addr_t   virtAddr
);

#endif /* DEVICE_H_ */

/** @} */