File indexing completed on 2025-05-11 08:23:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #include <stdlib.h>
0036
0037 #include <rtems.h>
0038 #include <rtems/counter.h>
0039
0040 #include <libcpu/powerpc-utility.h>
0041
0042 #include <bsp.h>
0043 #include <bsp/vectors.h>
0044 #include <bsp/bootcard.h>
0045 #include <bsp/irq-generic.h>
0046
0047 #ifdef BSP_HAS_TQMMON
0048
0049
0050
0051 #endif
0052
0053
0054 uint32_t BSP_bus_frequency;
0055
0056
0057 uint32_t bsp_time_base_frequency;
0058
0059
0060 uint32_t bsp_clicks_per_usec;
0061
0062 static const char *bsp_tqm_get_cib_string( const char *cib_id)
0063 {
0064 char srch_pattern[10] = "";
0065 char *fnd_str;
0066
0067
0068
0069 strcat(srch_pattern,"-");
0070 strncat(srch_pattern,
0071 cib_id,
0072 sizeof(srch_pattern)-1-strlen(srch_pattern));
0073 strncat(srch_pattern,
0074 " ",
0075 sizeof(srch_pattern)-1-strlen(srch_pattern));
0076
0077
0078
0079 fnd_str = strstr((const char *)TQM_CONF_INFO_BLOCK_ADDR,srch_pattern);
0080
0081 if (fnd_str == NULL) {
0082 return NULL;
0083 }
0084 else {
0085
0086
0087
0088 return fnd_str + strlen(srch_pattern);
0089 }
0090 }
0091
0092 static uint32_t str_to_u32(const char *s)
0093 {
0094 uint32_t v = 0;
0095
0096 while (true) {
0097 unsigned char digit = (unsigned char)*s - '0';
0098
0099 if (digit > 9) {
0100 break;
0101 }
0102
0103 v = (v * 10) + digit;
0104 ++s;
0105 }
0106
0107 return v;
0108 }
0109
0110 static rtems_status_code bsp_tqm_get_cib_uint32( const char *cib_id,
0111 uint32_t *result)
0112 {
0113 const char *item_ptr;
0114 item_ptr = bsp_tqm_get_cib_string(cib_id);
0115 if (item_ptr == NULL) {
0116 return RTEMS_INVALID_ID;
0117 }
0118
0119
0120
0121 *result = str_to_u32(item_ptr);
0122 return RTEMS_SUCCESSFUL;
0123 }
0124
0125 uint32_t _CPU_Counter_frequency(void)
0126 {
0127 return bsp_time_base_frequency;
0128 }
0129
0130 void bsp_start( void)
0131 {
0132
0133
0134
0135
0136
0137 get_ppc_cpu_type();
0138 get_ppc_cpu_revision();
0139
0140
0141 cpu_init();
0142
0143
0144
0145
0146
0147 #if BSP_INSTRUCTION_CACHE_ENABLED
0148 rtems_cache_enable_instruction();
0149 #endif
0150
0151 #if BSP_DATA_CACHE_ENABLED
0152 rtems_cache_enable_data();
0153 #endif
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167 if (RTEMS_SUCCESSFUL !=
0168 bsp_tqm_get_cib_uint32("cu",
0169 &BSP_bus_frequency)) {
0170 rtems_panic("Cannot determine BUS frequency\n");
0171 }
0172
0173 bsp_time_base_frequency = BSP_bus_frequency / 16;
0174 bsp_clicks_per_usec = bsp_time_base_frequency / 1000000;
0175
0176 ppc_exc_initialize();
0177 bsp_interrupt_initialize();
0178
0179 #ifdef SHOW_MORE_INIT_SETTINGS
0180 printk("Exit from bspstart\n");
0181 #endif
0182 }