📄 rtai_hal.h
字号:
static inline void rt_get_global_lock(void) { adeos_declare_cpuid; rtai_cli();#ifdef adeos_load_cpuid adeos_load_cpuid();#endif /* adeos_load_cpuid */ if (!test_and_set_bit(cpuid,&rtai_cpu_lock)) while (test_and_set_bit(31,&rtai_cpu_lock)) CPU_RELAX(cpuid);}static inline void rt_release_global_lock(void) { adeos_declare_cpuid; rtai_cli();#ifdef adeos_load_cpuid adeos_load_cpuid();#endif /* adeos_load_cpuid */ if (test_and_clear_bit(cpuid,&rtai_cpu_lock)) { clear_bit(31,&rtai_cpu_lock); CPU_RELAX(cpuid); }}/** * Disable interrupts across all CPUs * * rt_global_cli hard disables interrupts (cli) on the requesting CPU and * acquires the global spinlock to the calling CPU so that any other CPU * synchronized by this method is blocked. Nested calls to rt_global_cli within * the owner CPU will not cause a deadlock on the global spinlock, as it would * happen for a normal spinlock. * * rt_global_sti hard enables interrupts (sti) on the calling CPU and releases * the global lock. */static inline void rt_global_cli(void) { rt_get_global_lock();}/** * Enable interrupts across all CPUs * * rt_global_sti hard enables interrupts (sti) on the calling CPU and releases * the global lock. */static inline void rt_global_sti(void) { rt_release_global_lock(); rtai_sti();}/** * Save CPU flags * * rt_global_save_flags_and_cli combines rt_global_save_flags() and * rt_global_cli(). */static inline int rt_global_save_flags_and_cli(void) { unsigned long flags = rtai_get_iflag_and_cli(); adeos_declare_cpuid;#ifdef adeos_load_cpuid adeos_load_cpuid();#endif /* adeos_load_cpuid */ if (!test_and_set_bit(cpuid,&rtai_cpu_lock)) { while (test_and_set_bit(31,&rtai_cpu_lock)) CPU_RELAX(cpuid); return flags | 1; } return flags;}/** * Save CPU flags * * rt_global_save_flags saves the CPU interrupt flag (IF) bit 9 of @a flags and * ORs the global lock flag in the first 8 bits of flags. From that you can * rightly infer that RTAI does not support more than 8 CPUs. */static inline void rt_global_save_flags(unsigned long *flags) { unsigned long hflags = rtai_get_iflag_and_cli(), rflags; adeos_declare_cpuid;#ifdef adeos_load_cpuid adeos_load_cpuid();#endif /* adeos_load_cpuid */ if (test_bit(cpuid,&rtai_cpu_lock)) rflags = hflags; else rflags = hflags | 1; if (hflags) rtai_sti(); *flags = rflags;}/** * Restore CPU flags * * rt_global_restore_flags restores the CPU hard interrupt flag (IF) * and the state of the global inter-CPU lock, according to the state * given by flags. */static inline void rt_global_restore_flags(unsigned long flags) { switch (flags) { case (1 << RTAI_IFLAG) | 1: rt_release_global_lock(); rtai_sti(); break; case (1 << RTAI_IFLAG) | 0: rt_get_global_lock(); rtai_sti(); break; case (0 << RTAI_IFLAG) | 1: rt_release_global_lock(); break; case (0 << RTAI_IFLAG) | 0: rt_get_global_lock(); break; }}static inline void rt_switch_to_real_time(int cpuid) { TRACE_RTAI_SWITCHTO_RT(cpuid); rtai_linux_context[cpuid].oldtask = rtai_get_current(cpuid); rtai_linux_local_irq_save(rtai_linux_context[cpuid].oldflags); set_bit(cpuid,&rtai_cpu_realtime);}static inline void rt_switch_to_linux(int cpuid) { TRACE_RTAI_SWITCHTO_LINUX(cpuid); clear_bit(cpuid,&rtai_cpu_realtime); rtai_linux_local_irq_restore_nosync(rtai_linux_context[cpuid].oldflags,cpuid); rtai_linux_context[cpuid].oldtask = NULL;}static inline struct task_struct *rt_whoislinux(int cpuid) { return rtai_linux_context[cpuid].oldtask;}static inline int rt_is_linux (void) { return !test_bit(adeos_processor_id(),&rtai_cpu_realtime);}static inline int rt_is_lxrt (void) { return test_bit(adeos_processor_id(),&rtai_cpu_lxrt);}static inline void rt_set_timer_delay (int delay) { if (delay) { unsigned long flags; rtai_hw_lock(flags);#ifdef __USE_APIC__ apic_read(APIC_TMICT); apic_write(APIC_TMICT,delay);#else /* !__USE_APIC__ */ outb(delay & 0xff,0x40); outb(delay >> 8,0x40);#endif /* __USE_APIC__ */ rtai_hw_unlock(flags); }} /* Private interface -- Internal use only */unsigned long rtai_critical_enter(void (*synch)(void));void rtai_critical_exit(unsigned long flags);int rtai_calibrate_8254(void);void rtai_set_linux_task_priority(struct task_struct *task, int policy, int prio);#endif /* __KERNEL__ && !__cplusplus */ /* Public interface */#ifdef __KERNEL__#include <linux/kernel.h>#define rt_printk printk /* This is safe over Adeos */#define rtai_print_to_screen printk#ifdef __cplusplusextern "C" {#endif /* __cplusplus */int rt_request_irq(unsigned irq, void (*handler)(unsigned irq, void *cookie), void *cookie);int rt_release_irq(unsigned irq);void rt_set_irq_cookie(unsigned irq, void *cookie);/** * @name Programmable Interrupt Controllers (PIC) management functions. * *@{*/unsigned rt_startup_irq(unsigned irq);void rt_shutdown_irq(unsigned irq);void rt_enable_irq(unsigned irq);void rt_disable_irq(unsigned irq);void rt_mask_and_ack_irq(unsigned irq);void rt_unmask_irq(unsigned irq);void rt_ack_irq(unsigned irq);/*@}*/void rt_do_irq(unsigned irq);int rt_request_linux_irq(unsigned irq, irqreturn_t (*handler)(int irq, void *dev_id, struct pt_regs *regs), char *name, void *dev_id);int rt_free_linux_irq(unsigned irq, void *dev_id);void rt_pend_linux_irq(unsigned irq);void rt_pend_linux_srq(unsigned srq);int rt_request_srq(unsigned label, void (*k_handler)(void), long long (*u_handler)(unsigned));int rt_free_srq(unsigned srq);int rt_assign_irq_to_cpu(int irq, unsigned long cpus_mask);int rt_reset_irq_to_sym_mode(int irq);void rt_request_timer_cpuid(void (*handler)(void), unsigned tick, int cpuid);void rt_request_apic_timers(void (*handler)(void), struct apic_timer_setup_data *tmdata);void rt_free_apic_timers(void);int rt_request_timer(void (*handler)(void), unsigned tick, int use_apic);void rt_free_timer(void);RT_TRAP_HANDLER rt_set_trap_handler(RT_TRAP_HANDLER handler);void rt_mount(void);void rt_umount(void);RTIME rd_8254_ts(void);void rt_setup_8254_tsc(void);void (*rt_set_ihook(void (*hookfn)(int)))(int);/* Deprecated calls. */static inline int rt_request_global_irq_ext(unsigned irq, void (*handler)(void), unsigned long cookie) { return rt_request_irq(irq,(void (*)(unsigned,void *))handler,(void *)cookie);}static inline int rt_request_global_irq(unsigned irq, void (*handler)(void)) { return rt_request_irq(irq,(void (*)(unsigned,void *))handler,0);}static inline void rt_set_global_irq_ext(unsigned irq, int ext, unsigned long cookie) { rt_set_irq_cookie(irq,(void *)cookie);}static inline int rt_free_global_irq(unsigned irq) { return rt_release_irq(irq);}#ifdef __cplusplus}#endif /* __cplusplus */#endif /* __KERNEL__ */#include <asm/rtai_oldnames.h>#define RTAI_DEFAULT_TICK 100000#ifdef CONFIG_RTAI_TRACE#define RTAI_DEFAULT_STACKSZ 8192#else /* !CONFIG_RTAI_TRACE */#define RTAI_DEFAULT_STACKSZ 1024#endif /* CONFIG_RTAI_TRACE *//*@}*/#endif /* !_RTAI_ASM_I386_HAL_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -