FreeBSD kernel pms device code
dmtimer.c
Go to the documentation of this file.
1/*******************************************************************************
2**
3*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
4*
5*Redistribution and use in source and binary forms, with or without modification, are permitted provided
6*that the following conditions are met:
7*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8*following disclaimer.
9*2. Redistributions in binary form must reproduce the above copyright notice,
10*this list of conditions and the following disclaimer in the documentation and/or other materials provided
11*with the distribution.
12*
13*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
14*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
18*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
19*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
21
22**
23********************************************************************************/
24#include <sys/cdefs.h>
25__FBSDID("$FreeBSD$");
26#include <dev/pms/config.h>
27
31
35
36#ifdef FDS_DM
40
44
45osGLOBAL void
46dmTimerTick(dmRoot_t *dmRoot )
47{
48 DM_DBG6(("dmTimerTick: start\n"));
49
50 dmProcessTimers(dmRoot);
51
52 return;
53}
54
55osGLOBAL void
57 dmRoot_t *dmRoot,
58 dmTimerRequest_t *timerRequest
59 )
60{
61 timerRequest->timeout = 0;
62 timerRequest->timerCBFunc = agNULL;
63 timerRequest->timerData1 = agNULL;
64 timerRequest->timerData2 = agNULL;
65 timerRequest->timerData3 = agNULL;
66 DMLIST_INIT_ELEMENT((&timerRequest->timerLink));
67}
68
69osGLOBAL void
71 dmRoot_t *dmRoot,
72 dmTimerRequest_t *timerRequest,
73 bit32 timeout,
74 dmTimerCBFunc_t CBFunc,
75 void *timerData1,
76 void *timerData2,
77 void *timerData3
78 )
79{
80 timerRequest->timeout = timeout;
81 timerRequest->timerCBFunc = CBFunc;
82 timerRequest->timerData1 = timerData1;
83 timerRequest->timerData2 = timerData2;
84 timerRequest->timerData3 = timerData3;
85}
86
87osGLOBAL void
89 dmRoot_t *dmRoot,
90 dmList_t *timerListHdr,
91 dmTimerRequest_t *timerRequest
92 )
93{
95 DMLIST_ENQUEUE_AT_TAIL(&(timerRequest->timerLink), timerListHdr);
96 timerRequest->timerRunning = agTRUE;
98}
99
100osGLOBAL void
102 dmRoot_t *dmRoot,
103 dmTimerRequest_t *timerRequest
104 )
105{
107 timerRequest->timerRunning = agFALSE;
108 DMLIST_DEQUEUE_THIS(&(timerRequest->timerLink));
110}
111
112
113osGLOBAL void
115 dmRoot_t *dmRoot
116 )
117{
118 dmIntRoot_t *dmIntRoot = (dmIntRoot_t *)dmRoot->dmData;
119 dmIntContext_t *dmAllShared = (dmIntContext_t *)&dmIntRoot->dmAllShared;
120 dmTimerRequest_t *timerRequest_to_process = agNULL;
121 dmList_t *timerlist_to_process, *nexttimerlist = agNULL;
122
123
124 timerlist_to_process = &dmAllShared->timerlist;
125
126 timerlist_to_process = timerlist_to_process->flink;
127
128 while ((timerlist_to_process != agNULL) && (timerlist_to_process != &dmAllShared->timerlist))
129 {
130 nexttimerlist = timerlist_to_process->flink;
131
133 timerRequest_to_process = DMLIST_OBJECT_BASE(dmTimerRequest_t, timerLink, timerlist_to_process);
135
136 if (timerRequest_to_process == agNULL)
137 {
138 DM_DBG1(("dmProcessTimers: timerRequest_to_process is NULL! Error!!!\n"));
139 return;
140 }
141
142 timerRequest_to_process->timeout--;
143
144 if (timerRequest_to_process->timeout == 0)
145 {
147 timerRequest_to_process->timerRunning = agFALSE;
148 DMLIST_DEQUEUE_THIS(timerlist_to_process);
150 /* calling call back function */
151 (timerRequest_to_process->timerCBFunc)(dmRoot,
152 timerRequest_to_process->timerData1,
153 timerRequest_to_process->timerData2,
154 timerRequest_to_process->timerData3
155 );
156 }
157 timerlist_to_process = nexttimerlist;
158 }
159
160 return;
161}
162#endif /* FDS_ DM */
163
osGLOBAL void dmTimerTick(dmRoot_t *dmRoot)
@ DM_TIMER_LOCK
Definition: dmdefs.h:67
#define DM_DBG6(format)
Definition: dmdefs.h:129
#define DM_DBG1(format)
Definition: dmdefs.h:124
#define DMLIST_DEQUEUE_THIS(hdr)
Definition: dmlist.h:70
#define DMLIST_OBJECT_BASE(baseType, fieldName, fieldPtr)
Definition: dmlist.h:152
#define DMLIST_INIT_ELEMENT(hdr)
Definition: dmlist.h:42
#define DMLIST_ENQUEUE_AT_TAIL(toAddHdr, listHdr)
Definition: dmlist.h:56
osGLOBAL void dmKillTimer(dmRoot_t *dmRoot, dmTimerRequest_t *timerRequest)
osGLOBAL void dmSetTimerRequest(dmRoot_t *dmRoot, dmTimerRequest_t *timerRequest, bit32 timeout, dmTimerCBFunc_t CBFunc, void *timerData1, void *timerData2, void *timerData3)
osGLOBAL void dmInitTimerRequest(dmRoot_t *dmRoot, dmTimerRequest_t *timerRequest)
osGLOBAL void dmAddTimer(dmRoot_t *dmRoot, dmList_t *timerListHdr, dmTimerRequest_t *timerRequest)
osGLOBAL void dmProcessTimers(dmRoot_t *dmRoot)
__FBSDID("$FreeBSD$")
void(* dmTimerCBFunc_t)(dmRoot_t *dmRoot, void *timerData1, void *timerData2, void *timerData3)
Definition: dmtypes.h:56
#define osGLOBAL
Definition: ostypes.h:147
#define agNULL
Definition: ostypes.h:151
unsigned int bit32
Definition: ostypes.h:99
#define agFALSE
Definition: ostypes.h:150
#define agTRUE
Definition: ostypes.h:149
The file defines the constants, data structure, and functions defined by LL API.
The file defines the declaration of tSDK APIs.
The file defines the declaration of OS APIs.
Definition: dm.h:91
void * dmData
Definition: dm.h:93
dmIntContext_t dmAllShared
Definition: dmtypes.h:424
dmList_t * flink
Definition: dmlist.h:32
data structure for timer request Timer requests are enqueued and dequeued using dmList_t and have a c...
Definition: dmtypes.h:63
dmTimerCBFunc_t timerCBFunc
Definition: dmtypes.h:69
void * timerData2
Definition: dmtypes.h:67
void * timerData1
Definition: dmtypes.h:66
dmList_t timerLink
Definition: dmtypes.h:70
void * timerData3
Definition: dmtypes.h:68
bit32 timeout
Definition: dmtypes.h:65
bit32 timerRunning
Definition: dmtypes.h:71
osGLOBAL void tddmSingleThreadedLeave(dmRoot_t *dmRoot, bit32 syncLockId)
osGLOBAL void tddmSingleThreadedEnter(dmRoot_t *dmRoot, bit32 syncLockId)