hal.h

Go to the documentation of this file.
00001 
00028 #ifndef _RTAI_ASM_GENERIC_HAL_H
00029 #define _RTAI_ASM_GENERIC_HAL_H
00030 
00031 #ifdef __KERNEL__
00032 
00033 #include <rtai_config.h>
00034 #include <linux/kernel.h>
00035 #include <linux/sched.h>
00036 #include <linux/interrupt.h>
00037 #include <linux/kallsyms.h>
00038 
00039 #define RTHAL_DOMAIN_ID  0x52544149
00040 
00041 #define RTHAL_NR_CPUS  ADEOS_NR_CPUS
00042 
00043 #define RTHAL_NR_APCS  BITS_PER_LONG
00044 
00045 #define RTHAL_TIMER_FREQ  (rthal_tunables.timer_freq)
00046 #define RTHAL_CPU_FREQ    (rthal_tunables.cpu_freq)
00047 
00048 #define rthal_cli()                     adeos_stall_pipeline_from(&rthal_domain)
00049 #define rthal_sti()                     adeos_unstall_pipeline_from(&rthal_domain)
00050 #define rthal_local_irq_save(x)         ((x) = !!adeos_test_and_stall_pipeline_from(&rthal_domain))
00051 #define rthal_local_irq_restore(x)      adeos_restore_pipeline_from(&rthal_domain,(x))
00052 #define rthal_local_irq_flags(x)        ((x) = !!adeos_test_pipeline_from(&rthal_domain))
00053 #define rthal_local_irq_test()          (!!adeos_test_pipeline_from(&rthal_domain))
00054 #define rthal_local_irq_sync(x)         ((x) = !!adeos_test_and_unstall_pipeline_from(&rthal_domain))
00055 
00056 #define rthal_hw_lock(flags)            adeos_hw_local_irq_save(flags)
00057 #define rthal_hw_unlock(flags)          adeos_hw_local_irq_restore(flags)
00058 #define rthal_hw_enable()               adeos_hw_sti()
00059 #define rthal_hw_disable()              adeos_hw_cli()
00060 
00061 #define rthal_linux_sti()                adeos_unstall_pipeline_from(adp_root)
00062 #define rthal_linux_cli()                adeos_stall_pipeline_from(adp_root)
00063 #define rthal_linux_local_irq_save(x)    ((x) = !!adeos_test_and_stall_pipeline_from(adp_root))
00064 #define rthal_linux_local_irq_restore(x) adeos_restore_pipeline_from(adp_root,x)
00065 #define rthal_linux_local_irq_restore_nosync(x,cpuid) adeos_restore_pipeline_nosync(adp_root,x,cpuid)
00066 
00067 #define rthal_spin_lock(lock)    adeos_spin_lock(lock)
00068 #define rthal_spin_unlock(lock)  adeos_spin_unlock(lock)
00069 
00070 #define rthal_spin_lock_irq(lock) \
00071 do {  \
00072     rthal_cli(); \
00073     rthal_spin_lock(lock); \
00074 } while(0)
00075 
00076 #define rthal_spin_unlock_irq(lock) \
00077 do {  \
00078     rthal_spin_unlock(lock); \
00079     rthal_sti(); \
00080 } while(0)
00081 
00082 #define rthal_spin_lock_irqsave(lock,flags) \
00083 do {  \
00084     rthal_local_irq_save(flags); \
00085     rthal_spin_lock(lock); \
00086 } while(0)
00087 
00088 #define rthal_spin_unlock_irqrestore(lock,flags) \
00089 do {  \
00090     rthal_spin_unlock(lock); \
00091     rthal_local_irq_restore(flags); \
00092 } while(0)
00093 
00094 typedef void (*rthal_irq_handler_t)(unsigned irq,
00095                                     void *cookie);
00096 
00097 struct rthal_calibration_data {
00098 
00099     unsigned long cpu_freq;
00100     unsigned long timer_freq;
00101 };
00102 
00103 typedef int (*rthal_trap_handler_t)(adevinfo_t *evinfo);
00104 
00105 extern unsigned long rthal_cpufreq_arg;
00106 
00107 extern unsigned long rthal_timerfreq_arg;
00108 
00109 extern adomain_t rthal_domain;
00110 
00111 extern struct rthal_calibration_data rthal_tunables;
00112 
00113 extern volatile int rthal_sync_op;
00114 
00115 extern volatile unsigned long rthal_cpu_realtime;
00116 
00117 extern rthal_trap_handler_t rthal_trap_handler;
00118 
00119 extern int rthal_realtime_faults[RTHAL_NR_CPUS][ADEOS_NR_FAULTS];
00120 
00121 extern void rthal_domain_entry(int iflag);
00122 
00123 extern int rthal_arch_init(void);
00124 
00125 extern void rthal_arch_cleanup(void);
00126 
00127     /* Private interface -- Internal use only */
00128 
00129 unsigned long rthal_critical_enter(void (*synch)(void));
00130 
00131 void rthal_critical_exit(unsigned long flags);
00132 
00133     /* Public interface */
00134 
00135 #define rthal_printk    printk /* This is safe over Adeos */
00136 
00137 #ifdef __cplusplus
00138 extern "C" {
00139 #endif /* __cplusplus */
00140 
00141 int rthal_irq_request(unsigned irq,
00142                       void (*handler)(unsigned irq, void *cookie),
00143                       void *cookie);
00144 
00145 int rthal_irq_release(unsigned irq);
00146 
00147 int rthal_irq_enable(unsigned irq);
00148 
00149 int rthal_irq_disable(unsigned irq);
00150 
00151 int rthal_irq_host_request(unsigned irq,
00152                            irqreturn_t (*handler)(int irq,
00153                                                   void *dev_id,
00154                                                   struct pt_regs *regs), 
00155                            char *name,
00156                            void *dev_id);
00157 
00158 int rthal_irq_host_release(unsigned irq,
00159                            void *dev_id);
00160 
00161 int rthal_irq_host_pend(unsigned irq);
00162 
00163 int rthal_apc_alloc(const char *name,
00164                     void (*handler)(void *cookie),
00165                     void *cookie);
00166 
00167 int rthal_apc_free(int apc);
00168 
00169 int rthal_apc_schedule(int apc);
00170 
00171 int rthal_irq_affinity(unsigned irq,
00172                        cpumask_t cpumask,
00173                        cpumask_t *oldmask);
00174 
00175 int rthal_timer_request(void (*handler)(void),
00176                         unsigned long nstick);
00177 
00178 void rthal_timer_release(void);
00179 
00180 rthal_trap_handler_t rthal_trap_catch(rthal_trap_handler_t handler);
00181 
00182 unsigned long rthal_timer_calibrate(void);
00183 
00184 #ifdef __cplusplus
00185 }
00186 #endif /* __cplusplus */
00187 
00188 #endif /* __KERNEL__ */
00189 
00192 #endif /* !_RTAI_ASM_GENERIC_HAL_H */

Generated on Wed Jun 22 22:54:01 2005 for RTAI Fusion API by  doxygen 1.4.1