Skip to contentSkip to conversation

Adeos (oldgen) 2.6.10 ppc64 r3

Xenomai-core Heikki Lindholm 1 participant 1 message Nov 14, 2005

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

A new Adeos patch for the 2.6.10 ppc64 (r3) with minor paranoia reduction. Also from:

http://www.cs.helsinki.fi/group/nonsto/rtaippc64.html

-- Heikki Lindholm

adeos/generic.c +640 -0
diff -Nru linux-2.6.10/adeos/generic.c linux-2.6.10-adeos-ppc64-r3/adeos/generic.c
@@ -0,0 +1,640 @@
+/*
+ *   linux/adeos/generic.c
+ *
+ *   Copyright (C) 2002 Philippe Gerum.
+ *
+ *   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, Inc., 675 Mass Ave, Cambridge MA 02139,
+ *   USA; 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.
+ *
+ *   Architecture-independent ADEOS services.
+ */
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/irq.h>
+
+MODULE_DESCRIPTION("Adeos nanokernel");
+MODULE_AUTHOR("Philippe Gerum");
+MODULE_LICENSE("GPL");
+
+/* adeos_register_domain() -- Add a new domain to the system. All
+   client domains must call this routine to register themselves to
+   ADEOS before using its services. */
+
+int adeos_register_domain (adomain_t *adp, adattr_t *attr)
+
+{
+    struct list_head *pos;
+    unsigned long flags;
+    int n;
+
+    if (adp_current != adp_root)
+	{
+	printk(KERN_WARNING "Adeos: Only the root domain may register a new domain.\n");
+	return -EPERM;
+	}
+
+    flags = adeos_critical_enter(NULL);
+
+    list_for_each(pos,&__adeos_pipeline) {
+    	adomain_t *_adp = list_entry(pos,adomain_t,p_link);
+	if (_adp->domid == attr->domid)
+            break;
+    }
+
+    adeos_critical_exit(flags);
+
+    if (pos != &__adeos_pipeline)
+	/* A domain with the given id already exists -- fail. */
+	return -EBUSY;
+
+    for (n = 0; n < ADEOS_NR_CPUS; n++)
+	{
+	/* Each domain starts in sleeping state on every CPU. */
+	adp->cpudata[n].status = (1 << IPIPE_SLEEP_FLAG);
+#ifdef CONFIG_ADEOS_THREADS
+	adp->estackbase[n] = 0;
+#endif /* CONFIG_ADEOS_THREADS */
+	}
+
+    adp->name = attr->name;
+    adp->priority = attr->priority;
+    adp->domid = attr->domid;
+    adp->dswitch = attr->dswitch;
+    adp->flags = 0;
+    adp->ptd_setfun = attr->ptdset;
+    adp->ptd_getfun = attr->ptdget;
+    adp->ptd_keymap = 0;
+    adp->ptd_keycount = 0;
+    adp->ptd_keymax = attr->nptdkeys;
+
+    for (n = 0; n < ADEOS_NR_EVENTS; n++)
+	/* Event handlers must be cleared before the i-pipe stage is
+	   inserted since an exception may occur on behalf of the new
+	   emerging domain. */
+	adp->events[n].handler = NULL;
+
+    if (attr->entry != NULL)
+	__adeos_init_domain(adp,attr);
+
+    /* Insert the domain in the interrupt pipeline last, so it won't
+       be resumed for processing interrupts until it has a valid stack
+       context. */
+
+    __adeos_init_stage(adp);
+
+    INIT_LIST_HEAD(&adp->p_link);
+
+    flags = adeos_critical_enter(NULL);
+
+    list_for_each(pos,&__adeos_pipeline) {
+    	adomain_t *_adp = list_entry(pos,adomain_t,p_link);
+	if (adp->priority > _adp->priority)
+            break;
+    }
+
+    list_add_tail(&adp->p_link,pos);
+
+    adeos_critical_exit(flags);
+
+    printk(KERN_WARNING "Adeos: Domain %s registered.\n",adp->name);
+
+    /* Finally, allow the new domain to perform its initialization
+       chores. */
+
+    if (attr->entry != NULL)
+	{
+	adeos_declare_cpuid;
+
+	adeos_lock_cpu(flags);
+
+#ifdef CONFIG_ADEOS_THREADS
+	__adeos_switch_to(adp_root,adp,cpuid);
+#else /* !CONFIG_ADEOS_THREADS */
+	adp_cpu_current[cpuid] = adp;
+	attr->entry(1);
+	adp_cpu_current[cpuid] = adp_root;
+#endif /* CONFIG_ADEOS_THREADS */
+
+	adeos_load_cpuid();	/* Processor might have changed. */
+
+	if (adp_root->cpudata[cpuid].irq_pending_hi != 0 &&
+	    !test_bit(IPIPE_STALL_FLAG,&adp_root->cpudata[cpuid].status))
+	    __adeos_sync_stage(IPIPE_IRQMASK_ANY);
+
+	adeos_unlock_cpu(flags);
+	}
+
+    return 0;
+}
+
+/* adeos_unregister_domain() -- Remove a domain from the system. All
+   client domains must call this routine to unregister themselves from
+   the ADEOS layer. */
+
+int adeos_unregister_domain (adomain_t *adp)
+
+{
+    unsigned long flags;
+    unsigned event;
+
+    if (adp_current != adp_root)
+	{
+	printk(KERN_WARNING "Adeos: Only the root domain may unregister a domain.\n");
+	return -EPERM;
+	}
+
+    if (adp == adp_root)
+	{
+	printk(KERN_WARNING "Adeos: Cannot unregister the root domain.\n");
+	return -EPERM;
+	}
+
+    for (event = 0; event < ADEOS_NR_EVENTS; event++)
+	/* Need this to update the monitor count. */
+	adeos_catch_event_from(adp,event,NULL);
+
+#ifdef CONFIG_SMP
+    {
+    int nr_cpus = num_online_cpus(), _cpuid;
+    unsigned irq;
+
+    /* In the SMP case, wait for the logged events to drain on other
+       processors before eventually removing the domain from the
+       pipeline. */
+
+    adeos_unstall_pipeline_from(adp);
+
+    flags = adeos_critical_enter(NULL);
+
+    for (irq = 0; irq < IPIPE_NR_IRQS; irq++)
+	{
+	clear_bit(IPIPE_HANDLE_FLAG,&adp->irqs[irq].control);
+	clear_bit(IPIPE_STICKY_FLAG,&adp->irqs[irq].control);
+	set_bit(IPIPE_PASS_FLAG,&adp->irqs[irq].control);
+	}
+
+    adeos_critical_exit(flags);
+
+    for (_cpuid = 0; _cpuid < nr_cpus; _cpuid++)
+	{
+	for (irq = 0; irq < IPIPE_NR_IRQS; irq++)
+	    while (adp->cpudata[_cpuid].irq_hits[irq] > 0)
+		cpu_relax();
+
+	while (test_bit(IPIPE_XPEND_FLAG,&adp->cpudata[_cpuid].status))
+	    cpu_relax();
+
+	while (!test_bit(IPIPE_SLEEP_FLAG,&adp->cpudata[_cpuid].status))
+	     cpu_relax();
+	}
+    }
+#endif /* CONFIG_SMP */
+
+    /* Simply remove the domain from the pipeline and we are almost
+       done. */
+
+    flags = adeos_critical_enter(NULL);
+    list_del_init(&adp->p_link);
+    adeos_critical_exit(flags);
+
+    __adeos_cleanup_domain(adp);
+
+    printk(KERN_WARNING "Adeos: Domain %s unregistered.\n",adp->name);
+
+    return 0;
+}
+
+/* adeos_propagate_irq() -- Force a given IRQ propagation on behalf of
+   a running interrupt handler to the next domain down the pipeline.
+   Returns non-zero if a domain has received the interrupt
+   notification, zero otherwise.
+   This call is useful for handling shared interrupts among domains.
+   e.g. pipeline = [domain-A]---[domain-B]...
+   Both domains share IRQ #X.
+   - domain-A handles IRQ #X but does not pass it down (i.e. Terminate
+   or Dynamic interrupt control mode)
+   - domain-B handles IRQ #X (i.e. Terminate or Accept interrupt
+   control modes).
+   When IRQ #X is raised, domain-A's handler determines whether it
+   should process the interrupt by identifying its source. If not,
+   adeos_propagate_irq() is called so that the next domain down the
+   pipeline which handles IRQ #X is given a chance to process it. This
+   process can be repeated until the end of the pipeline is
+   reached. */
+
+/* adeos_schedule_irq() -- Almost the same as adeos_propagate_irq(),
+   but attempts to pend the interrupt for the current domain first. */
+
+int fastcall __adeos_schedule_irq (unsigned irq, struct list_head *head)
+
+{
+    struct list_head *ln;
+    unsigned long flags;
+    adeos_declare_cpuid;
+
+    if (irq >= IPIPE_NR_IRQS ||
+	(adeos_virtual_irq_p(irq) && !test_bit(irq - IPIPE_VIRQ_BASE,&__adeos_virtual_irq_map)))
+	return -EINVAL;
+
+    adeos_lock_cpu(flags);
+
+    ln = head;
+
+    while (ln != &__adeos_pipeline)
+	{
+	adomain_t *adp = list_entry(ln,adomain_t,p_link);
+
+	if (test_bit(IPIPE_HANDLE_FLAG,&adp->irqs[irq].control))
+	    {
+	    adp->cpudata[cpuid].irq_hits[irq]++;
+	    __adeos_set_irq_bit(adp,cpuid,irq);
+	    adeos_unlock_cpu(flags);
+	    return 1;
+	    }
+
+	ln = adp->p_link.next;
+	}
+
+    adeos_unlock_cpu(flags);
+
+    return 0;
+}
+
+/* adeos_free_irq() -- Return a previously allocated virtual/soft
+   pipelined interrupt to the pool of allocatable interrupts. */
+
+int adeos_free_irq (unsigned irq)
+
+{
+    if (irq >= IPIPE_NR_IRQS)
+	return -EINVAL;
+
+    clear_bit(irq - IPIPE_VIRQ_BASE,&__adeos_virtual_irq_map);
+
+    return 0;
+}
+
+cpumask_t adeos_set_irq_affinity (unsigned irq, cpumask_t cpumask)
+
+{
+#ifdef CONFIG_SMP
+     if (irq >= IPIPE_NR_XIRQS)
+	 /* Allow changing affinity of external IRQs only. */
+	 return CPU_MASK_NONE;
+
+     if (num_online_cpus() > 1)
+	 /* Allow changing affinity of external IRQs only. */
+	 return __adeos_set_irq_affinity(irq,cpumask);
+#endif /* CONFIG_SMP */
+
+    return CPU_MASK_NONE;
+}
+
+/* adeos_catch_event_from() -- Interpose an event handler starting
+   from a given domain. */
+
+adevhand_t adeos_catch_event_from (adomain_t *adp, unsigned event, adevhand_t handler)
+
+{
+    adevhand_t oldhandler;
+
+    if (event >= ADEOS_NR_EVENTS)
+	return NULL;
+
+    if ((oldhandler = (adevhand_t)xchg(&adp->events[event].handler,handler)) == NULL)
+	{
+	if (handler)
+	    __adeos_event_monitors[event]++;
+	}
+    else if (!handler)
+	__adeos_event_monitors[event]--;
+
+    return oldhandler;
+}
+
+void adeos_init_attr (adattr_t *attr)
+
+{
+    attr->name = "Anonymous";
+    attr->domid = 1;
+    attr->entry = NULL;
+    attr->estacksz = 0;	/* Let ADEOS choose a reasonable stack size */
+    attr->priority = ADEOS_ROOT_PRI;
+    attr->dswitch = NULL;
+    attr->nptdkeys = 0;
+    attr->ptdset = NULL;
+    attr->ptdget = NULL;
+}
+
+int adeos_alloc_ptdkey (void)
+
+{
+    unsigned long flags;
+    int key = -1;
+
+    spin_lock_irqsave_hw(&__adeos_pipelock,flags);
+
+    if (adp_current->ptd_keycount < adp_current->ptd_keymax)
+	{
+	key = ffz(adp_current->ptd_keymap);
+	set_bit(key,&adp_current->ptd_keymap);
+	adp_current->ptd_keycount++;
+	}
+
+    spin_unlock_irqrestore_hw(&__adeos_pipelock,flags);
+
+    return key;
+}
+
+int adeos_free_ptdkey (int key)
+
+{
+    unsigned long flags; 
+
+    if (key < 0 || key >= adp_current->ptd_keymax)
+	return -EINVAL;
+
+    spin_lock_irqsave_hw(&__adeos_pipelock,flags);
+
+    if (test_and_clear_bit(key,&adp_current->ptd_keymap))
+	adp_current->ptd_keycount--;
+
+    spin_unlock_irqrestore_hw(&__adeos_pipelock,flags);
+
+    return 0;
+}
+
+int adeos_set_ptd (int key, void *value)
+
+{
+    if (key < 0 || key >= adp_current->ptd_keymax)
+	return -EINVAL;
+
+    if (!adp_current->ptd_setfun)
+	{
+	printk(KERN_WARNING "Adeos: No ptdset hook for %s\n",adp_current->name);
+	return -EINVAL;
+	}
+
+    adp_current->ptd_setfun(key,value);
+
+    return 0;
+}
+
+void *adeos_get_ptd (int key)
+
+{
+    if (key < 0 || key >= adp_current->ptd_keymax)
+	return NULL;
+
+    if (!adp_current->ptd_getfun)
+	{
+	printk(KERN_WARNING "Adeos: No ptdget hook for %s\n",adp_current->name);
+	return NULL;
+	}
+
+    return adp_current->ptd_getfun(key);
+}
+
+int adeos_init_mutex (admutex_t *mutex)
+
+{
+    admutex_t initm = ADEOS_MUTEX_UNLOCKED;
+    *mutex = initm;
+    return 0;
+}
+
+#ifdef CONFIG_ADEOS_THREADS
+
+int adeos_destroy_mutex (admutex_t *mutex)
+
+{
+    if (!adeos_spin_trylock(&mutex->lock) &&
+	adp_current != adp_root &&
+	mutex->owner != adp_current)
+	return -EBUSY;
+
+    return 0;
+}
+
+static inline void __adeos_sleepon_mutex (admutex_t *mutex, adomain_t *sleeper, int cpuid)
+
+{
+    adomain_t *owner = mutex->owner;
+
+    /* Make the current domain (== sleeper) wait for the mutex to be
+       released. Adeos' pipelined scheme guarantees that the new
+       sleeper _is_ higher priority than any aslept domain since we
+       have stalled each sleeper's stage. Must be called with local hw
+       interrupts off. */
+
+    sleeper->m_link = mutex->sleepq;
+    mutex->sleepq = sleeper;
+    __adeos_switch_to(adp_cpu_current[cpuid],owner,cpuid);
+    mutex->owner = sleeper;
+    adeos_spin_unlock(&mutex->lock);
+}
+
+unsigned long fastcall adeos_lock_mutex (admutex_t *mutex)
+
+{
+    unsigned long flags, hwflags;
+    adeos_declare_cpuid;
+    adomain_t *adp;
+
+    if (!adp_pipelined)
+	{
+	adeos_hw_local_irq_save(hwflags);
+	flags = !adeos_hw_test_iflag(hwflags);
+	adeos_spin_lock(&mutex->lock);
+	return flags;
+	}
+
+    adeos_lock_cpu(hwflags);
+
+    adp = adp_cpu_current[cpuid];
+
+    flags = __test_and_set_bit(IPIPE_STALL_FLAG,&adp->cpudata[cpuid].status);
+
+    /* Two cases to handle here on SMP systems, only one for UP: 1) in
+       case of a conflicting access from a higher priority domain
+       running on the same cpu, make this domain sleep on the mutex,
+       and resume the current owner so it can release the lock asap.
+       2) in case of a conflicting access from any domain on a
+       different cpu than the current owner's, simply enter a spinning
+       loop. Note that testing mutex->owncpu is safe since it is only
+       changed by the current owner, and set to -1 when the mutex is
+       unlocked. */
+
+#ifdef CONFIG_SMP
+    while (!adeos_spin_trylock(&mutex->lock))
+	{
+	if (mutex->owncpu == cpuid)
+	    {
+	    __adeos_sleepon_mutex(mutex,adp,cpuid);
+	    adeos_load_cpuid();
+	    }
+	}
+
+    mutex->owncpu = cpuid;
+#else  /* !CONFIG_SMP */
+    while (mutex->owner != NULL && mutex->owner != adp)
+	__adeos_sleepon_mutex(mutex,adp,cpuid);
+#endif /* CONFIG_SMP */
+
+    mutex->owner = adp;
+
+    adeos_unlock_cpu(hwflags);
+
+    return flags;
+}
+
+void fastcall adeos_unlock_mutex (admutex_t *mutex, unsigned long flags)
+
+{
+    unsigned long hwflags;
+    adeos_declare_cpuid;
+    adomain_t *adp;
+
+    if (!adp_pipelined)
+	{
+	adeos_spin_unlock(&mutex->lock);
+
+	if (flags)
+	    adeos_hw_cli();
+	else
+	    adeos_hw_sti();
+
+	return;
+	}
+
+#ifdef CONFIG_SMP
+    mutex->owncpu = -1;
+#endif /* CONFIG_SMP */
+
+    if (!flags)
+	adeos_hw_sti();	/* Absolutely needed. */
+	
+    adeos_lock_cpu(hwflags);
+
+    if (mutex->sleepq != NULL)
+	{
+	adomain_t *sleeper = mutex->sleepq;
+	/* Wake up the highest priority sleeper. */
+	mutex->sleepq = sleeper->m_link;
+	__adeos_switch_to(adp_cpu_current[cpuid],sleeper,cpuid);
+	adeos_load_cpuid();
+	}
+    else
+	{
+	mutex->owner = NULL;
+	adeos_spin_unlock(&mutex->lock);
+	}
+
+    adp = adp_cpu_current[cpuid];
+
+    if (flags)
+	__set_bit(IPIPE_STALL_FLAG,&adp->cpudata[cpuid].status);
+    else
+	{
+	__clear_bit(IPIPE_STALL_FLAG,&adp->cpudata[cpuid].status);
+	
+	if (adp->cpudata[cpuid].irq_pending_hi != 0)
+	    __adeos_sync_stage(IPIPE_IRQMASK_ANY);
+	}
+
+    adeos_unlock_cpu(hwflags);
+}
+
+#else /* !CONFIG_ADEOS_THREADS */
+
+int adeos_destroy_mutex (admutex_t *mutex)
+
+{
+    if (!adeos_spin_trylock(&mutex->lock) &&
+	adp_current != adp_root)
+	return -EBUSY;
+
+    return 0;
+}
+
+unsigned long fastcall adeos_lock_mutex (admutex_t *mutex)
+
+{
+    unsigned long flags; /* FIXME: won't work on SPARC */
+    spin_lock_irqsave_hw(&mutex->lock,flags);
+    return flags;
+}
+
+void fastcall adeos_unlock_mutex (admutex_t *mutex, unsigned long flags)
+
+{
+    spin_unlock_irqrestore_hw(&mutex->lock,flags);
+}
+
+#endif /* CONFIG_ADEOS_THREADS */
+
+void __adeos_takeover (void)
+
+{
+    __adeos_enable_pipeline();
+    printk(KERN_WARNING "Adeos: Pipelining started.\n");
+}
+
+#ifdef MODULE
+
+static int __init adeos_init_module (void)
+
+{
+    __adeos_takeover();
+    return 0;
+}
+
+static void __exit adeos_exit_module (void)
+
+{
+    __adeos_disable_pipeline();
+    printk(KERN_WARNING "Adeos: Pipelining stopped.\n");
+}
+
+module_init(adeos_init_module);
+module_exit(adeos_exit_module);
+
+#endif /* MODULE */
+
+EXPORT_SYMBOL(adeos_register_domain);
+EXPORT_SYMBOL(adeos_unregister_domain);
+EXPORT_SYMBOL(adeos_virtualize_irq_from);
+EXPORT_SYMBOL(adeos_control_irq);
+EXPORT_SYMBOL(__adeos_schedule_irq);
+EXPORT_SYMBOL(adeos_free_irq);
+EXPORT_SYMBOL(adeos_send_ipi);
+EXPORT_SYMBOL(adeos_catch_event_from);
+EXPORT_SYMBOL(adeos_init_attr);
+EXPORT_SYMBOL(adeos_get_sysinfo);
+EXPORT_SYMBOL(adeos_tune_timer);
+EXPORT_SYMBOL(adeos_alloc_ptdkey);
+EXPORT_SYMBOL(adeos_free_ptdkey);
+EXPORT_SYMBOL(adeos_set_ptd);
+EXPORT_SYMBOL(adeos_get_ptd);
+EXPORT_SYMBOL(adeos_set_irq_affinity);
+EXPORT_SYMBOL(adeos_init_mutex);
+EXPORT_SYMBOL(adeos_destroy_mutex);
+EXPORT_SYMBOL(adeos_lock_mutex);
+EXPORT_SYMBOL(adeos_unlock_mutex);
adeos/Kconfig +40 -0
diff -Nru linux-2.6.10/adeos/Kconfig linux-2.6.10-adeos-ppc64-r3/adeos/Kconfig
@@ -0,0 +1,40 @@
+menu "Adeos support"
+
+config ADEOS
+	tristate "Adeos support"
+	default y
+	---help---
+	  Activate this option if you want the Adeos nanokernel to be
+	  compiled in.
+
+config ADEOS_CORE
+	def_bool ADEOS
+
+config ADEOS_THREADS
+	bool "Threaded domains"
+	depends on ADEOS && !PPC64
+	default y
+	---help---
+	  This option causes the domains to run as lightweight
+	  threads, which is useful for having seperate stacks
+	  for domains. Enabling this option is the safest setting for
+	  now; disabling it causes an experimental mode to be used
+	  where interrupts/events are directly processed on behalf of
+	  the preempted context. Say Y if unsure.
+
+config ADEOS_NOTHREADS
+	def_bool !ADEOS_THREADS
+
+config ADEOS_PROFILING
+	bool "Pipeline profiling"
+	depends on ADEOS
+	default n
+	---help---
+	  This option activates the profiling code which collects the
+	  timestamps needed to measure the propagation time of
+	  interrupts through the pipeline. Say N if unsure.
+
+config ADEOS_PREEMPT_RT
+	def_bool PREEMPT_NONE || PREEMPT_VOLUNTARY || PREEMPT_DESKTOP || PREEMPT_RT
+
+endmenu
adeos/Makefile +15 -0
diff -Nru linux-2.6.10/adeos/Makefile linux-2.6.10-adeos-ppc64-r3/adeos/Makefile
@@ -0,0 +1,15 @@
+#
+# Makefile for the Adeos layer.
+#
+
+obj-$(CONFIG_ADEOS)	+= adeos.o
+
+adeos-objs		:= generic.o
+
+adeos-$(CONFIG_X86)	+= x86.o
+
+adeos-$(CONFIG_IA64)	+= ia64.o
+
+adeos-$(CONFIG_PPC32)	+= ppc.o
+
+adeos-$(CONFIG_PPC64)	+= ppc64.o
adeos/ppc64.c +527 -0

