hal.h

Go to the documentation of this file.
00001 
00031 #ifndef _RTAI_ASM_IA64_HAL_H
00032 #define _RTAI_ASM_IA64_HAL_H
00033 
00034 #include <nucleus/asm-generic/hal.h>    /* Read the generic bits. */
00035 
00036 typedef unsigned long long rthal_time_t;
00037 
00038 static inline unsigned long long rthal_ullmul(const unsigned long m0, 
00039                                               const unsigned long m1)
00040 {
00041     return (unsigned long long) m0 * m1;
00042 }
00043 
00044 static inline unsigned long long rthal_ulldiv (unsigned long long ull,
00045                                                const unsigned long uld,
00046                                                unsigned long *const rp)
00047 {
00048     unsigned long long result = ull / uld;
00049 
00050     if (rp)
00051         *rp = ull % uld;
00052 
00053     return result;
00054 }
00055 
00056 #define rthal_uldivrem(ull,ul,rp) ((u_long) rthal_ulldiv((ull),(ul),(rp)))
00057 
00058 static inline int rthal_imuldiv (int i, int mult, int div)
00059 {
00060     return ((long long)i * mult) / div;
00061 }
00062 
00063 static inline long long rthal_llimd (long long op,
00064                                      unsigned long m,
00065                                      unsigned long d)
00066 {
00067     long long h, l, qh, ql, rh;
00068 
00069     /* (ll * mult) may need 96 bits, so we split it into two parts. We use / and
00070        % on purpose, not shift operations, to handle correctly negative numbers.
00071     */
00072     h = (op / (1LL << 32)) * m;
00073     l = (op % (1LL << 32)) * m;
00074     h += l / (1LL << 32);
00075     l %= (1LL << 32);
00076 
00077     rh = (h % d) * (1LL << 32);
00078     qh = (h / d) * (1LL << 32);
00079     ql = (rh + l) / d;
00080 
00081     return qh + ql;
00082 }
00083 
00084 static inline  __attribute_const__ unsigned long ffnz (unsigned long ul)
00085 {
00086     unsigned long r;
00087     asm ("popcnt %0=%1" : "=r" (r) : "r" ((ul-1) & ~ul));
00088     return r;
00089 }
00090 
00091 #if defined(__KERNEL__) && !defined(__cplusplus)
00092 #include <asm/system.h>
00093 #include <nucleus/asm/atomic.h>
00094 #include <asm/processor.h>
00095 #include <asm/delay.h>          /* For ia64_get_itc / ia64_set_itm */
00096 
00097 #define RTHAL_TIMER_VECTOR      ADEOS_SERVICE_VECTOR3
00098 #define RTHAL_TIMER_IRQ         ADEOS_SERVICE_IPI3
00099 #define RTHAL_HOST_TIMER_VECTOR IA64_TIMER_VECTOR
00100 #define RTHAL_HOST_TIMER_IRQ    __ia64_local_vector_to_irq(IA64_TIMER_VECTOR)
00101 
00102 #define rthal_irq_descp(irq)  irq_descp(irq)
00103 
00104 static inline unsigned long long rthal_rdtsc (void)
00105 {
00106     unsigned long long t;
00107     adeos_hw_tsc(t);
00108     return t;
00109 }
00110 
00111 static inline struct task_struct *rthal_root_host_task (int cpuid)
00112 {
00113     return current;
00114 }
00115 
00116 static inline struct task_struct *rthal_current_host_task (int cpuid)
00117 {
00118     return current;
00119 }
00120 
00121 static inline void rthal_timer_program_shot (unsigned long delay)
00122 {
00123     unsigned long flags;
00124     if (!delay) { delay = 10; }
00125     rthal_hw_lock(flags);
00126     ia64_set_itm(ia64_get_itc() + delay);
00127     rthal_hw_unlock(flags);
00128 }
00129 
00130     /* Private interface -- Internal use only */
00131 
00132 void rthal_switch_context(void *out_tcb,
00133                           void *in_tcb);
00134 
00135 void rthal_prepare_stack(unsigned long stackbase);
00136 
00137 static const char *const rthal_fault_labels[] = {
00138     [0] = "General exception",
00139     [1] = "FPU disabled",
00140     [2] = "NaT consumption",
00141     [3] = "Unsupported data reference",
00142     [4] = "Debug",
00143     [5] = "FPU fault",
00144     [6] = "Unimplemented instruction address",
00145     [7] = "ia32 exception",
00146     [8] = "Generic fault",
00147     [9] = "Page fault",
00148     [10] = NULL
00149 };
00150 
00151 #endif /* __KERNEL__ && !__cplusplus */
00152 
00155 #endif /* !_RTAI_ASM_IA64_HAL_H */

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