Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | /* |
| 2 | <:copyright-BRCM:2016:proprietary:standard |
| 3 | |
| 4 | Broadcom Proprietary and Confidential.(c) 2016 Broadcom |
| 5 | All Rights Reserved |
| 6 | |
| 7 | This program is the proprietary software of Broadcom Corporation and/or its |
| 8 | licensors, and may only be used, duplicated, modified or distributed pursuant |
| 9 | to the terms and conditions of a separate, written license agreement executed |
| 10 | between you and Broadcom (an "Authorized License"). Except as set forth in |
| 11 | an Authorized License, Broadcom grants no license (express or implied), right |
| 12 | to use, or waiver of any kind with respect to the Software, and Broadcom |
| 13 | expressly reserves all rights in and to the Software and all intellectual |
| 14 | property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE |
| 15 | NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY |
| 16 | BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
| 17 | |
| 18 | Except as expressly set forth in the Authorized License, |
| 19 | |
| 20 | 1. This program, including its structure, sequence and organization, |
| 21 | constitutes the valuable trade secrets of Broadcom, and you shall use |
| 22 | all reasonable efforts to protect the confidentiality thereof, and to |
| 23 | use this information only in connection with your use of Broadcom |
| 24 | integrated circuit products. |
| 25 | |
| 26 | 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
| 27 | AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
| 28 | WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH |
| 29 | RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND |
| 30 | ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, |
| 31 | FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR |
| 32 | COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE |
| 33 | TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF USE OR |
| 34 | PERFORMANCE OF THE SOFTWARE. |
| 35 | |
| 36 | 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR |
| 37 | ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, |
| 38 | INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY |
| 39 | WAY RELATING TO YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN |
| 40 | IF BROADCOM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; |
| 41 | OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE |
| 42 | SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE LIMITATIONS |
| 43 | SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY |
| 44 | LIMITED REMEDY. |
| 45 | :> |
| 46 | */ |
| 47 | #ifndef BCMOS_SYSTEM_H_ |
| 48 | #define BCMOS_SYSTEM_H_ |
| 49 | |
| 50 | #include <limits.h> |
| 51 | |
| 52 | #include "lib_types.h" |
| 53 | #include "lib_string.h" |
| 54 | |
| 55 | #include "../bcmos_errno.h" |
| 56 | #include "../bcmos_types.h" |
| 57 | #include "../bcmos_endian.h" |
| 58 | #include "cfe_timer.h" |
| 59 | #include "lib_printf.h" |
| 60 | |
| 61 | #define bcmos_printf printf |
| 62 | |
| 63 | #define bcmos_usleep(x) \ |
| 64 | do { \ |
| 65 | cfe_usleep (x); \ |
| 66 | } \ |
| 67 | while(0) |
| 68 | /* Define bcmos_bool - the boolean type for bcmos - based on C99 standard boolean type */ |
| 69 | #ifndef BCMOS_BOOLEAN |
| 70 | typedef _Bool bcmos_bool; |
| 71 | #define BCMOS_FALSE 0 |
| 72 | #define BCMOS_TRUE 1 |
| 73 | #endif |
| 74 | |
| 75 | #define PERIPH_GENINT_REVID 0xffe00000 |
| 76 | #define CHIP_REV_MASK 0xFF |
| 77 | static inline unsigned int get_chip_revision(void) |
| 78 | { |
| 79 | return *(volatile unsigned int*)PERIPH_GENINT_REVID & CHIP_REV_MASK; |
| 80 | } |
| 81 | |
| 82 | #define CHIP_REVISION_A0 0xA0 |
| 83 | #define CHIP_REVISION_B0 0xB0 |
| 84 | |
| 85 | #ifdef SIMULATION_BUILD |
| 86 | #define GET_CHIP_REVISION CHIP_REVISION_A0 |
| 87 | #else |
| 88 | extern uint32_t chip_revision; |
| 89 | #define GET_CHIP_REVISION (chip_revision != 0 ? chip_revision : (chip_revision = get_chip_revision())) |
| 90 | #endif |
| 91 | |
| 92 | |
| 93 | typedef uint16_t bcmos_fastlock; |
| 94 | #define BCMOS_FASTLOCK_INITIALIZER 0 |
| 95 | #define bcmos_fastlock_lock(fastlock) (long)fastlock |
| 96 | #define bcmos_fastlock_unlock(fastlock, flags) (void)flags |
| 97 | |
| 98 | typedef uint16_t bcmos_mutex; |
| 99 | #define bcmos_mutex_create(mutex, flags, name) |
| 100 | #define bcmos_mutex_lock(mutex) |
| 101 | #define bcmos_mutex_unlock(mutex) |
| 102 | |
| 103 | |
| 104 | #define BCM_SIZEOFARRAY(arr) (sizeof(arr)/sizeof(*arr)) |
| 105 | #define BCM_SIZEOFFIELD(s, f) (sizeof(((s*)NULL)->f)) |
| 106 | #define BCM_MEMZERO_STRUCT(ptr) memset(ptr, 0, sizeof(*(ptr))) |
| 107 | #define BCM_MEMCPY_ARRAY(dst, src) memcpy(dst, src, sizeof(dst)) |
| 108 | |
| 109 | |
| 110 | #define BUG_ON_PRINT(condition, fmt, args...) \ |
| 111 | do \ |
| 112 | { \ |
| 113 | if (condition) \ |
| 114 | { \ |
| 115 | printf(fmt, ##args); \ |
| 116 | /* On one hand, don't let this task continue - it is likely to crash/create a system exception. |
| 117 | * On the other hand, it mustn't do a busy loop - otherwise it can cause lower priority tasks to stop responding. */ \ |
| 118 | while (1) \ |
| 119 | bcmos_usleep(10000000); \ |
| 120 | } \ |
| 121 | } while (0) |
| 122 | |
| 123 | #define BUG_ON(condition) BUG_ON_PRINT((condition), "BUG in %s %d!\n", __FUNCTION__, __LINE__) |
| 124 | #define BUG() BUG_ON(1) |
| 125 | #define BUG_UNLESS(condition) BUG_ON(!(condition)) |
| 126 | |
| 127 | |
| 128 | #define BCMOS_TRACE_ERR(fmt, args...) \ |
| 129 | do \ |
| 130 | { \ |
| 131 | printf( fmt, ## args); \ |
| 132 | } while (0) |
| 133 | |
| 134 | |
| 135 | #define bcmos_vprintf printf |
| 136 | #define bcmos_calloc(s) KMALLOC((s), 0) |
| 137 | |
| 138 | #endif |