| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2004-2008, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bsyslib.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/2 $ |
|---|
| 12 | * $brcm_Date: 4/3/08 2:33p $ |
|---|
| 13 | * |
|---|
| 14 | * Revision History: |
|---|
| 15 | * |
|---|
| 16 | * $brcm_Log: /magnum/syslib/framework/noarch/bsyslib.h $ |
|---|
| 17 | * |
|---|
| 18 | * Hydra_Software_Devel/2 4/3/08 2:33p bandrews |
|---|
| 19 | * PR40090: synclib needs to have different contexts for syslib callbacks |
|---|
| 20 | * and synclib callbacks |
|---|
| 21 | * |
|---|
| 22 | * Hydra_Software_Devel/1 3/24/08 3:08p bandrews |
|---|
| 23 | * PR40865: Fixed |
|---|
| 24 | * |
|---|
| 25 | * Hydra_Software_Devel/7 1/25/08 9:24p bandrews |
|---|
| 26 | * PR36148: Extracted callback code into separate file |
|---|
| 27 | * |
|---|
| 28 | * Hydra_Software_Devel/6 1/3/08 5:17p bandrews |
|---|
| 29 | * PR37951: Updated based on initial feedback |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/5 12/17/07 1:11p bandrews |
|---|
| 32 | * PR36149: Updated per feedback from impl reviewq |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/4 12/12/07 3:50p bandrews |
|---|
| 35 | * PR36149: Fixed dependency on berr |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/3 12/6/07 5:12p bandrews |
|---|
| 38 | * PR36149: Fixed extra comma and separated handle from settings |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/2 12/6/07 5:01p bandrews |
|---|
| 41 | * PR36149: Added timer create/destroy to separate isr from task time |
|---|
| 42 | * stuff |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/1 10/16/07 2:09p bandrews |
|---|
| 45 | * PR36149: Initial check-in |
|---|
| 46 | ***************************************************************************/ |
|---|
| 47 | |
|---|
| 48 | #include "bstd.h" |
|---|
| 49 | #include "bkni.h" |
|---|
| 50 | |
|---|
| 51 | #ifndef BSYSLIB_H__ |
|---|
| 52 | #define BSYSLIB_H__ |
|---|
| 53 | |
|---|
| 54 | /* 20071214 bandrews - Removed. Replace with scheduling a zero-length timer */ |
|---|
| 55 | #ifdef BSYSLIB_TASK_SUPPORT |
|---|
| 56 | |
|---|
| 57 | /* |
|---|
| 58 | Summary: |
|---|
| 59 | Delegate signature for a generic task function. This is a task-time call, |
|---|
| 60 | not a new OS "task" / thread. |
|---|
| 61 | Description: |
|---|
| 62 | A task delegate to be run at task time |
|---|
| 63 | */ |
|---|
| 64 | typedef void (*BSYSlib_Task) |
|---|
| 65 | ( |
|---|
| 66 | void * pvParm1, /* user context param 1 */ |
|---|
| 67 | int iParm2 /* user context param 2 */ |
|---|
| 68 | ); |
|---|
| 69 | |
|---|
| 70 | /* |
|---|
| 71 | Summary: |
|---|
| 72 | Settings for starting a task |
|---|
| 73 | */ |
|---|
| 74 | typedef struct |
|---|
| 75 | { |
|---|
| 76 | BSYSlib_Task pfDoTask; /* the task to start */ |
|---|
| 77 | void * pvParm1; /* first user context parameter to the task delegate */ |
|---|
| 78 | int iParm2; /* second user context parameter to the task delegate */ |
|---|
| 79 | } BSYSlib_Task_Settings; |
|---|
| 80 | |
|---|
| 81 | /* |
|---|
| 82 | Summary: |
|---|
| 83 | Task-scheduling isr-time delegate signature |
|---|
| 84 | Description: |
|---|
| 85 | Schedules a task to be run out of isr context |
|---|
| 86 | */ |
|---|
| 87 | typedef BERR_Code (*BSYSlib_Task_Schedule_isr) |
|---|
| 88 | ( |
|---|
| 89 | void * pvParm1, /* first user context parameter to the schedule function [in] */ |
|---|
| 90 | int iParm2, /* second user context parameter to the schedule function [in] */ |
|---|
| 91 | const BSYSlib_Task_Settings * psSettings /* the task settings [in] */ |
|---|
| 92 | ); |
|---|
| 93 | |
|---|
| 94 | /* |
|---|
| 95 | Summary: |
|---|
| 96 | Encapsulates the task callback function plus context |
|---|
| 97 | */ |
|---|
| 98 | typedef struct BSYSlib_TaskCallback |
|---|
| 99 | { |
|---|
| 100 | BSYSlib_Task_Schedule_isr pfSchedule_isr; /* schedule signature */ |
|---|
| 101 | void * pvParm1; /* first user context parameter used for the task callback */ |
|---|
| 102 | int iParm; /* second user context parameter used for the task callback */ |
|---|
| 103 | } BSYSlib_EventCallback; |
|---|
| 104 | |
|---|
| 105 | #endif |
|---|
| 106 | |
|---|
| 107 | /* |
|---|
| 108 | Summary: |
|---|
| 109 | A task-time event-handling delegate signature |
|---|
| 110 | Description: |
|---|
| 111 | Called when the specified event this handler was registered for occurs |
|---|
| 112 | */ |
|---|
| 113 | typedef BERR_Code (*BSYSlib_Event_Handler) |
|---|
| 114 | ( |
|---|
| 115 | void * pvParm1, /* first user context parameter [in] */ |
|---|
| 116 | int iParm2, /* second user context parameter [in] */ |
|---|
| 117 | BKNI_EventHandle hEvent /* the event that occurred [in] */ |
|---|
| 118 | ); |
|---|
| 119 | |
|---|
| 120 | /* |
|---|
| 121 | Summary: |
|---|
| 122 | Settings for listening to an event |
|---|
| 123 | */ |
|---|
| 124 | typedef struct |
|---|
| 125 | { |
|---|
| 126 | BKNI_EventHandle hEvent; /* the event to be handled */ |
|---|
| 127 | BSYSlib_Event_Handler pfEventOccurred; /* the delegate to handle the event */ |
|---|
| 128 | void * pvParm1; /* user context param for the event handler */ |
|---|
| 129 | int iParm2; /* user context param2 for the event handler */ |
|---|
| 130 | } BSYSlib_Event_Settings; |
|---|
| 131 | |
|---|
| 132 | /* |
|---|
| 133 | Summary: |
|---|
| 134 | Adds an event handler for the specified event |
|---|
| 135 | Description: |
|---|
| 136 | Task-time delegate signature for adding event handlers to events |
|---|
| 137 | */ |
|---|
| 138 | typedef BERR_Code (*BSYSlib_Event_AddHandler) |
|---|
| 139 | ( |
|---|
| 140 | void * pvParm1, /* user context param for the add function [in] */ |
|---|
| 141 | int iParm2, /* user context param2 for the add function [in] */ |
|---|
| 142 | const BSYSlib_Event_Settings * psSettings /* the event handler settings for the handler to add [in] */ |
|---|
| 143 | ); |
|---|
| 144 | |
|---|
| 145 | /* |
|---|
| 146 | Summary: |
|---|
| 147 | Removes an event handler for the specified event |
|---|
| 148 | Description: |
|---|
| 149 | Task-time delegate signature for removing event handlers from events |
|---|
| 150 | */ |
|---|
| 151 | typedef BERR_Code (*BSYSlib_Event_RemoveHandler) |
|---|
| 152 | ( |
|---|
| 153 | void * pvParm1, /* user context param for the remove function [in] */ |
|---|
| 154 | int iParm2, /* user context param2 for the remove function [in] */ |
|---|
| 155 | const BSYSlib_Event_Settings * psSettings /* the event handler settings for the handler to remove [in] */ |
|---|
| 156 | ); |
|---|
| 157 | |
|---|
| 158 | /* |
|---|
| 159 | Summary: |
|---|
| 160 | Encapsulates all event-related callback functions plus context |
|---|
| 161 | */ |
|---|
| 162 | typedef struct BSYSlib_EventCallback |
|---|
| 163 | { |
|---|
| 164 | BSYSlib_Event_AddHandler pfAdd; /* add signature */ |
|---|
| 165 | BSYSlib_Event_RemoveHandler pfRemove; /* remove signature */ |
|---|
| 166 | void * pvParm1; /* first user context parameter used for the event callbacks */ |
|---|
| 167 | int iParm2; /* second user context parameter used for the event callbacks */ |
|---|
| 168 | } BSYSlib_EventCallback; |
|---|
| 169 | |
|---|
| 170 | /* |
|---|
| 171 | Summary: |
|---|
| 172 | Generic timer handle |
|---|
| 173 | */ |
|---|
| 174 | typedef void * BSYSlib_Timer_Handle; |
|---|
| 175 | |
|---|
| 176 | /* |
|---|
| 177 | Summary: |
|---|
| 178 | Edge-triggered timer expiry notification function |
|---|
| 179 | Description: |
|---|
| 180 | Task-time timer expiry delegate signature |
|---|
| 181 | */ |
|---|
| 182 | typedef BERR_Code (*BSYSlib_Timer_ExpiryHandler) |
|---|
| 183 | ( |
|---|
| 184 | void * pvParm1, /* first user context parameter [in] */ |
|---|
| 185 | int iParm2, /* second user context parameter [in] */ |
|---|
| 186 | BSYSlib_Timer_Handle hTimer /* the handle of the timer that expired [in] */ |
|---|
| 187 | ); |
|---|
| 188 | |
|---|
| 189 | /* |
|---|
| 190 | Summary: |
|---|
| 191 | Settings for starting a timer |
|---|
| 192 | */ |
|---|
| 193 | typedef struct |
|---|
| 194 | { |
|---|
| 195 | unsigned long ulTimeout; /* timeout of timer */ |
|---|
| 196 | BSYSlib_Timer_ExpiryHandler pfTimerExpired; /* the handler function to call back when the timer expires */ |
|---|
| 197 | void * pvParm1; /* first user context parameter to the expiry handler function */ |
|---|
| 198 | int iParm2; /* second user context parameter to the expiry handler function */ |
|---|
| 199 | } BSYSlib_Timer_Settings; |
|---|
| 200 | |
|---|
| 201 | /* |
|---|
| 202 | Summary: |
|---|
| 203 | Timer creation delegate. |
|---|
| 204 | Description: |
|---|
| 205 | The system will allocate resources for a timer. The system should keep track of the timer through the specified handle. |
|---|
| 206 | */ |
|---|
| 207 | typedef BERR_Code (*BSYSlib_Timer_Create) |
|---|
| 208 | ( |
|---|
| 209 | void * pvParm1, /* first user context parameter to the start function [in] */ |
|---|
| 210 | int iParm2, /* second user context parameter to the start function [in] */ |
|---|
| 211 | BSYSlib_Timer_Handle * phTimer /* handle of timer [out] */ |
|---|
| 212 | ); |
|---|
| 213 | |
|---|
| 214 | /* |
|---|
| 215 | Summary: |
|---|
| 216 | Timer destruction delegate |
|---|
| 217 | Description: |
|---|
| 218 | The system will destroy resources associated with the specified timer handle. |
|---|
| 219 | */ |
|---|
| 220 | typedef void (*BSYSlib_Timer_Destroy) |
|---|
| 221 | ( |
|---|
| 222 | void * pvParm1, /* first user context parameter to the start function [in] */ |
|---|
| 223 | int iParm2, /* second user context parameter to the start function [in] */ |
|---|
| 224 | BSYSlib_Timer_Handle hTimer /* handle of timer [in] */ |
|---|
| 225 | ); |
|---|
| 226 | |
|---|
| 227 | /* |
|---|
| 228 | Summary: |
|---|
| 229 | Timer start delegate. |
|---|
| 230 | Description: |
|---|
| 231 | The system will start the timer specified by handle (and created earlier) with the specified timeout and callback function. |
|---|
| 232 | */ |
|---|
| 233 | typedef BERR_Code (*BSYSlib_Timer_Start_isr) |
|---|
| 234 | ( |
|---|
| 235 | void * pvParm1, /* first user context parameter to the start function [in] */ |
|---|
| 236 | int iParm2, /* second user context parameter to the start function [in] */ |
|---|
| 237 | BSYSlib_Timer_Handle hTimer, /* the handle of the timer */ |
|---|
| 238 | const BSYSlib_Timer_Settings * psSettings /* the timer settings [in] */ |
|---|
| 239 | ); |
|---|
| 240 | |
|---|
| 241 | /* |
|---|
| 242 | Summary: |
|---|
| 243 | Timer cancel delegate. |
|---|
| 244 | Description: |
|---|
| 245 | The system will cancel the timer with the specified handle. |
|---|
| 246 | */ |
|---|
| 247 | typedef BERR_Code (*BSYSlib_Timer_Cancel_isr) |
|---|
| 248 | ( |
|---|
| 249 | void * pvParm1, /* first user context parameter [in] */ |
|---|
| 250 | int iParm2, /* second user context parameter [in] */ |
|---|
| 251 | BSYSlib_Timer_Handle hTimer /* handle of timer [in] */ |
|---|
| 252 | ); |
|---|
| 253 | |
|---|
| 254 | /* |
|---|
| 255 | Summary: |
|---|
| 256 | Encapsulates all timer-related callback functions plus context |
|---|
| 257 | */ |
|---|
| 258 | typedef struct BSYSlib_TimerCallback |
|---|
| 259 | { |
|---|
| 260 | BSYSlib_Timer_Create pfCreate; /* create signature */ |
|---|
| 261 | BSYSlib_Timer_Destroy pfDestroy; /* destroy signature */ |
|---|
| 262 | BSYSlib_Timer_Start_isr pfStart_isr; /* start signature */ |
|---|
| 263 | BSYSlib_Timer_Cancel_isr pfCancel_isr; /* cancel signature */ |
|---|
| 264 | void * pvParm1; /* first user context parameter used for the timer callbacks */ |
|---|
| 265 | int iParm2; /* second user context parameter used for the timer callbacks */ |
|---|
| 266 | } BSYSlib_TimerCallback; |
|---|
| 267 | |
|---|
| 268 | /* |
|---|
| 269 | Summary: |
|---|
| 270 | Retrieves the current system time |
|---|
| 271 | */ |
|---|
| 272 | typedef BERR_Code (*BSYSlib_GetTime_isr) |
|---|
| 273 | ( |
|---|
| 274 | void * pvParm1, /* first user context parameter to the get time function [in] */ |
|---|
| 275 | int iParm2, /* second user context parameter to the get time function [in] */ |
|---|
| 276 | unsigned long * pulNow /* the current time in ms [out] */ |
|---|
| 277 | ); |
|---|
| 278 | |
|---|
| 279 | /* |
|---|
| 280 | Summary: |
|---|
| 281 | Encapsulates system-time-related callback functions plus context |
|---|
| 282 | */ |
|---|
| 283 | typedef struct BSYSlib_TimeCallback |
|---|
| 284 | { |
|---|
| 285 | BSYSlib_GetTime_isr pfGetTime_isr; /* get time signature */ |
|---|
| 286 | void * pvParm1; /* first user context parameter used for the get time callback */ |
|---|
| 287 | int iParm2; /* second user context parameter used for the get time callback */ |
|---|
| 288 | } BSYSlib_TimeCallback; |
|---|
| 289 | |
|---|
| 290 | #endif /* BSYSLIB_H__ */ |
|---|
| 291 | |
|---|