File indexing completed on 2025-05-11 08:23:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include <string.h>
0025 #include <stdlib.h>
0026 #include <ctype.h>
0027
0028 #include <rtems/sysinit.h>
0029 #include <rtems/powerpc/powerpc.h>
0030
0031 #include <libcpu/spr.h> /* registers.h is included here */
0032 #include <bsp.h>
0033 #include <bsp/bootcard.h>
0034 #include <bsp/uart.h>
0035 #include <bsp/pci.h>
0036 #include <libcpu/bat.h>
0037 #include <libcpu/pte121.h>
0038 #include <libcpu/cpuIdent.h>
0039 #include <bsp/vectors.h>
0040 #include <bsp/VME.h>
0041 #include <bsp/bspException.h>
0042
0043 #include <rtems/bspIo.h>
0044 #include <rtems/counter.h>
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 extern uint32_t probeMemoryEnd(void);
0055
0056 BSP_output_char_function_type BSP_output_char = BSP_output_char_via_serial;
0057 BSP_polling_getchar_function_type BSP_poll_char = NULL;
0058
0059 extern void _return_to_ppcbug(void);
0060 extern unsigned long __rtems_end[];
0061 extern unsigned get_L1CR(void), get_L2CR(void), get_L3CR(void);
0062 extern Triv121PgTbl BSP_pgtbl_setup(unsigned int *);
0063 extern void BSP_pgtbl_activate(Triv121PgTbl);
0064 extern int I2Cread_eeprom(unsigned char I2cBusAddr, uint32_t devA2A1A0, uint32_t AddrBytes, unsigned char *pBuff, uint32_t numBytes);
0065 extern void BSP_vme_config(void);
0066
0067 extern unsigned char ReadConfVPD_buff(int offset);
0068
0069 uint32_t bsp_clicks_per_usec;
0070
0071 typedef struct CmdLineRec_ {
0072 unsigned long size;
0073 char buf[0];
0074 } CmdLineRec, *CmdLine;
0075
0076
0077 #define mtspr(reg, val) \
0078 __asm __volatile("mtspr %0,%1" : : "K"(reg), "r"(val))
0079
0080
0081 #define mfspr(reg) \
0082 ( { unsigned val; \
0083 __asm __volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); \
0084 val; } )
0085
0086
0087
0088
0089 #define MAX_LOADER_ADD_PARM 80
0090 char loaderParam[MAX_LOADER_ADD_PARM];
0091
0092
0093
0094
0095 unsigned int BSP_mem_size;
0096
0097
0098
0099 unsigned int BSP_bus_frequency;
0100
0101
0102
0103 unsigned int BSP_processor_frequency;
0104
0105
0106
0107 unsigned int BSP_time_base_divisor;
0108 static unsigned char ConfVPD_buff[200];
0109
0110 #define CMDLINE_BUF_SIZE 2048
0111
0112 static char cmdline_buf[CMDLINE_BUF_SIZE];
0113 char *BSP_commandline_string = cmdline_buf;
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 char *
0151 save_boot_params(
0152 void *r3,
0153 void *r4,
0154 void* r5,
0155 char *cmdline_start,
0156 char *cmdline_end
0157 )
0158 {
0159 int i=cmdline_end-cmdline_start;
0160
0161 if ( i >= CMDLINE_BUF_SIZE )
0162 i = CMDLINE_BUF_SIZE-1;
0163 else if ( i < 0 )
0164 i = 0;
0165
0166 memmove(cmdline_buf, cmdline_start, i);
0167 cmdline_buf[i]=0;
0168 return cmdline_buf;
0169 }
0170
0171 uint32_t _CPU_Counter_frequency(void)
0172 {
0173 return BSP_bus_frequency / (BSP_time_base_divisor / 1000);
0174 }
0175
0176 static void bsp_early( void )
0177 {
0178 #ifdef CONF_VPD
0179 int i;
0180 #endif
0181 #ifdef SHOW_LCR1_REGISTER
0182 unsigned l1cr;
0183 #endif
0184 #ifdef SHOW_LCR2_REGISTER
0185 unsigned l2cr;
0186 #endif
0187 #ifdef SHOW_LCR3_REGISTER
0188 unsigned l3cr;
0189 #endif
0190 Triv121PgTbl pt=0;
0191
0192
0193
0194
0195
0196
0197
0198
0199 setdbat(2, PCI0_MEM_BASE, PCI0_MEM_BASE, 0x10000000, IO_PAGE);
0200
0201
0202
0203
0204
0205
0206
0207 setdbat(3,PCI0_IO_BASE, PCI0_IO_BASE, 0x10000000, IO_PAGE);
0208
0209
0210
0211
0212
0213
0214 get_ppc_cpu_type();
0215 get_ppc_cpu_revision();
0216
0217 #ifdef SHOW_LCR1_REGISTER
0218 l1cr = get_L1CR();
0219 printk("Initial L1CR value = %x\n", l1cr);
0220 #endif
0221
0222 ppc_exc_initialize();
0223
0224
0225
0226
0227
0228
0229 printk("-----------------------------------------\n");
0230 printk("Welcome to %s on MVME5500-0163\n", rtems_get_version_string() );
0231 printk("-----------------------------------------\n");
0232
0233 BSP_mem_size = probeMemoryEnd();
0234
0235
0236
0237
0238
0239 BSP_bus_frequency = 133333333;
0240 BSP_processor_frequency = 1000000000;
0241
0242 BSP_time_base_divisor = 4000;
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 pt = BSP_pgtbl_setup(&BSP_mem_size);
0253 if (!pt)
0254 printk("WARNING: unable to setup page tables.\n");
0255
0256 printk("Now BSP_mem_size = 0x%x\n",BSP_mem_size);
0257
0258
0259
0260 bsp_clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
0261
0262
0263
0264
0265 BSP_rtems_irq_mng_init(0);
0266
0267 #ifdef SHOW_LCR2_REGISTER
0268 l2cr = get_L2CR();
0269 printk("Initial L2CR value = %x\n", l2cr);
0270 #endif
0271
0272 #ifdef SHOW_LCR3_REGISTER
0273
0274 l3cr = get_L3CR();
0275 printk("Initial L3CR value = %x\n", l3cr);
0276 #endif
0277
0278
0279
0280
0281
0282
0283 if (pt) {
0284 #ifdef SHOW_MORE_INIT_SETTINGS
0285 printk("Page table setup finished; will activate it NOW...\n");
0286 #endif
0287 BSP_pgtbl_activate(pt);
0288 }
0289
0290 if ( I2Cread_eeprom(0xa8, 4,2, &ConfVPD_buff[0], 150))
0291 printk("I2Cread_eeprom() error \n");
0292 else {
0293 #ifdef CONF_VPD
0294 printk("\n");
0295 for (i=0; i<150; i++) {
0296 printk("%2x ", ConfVPD_buff[i]);
0297 if ((i % 20)==0 ) printk("\n");
0298 }
0299 printk("\n");
0300 #endif
0301 }
0302
0303
0304
0305
0306 setdbat(1, PCI1_MEM_BASE, PCI1_MEM_BASE, 0x10000000, IO_PAGE);
0307
0308
0309 #ifdef SHOW_MORE_INIT_SETTINGS
0310 printk("Going to start PCI buses scanning and initialization\n");
0311 #endif
0312 pci_initialize();
0313 #ifdef SHOW_MORE_INIT_SETTINGS
0314 printk("Number of PCI buses found is : %d\n", pci_bus_count());
0315 #endif
0316
0317
0318 globalExceptHdl = BSP_exceptionHandler;
0319
0320
0321
0322
0323 _BSP_clear_hostbridge_errors(0, 1 );
0324
0325 #ifdef SHOW_MORE_INIT_SETTINGS
0326 printk("MSR %x \n", _read_MSR());
0327 printk("Exit from bspstart\n");
0328 #endif
0329
0330 }
0331
0332 RTEMS_SYSINIT_ITEM(
0333 bsp_early,
0334 RTEMS_SYSINIT_BSP_EARLY,
0335 RTEMS_SYSINIT_ORDER_MIDDLE
0336 );
0337
0338 void bsp_start( void )
0339 {
0340
0341 }
0342
0343 unsigned char ReadConfVPD_buff(int offset)
0344 {
0345 return(ConfVPD_buff[offset]);
0346 }
0347
0348 RTEMS_SYSINIT_ITEM(
0349 BSP_vme_config,
0350 RTEMS_SYSINIT_BSP_PRE_DRIVERS,
0351 RTEMS_SYSINIT_ORDER_MIDDLE
0352 );