Copyright (c) 2004
LIFL - Laboratoire d'Informatique Fondamentale de Lille
USTL - Université des Sciences et Technologies de Lille

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


Index: arch/ia64/Kconfig
===================================================================
RCS file: /west/artis/kernel/2.6.3/arch/ia64/Kconfig,v
retrieving revision 1.3
retrieving revision 1.5
diff -u -r1.3 -r1.5
--- arch/ia64/Kconfig	30 Mar 2004 12:10:36 -0000	1.3
+++ arch/ia64/Kconfig	5 Apr 2004 14:39:49 -0000	1.5
@@ -56,6 +56,26 @@
 
 endchoice
 
+config ARTIS
+	bool "Compile the kernel with ARTiS support (highly EXPERIMENTAL)"
+	help
+		ARTiS (LIFL) support. If you say Y here you're kernel will 
+		probably crash ;-).
+
+config ARTIS_DEBUG
+       bool "Compile the kernel with ARTiS debugging support (highly EXPERIMENTAL)"
+       depends on ARTIS
+       help
+               ARTiS (LIFL) support. If you say Y here you're kernel will
+               probably crash ;-).
+
+config ARTIS_STAT
+       bool "Compile the kernel with ARTiS accounting support (highly EXPERIMENTAL)"
+       depends on ARTIS
+       help
+               ARTiS (LIFL) support. If you say Y here you're kernel will
+               probably crash ;-).
+
 choice
 	prompt "System type"
 	default IA64_GENERIC
Index: arch/ia64/kdb/Makefile
===================================================================
RCS file: /west/artis/kernel/2.6.3/arch/ia64/kdb/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- arch/ia64/kdb/Makefile	30 Mar 2004 12:10:36 -0000	1.3
+++ arch/ia64/kdb/Makefile	30 Mar 2004 13:48:07 -0000	1.4
@@ -31,7 +31,7 @@
 #
 
 obj-y	 := kdba_bt.o kdba_bp.o kdba_io.o kdbasupport.o \
-	    cpu-ia64-opc.o ia64-dis.o ia64-opc.o kdba_id.o kdba_jmp.o
+	    cpu-ia64-opc.o ia64-dis.o ia64-opc.o kdba_id.o kdba_jmp.o kdba_artis.o
 
 # fru does not compile on 2.6.
 # obj-$(CONFIG_IA64_SGI_SN2) += kdba_fru.o
Index: arch/ia64/kdb/kdba_artis.c
===================================================================
RCS file: /west/artis/kernel/2.6.3/arch/ia64/kdb/kdba_artis.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- arch/ia64/kdb/kdba_artis.c	30 Mar 2004 12:10:36 -0000	1.3
+++ arch/ia64/kdb/kdba_artis.c	30 Mar 2004 13:48:07 -0000	1.4
@@ -0,0 +1,9 @@
+int artis_bph(void *addr, int write, int len) {
+	return 0;
+}
+
+int
+artis_unbph(void *addr) {
+	return 0;
+}
+
Index: arch/ia64/kernel/process.c
===================================================================
RCS file: /west/artis/kernel/2.6.3/arch/ia64/kernel/process.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- arch/ia64/kernel/process.c	30 Mar 2004 12:10:37 -0000	1.3
+++ arch/ia64/kernel/process.c	30 Mar 2004 13:48:07 -0000	1.4
@@ -41,6 +41,43 @@
 
 void (*ia64_mark_idle)(int);
 