527 lines not on this page · raw message

arch/ppc64/Kconfig +2 -0
diff -Nru linux-2.6.10/arch/ppc64/Kconfig linux-2.6.10-adeos-ppc64-r3/arch/ppc64/Kconfig
@@ -370,6 +370,8 @@
 	depends on VIOCONS || VIODASD || VIOCD || VIOTAPE || VETH
 	default y
 
+source "adeos/Kconfig"
+
 source "arch/ppc64/oprofile/Kconfig"
 
 source "arch/ppc64/Kconfig.debug"
arch/ppc64/kernel/adeos.c +700 -0

700 lines not on this page · raw message

arch/ppc64/kernel/entry.S +196 -2

237 lines not on this page · raw message

arch/ppc64/kernel/head.S +22 -0
diff -Nru linux-2.6.10/arch/ppc64/kernel/head.S linux-2.6.10-adeos-ppc64-r3/arch/ppc64/kernel/head.S
@@ -381,6 +381,18 @@
 	bl	hdlr;					\
 	b	.ret_from_except_lite
 
+#ifdef CONFIG_ADEOS_CORE
+#define ADEOS_EXCEPTION_COMMON_LITE(trap, label, hdlr)	\
+	.align	7;					\
+	.globl label##_common;				\
+label##_common:						\
+	EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN);	\
+	DISABLE_INTS;					\
+	addi	r3,r1,STACK_FRAME_OVERHEAD;		\
+	bl	hdlr;					\
+	b	.__adeos_ret_from_except_lite
+#endif /* CONFIG_ADEOS_CORE */
+
 /*
  * Start of pSeries system interrupt routines
  */
