# rtai_oldnames.h

    00001 /*
    00002  *   ARTI -- RTAI-compatible Adeos-based Real-Time Interface. Based on
    00003  *   the original RTAI layer for PPC and the RTAI/x86 rewrite over ADEOS.
    00004  *   This file provides user-visible definitions for compatibility purpose
    00005  *   with the legacy RTHAL. Must be included from rtai_hal.h only.
    00006  *
    00007  *   Original RTAI/PPC layer implementation: \n
    00008  *   Copyright &copy; 2000 Paolo Mantegazza, \n
    00009  *   Copyright &copy; 2001 David Schleef, \n
    00010  *   Copyright &copy; 2001 Lineo, Inc, \n
    00011  *   Copyright &copy; 2002 Wolfgang Grandegger. \n
    00012  *
    00013  *   RTAI/x86 rewrite over Adeos: \n
    00014  *   Copyright &copy 2002 Philippe Gerum.
    00015  *
    00016  *   RTAI/PPC rewrite over Adeos: \n
    00017  *   Copyright &copy 2004 Wolfgang Grandegger.
    00018
    00019  *   This program is free software; you can redistribute it and/or modify
    00020  *   it under the terms of the GNU General Public License as published by
    00021  *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
    00022  *   USA; either version 2 of the License, or (at your option) any later
    00023  *   version.
    00024  *
    00025  *   This program is distributed in the hope that it will be useful,
    00026  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00027  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00028  *   GNU General Public License for more details.
    00029  *
    00030  *   You should have received a copy of the GNU General Public License
    00031  *   along with this program; if not, write to the Free Software
    00032  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00033  */
    00034
    00035 #ifndef _RTAI_ASM_PPC_OLDNAMES_H
    00036 #define _RTAI_ASM_PPC_OLDNAMES_H
    00037
    00038 #ifdef __KERNEL__
    00039
    00040 #define IFLAG                        RTAI_IFLAG
    00041 #define hard_cli()                   rtai_cli()
    00042 #define hard_sti()                   rtai_sti()
    00043 #define hard_save_flags_and_cli(x)   rtai_local_irq_save(x)
    00044 #define hard_restore_flags(x)        rtai_local_irq_restore(x)
    00045 #define hard_save_flags(x)           rtai_local_irq_flags(x)
    00046 #define hard_cpu_id                  adeos_processor_id
    00047 #define this_rt_task                 ptd
    00048
    00049 #endif /* __KERNEL__ */
    00050
    00051 #ifndef __RTAI_HAL__
    00052
    00053 #define tuned           rtai_tunables
    00054 #define NR_RT_CPUS      RTAI_NR_CPUS
    00055 #define RT_TIME_END     RTAI_TIME_LIMIT
    00056
    00057 #define CPU_FREQ        RTAI_CPU_FREQ
    00058 #define TIMER_8254_IRQ  RTAI_TIMER_8254_IRQ
    00059 #define FREQ_8254       RTAI_FREQ_8254
    00060 #define LATENCY_8254    RTAI_LATENCY_8254
    00061 #define SETUP_TIME_8254 RTAI_SETUP_TIME_8254
    00062
    00063 #define FREQ_APIC       RTAI_FREQ_APIC
    00064 #define LATENCY_APIC    RTAI_LATENCY_APIC
    00065 #define SETUP_TIME_APIC RTAI_SETUP_TIME_APIC
    00066
    00067 #define CALIBRATED_APIC_FREQ  RTAI_CALIBRATED_APIC_FREQ
    00068 #define CALIBRATED_CPU_FREQ   RTAI_CALIBRATED_CPU_FREQ
    00069
    00070 #ifdef __KERNEL__
    00071
    00072 /* For compatibility reasons with RTHAL, IPIs numbers are indices into
    00073    the __ipi2vec[] array, instead of actual interrupt numbers. */
    00074
    00075 #define RTAI_1_VECTOR  RTAI_APIC1_VECTOR
    00076 #define RTAI_1_IPI     6
    00077 #define RTAI_2_VECTOR  RTAI_APIC2_VECTOR
    00078 #define RTAI_2_IPI     7
    00079 #define RTAI_3_VECTOR  RTAI_APIC3_VECTOR
    00080 #define RTAI_3_IPI     8
    00081 #define RTAI_4_VECTOR  RTAI_APIC4_VECTOR
    00082 #define RTAI_4_IPI     9
    00083
    00084 #define broadcast_to_local_timers rtai_broadcast_to_timers
    00085 #define rtai_signal_handler       rtai_signal_handler
    00086 #define rt_set_rtai_trap_handler  rt_set_trap_handler
    00087 #define rt_mount_rtai             rt_mount
    00088 #define rt_umount_rtai            rt_umount
    00089 #define calibrate_8254            rtai_calibrate_8254
    00090
    00091 static inline int rt_request_global_irq_ext(unsigned irq,
    00092                                             void (*handler)(void),
    00093                                             unsigned long cookie) {
    00094
    00095     return rt_request_irq(irq,(void (*)(unsigned,void *))handler,(void *)cookie);
    00096 }
    00097
    00098 static inline int rt_request_global_irq(unsigned irq,
    00099                                         void (*handler)(void)) {
    00100
    00101     return rt_request_irq(irq,(void (*)(unsigned,void *))handler,0);
    00102 }
    00103
    00104 static inline void rt_set_global_irq_ext(unsigned irq,
    00105                                          int ext,
    00106                                          unsigned long cookie) {
    00107
    00108     rt_set_irq_cookie(irq,(void *)cookie);
    00109 }
    00110
    00111 static inline int rt_free_global_irq(unsigned irq) {
    00112
    00113     return rt_release_irq(irq);
    00114 }
    00115
    00116 #undef  rdtsc
    00117 #define rdtsc()     rtai_rdtsc()
    00118 #define rd_CPU_ts() rdtsc()
    00119
    00120 #define ulldiv(a,b,c)  rtai_ulldiv(a,b,c)
    00121 #define imuldiv(a,b,c) rtai_imuldiv(a,b,c)
    00122 #define llimd(a,b,c)   rtai_llimd(a,b,c)
    00123
    00124 #define locked_cpus                        (&rtai_cpu_lock)
    00125
    00126 #define lxrt_hrt_flags        rtai_cpu_lxrt
    00127 #define rtai_print_to_screen  rt_printk
    00128
    00129 #define RTAI_NR_TRAPS         ADEOS_NR_FAULTS
    00130
    00131 #define DECLR_8254_TSC_EMULATION
    00132 #define TICK_8254_TSC_EMULATION
    00133 #define SETUP_8254_TSC_EMULATION
    00134 #define CLEAR_8254_TSC_EMULATION
    00135
    00136 #ifndef __cplusplus
    00137
    00138 #include <linux/irq.h>
    00139
    00140 extern struct desc_struct idt_table[];
    00141
    00142 extern struct rt_hal rthal;
    00143
    00144 #ifdef FIXME
    00145 static inline struct desc_struct rt_set_full_intr_vect (unsigned vector,
    00146                                                         int type,
    00147                                                         int dpl,
    00148                                                         void (*handler)(void)) {
    00149     struct desc_struct e = idt_table[vector];
    00150     idt_table[vector].a = (__KERNEL_CS << 16) | ((unsigned)handler & 0x0000FFFF);
    00151     idt_table[vector].b = ((unsigned)handler & 0xFFFF0000) | (0x8000 + (dpl << 13) + (type << 8));
    00152     return e;
    00153 }
    00154
    00155 static inline void rt_reset_full_intr_vect(unsigned vector,
    00156                                            struct desc_struct e) {
    00157     idt_table[vector] = e;
    00158 }
    00159
    00160 static const int __ipi2vec[] = {
    00161     INVALIDATE_TLB_VECTOR,
    00162     LOCAL_TIMER_VECTOR,
    00163     RESCHEDULE_VECTOR,
    00164     CALL_FUNCTION_VECTOR,
    00165     SPURIOUS_APIC_VECTOR,
    00166     ERROR_APIC_VECTOR,
    00167     -1,                 /* RTAI_1_VECTOR: reserved */
    00168     -1,                 /* RTAI_2_VECTOR: reserved */
    00169     RTAI_3_VECTOR,
    00170     RTAI_4_VECTOR
    00171 };
    00172
    00173 #define __vec2irq(v) ((v) - FIRST_EXTERNAL_VECTOR)
    00174
    00175 static const unsigned __ipi2irq[] = {
    00176     __vec2irq(INVALIDATE_TLB_VECTOR),
    00177     __vec2irq(LOCAL_TIMER_VECTOR),
    00178     __vec2irq(RESCHEDULE_VECTOR),
    00179     __vec2irq(CALL_FUNCTION_VECTOR),
    00180     __vec2irq(SPURIOUS_APIC_VECTOR),
    00181     __vec2irq(ERROR_APIC_VECTOR),
    00182     (unsigned)-1,       /* RTAI_1_IPI: reserved */
    00183     (unsigned)-1,       /* RTAI_2_IPI: reserved */
    00184     RTAI_APIC3_IPI,
    00185     RTAI_APIC4_IPI
    00186 };
    00187 #endif
    00188
    00189 /* cpu_own_irq() routines are RTHAL-specific and emulated here for
    00190    compatibility purposes. */
    00191
    00192 static inline int rt_request_cpu_own_irq (unsigned ipi, void (*handler)(void)) {
    00193
    00194 #ifdef FIXME
    00195     return ipi < 10 ? rt_request_irq(__ipi2irq[ipi],(rt_irq_handler_t)handler,0) : -EINVAL;
    00196 #else
    00197     return 0;
    00198 #endif
    00199 }
    00200
    00201 static inline int rt_free_cpu_own_irq (unsigned ipi) {
    00202
    00203 #ifdef FIXME
    00204     return ipi < 10 ? rt_release_irq(__ipi2irq[ipi]) : -EINVAL;
    00205 #else
    00206     return 0;
    00207 #endif
    00208 }
    00209
    00210 #ifdef CONFIG_SMP
    00211
    00212 static inline void send_ipi_shorthand (unsigned shorthand,
    00213                                        int irq) {
    00214     unsigned long flags;
    00215     rtai_hw_lock(flags);
    00216     apic_wait_icr_idle();
    00217     apic_write_around(APIC_ICR,APIC_DEST_LOGICAL|shorthand|__ipi2vec[irq]);
    00218     rtai_hw_unlock(flags);
    00219 }
    00220
    00221 static inline void send_ipi_logical (unsigned long dest,
    00222                                      int irq) {
    00223     unsigned long flags;
    00224
    00225     if ((dest &= cpu_online_map) != 0)
    00226         {
    00227         rtai_hw_lock(flags);
    00228         apic_wait_icr_idle();
    00229         apic_write_around(APIC_ICR2,SET_APIC_DEST_FIELD(dest));
    00230         apic_write_around(APIC_ICR,APIC_DEST_LOGICAL|__ipi2vec[irq]);
    00231         rtai_hw_unlock(flags);
    00232         }
    00233 }
    00234
    00235 #endif /* CONFIG_SMP */
    00236
    00237 #ifdef FIXME
    00238 static inline void *get_intr_handler (unsigned vector) {
    00239
    00240     return (void *)((idt_table[vector].b & 0xFFFF0000) |
    00241                     (idt_table[vector].a & 0x0000FFFF));
    00242 }
    00243
    00244 static inline void set_intr_vect (unsigned vector,
    00245                                   void (*handler)(void)) {
    00246
    00247     idt_table[vector].a = (idt_table[vector].a & 0xFFFF0000) |
    00248         ((unsigned)handler & 0x0000FFFF);
    00249     idt_table[vector].b = ((unsigned)handler & 0xFFFF0000) |
    00250         (idt_table[vector].b & 0x0000FFFF);
    00251 }
    00252
    00253 static inline void *rt_set_intr_handler (unsigned vector,
    00254                                          void (*handler)(void)) {
    00255
    00256     void (*saved_handler)(void) = get_intr_handler(vector);
    00257     set_intr_vect(vector, handler);
    00258     return saved_handler;
    00259 }
    00260
    00261 static inline void rt_reset_intr_handler (unsigned vector,
    00262                                           void (*handler)(void)) {
    00263     set_intr_vect(vector, handler);
    00264 }
    00265
    00266 static inline unsigned long get_cr2 (void) {
    00267
    00268     unsigned long address;
    00269     __asm__("movl %%cr2,%0":"=r" (address));
    00270     return address;
    00271 }
    00272 #endif
    00273
    00274 #endif /* __KERNEL__ */
    00275
    00276 #endif /* !__cplusplus */
    00277
    00278 #endif /* __RTAI_HAL__ */
    00279
    00280 #endif /* !_RTAI_ASM_PPC_OLDNAMES_H */