sal.h (2432B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: sal.h 8 * Purpose: SAL Support definitions 9 */ 10 11 #ifndef _SAL_H 12 #define _SAL_H 13 14 #include <sal/types.h> 15 #include <sal/core/thread.h> 16 #include <sal/core/time.h> 17 18 /* 19 * Include the system types so that things like uint32_t are always 20 * available and consistent. 21 */ 22 #ifdef __KERNEL__ 23 #include <linux/types.h> 24 #else 25 #include <sys/types.h> 26 #include <ctype.h> 27 #include <string.h> 28 #endif 29 30 #if defined(UNIX) && !defined(__STRICT_ANSI__) 31 #define sal_strncasecmp strncasecmp 32 #define sal_strcasecmp strcasecmp 33 #else 34 extern int sal_strncasecmp(const char *s1, const char *s2, size_t n); 35 extern int sal_strcasecmp(const char *s1, const char *s2); 36 #endif 37 38 extern char *sal_strcasestr(const char *haystack, const char *needle); 39 40 41 /* 42 * SAL Initialization 43 */ 44 45 int sal_appl_init(void); 46 /* 47 * Console Initialization 48 */ 49 void sal_readline_init(void); 50 void sal_readline_term(void); 51 52 /* 53 * SAL Date Routines 54 */ 55 56 int sal_date_set(sal_time_t *val); 57 int sal_date_get(sal_time_t *val); 58 59 /* 60 * SAL Booting/Rebooting routines. 61 */ 62 63 void sal_reboot(void); 64 65 /* 66 * SAL Shell routine - to escape to shell on whatever platform. 67 */ 68 69 void sal_shell(void); 70 71 /* 72 * LED Support, platform specific routine to set led value. 73 * sal_led: sets the state of one or more discrete LEDs; bit 0 is first LED 74 * sal_led_string: sets the state of an alphanumeric display, if any. 75 */ 76 77 extern uint32 sal_led(uint32 led); 78 extern void sal_led_string(const char *s); 79 80 /* 81 * Watchdog timer, platform specific 82 */ 83 84 extern int sal_watchdog_arm(uint32 usec); 85 86 /* 87 * Memory Testing 88 */ 89 90 extern int sal_memory_check(uint32 addr); 91 92 #ifdef BROADCOM_DEBUG 93 #ifdef INCLUDE_BCM_SAL_PROFILE 94 extern void sal_dma_alloc_resource_usage_get(unsigned int *alloc_curr, 95 unsigned int *alloc_max); 96 #endif 97 #endif 98 99 /* 100 * Compatibility macros 101 */ 102 103 #ifdef __KERNEL__ 104 #include <linux/kernel.h> 105 #define strtol simple_strtol 106 #define strtoul simple_strtoul 107 #endif 108 109 /* 110 * Some time functions only available on UNIX 111 * For now other systems just won't use these. 112 */ 113 #if defined(UNIX) 114 #define sal_mktime mktime 115 #define sal_localtime localtime 116 #define sal_strftime strftime 117 #endif 118 119 #endif /* !_SAL_H */ 120