@@ -761,7 +773,12 @@
 	bl	.MachineCheckException
 	b	.ret_from_except
 
+
+#ifdef CONFIG_ADEOS_CORE
+	ADEOS_EXCEPTION_COMMON_LITE(0x900, Decrementer, .__adeos_grab_timer) 
+#else /* !CONFIG_ADEOS_CORE */
 	STD_EXCEPTION_COMMON_LITE(0x900, Decrementer, .timer_interrupt)
+#endif /* CONFIG_ADEOS_CORE */
 	STD_EXCEPTION_COMMON(0xa00, Trap_0a, .UnknownException)
 	STD_EXCEPTION_COMMON(0xb00, Trap_0b, .UnknownException)
 	STD_EXCEPTION_COMMON(0xd00, SingleStep, .SingleStepException)
@@ -890,8 +907,13 @@
 HardwareInterrupt_entry:
 	DISABLE_INTS
 	addi	r3,r1,STACK_FRAME_OVERHEAD
+#ifdef CONFIG_ADEOS_CORE
+	bl	.__adeos_grab_irq
+	b	.__adeos_ret_from_except_lite
+#else /* !CONFIG_ADEOS_CORE */
 	bl	.do_IRQ
 	b	.ret_from_except_lite
+#endif /* CONFIG_ADEOS_CORE */
 
 	.align	7
 	.globl Alignment_common
