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

📄 rthal-5g-2.4.18.patch

📁 rtai-3.1-test3的源代码(Real-Time Application Interface )
💻 PATCH
字号:
+ diff -u linux-2.4.18/arch/ppc/config.in.PRE_RTAI linux-2.4.18/arch/ppc/config.in--- linux-2.4.18/arch/ppc/config.in.PRE_RTAI	Thu Mar 21 09:33:13 2002+++ linux-2.4.18/arch/ppc/config.in	Thu Mar 21 10:59:06 2002@@ -109,6 +109,9 @@   bool '  Distribute interrupts on all CPUs by default' CONFIG_IRQ_ALL_CPUS fi +#bool 'Real-Time Hardware Abstraction Layer' CONFIG_RTHAL+define_bool CONFIG_RTHAL y+ if [ "$CONFIG_6xx" = "y" -a "$CONFIG_8260" = "n" ];then   bool 'AltiVec Support' CONFIG_ALTIVEC   bool 'Thermal Management Support' CONFIG_TAU+ diff -u linux-2.4.18/arch/ppc/kernel/entry.S.PRE_RTAI linux-2.4.18/arch/ppc/kernel/entry.S--- linux-2.4.18/arch/ppc/kernel/entry.S.PRE_RTAI	Thu Mar 21 09:33:13 2002+++ linux-2.4.18/arch/ppc/kernel/entry.S	Thu Mar 21 10:59:06 2002@@ -294,6 +294,7 @@ 	bl	do_signal 	.globl	do_signal_ret do_signal_ret:+	bl	do_soft_sti 	.globl ret_to_user_hook	 ret_to_user_hook: 	nop+ diff -u linux-2.4.18/arch/ppc/kernel/irq.c.PRE_RTAI linux-2.4.18/arch/ppc/kernel/irq.c--- linux-2.4.18/arch/ppc/kernel/irq.c.PRE_RTAI	Thu Mar 21 09:33:13 2002+++ linux-2.4.18/arch/ppc/kernel/irq.c	Thu Mar 21 11:05:30 2002@@ -534,12 +534,21 @@ 	spin_unlock(&desc->lock); } -int do_IRQ(struct pt_regs *regs)+void (*rtai_soft_sti)(void);++void do_soft_sti(void)+{+	if(rtai_soft_sti)rtai_soft_sti();+}++int do_IRQ(struct pt_regs *regs, int isfake) { 	int cpu = smp_processor_id(); 	int irq, first = 1;         hardirq_enter( cpu ); +	if (do_IRQ == (unsigned long)do_IRQ_intercept) {+ 	for (;;) { 		/* 		 * Every arch is required to implement ppc_md.get_irq.@@ -561,6 +570,11 @@ 		} 		first = 0; 	}++	} else {+		ppc_irq_dispatch_handler(regs, isfake);+	}+         hardirq_exit( cpu );  	if (softirq_pending(cpu))+ diff -u linux-2.4.18/arch/ppc/kernel/ppc_ksyms.c.PRE_RTAI linux-2.4.18/arch/ppc/kernel/ppc_ksyms.c--- linux-2.4.18/arch/ppc/kernel/ppc_ksyms.c.PRE_RTAI	Thu Mar 21 09:33:13 2002+++ linux-2.4.18/arch/ppc/kernel/ppc_ksyms.c	Thu Mar 21 10:59:06 2002@@ -217,6 +217,12 @@ EXPORT_SYMBOL(synchronize_irq); #endif +extern int (*rtai_srq_bckdr)(struct pt_regs *);+EXPORT_SYMBOL(rtai_srq_bckdr);++extern void (*rtai_soft_sti)(void);+EXPORT_SYMBOL(rtai_soft_sti);+ EXPORT_SYMBOL(ppc_md);  #ifdef CONFIG_ADB+ diff -u linux-2.4.18/arch/ppc/kernel/traps.c.PRE_RTAI linux-2.4.18/arch/ppc/kernel/traps.c--- linux-2.4.18/arch/ppc/kernel/traps.c.PRE_RTAI	Thu Mar 21 09:33:13 2002+++ linux-2.4.18/arch/ppc/kernel/traps.c	Thu Mar 21 11:10:27 2002@@ -269,9 +269,15 @@ 	return(retval); } +int (*rtai_srq_bckdr)(struct pt_regs *regs) = NULL;+ void ProgramCheckException(struct pt_regs *regs) {+	if (rtai_srq_bckdr && !rtai_srq_bckdr(regs)) {+		return;+	}+ #if defined(CONFIG_4xx) 	unsigned int esr = mfspr(SPRN_ESR); + diff -u linux-2.4.18/arch/ppc/mm/pgtable.c.PRE_RTAI linux-2.4.18/arch/ppc/mm/pgtable.c--- linux-2.4.18/arch/ppc/mm/pgtable.c.PRE_RTAI	Thu Mar 21 09:33:14 2002+++ linux-2.4.18/arch/ppc/mm/pgtable.c	Thu Mar 21 11:12:04 2002@@ -273,7 +273,7 @@ 		 * don't get ASID compares on kernel space. 		 */ 		f = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_SHARED;-#if defined(CONFIG_KGDB) || defined(CONFIG_XMON)+#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_RTHAL) 		/* Allows stub to set breakpoints everywhere */ 		f |= _PAGE_WRENABLE; #else	/* !CONFIG_KGDB && !CONFIG_XMON */+ diff -u linux-2.4.18/Documentation/Configure.help.PRE_RTAI linux-2.4.18/Documentation/Configure.help--- linux-2.4.18/Documentation/Configure.help.PRE_RTAI	Thu Mar 21 09:33:13 2002+++ linux-2.4.18/Documentation/Configure.help	Thu Mar 21 10:59:06 2002@@ -241,6 +241,13 @@   You will need a new lynxer.elf file to flash your firmware with - send   email to Martin.Bligh@us.ibm.com +Real-Time Harware Abstraction+CONFIG_RTHAL+  The Real-Time Hardware Abstraction Layer (RTHAL) is used by+  the Real-Time Application Interface (RTAI) to provide a+  hard real-time environment as part of Linux.  This feature+  cannot be turned off, so say Y.+ IO-APIC support on uniprocessors CONFIG_X86_UP_IOAPIC   An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an+ diff -u linux-2.4.18/include/asm-ppc/system.h.PRE_RTAI linux-2.4.18/include/asm-ppc/system.h--- linux-2.4.18/include/asm-ppc/system.h.PRE_RTAI	Thu Mar 21 10:34:16 2002+++ linux-2.4.18/include/asm-ppc/system.h	Thu Mar 21 10:59:06 2002@@ -81,6 +81,7 @@  struct task_struct; #define prepare_to_switch()	do { } while(0)+#define end_switch()		do { } while(0) #define switch_to(prev,next,last) _switch_to((prev),(next),&(last)) extern void _switch_to(struct task_struct *, struct task_struct *, 		       struct task_struct **);+ diff -u linux-2.4.18/include/linux/sched.h.PRE_RTAI linux-2.4.18/include/linux/sched.h--- linux-2.4.18/include/linux/sched.h.PRE_RTAI	Thu Mar 21 10:34:17 2002+++ linux-2.4.18/include/linux/sched.h	Thu Mar 21 11:18:05 2002@@ -410,6 +410,8 @@  /* journalling filesystem info */ 	void *journal_info;++	void *this_rt_task[2]; };  /*@@ -501,6 +503,7 @@     blocked:		{{0}},						\     alloc_lock:		SPIN_LOCK_UNLOCKED,				\     journal_info:	NULL,						\+    this_rt_task:	{0,0},						\ }  + diff -u linux-2.4.18/kernel/exit.c.PRE_RTAI linux-2.4.18/kernel/exit.c--- linux-2.4.18/kernel/exit.c.PRE_RTAI	Mon Feb 25 20:38:13 2002+++ linux-2.4.18/kernel/exit.c	Thu Mar 21 10:59:07 2002@@ -429,6 +429,71 @@ 	write_unlock_irq(&tasklist_lock); } +//+// PGGC added these lines to callback rtai when a task dies.+// A list of functions allows different rt_modules to be informed.+//+static struct t_callback {+	void (*rtai_callback)(struct task_struct *tsk);+	struct t_callback *next;+	} *rtai_callback_list;++extern int  set_rtai_callback(    void (*fun)(struct task_struct *tsk));+extern void remove_rtai_callback( void (*fun)(struct task_struct *tsk));++void inform_rtai(void)+{+	struct t_callback *pt;++	pt = rtai_callback_list;+	while (pt) {+		(*(pt->rtai_callback))(current);+		pt = pt->next;+	}+//printk( "Task pid %d going down\n", current->pid);+}++int set_rtai_callback( void (*pt)(struct task_struct *tsk))+{+	struct t_callback *ptn;++	ptn = kmalloc(sizeof(struct t_callback), GFP_KERNEL);+	if (!ptn) {+		return -ENOMEM;+	}+	ptn->rtai_callback = pt;+	ptn->next = rtai_callback_list ? rtai_callback_list : 0;+	rtai_callback_list = ptn;+	return 0;+}++void remove_rtai_callback(void (*pt)(struct task_struct *tsk))+{+	struct t_callback *pto, *ptoo, *ptd;++	pto  = rtai_callback_list;+	ptoo = 0;+	while (pto) {+		if (pto->rtai_callback == pt) {+			if (!ptoo) {+				rtai_callback_list = pto->next;+			} else {+				ptoo->next = pto->next; +			}+ 			ptd = pto;+			pto = pto->next;+			kfree(ptd);+		} else {+			ptoo = pto;+			pto = pto->next;+		}	+	}+//printk("rtai_callback_list %X\n", rtai_callback_list);+}+//+//+//+ NORET_TYPE void do_exit(long code) { 	struct task_struct *tsk = current;@@ -446,6 +511,18 @@ #ifdef CONFIG_BSD_PROCESS_ACCT 	acct_process(code); #endif++/*+ * PGGC added these lines to callback rtai when a task dies.+ * This assumes that a LXRT task should/will always set its+ * scheduling police to SCHED_FIFO or SCHED_RR.+ * We may want to enforce this in rt_task_init(...).+ * (For the moment it is not so, thus let's inform LXRT anyhow (Paolo))+ */+	if(tsk->this_rt_task[0]) {+		inform_rtai();+	}+ 	__exit_mm(tsk);  	lock_kernel();+ diff -u linux-2.4.18/kernel/fork.c.PRE_RTAI linux-2.4.18/kernel/fork.c--- linux-2.4.18/kernel/fork.c.PRE_RTAI	Mon Feb 25 20:38:13 2002+++ linux-2.4.18/kernel/fork.c	Thu Mar 21 10:59:07 2002@@ -220,7 +220,9 @@ 	atomic_set(&mm->mm_count, 1); 	init_rwsem(&mm->mmap_sem); 	mm->page_table_lock = SPIN_LOCK_UNLOCKED;+	lock_kernel(); 	mm->pgd = pgd_alloc(mm);+	unlock_kernel(); 	mm->def_flags = 0; 	if (mm->pgd) 		return mm;@@ -252,7 +254,9 @@ inline void __mmdrop(struct mm_struct *mm) { 	if (mm == &init_mm) BUG();+	lock_kernel(); 	pgd_free(mm->pgd);+	unlock_kernel(); 	destroy_context(mm); 	free_mm(mm); }+ diff -u linux-2.4.18/kernel/ksyms.c.PRE_RTAI linux-2.4.18/kernel/ksyms.c--- linux-2.4.18/kernel/ksyms.c.PRE_RTAI	Mon Feb 25 20:38:13 2002+++ linux-2.4.18/kernel/ksyms.c	Thu Mar 21 10:59:07 2002@@ -559,3 +559,44 @@  EXPORT_SYMBOL(tasklist_lock); EXPORT_SYMBOL(pidhash);++/*+ * used to inform rtai a task is about to die.+ */+extern int  set_rtai_callback(   void (*fun)(struct task_struct *tsk));+extern void remove_rtai_callback(void (*fun)(struct task_struct *tsk));+extern NORET_TYPE void do_exit(long code);+EXPORT_SYMBOL(set_rtai_callback);+EXPORT_SYMBOL(remove_rtai_callback);+EXPORT_SYMBOL(do_exit);++/*+ * used to inform RTAI LXRT a task should deal with a Linux signal, and for rt_lxrt_fork()+ */+extern int (*rtai_signal_handler)(struct task_struct *lnxt, int sig);+EXPORT_SYMBOL(rtai_signal_handler);+extern int do_fork(unsigned long clone_flags, unsigned long stack_start, struct pt_regs *regs, unsigned long stack_size);+EXPORT_SYMBOL(do_fork);++/*+ * used to provide async io support (aio) to RTAI LXRT.+ */+extern ssize_t sys_read(unsigned int fd, char * buf, size_t count);+extern ssize_t sys_write(unsigned int fd, const char * buf, size_t count);+extern ssize_t sys_pread(unsigned int fd, char * buf,+				                             size_t count, loff_t pos);+extern ssize_t sys_pwrite(unsigned int fd, const char * buf,+				                              size_t count, loff_t pos);+extern long sys_fsync(unsigned int fd);+extern long sys_fdatasync(unsigned int fd);+extern long sys_open(const char * filename, int flags, int mode);+extern long sys_close(unsigned int fd);++EXPORT_SYMBOL(sys_read);+EXPORT_SYMBOL(sys_write);+EXPORT_SYMBOL(sys_open);+//EXPORT_SYMBOL(sys_close);+EXPORT_SYMBOL(sys_pread);+EXPORT_SYMBOL(sys_pwrite);+EXPORT_SYMBOL(sys_fsync);+EXPORT_SYMBOL(sys_fdatasync);+ diff -u linux-2.4.18/kernel/sched.c.PRE_RTAI linux-2.4.18/kernel/sched.c--- linux-2.4.18/kernel/sched.c.PRE_RTAI	Fri Dec 21 18:42:04 2001+++ linux-2.4.18/kernel/sched.c	Thu Mar 21 10:59:07 2002@@ -546,6 +546,75 @@  * tasks can run. It can not be killed, and it cannot sleep. The 'state'  * information in task[0] is never used.  */++int idle_weight = -1000;+#define MAX_MM 4096  // How large should it be?+static struct smm_t { int in, out; struct mm_struct *mm[MAX_MM]; } smm[NR_CPUS];+#define incpnd(x) do { x = (x + 1) & (MAX_MM - 1); } while(0)++#ifdef CONFIG_X86+static inline void pend_mm(struct mm_struct *mm, int cpu)+{+	if (rthal.lxrt_global_cli) {+        	struct smm_t *p = smm + cpu;+        	p->mm[p->in] = mm;+	        incpnd(p->in);+	} else {+		mmdrop(mm);+	}+}++static inline void drop_mm(void)+{+	if (rthal.lxrt_global_cli) {+        	struct smm_t *p = smm + smp_processor_id();+	        while (p->out != p->in) {+        	        mmdrop(p->mm[p->out]);+              		incpnd(p->out);+        	}+        }+}++void switch_mem(struct task_struct *prevp, struct task_struct *nextp, int cpuid)+{+	if (cpuid < 0) {+		struct mm_struct *next = nextp->active_mm;+		if (prevp->active_mm != next || (cpuid & 0x40000000)) {+			if ((prevp->active_mm)->context.segments != next->context.segments) {+				load_LDT(next);+			}+			set_bit(cpuid & 0xFFFFFFF, &next->context.cpuvalid);+			asm volatile("movl %0,%%cr3": :"r" (__pa(next->pgd)));+		}+#ifdef CONFIG_SMP+		  else if (!test_and_set_bit(cpuid & 0xFFFFFFF, &next->context.cpuvalid)) {+			load_LDT(next);+		}+#endif+	} else {+		struct mm_struct *oldmm = prevp->active_mm;+		if (nextp->mm) {+			switch_mm(oldmm, nextp->mm, nextp, cpuid);+		} else {+			nextp->active_mm = oldmm;+			atomic_inc(&oldmm->mm_count);+			enter_lazy_tlb(oldmm, nextp, cpuid);+		}+		if (!prevp->mm) {+			prevp->active_mm = NULL;+			pend_mm(oldmm, cpuid);+		}+	}+}+#else+static inline void pend_mm(struct mm_struct *mm, int cpu)+{+	mmdrop(mm);+}+static inline void drop_mm(void) {}+void switch_mem(struct task_struct *prevp, struct task_struct *nextp, int cpuid) {}+#endif+ asmlinkage void schedule(void) { 	struct schedule_data * sched_data;@@ -604,7 +673,7 @@ 	 * Default process to select.. 	 */ 	next = idle_task(this_cpu);-	c = -1000;+	c = idle_weight; 	list_for_each(tmp, &runqueue_head) { 		p = list_entry(tmp, struct task_struct, run_list); 		if (can_schedule(p, this_cpu)) {@@ -686,7 +755,7 @@  		if (!prev->mm) { 			prev->active_mm = NULL;-			mmdrop(oldmm);+			pend_mm(oldmm, this_cpu); 		} 	} @@ -695,6 +764,7 @@ 	 * stack. 	 */ 	switch_to(prev, next, prev);+	drop_mm(); 	__schedule_tail(prev);  same_process:+ diff -u linux-2.4.18/kernel/signal.c.PRE_RTAI linux-2.4.18/kernel/signal.c--- linux-2.4.18/kernel/signal.c.PRE_RTAI	Thu Nov 22 01:26:27 2001+++ linux-2.4.18/kernel/signal.c	Thu Mar 21 10:59:07 2002@@ -974,9 +974,30 @@ 	return ret; } +//+//  Add this pointer to the RTAI signal handler.+//+int (*rtai_signal_handler)(struct task_struct *lnxt, int sig);+ asmlinkage long sys_kill(int pid, int sig) {+// Add this section to call the RTAI signal handler.+//+	{+	struct task_struct *p;+	int ret;++	if (rtai_signal_handler) {+	    p = find_task_by_pid(pid);+		if(p && (p->policy == SCHED_FIFO || p->policy == SCHED_RR) && p->this_rt_task[0]) {+			ret = rtai_signal_handler(p, sig);+			if(!ret) return 0; //let Linux deal with it.+			}+		}+	}++	{ 	struct siginfo info;  	info.si_signo = sig;@@ -986,6 +1007,7 @@ 	info.si_uid = current->uid;  	return kill_something_info(sig, &info, pid);+	} }  asmlinkage long+ diff -u linux-2.4.18/Makefile.PRE_RTAI linux-2.4.18/Makefile--- linux-2.4.18/Makefile.PRE_RTAI	Thu Mar 21 09:33:13 2002+++ linux-2.4.18/Makefile	Thu Mar 21 10:59:06 2002@@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 18-EXTRAVERSION =+EXTRAVERSION = -rthal5  KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + diff -u linux-2.4.18/mm/vmalloc.c.PRE_RTAI linux-2.4.18/mm/vmalloc.c--- linux-2.4.18/mm/vmalloc.c.PRE_RTAI	Mon Feb 25 20:38:14 2002+++ linux-2.4.18/mm/vmalloc.c	Thu Mar 21 10:59:07 2002@@ -148,6 +148,9 @@ 	spin_lock(&init_mm.page_table_lock); 	do { 		pmd_t *pmd;+#ifdef CONFIG_X86+		pgd_t olddir = *dir;+#endif 		 		pmd = pmd_alloc(&init_mm, dir, address); 		ret = -ENOMEM;@@ -157,6 +160,10 @@ 		ret = -ENOMEM; 		if (alloc_area_pmd(pmd, address, end - address, gfp_mask, prot)) 			break;+#ifdef CONFIG_X86+		if (pgd_val(olddir) != pgd_val(*dir))+			set_pgdir(address, *dir);+#endif  		address = (address + PGDIR_SIZE) & PGDIR_MASK; 		dir++;

⌨️ 快捷键说明

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