00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "lpc2000.h"
00023
00024 #include "global.h"
00025 #include "processor.h"
00026
00027 void processorInit(void)
00028 {
00029
00030
00031 PLLCFG = PLLCFG_MSEL | PLLCFG_PSEL;
00032
00033
00034 PLLCON = PLLCON_PLLE;
00035 PLLFEED = 0xAA; PLLFEED = 0x55;
00036 while(!(PLLSTAT & PLLSTAT_LOCK));
00037 PLLCON = PLLCON_PLLE | PLLCON_PLLC;
00038 PLLFEED = 0xAA; PLLFEED = 0x55;
00039
00040
00041 MAMTIM = MAMTIM_CYCLES;
00042 MAMCR = MAMCR_FULL;
00043
00044
00045 VPBDIV = VPBDIV_VALUE;
00046
00047
00048 processorVicInit();
00049 }
00050
00051 unsigned int processorDisableInt(unsigned int cpsr_mask)
00052 {
00053 unsigned int cpsr;
00054
00055 asm volatile ("mrs %0, cpsr" : "=r" (cpsr) : );
00056
00057 asm volatile ("msr cpsr, %0" : : "r" (cpsr|(cpsr_mask&CPSR_MASK_INT)) );
00058
00059 return cpsr;
00060 }
00061
00062 unsigned int processorEnableInt(unsigned int cpsr_mask)
00063 {
00064 unsigned int cpsr;
00065
00066 asm volatile ("mrs %0, cpsr" : "=r" (cpsr) : );
00067
00068 asm volatile ("msr cpsr, %0" : : "r" (cpsr&~(cpsr_mask&CPSR_MASK_INT)) );
00069
00070 return cpsr;
00071 }
00072
00073 unsigned int processorRestoreInt(unsigned int cpsr_orig)
00074 {
00075 unsigned int cpsr;
00076
00077 asm volatile ("mrs %0, cpsr" : "=r" (cpsr) : );
00078
00079 asm volatile ("msr cpsr, %0" : : "r" ( (cpsr&~CPSR_MASK_INT) | (cpsr_orig&CPSR_MASK_INT)) );
00080
00081 return cpsr;
00082 }
00083
00084 void processorVicInit(void)
00085 {
00086 int i;
00087
00088
00089 VICIntEnClear = 0xFFFF;
00090
00091 VICSoftIntClear = 0xFFFF;
00092
00093 VICIntSelect = 0;
00094
00095
00096
00097
00098 for(i=0; i<16; i++)
00099 {
00100 (&VICVectCntl0)[i] = 0;
00101 (&VICVectAddr0)[i] = 0;
00102 }
00103
00104 VICDefVectAddr = 0;
00105 }
00106
00107 void processorVicAttach(int pid, int srcmode, void (*userFunc)(void) )
00108 {
00109
00110 VICIntEnClear = (1<<pid);
00111
00112 (&VICVectCntl0)[pid] = VIC_ENABLE | pid;
00113
00114 (&VICVectAddr0)[pid] = (unsigned int)userFunc;
00115
00116 VICIntSelect &= ~(1<<pid);
00117
00118 VICIntEnable |= (1<<pid);
00119 }
00120
00121 void processorVicDetach(int pid)
00122 {
00123
00124 VICIntEnClear = (1<<pid);
00125
00126
00127
00128 (&VICVectAddr0)[pid] = 0;
00129 }