Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

/projects/cubeos/src_current/kernel/cubeos.h

Go to the documentation of this file.
00001 /*  src_experimental/kernel/cubeos.h
00002     CubeOS Version 0.4.90 experimental
00003     Copyright (C) 1999,2000 Holger Kenn
00004 
00005     CubeOS is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or any later version.
00009 
00010     CubeOS is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
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         /* we're the first to disable interrupts */
00053         asm("move.w %%sr,%0" : "=m" (KERN_srsave) ); 
00054         asm("ori.w #0x0700,%sr");  /* Disable Interrupts */
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 /* something went wrong, fall back to enabled interrupts */
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");  /* Disable Interrupts */
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 /*  mutex */
00110 /* Should be posix too. */
00111 //#define mutex sem_t; 
00112 /* A mutex is a semaphore that starts out eqal 1 */
00113 //#define mutex_init(i) sem_init(i,1,1)
00114 //#define mutex_enter(i) sem_wait(i)
00115 //#define mutex_leave(i) sem_signal(i)
00116 /* This is unsafe !!! */
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

Generated on Thu Feb 20 15:38:44 2003 for cubeOS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002