diff -urN rtai-24.1.9/Documentation/README.arm rtai-24.1.9-arm-newlxrt/Documentation/README.arm --- rtai-24.1.9/Documentation/README.arm Fri Apr 5 18:25:32 2002 +++ rtai-24.1.9-arm-newlxrt/Documentation/README.arm Fri Dec 6 12:01:29 2002 @@ -124,3 +124,12 @@ - Something like rt_com support - Exception handling is implemented only for undefined opcodes. + +NEWLXRT for ARM +--------------- +Basic support for NEWLXRT on ARM is now available. It has been tested on rtai 24.1.9 +running on a 2.4.15-pre6-rmk2 Linux kernel. + +Paul Coene (coene@imec.be) + + diff -urN rtai-24.1.9/arch/arm/rtai.c rtai-24.1.9-arm-newlxrt/arch/arm/rtai.c --- rtai-24.1.9/arch/arm/rtai.c Fri Dec 6 12:03:14 2002 +++ rtai-24.1.9-arm-newlxrt/arch/arm/rtai.c Fri Dec 6 12:02:54 2002 @@ -173,6 +173,7 @@ volatile unsigned int linux_intr_flag; volatile rtai_irq_mask_t pending_irqs; volatile rtai_irq_mask_t active_irqs; + volatile struct task_struct *cur; // Linux task running before RT } processor[NR_RT_CPUS]; void send_ipi_shorthand(unsigned int shorthand, rtai_irq_t irq) { } @@ -472,14 +473,14 @@ { unsigned long vec; long long retval = -1; - + #if DEBUG_LEVEL > 1 if ( ! (_debug_srqs[srq]++ & 0xFF) && GL_debug ) { // every 0x100 srqs printk( " srq %u: %u\n", srq, _debug_srqs[srq] ); } #endif - - if (!(vec = srq >> 24)) { + /* AND operator needed: sign of leftmost bit not specified after right shift */ + if (! (vec = ((srq >> 24) & 0xff)) ) { if (srq > 1 && srq < NR_SYSRQS && sysrq[srq].user_handler) { retval = sysrq[srq].user_handler(whatever); } else { @@ -525,12 +526,19 @@ */ asmlinkage int dispatch_traps(int vector, struct pt_regs *regs) { +/* + if (test_bit(hard_cpu_id(), &global.used_by_linux) && + !test_bit(hard_cpu_id(), &lxrt_hrt_flags)) { + return 0; // Not RTAI, let Linux handle it + } +*/ if ( (vector < NR_TRAPS) && (rtai_trap_handler[vector]) ) return rtai_trap_handler[vector](vector, vector, regs, NULL); return 1; /* Let Linux do the job */ } +/* RT_TRAP_HANDLER rt_set_rtai_trap_handler(int trap, RT_TRAP_HANDLER handler) { RT_TRAP_HANDLER old_handler = NULL; @@ -541,6 +549,19 @@ } return old_handler; } +*/ +RT_TRAP_HANDLER rt_set_rtai_trap_handler(RT_TRAP_HANDLER handler) +{ + /* TODO: call this from __dabt_usr, __dabt_svc, __pabt_usr, + __pabt_svc, __und_usr, __und_svc (already in place) + and make return values compatible with i386: + 0 : call normal Linux trap handler + != 0 : don't call Linux trap handler + + */ + return 0; +} + void rt_free_rtai_trap_handler(int trap) { @@ -744,6 +765,11 @@ return 0; } +int rt_is_lxrt(void) +{ + return test_bit(hard_cpu_id(), &lxrt_hrt_flags); +} + int rt_is_linux(void) { return test_bit(hard_cpu_id(), &global.used_by_linux); @@ -753,10 +779,19 @@ { set_bit(cpuid, &global.used_by_linux); processor[cpuid].intr_flag = processor[cpuid].linux_intr_flag; + processor[cpuid].cur = 0 ; +} + +struct task_struct *rt_whoislinux(int cpuid) +{ + // Returns current before the last context switch to RTAI. + // If current changed while in RTAI mode the box is in big trouble... + return (struct task_struct *) processor[cpuid].cur; } void rt_switch_to_real_time(int cpuid) { + processor[cpuid].cur = current; if ( global.used_by_linux & (1< diff -urN rtai-24.1.9/arch/ppc/rtai.c rtai-24.1.9-arm-newlxrt/arch/ppc/rtai.c --- rtai-24.1.9/arch/ppc/rtai.c Tue Mar 26 16:26:19 2002 +++ rtai-24.1.9-arm-newlxrt/arch/ppc/rtai.c Fri Dec 6 12:02:54 2002 @@ -600,7 +600,7 @@ TRACE_RTAI_SRQ_ENTRY(srq, !user_mode(regs)); - if (!(vec = srq >> 24)) { + if (! (vec = ((srq >> 24) & 0xff)) ) { if (srq > 1 && srq < NR_SYSRQS && sysrq[srq].user_handler) { retval = sysrq[srq].user_handler(whatever); } else { diff -urN rtai-24.1.9/include/asm-arm/rtai.h rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai.h --- rtai-24.1.9/include/asm-arm/rtai.h Fri Dec 6 12:03:14 2002 +++ rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai.h Fri Dec 6 12:02:54 2002 @@ -58,7 +58,7 @@ extern unsigned volatile int *locked_cpus; #ifndef CONFIG_SMP -extern unsigned long cpu_present_map; +//extern unsigned long cpu_present_map; #define smp_num_cpus 1 #endif @@ -177,7 +177,12 @@ #include #include +extern int rt_is_lxrt(void); +extern int rt_is_linux(void); +extern struct task_struct *rt_whoislinux(int cpuid); + #ifdef INTERFACE_TO_LINUX +extern RT_TRAP_HANDLER rt_set_rtai_trap_handler(RT_TRAP_HANDLER handler); extern void rt_switch_to_linux(int cpuid); extern void rt_switch_to_real_time(int cpuid); #endif diff -urN rtai-24.1.9/include/asm-arm/rtai_fpu.h rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai_fpu.h --- rtai-24.1.9/include/asm-arm/rtai_fpu.h Wed Feb 13 16:35:38 2002 +++ rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai_fpu.h Fri Dec 6 12:02:54 2002 @@ -8,6 +8,8 @@ #ifndef RTAI_FPU_ASM_H #define RTAI_FPU_ASM_H +#include + #ifdef CONFIG_RTAI_FPU_SUPPORT extern void save_fpenv(long *fpu_reg); @@ -17,7 +19,12 @@ #define save_fpenv(x) #define restore_fpenv(x) - +#define init_xfpu() #endif /* CONFIG_RTAI_FPU_SUPPORT */ +static inline void restore_fpenv_lxrt(struct task_struct *tsk) +{ + restore_fpenv(&tsk->thread.fpstate); +} + #endif /* RTAI_FPU_ASM_H */ diff -urN rtai-24.1.9/include/asm-arm/rtai_lxrt.h rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai_lxrt.h --- rtai-24.1.9/include/asm-arm/rtai_lxrt.h Wed Feb 13 16:35:38 2002 +++ rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai_lxrt.h Fri Dec 6 12:02:54 2002 @@ -27,19 +27,26 @@ #define RTAI_LXRT_VECTOR 0xFC -#define LOW 1 +/* Little endian ARM */ +#define LOW 0 +#define HIGH 1 + +#define HARD_CLI hard_cli + +#define HARD_LXRT + +union rtai_lxrt_t { RTIME rt; int i[2]; void *v[2]; }; #ifndef __KERNEL__ #define RTAI_SRQ_MAGIC "0x404404" -union rtai_lxrt_t { RTIME rt; int i[2]; void *v[2]; }; -static union rtai_lxrt_t rtai_lxrt(unsigned long srq, void *arg) +static union rtai_lxrt_t _rtai_lxrt(unsigned long srq, void *arg) { union rtai_lxrt_t retval; register unsigned long __sc_0 __asm__ ("r0") = srq | (RTAI_LXRT_VECTOR << 24); - register unsigned long __sc_1 __asm__ ("r1") = arg; + register unsigned long __sc_1 __asm__ ("r1") = (unsigned long) arg; __asm__ __volatile__ ( "swi\t" RTAI_SRQ_MAGIC "\n\t" @@ -53,7 +60,11 @@ #else -#define my_switch_to(prev, next, last) +#define my_switch_to(prev,next,last) \ + do { \ + last = rthal.__switch_to(prev,next); \ + mb(); \ + } while (0) #define STACK_STAGGER 27 @@ -63,11 +74,14 @@ #define DEFINE_LXRT_SYSCALL_HANDLER +/* This macro doesn't seem to be used for anything */ +/* #define init_lxrt_arch_stack( ) do { \ *(rt_task->stack_top - 8) = (int)lxrt_rtai_fun_call; \ *(rt_task->stack = rt_task->stack_top - 9) = MSR_KERNEL | MSR_FP | MSR_EE; \ rt_task->stack = rt_task->stack_top + STACK_STAGGER; \ } while (0) +*/ #endif diff -urN rtai-24.1.9/include/asm-arm/rtai_lxrt_sup.h rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai_lxrt_sup.h --- rtai-24.1.9/include/asm-arm/rtai_lxrt_sup.h Thu Jan 1 01:00:00 1970 +++ rtai-24.1.9-arm-newlxrt/include/asm-arm/rtai_lxrt_sup.h Fri Dec 6 12:02:54 2002 @@ -0,0 +1,40 @@ +/* +COPYRIGHT (C) 1999 Paolo Mantegazza (mantegazza@aero.polimi.it) +extensions for user space modules are jointly copyrighted (2000) with: + Pierre Cloutier (pcloutier@poseidoncontrols.com), + Steve Papacharalambous (stevep@zentropix.com). + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +*/ + + +#ifndef _RTAI_LXRT_ASM_SUP_H_ +#define _RTAI_LXRT_ASM_SUP_H_ + +DECLARE union rtai_lxrt_t rtai_lxrt(short int dynx, short int lsize, int srq, void *arg) +{ + void *pt; +// static int Arg[12]; + lsize /= sizeof(int); +/* if(my_cs() == __KERNEL_CS) { + // With this we can reenter lxrt from a user space function. + _memxcpy( &Arg, arg, __KERNEL_DS, lsize); + pt = &Arg; + } else */ pt = arg; + + return _rtai_lxrt((dynx << 20) | ((srq & 0xFFF) << 8) | lsize, pt); +} + +#endif // _RTAI_LXRT_ASM_SUP_H_ diff -urN rtai-24.1.9/include/asm-i386/rtai_lxrt_sup.h rtai-24.1.9-arm-newlxrt/include/asm-i386/rtai_lxrt_sup.h --- rtai-24.1.9/include/asm-i386/rtai_lxrt_sup.h Mon Feb 11 10:46:50 2002 +++ rtai-24.1.9-arm-newlxrt/include/asm-i386/rtai_lxrt_sup.h Fri Dec 6 12:02:54 2002 @@ -63,7 +63,7 @@ pt = &Arg; } else pt = arg; - return _rtai_lxrt((dynx << 28) | ((srq & 0xFFF) << 16) | lsize, pt); + return _rtai_lxrt((dynx << 20) | ((srq & 0xFFF) << 8) | lsize, pt); } #endif // _RTAI_LXRT_ASM_SUP_H_ diff -urN rtai-24.1.9/include/asm-ppc/fpu.h rtai-24.1.9-arm-newlxrt/include/asm-ppc/fpu.h --- rtai-24.1.9/include/asm-ppc/fpu.h Tue Mar 26 16:28:40 2002 +++ rtai-24.1.9-arm-newlxrt/include/asm-ppc/fpu.h Fri Dec 6 12:02:54 2002 @@ -133,6 +133,10 @@ #endif +static inline void restore_fpenv_lxrt(struct task_struct *tsk) +{ + __restore_fpenv((FPU_ENV *)tsk->thread.fpr); +} #endif diff -urN rtai-24.1.9/include/asm-ppc/rtai_lxrt.h rtai-24.1.9-arm-newlxrt/include/asm-ppc/rtai_lxrt.h --- rtai-24.1.9/include/asm-ppc/rtai_lxrt.h Tue Oct 24 02:32:28 2000 +++ rtai-24.1.9-arm-newlxrt/include/asm-ppc/rtai_lxrt.h Fri Dec 6 12:02:54 2002 @@ -53,6 +53,7 @@ #else +#warning fixme fixme #define my_switch_to(prev, next, last) #define STACK_STAGGER 27 @@ -63,11 +64,14 @@ #define DEFINE_LXRT_SYSCALL_HANDLER +/* This macro doesn't seem to be used for anything */ +/* #define init_lxrt_arch_stack( ) do { \ *(rt_task->stack_top - 8) = (int)lxrt_rtai_fun_call; \ *(rt_task->stack = rt_task->stack_top - 9) = MSR_KERNEL | MSR_FP | MSR_EE; \ rt_task->stack = rt_task->stack_top + STACK_STAGGER; \ } while (0) +*/ #endif diff -urN rtai-24.1.9/include/asm-ppc/rtai_lxrt_sup.h rtai-24.1.9-arm-newlxrt/include/asm-ppc/rtai_lxrt_sup.h --- rtai-24.1.9/include/asm-ppc/rtai_lxrt_sup.h Thu Jan 1 01:00:00 1970 +++ rtai-24.1.9-arm-newlxrt/include/asm-ppc/rtai_lxrt_sup.h Fri Dec 6 12:02:54 2002 @@ -0,0 +1,26 @@ +/* +COPYRIGHT (C) 1999 Paolo Mantegazza (mantegazza@aero.polimi.it) +extensions for user space modules are jointly copyrighted (2000) with: + Pierre Cloutier (pcloutier@poseidoncontrols.com), + Steve Papacharalambous (stevep@zentropix.com). + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +*/ + + +#ifndef _RTAI_LXRT_ASM_SUP_H_ +#define _RTAI_LXRT_ASM_SUP_H_ + +#endif // _RTAI_LXRT_ASM_SUP_H_ diff -urN rtai-24.1.9/include/rtai_lxrt.h rtai-24.1.9-arm-newlxrt/include/rtai_lxrt.h --- rtai-24.1.9/include/rtai_lxrt.h Mon Apr 15 09:23:43 2002 +++ rtai-24.1.9-arm-newlxrt/include/rtai_lxrt.h Fri Dec 6 12:02:54 2002 @@ -313,9 +313,10 @@ #define USP_WSZ1LL(x) (((unsigned long *)&(x))[HIGH] & 0x40000000) #define USP_WSZ2LL(x) (((unsigned long *)&(x))[HIGH] & 0x80000000) -#define SRQ(x) (((x) >> 16) & 0xFFF) -#define NARG(x) ((x) & 0xFFFF) -#define INDX(x) (((x) >> 28) & 0xF) +/* Encoding changed here to make ARM/PPC work */ +#define SRQ(x) (((x) >> 8) & 0xFFF) +#define NARG(x) ((x) & 0xFF) +#define INDX(x) (((x) >> 20) & 0xF) extern struct rt_fun_entry rt_fun_lxrt[]; diff -urN rtai-24.1.9/lxrt/Makefile rtai-24.1.9-arm-newlxrt/lxrt/Makefile --- rtai-24.1.9/lxrt/Makefile Mon Apr 8 15:37:15 2002 +++ rtai-24.1.9-arm-newlxrt/lxrt/Makefile Fri Dec 6 12:02:54 2002 @@ -1,10 +1,14 @@ +CONFIG_RTAI_LXRT = 1 + ignore_subdirs := octave perl subdirs := lib leds forked forked-lib hardsig ipc latency_calibration \ many master_buddy msg_clock one pressa qblk fifosound \ resumefromintr rt_agent sem_clock sound switches testmbx_wp \ threads traps two unix sched_ext soundmsg aio C++ +subdirs := + ifdef CONFIG_RTAI_LXRT_OCTAVE subdirs += octave endif diff -urN rtai-24.1.9/newlxrt/Makefile rtai-24.1.9-arm-newlxrt/newlxrt/Makefile --- rtai-24.1.9/newlxrt/Makefile Fri Dec 6 12:03:42 2002 +++ rtai-24.1.9-arm-newlxrt/newlxrt/Makefile Fri Dec 6 12:02:54 2002 @@ -1,5 +1,8 @@ subdirs := scheduler +# REMOVE ME LATER +CONFIG_RTAI_NEWLXRT = 1 + ALL_SUB_DIRS := $(subdirs) MOD_SUB_DIRS := SUB_DIRS := diff -urN rtai-24.1.9/newlxrt/mytest/Makefile rtai-24.1.9-arm-newlxrt/newlxrt/mytest/Makefile --- rtai-24.1.9/newlxrt/mytest/Makefile Thu Jan 1 01:00:00 1970 +++ rtai-24.1.9-arm-newlxrt/newlxrt/mytest/Makefile Fri Dec 6 12:02:54 2002 @@ -0,0 +1,41 @@ +########################################################## +# $Id: Makefile,v 1.1 2002/11/15 09:44:02 coene Exp $ +# +########################################################## + +SOURCES = syscall-test.c + +CC = arm-linux-gcc + +CURRENT_DIR=`pwd` +RTAI_DIR=$(CURRENT_DIR)/../../../../rt-ext/rtai-24.1.9 +LINUX_DIR=$(CURRENT_DIR)/../../../../kernel/linux + +INCLUDELIST = -I$(LINUX_DIR)/include \ + -I../scheduler \ + -I$(RTAI_DIR)/include + + +TARGET_LIST = $(SOURCES:%.c=%.o) + +CFLAGS = -O2 -Wall $(INCLUDELIST) -mapcs-32 -march=armv4 -mtune=strongarm1100 -mshort-load-bytes + +CFLAGS_MODULE = $(CFLAGS) -D__KERNEL__ -DMODULE + +%.o : %.c + $(CC) $(CFLAGS) -c $< + + +all : syscall-test + +syscall-test: syscall-test.c + $(CC) $(CFLAGS) -o $@ $< + +module-test.o: module-test.c + $(CC) -c $(CFLAGS_MODULE) -o $@ $< + +mrproper clean: + rm -f syscall-test *.o *~ core + +prep: + @echo Nothing to prepare for $(MODULE_NAME) diff -urN rtai-24.1.9/newlxrt/mytest/module-test.c rtai-24.1.9-arm-newlxrt/newlxrt/mytest/module-test.c --- rtai-24.1.9/newlxrt/mytest/module-test.c Thu Jan 1 01:00:00 1970 +++ rtai-24.1.9-arm-newlxrt/newlxrt/mytest/module-test.c Fri Dec 6 12:02:54 2002 @@ -0,0 +1,73 @@ +/* + $RCSfile$ + $Revision$ + $Author$ + $Date: 2002/10/21 08:26:14 $ + + + Description: + + + (c) IMEC vzw + */ + +#define __NO_VERSION__ +#define EXPORT_SYMTAB +#define MODVERSIONS + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "../registry.h" + +static RT_TASK thread1; + +MBX mbx; + +void thread1_fun(int arg) +{ + char message[128]; + + rt_printk("Kernel thread STARTED ...\n"); + + rt_mbx_init(&mbx, 1024); + rt_register(nam2num("MBX000"), &mbx, IS_MBX, current); + + rt_task_make_periodic_relative_ns(rt_whoami(), 0, 1000000000); + while(1) { + static int i = 0; + + sprintf(message,"Iteration %d..\n", i); + rt_mbx_send(&mbx, message, strlen(message)); + + i++; + rt_task_wait_period(); + } + return; +} + + +int init_module(void) +{ + printk("NEWLXRT kernel test module\n"); + + start_rt_timer(1000000); + rt_task_init(&thread1,thread1_fun, 0, 4000, 0, 0, (void*)0); + rt_task_resume(&thread1); + + return 0; +} + +void cleanup_module(void) +{ + rt_task_delete(&thread1); +} + + diff -urN rtai-24.1.9/newlxrt/mytest/syscall-test.c rtai-24.1.9-arm-newlxrt/newlxrt/mytest/syscall-test.c --- rtai-24.1.9/newlxrt/mytest/syscall-test.c Thu Jan 1 01:00:00 1970 +++ rtai-24.1.9-arm-newlxrt/newlxrt/mytest/syscall-test.c Fri Dec 6 12:02:54 2002 @@ -0,0 +1,77 @@ +#include +#include +#include +#include "../../lxrt/rtai_lxrt_user.h" +#include +#include "syscall-test.h" + +#define TEST_SYSCALL +#define TEST_SOFT_REALTIME +#define TEST_MAILBOX + +int main(int argc, char **argv) +{ + int retval; + char buf[16]; + char message[128]; + unsigned long tsk_name = nam2num("TASK"); + RT_TASK *tsk; + MBX *mbx; + + sprintf(buf,"%s","Foo"); + mlockall(MCL_CURRENT | MCL_FUTURE); + + /* Call to rt_task_init tests the syscall path. + Needs a funtional rt_alloc. + No copying between user/kernel space takes place + */ + if (!(tsk = rt_task_init(tsk_name, 0, 0, 0))) { + printf("rt_task_init: error\n"); + exit(1); + } +#ifdef TEST_MAILBOX + /* Look up the mailbox created in the module.. + If you want to create the mailbox here instead, use + rt_mbx_init(nam2num("MBX000"), 1024); + And look it up in the module with.. + mbx = rt_get_adr(nam2num("MBX000")); + */ + if (!(mbx = rt_get_adr(nam2num("MBX000")))) { + printf("Cannot find mailbox\n"); + exit(1); + } +#endif + +#ifndef TEST_SOFT_REALTIME + rt_make_hard_real_time(); +#endif + rt_set_oneshot_mode(); + start_rt_timer(0); + + while(1) { +#ifdef TEST_SYSCALL + retval = rt_test_system_call(NULL, buf, 16); + + rt_printk("%s, %d\n", buf, retval); +#endif +#ifdef TEST_MAILBOX + rt_mbx_receive(mbx, message, 64); + message[64] = 0; + rt_printk("%s\n", message); +#endif + rt_sleep(nano2count(1000000000)); +#ifdef TEST_SOFT_REALTIME + printf("Doing printf() in soft real time mode\n"); +#endif + } +#ifndef TEST_SOFT_REALTIME + rt_make_soft_real_time(); +#endif + rt_task_delete(tsk); + printf("rt_task_delete completed\n"); + retval = 0; + + return 0; + +} + diff -urN rtai-24.1.9/newlxrt/mytest/syscall-test.h rtai-24.1.9-arm-newlxrt/newlxrt/mytest/syscall-test.h --- rtai-24.1.9/newlxrt/mytest/syscall-test.h Thu Jan 1 01:00:00 1970 +++ rtai-24.1.9-arm-newlxrt/newlxrt/mytest/syscall-test.h Fri Dec 6 12:02:54 2002 @@ -0,0 +1,43 @@ +/* + $RCSfile$ + $Revision$ + $Author$ + $Date$ + + + Description: + This file shows how to add user space definitions for your own syscalls + + (c) IMEC vzw + */ +#ifndef _SYSCALL_TEST_H_INCLUDED_ +#define _SYSCALL_TEST_H_INCLUDED_ + +#ifndef __KERNEL__ + +#include "../../lxrt/rtai_lxrt_user.h" + + +/* System call number, check tabnewlxrt.c for free slots */ +#define TEST_SYSTEM_CALL 132 + +DECLARE int rt_test_system_call(void *src, void *dst, size_t size) +{ + struct { void *src; void *dst; size_t size;} arg = { src, dst, size }; + return (int) rtai_lxrt(BIDX, SIZARG, TEST_SYSTEM_CALL, &arg).i[LOW]; +} + + +#else /* __KERNEL__ */ +/* To be included in tabnewlxrt.c */ + +int rt_test_system_call(void *src, void *dst, size_t size) +{ + printk("Executing test system call, size=%d, LOW=%d\n", size, LOW); + strcpy(dst,"Bar"); + return 1234; +} + +#endif + +#endif /* _SYSCALL_TEST_H_INCLUDED_ */ diff -urN rtai-24.1.9/newlxrt/newlxrt.c rtai-24.1.9-arm-newlxrt/newlxrt/newlxrt.c --- rtai-24.1.9/newlxrt/newlxrt.c Fri Dec 6 12:03:42 2002 +++ rtai-24.1.9-arm-newlxrt/newlxrt/newlxrt.c Fri Dec 6 12:02:54 2002 @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -209,7 +210,8 @@ if (!(msg_buf = rt_malloc(2*max_msg_size))) { return 0; } - rt_task = rt_malloc(sizeof(RT_TASK) + 3*sizeof(struct fun_args)); + rt_task = rt_malloc(sizeof(RT_TASK) + 3*sizeof(struct fun_args)); + rt_task->magic = 0; if (smp_num_cpus > 1 && cpus_allowed) { cpus_allowed = hweight32(cpus_allowed) > 1 ? get_min_tasks_cpuid() : ffnz(cpus_allowed); @@ -223,9 +225,12 @@ rt_task->max_msg_size[0] = rt_task->max_msg_size[1] = max_msg_size; if (rt_register(name, rt_task, IS_TASK, 0)) { - extern void *sys_call_table[]; /* mlockalls can be many without any harm, so we'll give a hint anyhow */ +/* Whoa there, doing syscalls this way is arch dependent */ +#ifdef CONFIG_I386 + extern void *sys_call_table[]; ((void (*)(int))sys_call_table[__NR_mlockall])(MCL_CURRENT | MCL_FUTURE); +#endif return rt_task; } else { clr_rtext(rt_task); @@ -498,6 +503,7 @@ RT_TASK *rt_linux_tasks[1]; sidt = rt_set_full_intr_vect(RTAI_LXRT_VECTOR, 15, 3, (void *)RTAI_LXRT_HANDLER); + if(set_rtai_callback(linux_process_termination)) { printk("Could not setup rtai_callback\n"); return -ENODEV; @@ -514,6 +520,7 @@ void cleanup_module(void) { + #ifdef CONFIG_PROC_FS rtai_proc_lxrt_unregister(); #endif diff -urN rtai-24.1.9/newlxrt/scheduler/Makefile rtai-24.1.9-arm-newlxrt/newlxrt/scheduler/Makefile --- rtai-24.1.9/newlxrt/scheduler/Makefile Fri Dec 6 12:03:42 2002 +++ rtai-24.1.9-arm-newlxrt/newlxrt/scheduler/Makefile Fri Dec 6 12:02:54 2002 @@ -1,5 +1,8 @@ EXTRA_CFLAGS := -I. +# REMOVE ME LATER +CONFIG_RTAI_NEWLXRT_NOBUDDY = y + M_OBJS += rtai_sched_newlxrt.o sched_objs := rtai_sched.o diff -urN rtai-24.1.9/newlxrt/scheduler/rtai_sched.c.nobuddy rtai-24.1.9-arm-newlxrt/newlxrt/scheduler/rtai_sched.c.nobuddy --- rtai-24.1.9/newlxrt/scheduler/rtai_sched.c.nobuddy Fri Dec 6 12:03:42 2002 +++ rtai-24.1.9-arm-newlxrt/newlxrt/scheduler/rtai_sched.c.nobuddy Fri Dec 6 12:02:54 2002 @@ -40,13 +40,16 @@ #include #include #include -#include +#include #include #include #include #include +#ifndef CONFIG_ARM +#include #include +#endif #define __KERNEL_SYSCALLS__ #include @@ -1036,7 +1039,7 @@ RTIME now; RT_TASK *task, *new_task; int prio, delay, preempt; - + ASSIGN_RT_CURRENT; task = new_task = &rt_linux_task; prio = RT_LINUX_PRIORITY; @@ -1229,6 +1232,7 @@ rt_request_timer(rt_timer_handler, period > LATCH? LATCH: period, 0); tuned.timers_tol[0] = rt_half_tick = (rt_times.periodic_tick + 1)>>1; } + rt_smp_times[cpuid].linux_tick = rt_times.linux_tick; rt_smp_times[cpuid].tick_time = rt_times.tick_time; rt_smp_times[cpuid].intr_time = rt_times.intr_time; @@ -1385,6 +1389,8 @@ int init_module(void) { int cpuid; + + sched_mem_init(); for (cpuid = 0; cpuid < NR_RT_CPUS; cpuid++) { rt_linux_task.uses_fpu = 1; @@ -1419,7 +1425,7 @@ #endif printk("\n***** STARTING THE NEWLXRT-NOBUDDY REAL TIME SCHEDULER *****"); printk("\n***<> LINUX TICK AT %d (HZ) <>***", HZ); - printk("\n***<> CALIBRATED CPU FREQUENCY %lu (HZ) <>***", tuned.cpu_freq); + printk("\n***<> CALIBRATED CPU FREQUENCY %u (HZ) <>***", tuned.cpu_freq); #ifdef CONFIG_SMP printk("\n***<> CALIBRATED APIC_INTERRUPT-TO-SCHEDULER LATENCY %d (ns) <>***", imuldiv(tuned.latency - tuned.setup_time_TIMER_CPUNIT, 1000000000, tuned.cpu_freq)); printk("\n***<> CALIBRATED ONE SHOT APIC SETUP TIME %d (ns) <>***\n\n", imuldiv(tuned.setup_time_TIMER_CPUNIT, 1000000000, tuned.cpu_freq)); @@ -1438,6 +1444,7 @@ void cleanup_module(void) { int cpuid; + stop_rt_timer(); for (cpuid = 0; cpuid < NR_RT_CPUS; cpuid++) { while (rt_linux_task.next) { @@ -1465,7 +1472,7 @@ RT_TASK *task; PROC_PRINT("\nRTAI NEWLXRT Real Time Task Scheduler.\n\n"); - PROC_PRINT(" Calibrated CPU Frequency: %lu Hz\n", tuned.cpu_freq); + PROC_PRINT(" Calibrated CPU Frequency: %u Hz\n", tuned.cpu_freq); PROC_PRINT(" Calibrated 8254 interrupt to scheduler latency: %d ns\n", imuldiv(tuned.latency - tuned.setup_time_TIMER_CPUNIT, 1000000000, tuned.cpu_freq)); PROC_PRINT(" Calibrated one shot setup time: %d ns\n\n", imuldiv(tuned.setup_time_TIMER_CPUNIT, 1000000000, tuned.cpu_freq)); @@ -1874,6 +1881,7 @@ { DECLARE_RT_CURRENT; unsigned long flags; + flags = rt_global_save_flags_and_cli(); ASSIGN_RT_CURRENT; if ((rt_current->resume_time = (oneshot_timer ? rdtsc(): rt_times.tick_time) + delay) > rt_time_h) { @@ -3943,6 +3951,8 @@ { int cpuid; + /* This changes the Linux syscall handler to call inhrtp - currently not + working for ARM/PPC */ linux_syscall_handler = rt_set_intr_handler(SYSCALL_VECTOR, (void *)LXRT_LINUX_SYSCALL_TRAP); rthal.lxrt_global_cli = linux_lxrt_global_cli; sched_trap_handler = rt_set_rtai_trap_handler(rtai_trap_handler); @@ -3990,6 +4000,7 @@ schedule_timeout(1); } } + endkthread = 1; for (cpuid = 0; cpuid < smp_num_cpus; cpuid++) { wake_up_process(kthreadb[cpuid]); diff -urN rtai-24.1.9/newlxrt/tabnewlxrt.c rtai-24.1.9-arm-newlxrt/newlxrt/tabnewlxrt.c --- rtai-24.1.9/newlxrt/tabnewlxrt.c Fri Dec 6 12:03:42 2002 +++ rtai-24.1.9-arm-newlxrt/newlxrt/tabnewlxrt.c Fri Dec 6 12:02:54 2002 @@ -24,7 +24,8 @@ characters names and fixed many inconsistencies within this file. */ - +#include +#include #include #include #include @@ -37,6 +38,8 @@ #include "msgnewlxrt.h" +#include "mytest/syscall-test.h" + static void nihil(void) { }; struct rt_fun_entry rt_fun_lxrt[] = { @@ -178,5 +181,9 @@ { 1, rt_change_prio }, // 128 { 0, rt_set_resume_time }, // 129 { 0, rt_set_period }, // 130 - { 0, rt_mbx_ovrwr_send }, // 131 + { 0, rt_mbx_ovrwr_send }, // 131 + + /* Add extra calls here */ + { UW1(2,3), rt_test_system_call }, // 132 + };