arch/ppc64/kernel/idle.c +11 -1
diff -Nru linux-2.6.10/arch/ppc64/kernel/idle.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/kernel/idle.c
@@ -131,6 +131,9 @@
 
 			while (!need_resched() && !cpu_is_offline(cpu)) {
 				barrier();
+#ifdef CONFIG_ADEOS_CORE
+				adeos_suspend_domain();
+#endif /* CONFIG_ADEOS_CORE */
 				/*
 				 * Go into low thread priority and possibly
 				 * low power mode.
@@ -288,8 +291,15 @@
 {
 	while(1) {
 		/* check CPU type here */
-		if (!need_resched())
+		if (!need_resched()) 
+#ifdef CONFIG_ADEOS_CORE
+		{
+			adeos_suspend_domain();
 			power4_idle();
+		}
+#else /* !CONFIG_ADEOS_CORE */
+			power4_idle();
+#endif /* CONFIG_ADEOS_CORE */		
 		if (need_resched())
 			schedule();
 	}
arch/ppc64/kernel/irq.c +11 -0
diff -Nru linux-2.6.10/arch/ppc64/kernel/irq.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/kernel/irq.c
@@ -134,14 +134,25 @@
 
 	if (desc->status & IRQ_PER_CPU) {
 		/* no locking required for CPU-local interrupts: */
+#ifdef CONFIG_ADEOS_CORE
+		if (!adp_pipelined)
+			ack_irq(irq);
+#else
 		ack_irq(irq);
+#endif /* CONFIG_ADEOS_CORE */
 		action_ret = handle_IRQ_event(irq, regs, desc->action);
 		desc->handler->end(irq);
 		return;
 	}
 
 	spin_lock(&desc->lock);
+#ifdef CONFIG_ADEOS_CORE
+	if (!adp_pipelined)
+		ack_irq(irq);
+#else
 	ack_irq(irq);	
+#endif /* CONFIG_ADEOS_CORE */
+	
 	/*
 	   REPLAY is when Linux resends an IRQ that was dropped earlier
 	   WAITING is used by probe to mark irqs that are being tested
arch/ppc64/kernel/Makefile +2 -0
diff -Nru linux-2.6.10/arch/ppc64/kernel/Makefile linux-2.6.10-adeos-ppc64-r3/arch/ppc64/kernel/Makefile
@@ -62,4 +62,6 @@
 
 obj-$(CONFIG_ALTIVEC)		+= vecemu.o vector.o
 
+obj-$(CONFIG_ADEOS_CORE)	+= adeos.o
+
 CFLAGS_ioctl32.o += -Ifs/
arch/ppc64/kernel/ppc_ksyms.c +27 -0
diff -Nru linux-2.6.10/arch/ppc64/kernel/ppc_ksyms.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/kernel/ppc_ksyms.c
@@ -163,3 +163,30 @@
 EXPORT_SYMBOL(paca);
 EXPORT_SYMBOL(cur_cpu_spec);
 EXPORT_SYMBOL(systemcfg);
+
+#ifdef CONFIG_ADEOS_CORE
+/* The following are per-platform convenience exports which are needed
+   by some Adeos domains loaded as kernel modules. */
+extern unsigned long disarm_decr[NR_CPUS];
+EXPORT_SYMBOL(disarm_decr);
+EXPORT_SYMBOL(tb_ticks_per_jiffy);
+EXPORT_SYMBOL(__switch_to);
+void show_stack(struct task_struct *task,
+		unsigned long *esp);
+EXPORT_SYMBOL(show_stack);
+EXPORT_SYMBOL(udbg_printf);
+
+/* these two are needed by the task switching code in fusion */
+extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
+extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
+EXPORT_SYMBOL(switch_stab);
+EXPORT_SYMBOL(switch_slb);
+
+/* flush_tlb_pending() */
+EXPORT_PER_CPU_SYMBOL(ppc64_tlb_batch);
+EXPORT_SYMBOL(__flush_tlb_pending);
+
+EXPORT_SYMBOL(_switch);
+extern struct task_struct *last_task_used_math;
+EXPORT_SYMBOL(last_task_used_math);
+#endif /* CONFIG_ADEOS_CORE */
arch/ppc64/kernel/time.c +6 -0
diff -Nru linux-2.6.10/arch/ppc64/kernel/time.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/kernel/time.c
@@ -73,6 +73,9 @@
 
 EXPORT_SYMBOL(jiffies_64);
 
