* better
[mascara-docs.git] / i386 / linux-2.3.21 / arch / sparc / ap1000 / hw.c
blobaabe15a3b5cad7bbf1a2d50acdf55f3dfcdd9fbb
1 /*
2 * Copyright 1996 The Australian National University.
3 * Copyright 1996 Fujitsu Laboratories Limited
4 *
5 * This software may be distributed under the terms of the Gnu
6 * Public License version 2 or later
7 */
8 /*
9 * Initialize the AP1000 hardware: BIF, MSC+, MC+, etc.
12 #include <linux/sched.h>
13 #include <linux/mm.h>
14 #include <linux/malloc.h>
15 #include <linux/mpp.h>
16 #include <asm/irq.h>
17 #include <asm/ap1000/apservice.h>
18 #include <asm/ap1000/apreg.h>
20 #define APLOG 0
22 /* these make using CellOS code easier */
23 int cap_nopt0;
24 int cap_cid0;
25 int cap_ncel0;
27 unsigned _cid, _ncel, _ncelx, _ncely, _cidx, _cidy;
29 /* yuck - needed for sun4c! */
30 static unsigned char dummy;
31 unsigned char *auxio_register = &dummy;
34 extern struct cap_init cap_init;
36 static void unexpected_irq(int irq, void *dev_id, struct pt_regs *regs)
38 ap_panic("** unexpected interrupt %d **\n",irq);
41 static void ap_other_irqs(void)
43 request_irq(3, unexpected_irq, SA_INTERRUPT, "unused", 0);
44 request_irq(5, unexpected_irq, SA_INTERRUPT, "unused", 0);
45 request_irq(12, unexpected_irq, SA_INTERRUPT, "unused", 0);
46 request_irq(15, unexpected_irq, SA_INTERRUPT, "unused", 0);
49 int ap_memory_size(void)
51 if ((MSC_IN(MSC_SIMMCHK) & MSC_SIMMCHK_MASK) == 0) {
52 return 16*1024*1024;
54 return 64*1024*1024;
57 static void show_registers(void)
59 extern struct pt_regs *bif_pt_regs;
60 if (bif_pt_regs)
61 show_regs(bif_pt_regs);
62 else
63 printk("unable to show registers\n");
67 static void check_alive(void)
69 printk("Cell %d is alive\n",mpp_cid());
74 static void show_task(struct task_struct *t)
76 printk("cell=%3d uid=%5d pid=%5d utime=%3d stime=%3d etime=%3d name=%s\n",
77 mpp_cid(),
78 t->uid,
79 (int)t->pid,
80 (int)t->utime,
81 (int)t->stime,
82 (jiffies - (int)t->start_time) / 100,
83 t->comm);
86 static void show_ptasks(void)
88 extern struct task_struct *task[];
89 struct task_struct *p;
90 int i;
91 int count=0;
93 read_lock(&tasklist_lock);
94 for_each_task(p) {
95 struct task_struct **tp = p->tarray_ptr;
97 if(tp >= &task[MPP_TASK_BASE]) {
98 show_task(p);
99 count++;
102 read_unlock(&tasklist_lock);
104 if (count == 0)
105 printk("no parallel tasks on cell %d\n",mpp_cid());
108 static void show_utasks(void)
110 extern struct task_struct *task[];
111 struct task_struct *p;
112 int i;
113 int count=0;
115 read_lock(&tasklist_lock);
116 for_each_task(p) {
117 if(p->uid > 1) {
118 show_task(task[i]);
119 count++;
122 read_unlock(&tasklist_lock);
124 if (count == 0)
125 printk("no user tasks on cell %d\n",mpp_cid());
129 static void show_otasks(void)
131 extern struct task_struct *task[];
132 struct task_struct *p;
133 int i;
134 int count=0;
135 extern int ap_current_uid;
137 read_lock(&tasklist_lock);
138 for_each_task(p) {
139 if(p->uid == ap_current_uid) {
140 show_task(task[i]);
141 count++;
144 read_unlock(&tasklist_lock);
146 if (count == 0)
147 printk("no tasks on cell %d\n",mpp_cid());
151 void do_panic(void)
153 int *x = 0;
154 *x = 1; /* uggh */
158 void mpp_hw_init(void)
160 extern void show_state(void);
161 extern void breakpoint(void);
162 extern void ctrl_alt_del(void);
163 extern void mac_print_state(void);
164 extern void show_debug_keys(void);
166 bif_add_debug_key('c',check_alive,"check if a cell is alive");
167 bif_add_debug_key('k',show_debug_keys,"show the kernel debug keys");
168 bif_add_debug_key('p',show_registers,"show register info");
169 bif_add_debug_key('p',show_registers,"show register info");
170 bif_add_debug_key('m',show_mem,"detailed memory stats");
171 bif_add_debug_key('s',show_state,"detailed process stats");
172 bif_add_debug_key('D',ap_start_debugger,"launch the kernel debugger");
173 bif_add_debug_key('i',breakpoint,"send a breakpoint");
174 bif_add_debug_key('r',ctrl_alt_del,"run shutdown (doesn't work)");
175 bif_add_debug_key('P',show_ptasks,"show running parallel tasks");
176 bif_add_debug_key('U',show_utasks,"show all user tasks");
177 bif_add_debug_key('O',show_otasks,"show own user tasks");
178 bif_add_debug_key('^',do_panic,"panic :-)");
181 cap_cid0 = BIF_IN(BIF_CIDR1);
182 cap_ncel0 = cap_init.numcells;
184 _cid = cap_cid0;
185 _ncel = cap_ncel0;
186 _ncelx = _ncel<8?_ncel:8;
187 _ncely = ((_ncel-1) / _ncelx) + 1;
188 _cidx = _cid % _ncelx;
189 _cidy = _cid / _ncelx;
191 ap_bif_init();
192 ap_msc_init();
193 ap_tnet_init();
194 ap_profile_init();
195 ap_other_irqs();
196 ap_ringbuf_init();
197 #if APLOG
198 ap_log(NULL,-1);
199 #endif