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