+#ifdef CONFIG_ADEOS_CORE
+unsigned long disarm_decr[NR_CPUS];
+#endif /* CONFIG_ADEOS_CORE */
 /* keep track of when we need to update the rtc */
 time_t last_rtc_update;
 extern int piranha_simulator;
@@ -293,6 +296,9 @@
 	next_dec = lpaca->next_jiffy_update_tb - cur_tb;
 	if (next_dec > lpaca->default_decr)
         	next_dec = lpaca->default_decr;
+#ifdef CONFIG_ADEOS_CORE
+	if (!disarm_decr[smp_processor_id()])
+#endif /* CONFIG_ADEOS_CORE */	
 	set_dec(next_dec);
 
 #ifdef CONFIG_PPC_ISERIES
arch/ppc64/kernel/traps.c +67 -3

151 lines not on this page · raw message

arch/ppc64/mm/fault.c +6 -0
diff -Nru linux-2.6.10/arch/ppc64/mm/fault.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/mm/fault.c
@@ -95,6 +95,12 @@
 
 	BUG_ON((trap == 0x380) || (trap == 0x480));
 
+#ifdef CONFIG_ADEOS_CORE
+	if (__adeos_event_monitors[ADEOS_ACCESS_TRAP] > 0 &&
+	    __adeos_handle_event(ADEOS_ACCESS_TRAP,regs) != 0)
+	    return 0;
+#endif /* CONFIG_ADEOS_CORE */
+
 	if (trap == 0x300) {
 		if (debugger_fault_handler(regs))
 			return 0;
arch/ppc64/mm/hash_native.c +4 -4
diff -Nru linux-2.6.10/arch/ppc64/mm/hash_native.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/mm/hash_native.c
@@ -278,7 +278,7 @@
 	if (large)
 		avpn &= ~0x1UL;
 
-	local_irq_save(flags);
+	adeos_hw_local_irq_save(flags);
 	native_lock_hpte(hptep);
 
 	dw0 = hptep->dw0.dw0;
@@ -301,7 +301,7 @@
 		if (lock_tlbie)
 			spin_unlock(&native_tlbie_lock);
 	}
