blob: 763cc799e075fea597ea838c1d4b0680a971effa [file] [log] [blame]
/*
<:copyright-BRCM:2016:proprietary:standard
Broadcom Proprietary and Confidential.(c) 2016 Broadcom
All Rights Reserved
This program is the proprietary software of Broadcom Corporation and/or its
licensors, and may only be used, duplicated, modified or distributed pursuant
to the terms and conditions of a separate, written license agreement executed
between you and Broadcom (an "Authorized License"). Except as set forth in
an Authorized License, Broadcom grants no license (express or implied), right
to use, or waiver of any kind with respect to the Software, and Broadcom
expressly reserves all rights in and to the Software and all intellectual
property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE
NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY
BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
Except as expressly set forth in the Authorized License,
1. This program, including its structure, sequence and organization,
constitutes the valuable trade secrets of Broadcom, and you shall use
all reasonable efforts to protect the confidentiality thereof, and to
use this information only in connection with your use of Broadcom
integrated circuit products.
2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND
ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT,
FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE
TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF USE OR
PERFORMANCE OF THE SOFTWARE.
3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL,
INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY
WAY RELATING TO YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN
IF BROADCOM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES;
OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE LIMITATIONS
SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY
LIMITED REMEDY.
:>
*/
#ifndef BCMOS_SYSTEM_H_
#define BCMOS_SYSTEM_H_
#include <limits.h>
#include "lib_types.h"
#include "lib_string.h"
#include "../bcmos_errno.h"
#include "../bcmos_types.h"
#include "../bcmos_endian.h"
#include "cfe_timer.h"
#include "lib_printf.h"
#define bcmos_printf printf
#define bcmos_usleep(x) \
do { \
cfe_usleep (x); \
} \
while(0)
/* Define bcmos_bool - the boolean type for bcmos - based on C99 standard boolean type */
#ifndef BCMOS_BOOLEAN
typedef _Bool bcmos_bool;
#define BCMOS_FALSE 0
#define BCMOS_TRUE 1
#endif
#define PERIPH_GENINT_REVID 0xffe00000
#define CHIP_REV_MASK 0xFF
static inline unsigned int get_chip_revision(void)
{
return *(volatile unsigned int*)PERIPH_GENINT_REVID & CHIP_REV_MASK;
}
#define CHIP_REVISION_A0 0xA0
#define CHIP_REVISION_B0 0xB0
#ifdef SIMULATION_BUILD
#define GET_CHIP_REVISION CHIP_REVISION_A0
#else
extern uint32_t chip_revision;
#define GET_CHIP_REVISION (chip_revision != 0 ? chip_revision : (chip_revision = get_chip_revision()))
#endif
typedef uint16_t bcmos_fastlock;
#define BCMOS_FASTLOCK_INITIALIZER 0
#define bcmos_fastlock_lock(fastlock) (long)fastlock
#define bcmos_fastlock_unlock(fastlock, flags) (void)flags
typedef uint16_t bcmos_mutex;
#define bcmos_mutex_create(mutex, flags, name)
#define bcmos_mutex_lock(mutex)
#define bcmos_mutex_unlock(mutex)
#define BCM_SIZEOFARRAY(arr) (sizeof(arr)/sizeof(*arr))
#define BCM_SIZEOFFIELD(s, f) (sizeof(((s*)NULL)->f))
#define BCM_MEMZERO_STRUCT(ptr) memset(ptr, 0, sizeof(*(ptr)))
#define BCM_MEMCPY_ARRAY(dst, src) memcpy(dst, src, sizeof(dst))
#define BUG_ON_PRINT(condition, fmt, args...) \
do \
{ \
if (condition) \
{ \
printf(fmt, ##args); \
/* On one hand, don't let this task continue - it is likely to crash/create a system exception.
* On the other hand, it mustn't do a busy loop - otherwise it can cause lower priority tasks to stop responding. */ \
while (1) \
bcmos_usleep(10000000); \
} \
} while (0)
#define BUG_ON(condition) BUG_ON_PRINT((condition), "BUG in %s %d!\n", __FUNCTION__, __LINE__)
#define BUG() BUG_ON(1)
#define BUG_UNLESS(condition) BUG_ON(!(condition))
#define BCMOS_TRACE_ERR(fmt, args...) \
do \
{ \
printf( fmt, ## args); \
} while (0)
#define bcmos_vprintf printf
#define bcmos_calloc(s) KMALLOC((s), 0)
#endif