00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef CUBEOS_H
00017 #define CUBEOS_H
00018 #include <config.h>
00019 #include <mc68332.h>
00020 #include <sys_var.h>
00021 #include <schedule.h>
00022 #include <taskconst.h>
00047 #ifdef NEW_INTSEM
00048 static inline void disable()
00049 {
00050 if ((_KERN_disablecount++) == 0)
00051 {
00052
00053 asm("move.w %%sr,%0" : "=m" (KERN_srsave) );
00054 asm("ori.w #0x0700,%sr");
00055 }
00056 }
00057
00058 static inline void enable()
00059 {
00060 if ((--KERN_disablecount)<=0){
00061 if ((KERN_srsave | 0x0700) != 0x0700)
00062 asm("move.w %0,%%sr" : :"m" (KERN_srsave));
00063 else
00064 asm("move.w #0x2100,%sr");
00065 _KERN_disablecount=0;
00066 }
00067 }
00068 #else
00069 static inline void disable()
00070 {
00071 asm("ori.w #0x0700,%sr");
00072 }
00073 static inline void enable()
00074 {
00075 asm("move.w #0x2000,%sr");
00076 }
00077 #endif
00078
00079 #ifdef MULTI_SEM
00080
00081 #include <seminl.h>
00082
00083 #else
00084
00092 typedef int sem_t;
00093 #define sem_post(x) x++;
00094 #define sem_signal(x) sem_post(x)
00095 #define sem_wait(x) x--;while(x<0)
00096
00097
00098 #define sem_trywait(x) (x<0)
00099 #define sem_getvalue(x,i) (*i=x)
00100
00101
00102 #define sem_init(x,i,v) (x.c=v)
00103 #define sem_destroy(x) (0)
00104
00105 #endif
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 #define readbyte(x) (*(volatile unsigned char *)x)
00121 #define writebyte(x,y) *(unsigned char *)(x) = y
00122 #define readshort(x) (*(unsigned short *)(void *)(x))
00123 #define writeshort(x,y) *(unsigned short *)(x) = y
00124 #define readint(x) (*(unsigned int *)(void *)(x))
00125 #define writeint(x,y) *(unsigned int *)(x) = y
00126
00127
00136 #define writeshortpos(x,y,mask,pos) writeshort(x,(readshort(x)\
00137 &(~((mask)<<(pos)))) \
00138 |(((mask)&y)<<(pos)))
00139
00149 #define readshortpos(x,mask,pos) ((readshort(x)>>(pos))&(mask))
00150
00156 static inline void init_LED()
00157 {
00158 writebyte(SIM_PORTE,0x0);
00159 writebyte(SIM_DDRE,0x8);
00160 writebyte(SIM_PEPAR,0xf7);
00161 }
00163 static inline void LED_ON()
00164 {
00165 writebyte(SIM_PORTE,0x8);
00166 }
00167
00169 static inline void LED_OFF()
00170 {
00171 writebyte(SIM_PORTE,0x0);
00172 }
00173
00174 #endif