-	local_irq_restore(flags);
+	adeos_hw_local_irq_restore(flags);
 }
 
 static void native_flush_hash_range(unsigned long context,
@@ -316,7 +316,7 @@
 	/* XXX fix for large ptes */
 	unsigned long large = 0;
 
-	local_irq_save(flags);
+	adeos_hw_local_irq_save(flags);
 
 	j = 0;
 	for (i = 0; i < number; i++) {
@@ -384,7 +384,7 @@
 			spin_unlock(&native_tlbie_lock);
 	}
 
-	local_irq_restore(flags);
+	adeos_hw_local_irq_restore(flags);
 }
 
 #ifdef CONFIG_PPC_PSERIES
arch/ppc64/mm/slb.c +19 -5
diff -Nru linux-2.6.10/arch/ppc64/mm/slb.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/mm/slb.c
@@ -83,6 +83,9 @@
 	unsigned long pc = KSTK_EIP(tsk);
 	unsigned long stack = KSTK_ESP(tsk);
 	unsigned long unmapped_base;
+	unsigned long flags;
+
+	adeos_hw_local_irq_save(flags);
 
 	if (offset <= SLB_CACHE_ENTRIES) {
 		int i;
@@ -115,24 +118,35 @@
 	else
 		unmapped_base = TASK_UNMAPPED_BASE_USER64;
 
-	if (pc >= KERNELBASE)
+	if (pc >= KERNELBASE) {
+		adeos_hw_local_irq_restore(flags);
 		return;
+	}
 	slb_allocate(pc);
 
-	if (GET_ESID(pc) == GET_ESID(stack))
+	if (GET_ESID(pc) == GET_ESID(stack)) {
+		adeos_hw_local_irq_restore(flags);
 		return;
+	}
 
-	if (stack >= KERNELBASE)
+	if (stack >= KERNELBASE) {
+		adeos_hw_local_irq_restore(flags);
 		return;
+	}
 	slb_allocate(stack);
 
 	if ((GET_ESID(pc) == GET_ESID(unmapped_base))
-	    || (GET_ESID(stack) == GET_ESID(unmapped_base)))
+	    || (GET_ESID(stack) == GET_ESID(unmapped_base))) {
+		adeos_hw_local_irq_restore(flags);
 		return;
+	}
 
