⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtai_xeno.h

📁 rtai-3.1-test3的源代码(Real-Time Application Interface )
💻 H
📖 第 1 页 / 共 2 页
字号:
    in_tcb->active_task = inproc ?: outproc;    if (inproc && inproc != outproc)	{	struct mm_struct *oldmm = outproc->active_mm;#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)	switch_mm(oldmm,inproc->active_mm,inproc,0);#else /* >= 2.6.0 */	switch_mm(oldmm,inproc->active_mm,inproc);#endif /* < 2.6.0 */	if (!inproc->mm)#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)	    enter_lazy_tlb(oldmm,inproc,0);#else /* >= 2.6.0 */	    enter_lazy_tlb(oldmm,inproc);#endif /* < 2.6.0 */	}    __switch_threads(out_tcb,in_tcb,outproc,inproc);    /* If TS was set for the restored user-space thread, set it       back. */    if (out_tcb->user_task && (cr0 & 0x8) != 0)	stts();}static inline void xnarch_finalize_and_switch (xnarchtcb_t *dead_tcb,					       xnarchtcb_t *next_tcb) {    xnarch_switch_to(dead_tcb,next_tcb);}static inline void xnarch_finalize_no_switch (xnarchtcb_t *dead_tcb) {    /* Empty */}static inline void xnarch_save_fpu (xnarchtcb_t *tcb){#ifdef CONFIG_RTAI_FPU_SUPPORT    if (!tcb->user_task) /* __switch_to() will take care otherwise. */	{	if (cpu_has_fxsr)	    __asm__ __volatile__ ("fxsave %0; fnclex" : "=m" (*tcb->fpup));	else	    __asm__ __volatile__ ("fnsave %0; fwait" : "=m" (*tcb->fpup));	}#endif /* CONFIG_RTAI_FPU_SUPPORT */}static inline void xnarch_restore_fpu (xnarchtcb_t *tcb){#ifdef CONFIG_RTAI_FPU_SUPPORT    if (tcb->user_task)	{	if (!tcb->user_task->used_math)	    return;	/* Uninit fpu area -- do not restore. */	/* Tell Linux that this task has altered the state of the FPU	   hardware. */	set_tsk_used_fpu(tcb->user_task);	}    /* Restore the FPU hardware with valid fp registers from a       user-space or kernel thread. */    clts();    if (cpu_has_fxsr)	__asm__ __volatile__ ("fxrstor %0": /* no output */ : "m" (*tcb->fpup));    else	__asm__ __volatile__ ("frstor %0": /* no output */ : "m" (*tcb->fpup));#endif /* CONFIG_RTAI_FPU_SUPPORT */}static inline void xnarch_init_root_tcb (xnarchtcb_t *tcb,					 struct xnthread *thread,					 const char *name){    tcb->module = THIS_MODULE;    tcb->user_task = current;    tcb->active_task = NULL;    tcb->esp = 0;    tcb->espp = &tcb->esp;    tcb->eipp = &tcb->eip;    tcb->fpup = &current->thread.i387;}static inline void xnarch_init_tcb (xnarchtcb_t *tcb, void *adcookie) {    tcb->module = (struct module *)adcookie;    tcb->user_task = NULL;    tcb->active_task = NULL;    tcb->espp = &tcb->esp;    tcb->eipp = &tcb->eip;    tcb->fpup = &tcb->fpuenv;    /* Must be followed by xnarch_init_thread(). */}static void xnarch_thread_redirect (struct xnthread *self,				    int imask,				    void(*entry)(void *),				    void *cookie){    rtai_local_irq_restore(!!imask);    xnpod_welcome_thread(self);    entry(cookie);    xnpod_delete_thread(self,NULL);}static inline void xnarch_init_thread (xnarchtcb_t *tcb,				       void (*entry)(void *),				       void *cookie,				       int imask,				       struct xnthread *thread,				       char *name){    unsigned long **psp = (unsigned long **)&tcb->esp;    tcb->eip = (unsigned long)&xnarch_thread_redirect;    tcb->esp = (unsigned long)tcb->stackbase;    **psp = 0;	/* Commit bottom stack memory */    *psp = (unsigned long *)(((unsigned long)*psp + tcb->stacksize - 0x10) & ~0xf);    *--(*psp) = (unsigned long)cookie;    *--(*psp) = (unsigned long)entry;    *--(*psp) = (unsigned long)imask;    *--(*psp) = (unsigned long)thread;    *--(*psp) = 0;}#ifdef CONFIG_RTAI_FPU_SUPPORTstatic inline void xnarch_init_fpu (xnarchtcb_t *tcb){    /* Initialize the FPU for an emerging kernel-based RT thread. This       must be run on behalf of the emerging thread. */    __asm__ __volatile__ ("clts; fninit");    if (cpu_has_xmm)	load_mxcsr(0x1f80);}#else /* !CONFIG_RTAI_FPU_SUPPORT */static inline void xnarch_init_fpu (xnarchtcb_t *tcb) {}#endif /* CONFIG_RTAI_FPU_SUPPORT */int xnarch_setimask (int imask){    spl_t s;    splhigh(s);    splexit(!!imask);    return !!s;}static inline void xnarch_relay_tick (void) {    rt_pend_linux_irq(RTAI_TIMER_8254_IRQ);}#define xnarch_notify_ready() /* Nullified */#endif /* XENO_POD_MODULE */#ifdef XENO_SHADOW_MODULEstatic inline void xnarch_init_shadow_tcb (xnarchtcb_t *tcb,					   struct xnthread *thread,					   const char *name){    struct task_struct *task = current;    tcb->module = THIS_MODULE;    tcb->user_task = task;    tcb->active_task = NULL;    tcb->esp = 0;    tcb->espp = &task->thread.esp;    tcb->eipp = &task->thread.eip;    tcb->fpup = &task->thread.i387;}#endif /* XENO_SHADOW_MODULE */#ifdef XENO_HEAP_MODULEvoid *xnarch_sysalloc (unsigned bytes) {    return kmalloc(bytes,GFP_ATOMIC);}void xnarch_sysfree (void *chunk, unsigned bytes) {    kfree(chunk);}#else /* !XENO_HEAP_MODULE */void *xnarch_sysalloc(unsigned bytes);void xnarch_sysfree(void *chunk,		    unsigned bytes);#endif /* XENO_HEAP_MODULE */#ifdef XENO_TIMER_MODULEstatic unsigned long xnarch_timer_calibration;void xnarch_calibrate_timer (void) {    /* Compute the time needed to program the 8254 PIT in aperiodic       mode. The stored value is expressed in CPU ticks. */    xnarch_timer_calibration = xnarch_ns_to_tsc(rtai_calibrate_8254());}static void xnarch_program_timer_shot (unsigned long long delay) /* <= in CPU ticks */{    if (delay < xnarch_timer_calibration)	/* If the delay value is lower than the time needed to program	   the PIT, increase it to a sane minimum so that we don't	   lose a tick. */	delay = xnarch_timer_calibration;    rt_set_timer_delay(rtai_imuldiv(delay,RTAI_FREQ_8254,RTAI_CPU_FREQ));}static inline void xnarch_stop_timer (void) {    rt_free_timer();}#endif /* XENO_TIMER_MODULE */#ifdef XENO_MAIN_MODULEint xnpod_trap_fault(xnarch_fltinfo_t *fltinfo);void xnarch_calibrate_timer(void);static RT_TRAP_HANDLER xnarch_old_trap_handler;static int xnarch_trap_fault (int vector,			      int signo,			      struct pt_regs *regs,			      void *dummy){    xnarch_fltinfo_t fltinfo;    fltinfo.vector = vector;    fltinfo.errcode = regs->orig_eax;    fltinfo.regs = regs;    return xnpod_trap_fault(&fltinfo);}static inline int xnarch_init (void){    xnarch_old_trap_handler = rt_set_trap_handler(&xnarch_trap_fault);    xnarch_calibrate_timer();    return xnshadow_init();}static inline void xnarch_exit (void) {    xnshadow_cleanup();    rt_set_trap_handler(xnarch_old_trap_handler);}#endif /* XENO_MAIN_MODULE */#ifdef __cplusplus}#endif/* Dashboard and graph control. */#define XNARCH_DECL_DISPLAY_CONTEXT();#define xnarch_init_display_context(obj)#define xnarch_create_display(obj,name,tag)#define xnarch_delete_display(obj)#define xnarch_post_graph(obj,state)#define xnarch_post_graph_if(obj,state,cond)#endif /* !_RTAI_ASM_I386_XENO_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -