upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / tile / kernel / proc.c
1 /*
2  * Copyright 2010 Tilera Corporation. All Rights Reserved.
3  *
4  *   This program is free software; you can redistribute it and/or
5  *   modify it under the terms of the GNU General Public License
6  *   as published by the Free Software Foundation, version 2.
7  *
8  *   This program is distributed in the hope that it will be useful, but
9  *   WITHOUT ANY WARRANTY; without even the implied warranty of
10  *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11  *   NON INFRINGEMENT.  See the GNU General Public License for
12  *   more details.
13  */
14
15 #include <linux/smp.h>
16 #include <linux/seq_file.h>
17 #include <linux/threads.h>
18 #include <linux/cpumask.h>
19 #include <linux/timex.h>
20 #include <linux/delay.h>
21 #include <linux/fs.h>
22 #include <linux/proc_fs.h>
23 #include <linux/sysctl.h>
24 #include <linux/hardirq.h>
25 #include <linux/mman.h>
26 #include <asm/pgtable.h>
27 #include <asm/processor.h>
28 #include <asm/sections.h>
29 #include <asm/homecache.h>
30 #include <arch/chip.h>
31
32
33 /*
34  * Support /proc/cpuinfo
35  */
36
37 #define cpu_to_ptr(n) ((void *)((long)(n)+1))
38 #define ptr_to_cpu(p) ((long)(p) - 1)
39
40 static int show_cpuinfo(struct seq_file *m, void *v)
41 {
42         int n = ptr_to_cpu(v);
43
44         if (n == 0) {
45                 char buf[NR_CPUS*5];
46                 cpulist_scnprintf(buf, sizeof(buf), cpu_online_mask);
47                 seq_printf(m, "cpu count\t: %d\n", num_online_cpus());
48                 seq_printf(m, "cpu list\t: %s\n", buf);
49                 seq_printf(m, "model name\t: %s\n", chip_model);
50                 seq_printf(m, "flags\t\t:\n");  /* nothing for now */
51                 seq_printf(m, "cpu MHz\t\t: %llu.%06llu\n",
52                            get_clock_rate() / 1000000,
53                            (get_clock_rate() % 1000000));
54                 seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
55                            loops_per_jiffy/(500000/HZ),
56                            (loops_per_jiffy/(5000/HZ)) % 100);
57         }
58
59 #ifdef CONFIG_SMP
60         if (!cpu_online(n))
61                 return 0;
62 #endif
63
64         seq_printf(m, "processor\t: %d\n", n);
65
66         /* Print only num_online_cpus() blank lines total. */
67         if (cpumask_next(n, cpu_online_mask) < nr_cpu_ids)
68                 seq_printf(m, "\n");
69
70         return 0;
71 }
72
73 static void *c_start(struct seq_file *m, loff_t *pos)
74 {
75         return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
76 }
77 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
78 {
79         ++*pos;
80         return c_start(m, pos);
81 }
82 static void c_stop(struct seq_file *m, void *v)
83 {
84 }
85 const struct seq_operations cpuinfo_op = {
86         .start  = c_start,
87         .next   = c_next,
88         .stop   = c_stop,
89         .show   = show_cpuinfo,
90 };