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