+#ifdef CONFIG_ARTIS_DEBUG
+#include <linux/artis.h>
+void
+artis_ia64_put_trace(struct unw_frame_info *info, void *arg)
+{
+	void **bt = (void **)arg;
+	int i, artis_skip_bt, r_unw;
+	unsigned long ip, sp, bsp;
+
+	memset(bt, 0, ARTIS_BT_SIZE*sizeof(void *));
+	r_unw=0; 
+	artis_skip_bt=0;
+	for(i=artis_skip_bt-1;
+			i>=0 && r_unw>=0; 
+			i--, r_unw=unw_unwind(info)) {
+		unw_get_ip(info, &ip);
+		if (ip == 0)
+			break;
+		unw_get_sp(info, &sp);
+		unw_get_bsp(info, &bsp);
+	}
+	for(i=ARTIS_BT_SIZE-1;
+			i>=0 && r_unw>=0; 
+			i--, r_unw=unw_unwind(info)) {
+		unw_get_ip(info, &ip);
+		if (ip == 0)
+			break;
+		unw_get_sp(info, &sp);
+		unw_get_bsp(info, &bsp);
+		bt[i] = (void *)ip;
+	}
+}
+void
+artis_put_trace(void **bt, struct task_struct *task, unsigned long *stack) {
+		unw_init_running(artis_ia64_put_trace, (void *)bt);
+}
+#endif
 
 void
 ia64_do_show_stack (struct unw_frame_info *info, void *arg)
Index: include/asm-ia64/system.h
===================================================================
RCS file: /west/artis/kernel/2.6.3/include/asm-ia64/system.h,v
retrieving revision 1.3
retrieving revision 1.7
diff -u -r1.3 -r1.7
--- include/asm-ia64/system.h	30 Mar 2004 12:10:37 -0000	1.3
+++ include/asm-ia64/system.h	3 Apr 2004 17:36:18 -0000	1.7
@@ -114,22 +114,35 @@
  */
 /* For spinlocks etc */
 
+
 /* clearing psr.i is implicitly serialized (visible by next insn) */
 /* setting psr.i requires data serialization */
-#define __local_irq_save(x)			\
+#define _raw__local_irq_save(x)			\
 do {						\
 	(x) = ia64_getreg(_IA64_REG_PSR);	\
 	ia64_stop();				\
 	ia64_rsm(IA64_PSR_I);			\
 } while (0)
 
-#define __local_irq_disable()			\
+#define _raw__local_irq_disable()			\
 do {						\
 	ia64_stop();				\
 	ia64_rsm(IA64_PSR_I);			\
 } while (0)
 
-#define __local_irq_restore(x)	ia64_intrin_local_irq_restore((x) & IA64_PSR_I)
+#define _raw__local_irq_restore(x)	ia64_intrin_local_irq_restore((x) & IA64_PSR_I)
+
+#ifdef CONFIG_ARTIS
+#include <linux/artis-macros.h>
+
+#define __local_irq_save(x) do { artis_force_migration(); _raw__local_irq_save(x); } while(0)
+#define __local_irq_disable() do { artis_force_migration(); _raw__local_irq_disable(); } while(0)
+#define __local_irq_restore(x) do { if (!((x) & IA64_PSR_I)) { artis_force_migration(); }; _raw__local_irq_restore(x); } while(0)
+#else
+#define __local_irq_save(x) _raw__local_irq_save(x)
+#define __local_irq_disable() _raw__local_irq_disable()
+#define __local_irq_restore(x) _raw__local_irq_restore(x)
+#endif
 
 #ifdef CONFIG_IA64_DEBUG_IRQ
 
@@ -275,6 +288,18 @@
 } while (0)
 #define finish_arch_switch(rq, prev)	spin_unlock_irq(&(prev)->switch_lock)
 #define task_running(rq, p) 		((rq)->curr == (p) || spin_is_locked(&(p)->switch_lock))
+#ifdef CONFIG_ARTIS
+/* in IA64, the end of scheduler release the runqueue lock 
+ * so a wake-up have been re-activate the task and we must
+ * deactivate it
+ * */
+#define artis_complete_arch(rq, task) do { \
+	spin_lock(&(rq)->lock); \
+	if ((task)->array) \
+		deactivate_task((task),(rq)); \
+	} while(0)
+#define artis_finish_complete_arch(rq, task) spin_unlock(&(rq)->lock)
+#endif
 
 #define ia64_platform_is(x) (strcmp(x, platform_name) == 0)
 
