| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2008-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_base_priv.h $ |
|---|
| 39 | * $brcm_Revision: 13 $ |
|---|
| 40 | * $brcm_Date: 11/29/11 11:37a $ |
|---|
| 41 | * |
|---|
| 42 | * API Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/base/src/nexus_base_priv.h $ |
|---|
| 47 | * |
|---|
| 48 | * 13 11/29/11 11:37a erickson |
|---|
| 49 | * SW7420-2129: store current default heap per module |
|---|
| 50 | * |
|---|
| 51 | * 12 7/21/11 2:32p vsilyaev |
|---|
| 52 | * SW7125-1014 : Add module enable/disable |
|---|
| 53 | * |
|---|
| 54 | * SW7125-1014/1 7/20/11 4:38p gmohile |
|---|
| 55 | * SW7125-1014 : Add module enable/disable |
|---|
| 56 | * |
|---|
| 57 | * 11 9/23/10 2:12p erickson |
|---|
| 58 | * SW7420-943: refactor for driver/firmware partitioning |
|---|
| 59 | * |
|---|
| 60 | * 10 4/8/09 12:30p erickson |
|---|
| 61 | * PR53862: reintroduce NEXUS_P_SchedulerGetInfo |
|---|
| 62 | * |
|---|
| 63 | * 9 1/20/09 3:46p vsilyaev |
|---|
| 64 | * PR 49285, PR 50582: Improved debugability of scheduller and fixed |
|---|
| 65 | * problem in the scheduller, where it goes to WaitForGroup to extended |
|---|
| 66 | * amount of time |
|---|
| 67 | * |
|---|
| 68 | * 8 6/18/08 1:12p erickson |
|---|
| 69 | * PR43758: fix warnings, misspellings |
|---|
| 70 | * |
|---|
| 71 | * 7 6/9/08 7:11p vsilyaev |
|---|
| 72 | * PR 43184: Changed phase of detection for outstanding callbacks |
|---|
| 73 | * |
|---|
| 74 | * 6 6/5/08 2:19p vsilyaev |
|---|
| 75 | * PR 42318: Rearranged scheduller to share the same context in user and |
|---|
| 76 | * kernel mode, this allows to serve callback from kernel to user with |
|---|
| 77 | * single transition kernel<->user |
|---|
| 78 | * |
|---|
| 79 | * 5 5/28/08 5:49p vsilyaev |
|---|
| 80 | * PR 42318: Reworked scheduller to allow use of externally created thread |
|---|
| 81 | * |
|---|
| 82 | * 4 4/8/08 10:40a vsilyaev |
|---|
| 83 | * PR 41083: Added bprofile support |
|---|
| 84 | * |
|---|
| 85 | * 3 2/28/08 9:39p vsilyaev |
|---|
| 86 | * PR 40103: Added NEXUS_TaskCallback functions |
|---|
| 87 | * |
|---|
| 88 | * 2 1/31/08 11:49a vsilyaev |
|---|
| 89 | * PR 38682: Added support for runtime options |
|---|
| 90 | * |
|---|
| 91 | * 1 1/18/08 2:13p jgarrett |
|---|
| 92 | * PR 38808: Merging to main branch |
|---|
| 93 | * |
|---|
| 94 | * Nexus_Devel/7 1/11/08 3:49p vsilyaev |
|---|
| 95 | * PR 38682: Fixed typos and removed unused code. |
|---|
| 96 | * |
|---|
| 97 | * Nexus_Devel/6 10/23/07 4:16p vsilyaev |
|---|
| 98 | * PR 36199: Added memory mapper sub-module |
|---|
| 99 | * |
|---|
| 100 | * Nexus_Devel/5 10/10/07 4:19p vsilyaev |
|---|
| 101 | * PR 35824: Added NEXUS_Time type |
|---|
| 102 | * |
|---|
| 103 | * Nexus_Devel/4 9/13/07 5:20p vsilyaev |
|---|
| 104 | * PR 34419: Use plugins for OS |
|---|
| 105 | * |
|---|
| 106 | * Nexus_Devel/3 8/31/07 6:02p vsilyaev |
|---|
| 107 | * PR 34419: Added configuration structure for NEXUS_Base |
|---|
| 108 | * |
|---|
| 109 | * Nexus_Devel/2 8/30/07 7:07p vsilyaev |
|---|
| 110 | * PR 34419: More complete implementation |
|---|
| 111 | * |
|---|
| 112 | * Nexus_Devel/1 8/28/07 6:39p vsilyaev |
|---|
| 113 | * PR 34419: Initial implementation |
|---|
| 114 | * |
|---|
| 115 | ***************************************************************************/ |
|---|
| 116 | #ifndef NEXUS_BASE_PRIV_H__ |
|---|
| 117 | #define NEXUS_BASE_PRIV_H__ |
|---|
| 118 | |
|---|
| 119 | #include "nexus_base_os.h" |
|---|
| 120 | #include "nexus_base_os_priv.h" |
|---|
| 121 | #include "blifo.h" |
|---|
| 122 | #include "bkni_event_group.h" |
|---|
| 123 | |
|---|
| 124 | extern NEXUS_ModuleHandle NEXUS_Base; |
|---|
| 125 | #define NEXUS_MODULE_SELF NEXUS_Base |
|---|
| 126 | |
|---|
| 127 | #ifdef __cplusplus |
|---|
| 128 | extern "C" |
|---|
| 129 | { |
|---|
| 130 | #endif |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | BERR_Code NEXUS_P_Base_Os_Init(void); |
|---|
| 134 | void NEXUS_P_Base_Os_Uninit(void); |
|---|
| 135 | |
|---|
| 136 | void NEXUS_P_Base_Scheduler_Init(void); |
|---|
| 137 | void NEXUS_P_Base_Scheduler_Uninit(void); |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | typedef struct NEXUS_P_Scheduler NEXUS_P_Scheduler; |
|---|
| 141 | |
|---|
| 142 | BDBG_OBJECT_ID_DECLARE(NEXUS_Module); |
|---|
| 143 | |
|---|
| 144 | struct NEXUS_Module { |
|---|
| 145 | BDBG_OBJECT(NEXUS_Module) |
|---|
| 146 | BKNI_MutexHandle lock; |
|---|
| 147 | NEXUS_P_Scheduler *scheduler; |
|---|
| 148 | NEXUS_ModuleSettings settings; |
|---|
| 149 | const char *pModuleName; |
|---|
| 150 | BLST_S_ENTRY(NEXUS_Module) link; |
|---|
| 151 | bool enabled; |
|---|
| 152 | struct { |
|---|
| 153 | NEXUS_HeapHandle heap; /* default heap for current client in this module */ |
|---|
| 154 | bool untrusted; /* current client in this module is untrusted */ |
|---|
| 155 | } currentClient; |
|---|
| 156 | }; |
|---|
| 157 | |
|---|
| 158 | NEXUS_P_Scheduler *NEXUS_P_Scheduler_Create(const char *name, const NEXUS_ThreadSettings *pSettings); |
|---|
| 159 | NEXUS_P_Scheduler *NEXUS_P_Scheduler_Init(unsigned priority, const char *name, const NEXUS_ThreadSettings *pSettings); /* initialiase scheduller for use with external thread */ |
|---|
| 160 | |
|---|
| 161 | void NEXUS_P_Scheduler_Destroy(NEXUS_P_Scheduler *scheduler); |
|---|
| 162 | void NEXUS_P_MapInit(void); |
|---|
| 163 | |
|---|
| 164 | typedef struct NEXUS_P_SchedulerInfo { |
|---|
| 165 | BKNI_MutexHandle callback_lock; /* callback that is acquired when callback active */ |
|---|
| 166 | } NEXUS_P_SchedulerInfo; |
|---|
| 167 | void NEXUS_P_SchedulerGetInfo(NEXUS_P_Scheduler *scheduler, NEXUS_P_SchedulerInfo *info); |
|---|
| 168 | |
|---|
| 169 | NEXUS_Error NEXUS_P_Scheduler_Step(NEXUS_P_Scheduler *scheduler, unsigned timeout, NEXUS_P_Base_Scheduler_Status *status, bool (*complete)(void *context), void *context); |
|---|
| 170 | |
|---|
| 171 | #ifdef __cplusplus |
|---|
| 172 | } |
|---|
| 173 | #endif |
|---|
| 174 | |
|---|
| 175 | #endif /* NEXUS_BASE_PRIV_H__ */ |
|---|