boot.c (2468B)
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: boot.c 8 * Purpose: Kernel initialization 9 */ 10 11 #include <stdio.h> 12 #include <stdlib.h> 13 14 15 #include <soc/debug.h> 16 17 18 19 #include <sal/core/libc.h> 20 #include <sal/core/boot.h> 21 #include <sal/core/spl.h> 22 #include <sal/core/dpc.h> 23 #include <sal/core/sync.h> 24 25 /* 26 * Function: 27 * sal_core_init 28 * Purpose: 29 * Initialize the Kernel SAL 30 * Returns: 31 * 0 on success, -1 on failure 32 */ 33 34 int 35 sal_core_init(void) 36 { 37 sal_udelay(0); /* Cause sal_udelay() to self-calibrate */ 38 39 sal_thread_main_set(sal_thread_self()); 40 41 if (sal_spl_init()) { 42 return -1; 43 } 44 45 if (sal_dpc_init()) { 46 return -1; 47 } 48 49 if (sal_global_lock_init()) { 50 return -1; 51 } 52 53 return 0; 54 } 55 56 /* 57 * Function: 58 * sal_boot_flags_get 59 * Purpose: 60 * Return boot flags from startup 61 * Flags are set for PLISIM and NO_PROBE by default, and can be 62 * overridden by setting the environment variable SOC_BOOT_FLAGS. 63 * Parameters: 64 * None 65 * Returns: 66 * 32-bit flags value, 0 if not supported or no flags set. 67 */ 68 69 static int _sal_boot_flags_init = FALSE; 70 static uint32 _sal_boot_flags = 0; 71 72 uint32 73 sal_boot_flags_get(void) 74 { 75 if (!_sal_boot_flags_init) { 76 char *s = getenv("SOC_BOOT_FLAGS"); 77 if (s == NULL) { 78 #ifdef PLISIM 79 _sal_boot_flags = (BOOT_F_PLISIM | BOOT_F_NO_PROBE); 80 #ifdef LINUX_PLI_COMBO_BDE 81 if (getenv("BCM_SIM_PATH") == NULL) { 82 _sal_boot_flags = 0; 83 } 84 #endif 85 #endif 86 } else { 87 _sal_boot_flags = sal_ctoi(s, NULL); 88 } 89 _sal_boot_flags_init = TRUE; 90 } 91 92 return _sal_boot_flags; 93 } 94 95 /* 96 * Function: 97 * sal_boot_flags_set 98 * Purpose: 99 * Change boot flags 100 * Parameters: 101 * flags - New boot flags 102 */ 103 104 void 105 sal_boot_flags_set(uint32 flags) 106 { 107 _sal_boot_flags_init = TRUE; 108 _sal_boot_flags = flags; 109 } 110 111 /* 112 * Function: 113 * sal_boot_script 114 * Purpose: 115 * Return name of boot script from startup 116 * Parameters: 117 * None 118 * Returns: 119 * Name of boot script, NULL if none 120 */ 121 char * 122 sal_boot_script(void) 123 { 124 return getenv("SOC_BOOT_SCRIPT"); 125 } 126 127 128 /* 129 * Function: 130 * sal_os_name 131 * Purpose: 132 * Provide a description of the underlying operating system 133 * Parameters: 134 * None 135 * Returns: 136 * String describing the OS 137 */ 138 const char* 139 sal_os_name(void) 140 { 141 return "Unix (Posix)"; 142 }