[274fa77] | 1 | /* |
---|
| 2 | * $Id |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | #include <mrm332.h> |
---|
| 6 | #include <sim.h> |
---|
| 7 | #define __START_C__ |
---|
| 8 | #include "bsp.h" |
---|
| 9 | |
---|
| 10 | m68k_isr_entry M68Kvec[256]; |
---|
| 11 | m68k_isr_entry vectors[256]; |
---|
| 12 | char * const __argv[]= {"main", ""}; |
---|
| 13 | |
---|
| 14 | void boot_card(int argc, char * const argv[]); |
---|
| 15 | |
---|
| 16 | /* |
---|
| 17 | * This prototype really should have the noreturn attribute but |
---|
| 18 | * that causes a warning. Not sure how to fix that. |
---|
| 19 | */ |
---|
| 20 | /* void dumby_start () __attribute__ ((noreturn)); */ |
---|
| 21 | void start_c (); |
---|
| 22 | |
---|
| 23 | void start_c() { |
---|
| 24 | |
---|
| 25 | /* Synthesizer Control Register */ |
---|
| 26 | /* see section(s) 4.8 */ |
---|
| 27 | /* end include in ram_init.S */ |
---|
| 28 | *SYNCR = (unsigned short int) |
---|
| 29 | ( SAM(MRM_W,15,VCO) | SAM(0x0,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) ); |
---|
| 30 | while (! (*SYNCR & SLOCK)); /* protect from clock overshoot */ |
---|
| 31 | /* include in ram_init.S */ |
---|
| 32 | *SYNCR = (unsigned short int) |
---|
| 33 | ( SAM(MRM_W,15,VCO) | SAM(MRM_X,14,PRESCALE) | SAM(MRM_Y,8,COUNTER) ); |
---|
| 34 | |
---|
| 35 | /* System Protection Control Register */ |
---|
| 36 | /* !!! can only write to once after reset !!! */ |
---|
| 37 | /* see section 3.8.4 of the SIM Reference Manual */ |
---|
| 38 | *SYPCR = (unsigned char)( HME | BME ); |
---|
| 39 | |
---|
| 40 | /* Periodic Interrupr Control Register */ |
---|
| 41 | /* see section 3.8.2 of the SIM Reference Manual */ |
---|
| 42 | *PICR = (unsigned short int) |
---|
| 43 | ( SAM(0,8,PIRQL) | SAM(MRM_PIV,0,PIV) ); |
---|
| 44 | /* ^^^ zero disables interrupt, don't enable here or ram_init will |
---|
| 45 | be wrong. It's enabled below. */ |
---|
| 46 | |
---|
| 47 | /* Periodic Interrupt Timer Register */ |
---|
| 48 | /* see section 3.8.3 of the SIM Reference Manual */ |
---|
| 49 | *PITR = (unsigned short int)( SAM(0x09,0,PITM) ); |
---|
| 50 | /* 1.098mS interrupt, assuming 32.768 KHz input clock */ |
---|
| 51 | |
---|
| 52 | /* Port C Data */ |
---|
| 53 | /* load values before enabled */ |
---|
| 54 | *PORTC = (unsigned char) 0x0; |
---|
| 55 | |
---|
| 56 | /* Port E and F Data Register */ |
---|
| 57 | /* see section 9 of the SIM Reference Manual */ |
---|
| 58 | *PORTE0 = (unsigned char) 0; |
---|
| 59 | *PORTF0 = (unsigned char) 0; |
---|
| 60 | |
---|
| 61 | /* Port E and F Data Direction Register */ |
---|
| 62 | /* see section 9 of the SIM Reference Manual */ |
---|
| 63 | *DDRE = (unsigned char) 0xff; |
---|
| 64 | *DDRF = (unsigned char) 0xfd; |
---|
| 65 | |
---|
| 66 | /* Port E and F Pin Assignment Register */ |
---|
| 67 | /* see section 9 of the SIM Reference Manual */ |
---|
| 68 | *PEPAR = (unsigned char) 0; |
---|
| 69 | *PFPAR = (unsigned char) 0; |
---|
| 70 | |
---|
| 71 | /* end of SIM initalization code */ |
---|
| 72 | /* end include in ram_init.S */ |
---|
| 73 | |
---|
| 74 | /* |
---|
| 75 | * Initialize RAM by copying the .data section out of ROM (if |
---|
| 76 | * needed) and "zero-ing" the .bss section. |
---|
| 77 | */ |
---|
| 78 | { |
---|
| 79 | register char *src = _etext; |
---|
| 80 | register char *dst = _copy_start; |
---|
| 81 | |
---|
| 82 | if (_copy_data_from_rom) |
---|
| 83 | /* ROM has data at end of text; copy it. */ |
---|
| 84 | while (dst < _edata) |
---|
| 85 | *dst++ = *src++; |
---|
| 86 | |
---|
| 87 | /* Zero bss */ |
---|
| 88 | for (dst = _clear_start; dst< end; dst++) |
---|
| 89 | { |
---|
| 90 | *dst = 0; |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | /* |
---|
| 95 | * Initialize vector table. |
---|
| 96 | */ |
---|
| 97 | { |
---|
| 98 | m68k_isr_entry *monitors_vector_table; |
---|
| 99 | |
---|
| 100 | m68k_get_vbr(monitors_vector_table); |
---|
| 101 | |
---|
| 102 | M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */ |
---|
| 103 | M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */ |
---|
| 104 | M68Kvec[ 31 ] = monitors_vector_table[ 31 ]; /* level 7 interrupt */ |
---|
| 105 | M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */ |
---|
| 106 | M68Kvec[ 66 ] = monitors_vector_table[ 66 ]; /* user defined */ |
---|
| 107 | |
---|
| 108 | m68k_set_vbr(&M68Kvec); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | /* |
---|
| 112 | * Initalize the board. |
---|
| 113 | */ |
---|
[c218824d] | 114 | |
---|
| 115 | /* Spurious should be called in the predriver hook */ |
---|
| 116 | /* Spurious_Initialize(); */ |
---|
[274fa77] | 117 | //console_init(); |
---|
| 118 | |
---|
| 119 | /* |
---|
| 120 | * Execute main with arguments argc and agrv. |
---|
| 121 | */ |
---|
| 122 | boot_card(1,__argv); |
---|
| 123 | reboot(); |
---|
| 124 | |
---|
| 125 | } |
---|
| 126 | |
---|