File indexing completed on 2025-05-11 08:24:00
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
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 #include <rtems.h>
0056 #include <rtems/config.h>
0057 #include <rtems/bspIo.h>
0058 #include <rtems/counter.h>
0059 #include <rtems/libio.h>
0060 #include <rtems/libcsupport.h>
0061 #include <rtems/sysinit.h>
0062
0063 #include <libcpu/cpuIdent.h>
0064 #include <libcpu/spr.h>
0065
0066 #include <bsp.h>
0067 #include <bsp/vectors.h>
0068 #include <bsp/bootcard.h>
0069 #include <bsp/irq.h>
0070
0071 #include <string.h>
0072 #include <fcntl.h>
0073 #include <inttypes.h>
0074
0075 #define DO_DOWN_ALIGN(x,a) ((x) & ~((a)-1))
0076
0077 #define DO_UP_ALIGN(x,a) DO_DOWN_ALIGN(((x) + (a) - 1 ),a)
0078
0079 #define CPU_DOWN_ALIGN(x) DO_DOWN_ALIGN(x, CPU_ALIGNMENT)
0080 #define CPU_UP_ALIGN(x) DO_UP_ALIGN(x, CPU_ALIGNMENT)
0081
0082
0083
0084 LINKER_SYMBOL(RamBase);
0085 LINKER_SYMBOL(RamSize);
0086 LINKER_SYMBOL(__bsp_ram_start);
0087 LINKER_SYMBOL(__bsp_ram_end);
0088 LINKER_SYMBOL(__rtems_end);
0089 LINKER_SYMBOL(WorkAreaBase);
0090 LINKER_SYMBOL(MsgAreaBase);
0091 LINKER_SYMBOL(MsgAreaSize);
0092 LINKER_SYMBOL(__phy_ram_end);
0093 LINKER_SYMBOL(bsp_exc_vector_base);
0094
0095
0096
0097 uint32_t bsp_clicks_per_usec;
0098
0099
0100
0101
0102 unsigned int BSP_bus_frequency;
0103
0104
0105
0106 unsigned int BSP_processor_frequency;
0107
0108
0109
0110
0111 unsigned int BSP_time_base_divisor;
0112
0113
0114
0115
0116 static void _noopfun(void) {}
0117
0118
0119 void app_bsp_start(void)
0120 __attribute__(( weak, alias("_noopfun") ));
0121
0122 void app_bsp_predriver_hook(void)
0123 __attribute__(( weak, alias("_noopfun") ));
0124
0125
0126 static char* bspMsgBuffer = (char*)MsgAreaBase;
0127
0128 static void __bsp_outchar_to_memory(char c)
0129 {
0130 static char* msgBuffer = (char*)MsgAreaBase;
0131 *msgBuffer++ = c;
0132 if (msgBuffer >= &bspMsgBuffer[(int)MsgAreaSize]) msgBuffer = bspMsgBuffer;
0133 *msgBuffer = 0x00;
0134 }
0135
0136 uint32_t _CPU_Counter_frequency(void)
0137 {
0138 return BSP_bus_frequency / (BSP_time_base_divisor / 1000);
0139 }
0140
0141
0142
0143
0144
0145
0146
0147
0148 void bsp_start(void)
0149 {
0150 ppc_cpu_id_t myCpu;
0151 ppc_cpu_revision_t myCpuRevision;
0152
0153
0154 BSP_output_char = __bsp_outchar_to_memory;
0155
0156 printk("RTEMS %s\n", rtems_get_version_string());
0157
0158
0159
0160
0161
0162 myCpu = get_ppc_cpu_type();
0163 myCpuRevision = get_ppc_cpu_revision();
0164 printk("CPU: 0x%04x, Revision: 0x%04x = %d, Name: %s\n",
0165 myCpu, myCpuRevision, myCpuRevision, get_ppc_cpu_type_name(myCpu));
0166
0167
0168
0169
0170
0171
0172 BSP_bus_frequency = 465000000;
0173 BSP_processor_frequency = 465000000;
0174 BSP_time_base_divisor = 1000;
0175
0176
0177 bsp_clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
0178
0179 ppc_exc_initialize();
0180
0181
0182 printk(" Base/Start End Size\n"
0183 "RAM: %p %p\n"
0184 "RTEMS: %p\n"
0185 "Workspace: %p %p\n"
0186 "MsgArea: %p %p\n"
0187 "Physical RAM %p\n",
0188 RamBase, RamSize,
0189 __rtems_end,
0190 WorkAreaBase, __bsp_ram_end,
0191 MsgAreaBase, MsgAreaSize,
0192 __phy_ram_end);
0193
0194
0195
0196
0197 BSP_rtems_irq_mngt_init(0);
0198
0199
0200 app_bsp_start();
0201 }
0202
0203
0204
0205
0206
0207
0208 static void virtex5_pre_driver_hook(void)
0209 {
0210 app_bsp_predriver_hook();
0211 }
0212
0213 RTEMS_SYSINIT_ITEM(
0214 virtex5_pre_driver_hook,
0215 RTEMS_SYSINIT_BSP_PRE_DRIVERS,
0216 RTEMS_SYSINIT_ORDER_MIDDLE
0217 );