linux-bk/kernel/cpu.c
<<
>>
Prefs
   1/* CPU control.
   2 * (C) 2001 Rusty Russell
   3 * This code is licenced under the GPL.
   4 */
   5#include <linux/proc_fs.h>
   6#include <linux/smp.h>
   7#include <linux/init.h>
   8#include <linux/notifier.h>
   9#include <linux/sched.h>
  10#include <linux/unistd.h>
  11#include <asm/semaphore.h>
  12
  13/* This protects CPUs going up and down... */
  14DECLARE_MUTEX(cpucontrol);
  15
  16static struct notifier_block *cpu_chain = NULL;
  17
  18/* Need to know about CPUs going up/down? */
  19int register_cpu_notifier(struct notifier_block *nb)
  20{
  21        return notifier_chain_register(&cpu_chain, nb);
  22}
  23
  24void unregister_cpu_notifier(struct notifier_block *nb)
  25{
  26        notifier_chain_unregister(&cpu_chain,nb);
  27}
  28
  29int __devinit cpu_up(unsigned int cpu)
  30{
  31        int ret;
  32
  33        if ((ret = down_interruptible(&cpucontrol)) != 0) 
  34                return ret;
  35
  36        if (cpu_online(cpu)) {
  37                ret = -EINVAL;
  38                goto out;
  39        }
  40
  41        /* Arch-specific enabling code. */
  42        ret = __cpu_up(cpu);
  43        if (ret != 0) goto out;
  44        if (!cpu_online(cpu))
  45                BUG();
  46
  47        /* Now call notifier in preparation. */
  48        printk("CPU %u IS NOW UP!\n", cpu);
  49        notifier_call_chain(&cpu_chain, CPU_ONLINE, (void *)(long)cpu);
  50
  51 out:
  52        up(&cpucontrol);
  53        return ret;
  54}
  55
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.