-	if (unmapped_base >= KERNELBASE)
+	if (unmapped_base >= KERNELBASE) {
+		adeos_hw_local_irq_restore(flags);
 		return;
+	}
 	slb_allocate(unmapped_base);
+	adeos_hw_local_irq_restore(flags);
 }
 
 void slb_initialize(void)
arch/ppc64/mm/tlb.c +4 -0
diff -Nru linux-2.6.10/arch/ppc64/mm/tlb.c linux-2.6.10-adeos-ppc64-r3/arch/ppc64/mm/tlb.c
@@ -122,7 +122,11 @@
 	cpumask_t tmp;
 	int local = 0;
 
+#ifdef CONFIG_ADEOS_CORE
+	BUG_ON(adp_current==adp_root && in_interrupt());
+#else /* !CONFIG_ADEOS_CORE */
 	BUG_ON(in_interrupt());
+#endif /* CONFIG_ADEOS_CORE */
 
 	cpu = get_cpu();
 	i = batch->index;
Documentation/adeos.txt +176 -0

176 lines not on this page · raw message

include/asm-ppc64/adeos.h +444 -0

255 lines not on this page · raw message

include/asm-ppc64/hw_irq.h +33 -0
diff -Nru linux-2.6.10/include/asm-ppc64/hw_irq.h linux-2.6.10-adeos-ppc64-r3/include/asm-ppc64/hw_irq.h

Lines of this file are not shown. View the raw message.

include/asm-ppc64/mmu_context.h +8 -0
diff -Nru linux-2.6.10/include/asm-ppc64/mmu_context.h linux-2.6.10-adeos-ppc64-r3/include/asm-ppc64/mmu_context.h

Lines of this file are not shown. View the raw message.

include/asm-ppc64/smp.h +5 -1
diff -Nru linux-2.6.10/include/asm-ppc64/smp.h linux-2.6.10-adeos-ppc64-r3/include/asm-ppc64/smp.h

Lines of this file are not shown. View the raw message.

include/asm-ppc64/time.h +3 -0
diff -Nru linux-2.6.10/include/asm-ppc64/time.h linux-2.6.10-adeos-ppc64-r3/include/asm-ppc64/time.h

Lines of this file are not shown. View the raw message.

include/linux/adeos.h +553 -0

553 lines not on this page · raw message

include/linux/preempt.h +43 -0

43 lines not on this page · raw message

include/linux/sched.h +7 -0
diff -Nru linux-2.6.10/include/linux/sched.h linux-2.6.10-adeos-ppc64-r3/include/linux/sched.h

Lines of this file are not shown. View the raw message.

init/main.c +10 -0
diff -Nru linux-2.6.10/init/main.c linux-2.6.10-adeos-ppc64-r3/init/main.c

Lines of this file are not shown. View the raw message.

kernel/adeos.c +826 -0

826 lines not on this page · raw message

kernel/exit.c +3 -0
diff -Nru linux-2.6.10/kernel/exit.c linux-2.6.10-adeos-ppc64-r3/kernel/exit.c

Lines of this file are not shown. View the raw message.

kernel/fork.c +8 -0
diff -Nru linux-2.6.10/kernel/fork.c linux-2.6.10-adeos-ppc64-r3/kernel/fork.c

Lines of this file are not shown. View the raw message.

kernel/Makefile +1 -0
diff -Nru linux-2.6.10/kernel/Makefile linux-2.6.10-adeos-ppc64-r3/kernel/Makefile

Lines of this file are not shown. View the raw message.

kernel/panic.c +3 -0
diff -Nru linux-2.6.10/kernel/panic.c linux-2.6.10-adeos-ppc64-r3/kernel/panic.c

Lines of this file are not shown. View the raw message.

kernel/printk.c +61 -0

61 lines not on this page · raw message

kernel/sched.c +106 -1

107 lines not on this page · raw message

kernel/signal.c +18 -0
diff -Nru linux-2.6.10/kernel/signal.c linux-2.6.10-adeos-ppc64-r3/kernel/signal.c

Lines of this file are not shown. View the raw message.

kernel/sysctl.c +3 -0
diff -Nru linux-2.6.10/kernel/sysctl.c linux-2.6.10-adeos-ppc64-r3/kernel/sysctl.c

Lines of this file are not shown. View the raw message.

Makefile +2 -0
diff -Nru linux-2.6.10/Makefile linux-2.6.10-adeos-ppc64-r3/Makefile

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.