blob: 5633e286aa6f929b4616717cbe6190b2f8555d84 [file] [log] [blame]
/*
<:copyright-BRCM:2016:DUAL/GPL:standard
Broadcom Proprietary and Confidential.(c) 2016 Broadcom
All Rights Reserved
Unless you and Broadcom execute a separate written software license
agreement governing use of this software, this software is licensed
to you under the terms of the GNU General Public License version 2
(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
with the following added to such license:
As a special exception, the copyright holders of this software give
you permission to link this software with independent modules, and
to copy and distribute the resulting executable under terms of your
choice, provided that you also meet, for each linked independent
module, the terms and conditions of the license of that module.
An independent module is a module which is not derived from this
software. The special exception does not apply to any modifications
of the software.
Not withstanding the above, under no circumstances may you combine
this software in any way with any other Broadcom software provided
under a license other than the GPL, without Broadcom's express prior
written consent.
:>
*/
/*
* bcmos_system.h
* Maple System Services
* vxWorks 5.5 port
*/
#ifndef BCMOS_SYSTEM_H_
#define BCMOS_SYSTEM_H_
#define BCMOS_IRQ_SINGLE 0
#define BCMOS_IRQ_SHARED 1
#define inline __inline
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include <unistd.h>
#include <sockLib.h>
#include <sys/socket.h>
#include <netinet/in.h>
/* Re-define GNU typeof as ISO __typeof__ */
#define typeof __typeof__
/* Specify here which system functions are inlined */
/* #define BCMOS_FASTLOCK_INLINE */
/* #define BCMOS_SEM_WAIT_INLINE */
/* #define BCMOS_SEM_POST_INLINE */
/* #define BCMOS_USLEEP_INLINE */
#define BCMOS_TRACE_PRINTF
#define BCMOS_BYTE_POOL_ALLOC_FREE_INLINE
/* #define BCMOS_MALLOC_FREE_INLINE */
/* #define BCMOS_CALLOC_INLINE */
/* if Host cpu is MIPS cpu,enable this macro */
/* Host cpu type will be determined during compile*/
//#define HOST_CPU_IS_MIPS
//#define HOST_CPU_IS_PPC
/*if the Memory allocated by cacheDmaMalloc/acheDmaFree() is non-cached memory,enable this macro*/
#define NON_CACHED_MEMORY_CREATED_BY_CACHEDMAMALLOC
/* Uncommentthe following line if h/w supports DMA cache coherency */
/* #define BCMOS_DMA_CACHE_COHERENCY */
static inline void bcmos_int_disable(int irq)
{}
void _bcmos_backtrace(void);
#define BUG_ON(_f) do { if (_f) { _bcmos_backtrace(); } } while (0)
#define BUG() BUG_ON(1)
#define BUG_UNLESS(_f) BUG_ON(!(_f))
/** Boolean */
#define BCMOS_BOOLEAN
typedef enum
{
BCMOS_FALSE = 0,
BCMOS_TRUE = 1,
} bcmos_bool;
#include "bcmos_common.h"
#define ffs(n) ffsLsb(n)
/** Semaphore control block */
struct bcmos_sem
{
uint32_t s;
};
/** Mutex control block */
struct bcmos_mutex
{
uint32_t m;
};
/** Fast lock control block */
struct bcmos_fastlock
{
uint32_t l;
};
/** Fastlock initializer. Can be used instead of calling bcmos_fastlock_init() */
#define BCMOS_FASTLOCK_INITIALIZER { 0 }
/** OS-specific task control block extension */
typedef struct bcmos_sys_task
{
uint32_t t; /**< vxWorks task ID */
} bcmos_sys_task;
/** System timer */
struct bcmos_sys_timer
{
uint32_t t; /**< VxW timer */
bcmos_sys_timer_handler handler; /**< Timer handler */
void *data; /**< Parameter to be passed to the handler */
};
/** Byte memory pool control block */
struct bcmos_byte_pool
{
bcmos_byte_pool_parm parm; /**< Pool parameters */
uint32_t allocated; /**< Number of bytes allocated */
#ifdef BCMOS_MEM_DEBUG
uint32_t magic; /**< magic number */
#define BCMOS_BYTE_POOL_VALID (('b'<<24) | ('y' << 16) | ('p' << 8) | 'o')
#define BCMOS_BYTE_POOL_DELETED (('b'<<24) | ('y' << 16) | ('p' << 8) | '~')
#endif
};
#define bcmos_sys_vprintf(fmt, args) vprintf(fmt, args)
#define EXPORT_SYMBOL(_sym)
/* 2nd part of OS-independent declarations */
#include "bcmos_common2.h"
void bcm_pci_write32(volatile uint32_t *address, uint32_t value);
uint32_t bcm_pci_read32(const volatile uint32_t *address);
/*todo must check validity that the string is numeric, sscanf cannot detect errors,
* if not valid, put (*tailptr) in the first non valid char in string,
if valid, point tailptr in the last char in string (*tailptr=string+strlen(string))*/
#define strtoull(string,tailptr,base) ({\
unsigned long long int __a;\
*(tailptr)=(char*)((string)+strlen(string));\
sscanf(string, base == 10 ? "%llu" : "%llx", &__a );\
__a;\
})
#define strtoll(string,tailptr,base) ({\
long long int __a;\
*(tailptr)=(char*)((string)+strlen(string));\
sscanf(string,"%lld", &__a );\
__a;\
})
#define snprintf(s1,n,s2,args...) sprintf(s1, s2,## args)
#define vsnprintf(s1,n,s2,args...) vsprintf(s1, s2,## args)
int ffsLsb (UINT32 i);
int ffsll(long long int i);
#endif /* BCMOS_SYSTEM_H_ */