ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / parisc / kernel / smp.c
1 /*
2 ** SMP Support
3 **
4 ** Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
5 ** Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
6 ** Copyright (C) 2001 Grant Grundler <grundler@parisc-linux.org>
7 ** 
8 ** Lots of stuff stolen from arch/alpha/kernel/smp.c
9 ** ...and then parisc stole from arch/ia64/kernel/smp.c. Thanks David! :^)
10 **
11 ** Thanks to John Curry and Ullas Ponnadi. I learned alot from their work.
12 ** -grant (1/12/2001)
13 **
14 **      This program is free software; you can redistribute it and/or modify
15 **      it under the terms of the GNU General Public License as published by
16 **      the Free Software Foundation; either version 2 of the License, or
17 **      (at your option) any later version.
18 */
19 #undef ENTRY_SYS_CPUS   /* syscall support for iCOD-like functionality */
20
21 #include <linux/autoconf.h>
22
23 #include <linux/types.h>
24 #include <linux/spinlock.h>
25 #include <linux/slab.h>
26
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/sched.h>
30 #include <linux/init.h>
31 #include <linux/interrupt.h>
32 #include <linux/smp.h>
33 #include <linux/kernel_stat.h>
34 #include <linux/mm.h>
35 #include <linux/delay.h>
36
37 #include <asm/system.h>
38 #include <asm/atomic.h>
39 #include <asm/bitops.h>
40 #include <asm/current.h>
41 #include <asm/delay.h>
42 #include <asm/pgalloc.h>        /* for flush_tlb_all() proto/macro */
43
44 #include <asm/io.h>
45 #include <asm/irq.h>            /* for CPU_IRQ_REGION and friends */
46 #include <asm/mmu_context.h>
47 #include <asm/page.h>
48 #include <asm/pgtable.h>
49 #include <asm/pgalloc.h>
50 #include <asm/processor.h>
51 #include <asm/ptrace.h>
52 #include <asm/unistd.h>
53 #include <asm/cacheflush.h>
54
55 #define kDEBUG 0
56
57 spinlock_t pa_dbit_lock = SPIN_LOCK_UNLOCKED;
58
59 spinlock_t smp_lock = SPIN_LOCK_UNLOCKED;
60
61 volatile struct task_struct *smp_init_current_idle_task;
62
63 static volatile int smp_commenced = 0;   /* Set when the idlers are all forked */
64 static volatile int cpu_now_booting = 0;      /* track which CPU is booting */
65 cpumask_t cpu_online_map = CPU_MASK_NONE;   /* Bitmap of online CPUs */
66 #define IS_LOGGED_IN(cpunum) (cpu_isset(cpunum, cpu_online_map))
67
68 EXPORT_SYMBOL(cpu_online_map);
69
70 int smp_num_cpus = 1;
71 int smp_threads_ready = 0;
72 unsigned long cache_decay_ticks;
73 static int max_cpus = -1;                            /* Command line */
74 cpumask_t cpu_present_mask;
75
76 EXPORT_SYMBOL(cpu_present_mask);
77
78 struct smp_call_struct {
79         void (*func) (void *info);
80         void *info;
81         long wait;
82         atomic_t unstarted_count;
83         atomic_t unfinished_count;
84 };
85 static volatile struct smp_call_struct *smp_call_function_data;
86
87 enum ipi_message_type {
88         IPI_NOP=0,
89         IPI_RESCHEDULE=1,
90         IPI_CALL_FUNC,
91         IPI_CPU_START,
92         IPI_CPU_STOP,
93         IPI_CPU_TEST
94 };
95
96
97 /********** SMP inter processor interrupt and communication routines */
98
99 #undef PER_CPU_IRQ_REGION
100 #ifdef PER_CPU_IRQ_REGION
101 /* XXX REVISIT Ignore for now.
102 **    *May* need this "hook" to register IPI handler
103 **    once we have perCPU ExtIntr switch tables.
104 */
105 static void
106 ipi_init(int cpuid)
107 {
108
109         /* If CPU is present ... */
110 #ifdef ENTRY_SYS_CPUS
111         /* *and* running (not stopped) ... */
112 #error iCOD support wants state checked here.
113 #endif
114
115 #error verify IRQ_OFFSET(IPI_IRQ) is ipi_interrupt() in new IRQ region
116
117         if(IS_LOGGED_IN(cpuid) )
118         {
119                 switch_to_idle_task(current);
120         }
121
122         return;
123 }
124 #endif
125
126
127 /*
128 ** Yoink this CPU from the runnable list... 
129 **
130 */
131 static void
132 halt_processor(void) 
133 {
134 #ifdef ENTRY_SYS_CPUS
135 #error halt_processor() needs rework
136 /*
137 ** o migrate I/O interrupts off this CPU.
138 ** o leave IPI enabled - __cli() will disable IPI.
139 ** o leave CPU in online map - just change the state
140 */
141         cpu_data[this_cpu].state = STATE_STOPPED;
142         mark_bh(IPI_BH);
143 #else
144         /* REVISIT : redirect I/O Interrupts to another CPU? */
145         /* REVISIT : does PM *know* this CPU isn't available? */
146         cpu_clear(smp_processor_id(), cpu_online_map);
147         local_irq_disable();
148         for (;;)
149                 ;
150 #endif
151 }
152
153
154 irqreturn_t
155 ipi_interrupt(int irq, void *dev_id, struct pt_regs *regs) 
156 {
157         int this_cpu = smp_processor_id();
158         struct cpuinfo_parisc *p = &cpu_data[this_cpu];
159         unsigned long ops;
160         unsigned long flags;
161
162         /* Count this now; we may make a call that never returns. */
163         p->ipi_count++;
164
165         mb();   /* Order interrupt and bit testing. */
166
167         for (;;) {
168                 spin_lock_irqsave(&(p->lock),flags);
169                 ops = p->pending_ipi;
170                 p->pending_ipi = 0;
171                 spin_unlock_irqrestore(&(p->lock),flags);
172
173                 mb(); /* Order bit clearing and data access. */
174
175                 if (!ops)
176                     break;
177
178                 while (ops) {
179                         unsigned long which = ffz(~ops);
180
181                         switch (which) {
182                         case IPI_RESCHEDULE:
183 #if (kDEBUG>=100)
184                                 printk(KERN_DEBUG "CPU%d IPI_RESCHEDULE\n",this_cpu);
185 #endif /* kDEBUG */
186                                 ops &= ~(1 << IPI_RESCHEDULE);
187                                 /*
188                                  * Reschedule callback.  Everything to be
189                                  * done is done by the interrupt return path.
190                                  */
191                                 break;
192
193                         case IPI_CALL_FUNC:
194 #if (kDEBUG>=100)
195                                 printk(KERN_DEBUG "CPU%d IPI_CALL_FUNC\n",this_cpu);
196 #endif /* kDEBUG */
197                                 ops &= ~(1 << IPI_CALL_FUNC);
198                                 {
199                                         volatile struct smp_call_struct *data;
200                                         void (*func)(void *info);
201                                         void *info;
202                                         int wait;
203
204                                         data = smp_call_function_data;
205                                         func = data->func;
206                                         info = data->info;
207                                         wait = data->wait;
208
209                                         mb();
210                                         atomic_dec ((atomic_t *)&data->unstarted_count);
211
212                                         /* At this point, *data can't
213                                          * be relied upon.
214                                          */
215
216                                         (*func)(info);
217
218                                         /* Notify the sending CPU that the
219                                          * task is done.
220                                          */
221                                         mb();
222                                         if (wait)
223                                                 atomic_dec ((atomic_t *)&data->unfinished_count);
224                                 }
225                                 break;
226
227                         case IPI_CPU_START:
228 #if (kDEBUG>=100)
229                                 printk(KERN_DEBUG "CPU%d IPI_CPU_START\n",this_cpu);
230 #endif /* kDEBUG */
231                                 ops &= ~(1 << IPI_CPU_START);
232 #ifdef ENTRY_SYS_CPUS
233                                 p->state = STATE_RUNNING;
234 #endif
235                                 break;
236
237                         case IPI_CPU_STOP:
238 #if (kDEBUG>=100)
239                                 printk(KERN_DEBUG "CPU%d IPI_CPU_STOP\n",this_cpu);
240 #endif /* kDEBUG */
241                                 ops &= ~(1 << IPI_CPU_STOP);
242 #ifdef ENTRY_SYS_CPUS
243 #else
244                                 halt_processor();
245 #endif
246                                 break;
247
248                         case IPI_CPU_TEST:
249 #if (kDEBUG>=100)
250                                 printk(KERN_DEBUG "CPU%d is alive!\n",this_cpu);
251 #endif /* kDEBUG */
252                                 ops &= ~(1 << IPI_CPU_TEST);
253                                 break;
254
255                         default:
256                                 printk(KERN_CRIT "Unknown IPI num on CPU%d: %lu\n",
257                                         this_cpu, which);
258                                 ops &= ~(1 << which);
259                                 return IRQ_NONE;
260                         } /* Switch */
261                 } /* while (ops) */
262         }
263         return IRQ_HANDLED;
264 }
265
266
267 static inline void
268 ipi_send(int cpu, enum ipi_message_type op)
269 {
270         struct cpuinfo_parisc *p = &cpu_data[cpu];
271         unsigned long flags;
272
273         spin_lock_irqsave(&(p->lock),flags);
274         p->pending_ipi |= 1 << op;
275         __raw_writel(IRQ_OFFSET(IPI_IRQ), cpu_data[cpu].hpa);
276         spin_unlock_irqrestore(&(p->lock),flags);
277 }
278
279
280 static inline void
281 send_IPI_single(int dest_cpu, enum ipi_message_type op)
282 {
283         if (dest_cpu == NO_PROC_ID) {
284                 BUG();
285                 return;
286         }
287
288         ipi_send(dest_cpu, op);
289 }
290
291 static inline void
292 send_IPI_allbutself(enum ipi_message_type op)
293 {
294         int i;
295         
296         for (i = 0; i < smp_num_cpus; i++) {
297                 if (i != smp_processor_id())
298                         send_IPI_single(i, op);
299         }
300 }
301
302 inline void 
303 smp_send_stop(void)     { send_IPI_allbutself(IPI_CPU_STOP); }
304
305 static inline void
306 smp_send_start(void)    { send_IPI_allbutself(IPI_CPU_START); }
307
308 void 
309 smp_send_reschedule(int cpu) { send_IPI_single(cpu, IPI_RESCHEDULE); }
310
311
312 /**
313  * Run a function on all other CPUs.
314  *  <func>      The function to run. This must be fast and non-blocking.
315  *  <info>      An arbitrary pointer to pass to the function.
316  *  <retry>     If true, keep retrying until ready.
317  *  <wait>      If true, wait until function has completed on other CPUs.
318  *  [RETURNS]   0 on success, else a negative status code.
319  *
320  * Does not return until remote CPUs are nearly ready to execute <func>
321  * or have executed.
322  */
323
324 int
325 smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
326 {
327         struct smp_call_struct data;
328         unsigned long timeout;
329         static spinlock_t lock = SPIN_LOCK_UNLOCKED;
330         
331         data.func = func;
332         data.info = info;
333         data.wait = wait;
334         atomic_set(&data.unstarted_count, smp_num_cpus - 1);
335         atomic_set(&data.unfinished_count, smp_num_cpus - 1);
336
337         if (retry) {
338                 spin_lock (&lock);
339                 while (smp_call_function_data != 0)
340                         barrier();
341         }
342         else {
343                 spin_lock (&lock);
344                 if (smp_call_function_data) {
345                         spin_unlock (&lock);
346                         return -EBUSY;
347                 }
348         }
349
350         smp_call_function_data = &data;
351         spin_unlock (&lock);
352         
353         /*  Send a message to all other CPUs and wait for them to respond  */
354         send_IPI_allbutself(IPI_CALL_FUNC);
355
356         /*  Wait for response  */
357         timeout = jiffies + HZ;
358         while ( (atomic_read (&data.unstarted_count) > 0) &&
359                 time_before (jiffies, timeout) )
360                 barrier ();
361
362         /* We either got one or timed out. Release the lock */
363
364         mb();
365         smp_call_function_data = NULL;
366         if (atomic_read (&data.unstarted_count) > 0) {
367                 printk(KERN_CRIT "SMP CALL FUNCTION TIMED OUT! (cpu=%d)\n",
368                       smp_processor_id());
369                 return -ETIMEDOUT;
370         }
371
372         while (wait && atomic_read (&data.unfinished_count) > 0)
373                         barrier ();
374
375         return 0;
376 }
377
378 EXPORT_SYMBOL(smp_call_function);
379
380
381
382 /*
383  *      Setup routine for controlling SMP activation
384  *
385  *      Command-line option of "nosmp" or "maxcpus=0" will disable SMP
386  *      activation entirely (the MPS table probe still happens, though).
387  *
388  *      Command-line option of "maxcpus=<NUM>", where <NUM> is an integer
389  *      greater than 0, limits the maximum number of CPUs activated in
390  *      SMP mode to <NUM>.
391  */
392
393 static int __init nosmp(char *str)
394 {
395         max_cpus = 0;
396         return 1;
397 }
398
399 __setup("nosmp", nosmp);
400
401 static int __init maxcpus(char *str)
402 {
403         get_option(&str, &max_cpus);
404         return 1;
405 }
406
407 __setup("maxcpus=", maxcpus);
408
409 /*
410  * Flush all other CPU's tlb and then mine.  Do this with on_each_cpu()
411  * as we want to ensure all TLB's flushed before proceeding.
412  */
413
414 extern void flush_tlb_all_local(void);
415
416 void
417 smp_flush_tlb_all(void)
418 {
419         on_each_cpu((void (*)(void *))flush_tlb_all_local, NULL, 1, 1);
420 }
421
422
423 void 
424 smp_do_timer(struct pt_regs *regs)
425 {
426         int cpu = smp_processor_id();
427         struct cpuinfo_parisc *data = &cpu_data[cpu];
428
429         if (!--data->prof_counter) {
430                 data->prof_counter = data->prof_multiplier;
431                 update_process_times(user_mode(regs));
432         }
433 }
434
435 /*
436  * Called by secondaries to update state and initialize CPU registers.
437  */
438 static void __init
439 smp_cpu_init(int cpunum)
440 {
441         extern int init_per_cpu(int);  /* arch/parisc/kernel/setup.c */
442         extern void init_IRQ(void);    /* arch/parisc/kernel/irq.c */
443
444         /* Set modes and Enable floating point coprocessor */
445         (void) init_per_cpu(cpunum);
446
447         disable_sr_hashing();
448
449         mb();
450
451         /* Well, support 2.4 linux scheme as well. */
452         if (cpu_test_and_set(cpunum, cpu_online_map))
453         {
454                 extern void machine_halt(void); /* arch/parisc.../process.c */
455
456                 printk(KERN_CRIT "CPU#%d already initialized!\n", cpunum);
457                 machine_halt();
458         }  
459
460         /* Initialise the idle task for this CPU */
461         atomic_inc(&init_mm.mm_count);
462         current->active_mm = &init_mm;
463         if(current->mm)
464                 BUG();
465         enter_lazy_tlb(&init_mm, current);
466
467         init_IRQ();   /* make sure no IRQ's are enabled or pending */
468 }
469
470
471 /*
472  * Slaves start using C here. Indirectly called from smp_slave_stext.
473  * Do what start_kernel() and main() do for boot strap processor (aka monarch)
474  */
475 void __init smp_callin(void)
476 {
477         extern void cpu_idle(void);     /* arch/parisc/kernel/process.c */
478         int slave_id = cpu_now_booting;
479 #if 0
480         void *istack;
481 #endif
482
483         smp_cpu_init(slave_id);
484
485 #if 0   /* NOT WORKING YET - see entry.S */
486         istack = (void *)__get_free_pages(GFP_KERNEL,ISTACK_ORDER);
487         if (istack == NULL) {
488             printk(KERN_CRIT "Failed to allocate interrupt stack for cpu %d\n",slave_id);
489             BUG();
490         }
491         mtctl(istack,31);
492 #endif
493
494         flush_cache_all_local(); /* start with known state */
495         flush_tlb_all_local();
496
497         local_irq_enable();  /* Interrupts have been off until now */
498
499         /* Slaves wait here until Big Poppa daddy say "jump" */
500         mb();   /* PARANOID */
501         while (!smp_commenced) ;
502         mb();   /* PARANOID */
503
504         cpu_idle();      /* Wait for timer to schedule some work */
505
506         /* NOTREACHED */
507         panic("smp_callin() AAAAaaaaahhhh....\n");
508 }
509
510 /*
511  * Create the idle task for a new Slave CPU.  DO NOT use kernel_thread()
512  * because that could end up calling schedule(). If it did, the new idle
513  * task could get scheduled before we had a chance to remove it from the
514  * run-queue...
515  */
516 static struct task_struct *fork_by_hand(void)
517 {
518         struct pt_regs regs;  
519
520         /*
521          * don't care about the regs settings since
522          * we'll never reschedule the forked task.
523          */
524         return copy_process(CLONE_VM|CLONE_IDLETASK, 0, &regs, 0, NULL, NULL);
525 }
526
527
528 /*
529  * Bring one cpu online.
530  */
531 static int __init smp_boot_one_cpu(int cpuid, int cpunum)
532 {
533         struct task_struct *idle;
534         long timeout;
535
536         /* 
537          * Create an idle task for this CPU.  Note the address wed* give 
538          * to kernel_thread is irrelevant -- it's going to start
539          * where OS_BOOT_RENDEVZ vector in SAL says to start.  But
540          * this gets all the other task-y sort of data structures set
541          * up like we wish.   We need to pull the just created idle task 
542          * off the run queue and stuff it into the init_tasks[] array.  
543          * Sheesh . . .
544          */
545
546         idle = fork_by_hand();
547         if (IS_ERR(idle))
548                 panic("SMP: fork failed for CPU:%d", cpuid);
549
550         wake_up_forked_process(idle);
551         init_idle(idle, cpunum);
552         unhash_process(idle);
553         idle->thread_info->cpu = cpunum;
554
555         /* Let _start know what logical CPU we're booting
556         ** (offset into init_tasks[],cpu_data[])
557         */
558         cpu_now_booting = cpunum;
559
560         /* 
561         ** boot strap code needs to know the task address since
562         ** it also contains the process stack.
563         */
564         smp_init_current_idle_task = idle ;
565         mb();
566
567         /*
568         ** This gets PDC to release the CPU from a very tight loop.
569         ** See MEM_RENDEZ comments in head.S.
570         */
571         __raw_writel(IRQ_OFFSET(TIMER_IRQ), cpu_data[cpunum].hpa);
572         mb();
573
574         /* 
575          * OK, wait a bit for that CPU to finish staggering about. 
576          * Slave will set a bit when it reaches smp_cpu_init() and then
577          * wait for smp_commenced to be 1.
578          * Once we see the bit change, we can move on.
579          */
580         for (timeout = 0; timeout < 10000; timeout++) {
581                 if(IS_LOGGED_IN(cpunum)) {
582                         /* Which implies Slave has started up */
583                         cpu_now_booting = 0;
584                         smp_init_current_idle_task = NULL;
585                         goto alive ;
586                 }
587                 udelay(100);
588                 barrier();
589         }
590
591         put_task_struct(idle);
592         idle = NULL;
593
594         printk(KERN_CRIT "SMP: CPU:%d is stuck.\n", cpuid);
595         return -1;
596
597 alive:
598         /* Remember the Slave data */
599 #if (kDEBUG>=100)
600         printk(KERN_DEBUG "SMP: CPU:%d (num %d) came alive after %ld _us\n",
601                 cpuid,  cpunum, timeout * 100);
602 #endif /* kDEBUG */
603 #ifdef ENTRY_SYS_CPUS
604         cpu_data[cpunum].state = STATE_RUNNING;
605 #endif
606         return 0;
607 }
608
609
610
611
612 /*
613 ** inventory.c:do_inventory() has already 'discovered' the additional CPU's.
614 ** We are ready to wrest them from PDC's control now.
615 ** Called by smp_init bring all the secondaries online and hold them.  
616 **
617 ** o Setup of the IPI irq handler is done in irq.c.
618 ** o MEM_RENDEZ is initialzed in head.S:stext()
619 **
620 */
621 void __init smp_boot_cpus(void)
622 {
623         int i, cpu_count = 1;
624         unsigned long bogosum = cpu_data[0].loops_per_jiffy; /* Count Monarch */
625
626         /* REVISIT - assumes first CPU reported by PAT PDC is BSP */
627         int bootstrap_processor=cpu_data[0].cpuid;      /* CPU ID of BSP */
628
629         /* Setup BSP mappings */
630         printk(KERN_DEBUG "SMP: bootstrap CPU ID is %d\n",bootstrap_processor);
631         init_task.thread_info->cpu = bootstrap_processor; 
632         current->thread_info->cpu = bootstrap_processor;
633         /* Mark Boostrap processor as present */
634         cpu_online_map = cpumask_of_cpu(bootstrap_processor);
635         current->active_mm = &init_mm;
636
637 #ifdef ENTRY_SYS_CPUS
638         cpu_data[0].state = STATE_RUNNING;
639 #endif
640         cpu_present_mask = cpumask_of_cpu(bootstrap_processor);
641
642         /* Nothing to do when told not to.  */
643         if (max_cpus == 0) {
644                 printk(KERN_INFO "SMP mode deactivated.\n");
645                 return;
646         }
647
648         if (max_cpus != -1) 
649                 printk(KERN_INFO "Limiting CPUs to %d\n", max_cpus);
650
651         /* We found more than one CPU.... */
652         if (boot_cpu_data.cpu_count > 1) {
653
654                 for (i = 0; i < NR_CPUS; i++) {
655                         if (cpu_data[i].cpuid == NO_PROC_ID || 
656                             cpu_data[i].cpuid == bootstrap_processor)
657                                 continue;
658
659                         if (smp_boot_one_cpu(cpu_data[i].cpuid, cpu_count) < 0)
660                                 continue;
661
662                         bogosum += cpu_data[i].loops_per_jiffy;
663                         cpu_count++; /* Count good CPUs only... */
664                         
665                         cpu_present_mask |= 1UL << i;
666                         
667                         /* Bail when we've started as many CPUS as told to */
668                         if (cpu_count == max_cpus)
669                                 break;
670                 }
671         }
672         if (cpu_count == 1) {
673                 printk(KERN_INFO "SMP: Bootstrap processor only.\n");
674         }
675
676         /*
677          * FIXME very rough.
678          */
679         cache_decay_ticks = HZ/100;
680
681         printk(KERN_INFO "SMP: Total %d of %d processors activated "
682                "(%lu.%02lu BogoMIPS noticed) (Present Mask: %lu).\n",
683                cpu_count, boot_cpu_data.cpu_count, (bogosum + 25) / 5000,
684                ((bogosum + 25) / 50) % 100, cpu_present_mask);
685
686         smp_num_cpus = cpu_count;
687 #ifdef PER_CPU_IRQ_REGION
688         ipi_init();
689 #endif
690         return;
691 }
692
693 /* 
694  * Called from main.c by Monarch Processor.
695  * After this, any CPU can schedule any task.
696  */
697 void smp_commence(void)
698 {
699         smp_commenced = 1;
700         mb();
701         return;
702 }
703
704 /*
705  * XXX FIXME : do nothing
706  */
707 void smp_cpus_done(unsigned int cpu_max)
708 {
709         smp_threads_ready = 1;
710 }
711
712 void __init smp_prepare_cpus(unsigned int max_cpus)
713 {
714         smp_boot_cpus();
715 }
716
717 void __devinit smp_prepare_boot_cpu(void)
718 {
719         cpu_set(smp_processor_id(), cpu_online_map);
720         cpu_set(smp_processor_id(), cpu_present_mask);
721 }
722
723 int __devinit __cpu_up(unsigned int cpu)
724 {
725         return cpu_online(cpu) ? 0 : -ENOSYS;
726 }
727
728
729
730 #ifdef ENTRY_SYS_CPUS
731 /* Code goes along with:
732 **    entry.s:        ENTRY_NAME(sys_cpus)   / * 215, for cpu stat * /
733 */
734 int sys_cpus(int argc, char **argv)
735 {
736         int i,j=0;
737         extern int current_pid(int cpu);
738
739         if( argc > 2 ) {
740                 printk("sys_cpus:Only one argument supported\n");
741                 return (-1);
742         }
743         if ( argc == 1 ){
744         
745 #ifdef DUMP_MORE_STATE
746                 for(i=0; i<NR_CPUS; i++) {
747                         int cpus_per_line = 4;
748                         if(IS_LOGGED_IN(i)) {
749                                 if (j++ % cpus_per_line)
750                                         printk(" %3d",i);
751                                 else
752                                         printk("\n %3d",i);
753                         }
754                 }
755                 printk("\n"); 
756 #else
757                 printk("\n 0\n"); 
758 #endif
759         } else if((argc==2) && !(strcmp(argv[1],"-l"))) {
760                 printk("\nCPUSTATE  TASK CPUNUM CPUID HARDCPU(HPA)\n");
761 #ifdef DUMP_MORE_STATE
762                 for(i=0;i<NR_CPUS;i++) {
763                         if (!IS_LOGGED_IN(i))
764                                 continue;
765                         if (cpu_data[i].cpuid != NO_PROC_ID) {
766                                 switch(cpu_data[i].state) {
767                                         case STATE_RENDEZVOUS:
768                                                 printk("RENDEZVS ");
769                                                 break;
770                                         case STATE_RUNNING:
771                                                 printk((current_pid(i)!=0) ? "RUNNING  " : "IDLING   ");
772                                                 break;
773                                         case STATE_STOPPED:
774                                                 printk("STOPPED  ");
775                                                 break;
776                                         case STATE_HALTED:
777                                                 printk("HALTED   ");
778                                                 break;
779                                         default:
780                                                 printk("%08x?", cpu_data[i].state);
781                                                 break;
782                                 }
783                                 if(IS_LOGGED_IN(i)) {
784                                         printk(" %4d",current_pid(i));
785                                 }       
786                                 printk(" %6d",cpu_number_map(i));
787                                 printk(" %5d",i);
788                                 printk(" 0x%lx\n",cpu_data[i].hpa);
789                         }       
790                 }
791 #else
792                 printk("\n%s  %4d      0     0 --------",
793                         (current->pid)?"RUNNING ": "IDLING  ",current->pid); 
794 #endif
795         } else if ((argc==2) && !(strcmp(argv[1],"-s"))) { 
796 #ifdef DUMP_MORE_STATE
797                 printk("\nCPUSTATE   CPUID\n");
798                 for (i=0;i<NR_CPUS;i++) {
799                         if (!IS_LOGGED_IN(i))
800                                 continue;
801                         if (cpu_data[i].cpuid != NO_PROC_ID) {
802                                 switch(cpu_data[i].state) {
803                                         case STATE_RENDEZVOUS:
804                                                 printk("RENDEZVS");break;
805                                         case STATE_RUNNING:
806                                                 printk((current_pid(i)!=0) ? "RUNNING " : "IDLING");
807                                                 break;
808                                         case STATE_STOPPED:
809                                                 printk("STOPPED ");break;
810                                         case STATE_HALTED:
811                                                 printk("HALTED  ");break;
812                                         default:
813                                 }
814                                 printk("  %5d\n",i);
815                         }       
816                 }
817 #else
818                 printk("\n%s    CPU0",(current->pid==0)?"RUNNING ":"IDLING  "); 
819 #endif
820         } else {
821                 printk("sys_cpus:Unknown request\n");
822                 return (-1);
823         }
824         return 0;
825 }
826 #endif /* ENTRY_SYS_CPUS */
827
828 #ifdef CONFIG_PROC_FS
829 int __init
830 setup_profiling_timer(unsigned int multiplier)
831 {
832         return -EINVAL;
833 }
834 #endif