ia64/xen-unstable

view xen/arch/ia64/xenmisc.c @ 6457:d34925e4144b

Stil more cleanup and moving to 2.6.13 base
author djm@kirby.fc.hp.com
date Thu Sep 01 11:09:27 2005 -0600 (2005-09-01)
parents 44316ce83277
children
line source
1 /*
2 * Xen misc
3 *
4 * Functions/decls that are/may be needed to link with Xen because
5 * of x86 dependencies
6 *
7 * Copyright (C) 2004 Hewlett-Packard Co.
8 * Dan Magenheimer (dan.magenheimer@hp.com)
9 *
10 */
12 #include <linux/config.h>
13 #include <xen/sched.h>
14 #include <linux/efi.h>
15 #include <asm/processor.h>
16 #include <xen/serial.h>
17 #include <asm/io.h>
18 #include <xen/softirq.h>
20 efi_memory_desc_t ia64_efi_io_md;
21 EXPORT_SYMBOL(ia64_efi_io_md);
22 unsigned long wait_init_idle;
23 int phys_proc_id[NR_CPUS];
24 unsigned long loops_per_jiffy = (1<<12); // from linux/init/main.c
26 void unw_init(void) { printf("unw_init() skipped (NEED FOR KERNEL UNWIND)\n"); }
27 void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort handling)\n"); }
28 void ia64_mca_cpu_init(void *x) { }
29 void ia64_patch_mckinley_e9(unsigned long a, unsigned long b) { }
30 void ia64_patch_vtop(unsigned long a, unsigned long b) { }
31 void hpsim_setup(char **x)
32 {
33 #ifdef CONFIG_SMP
34 init_smp_config();
35 #endif
36 }
38 // called from mem_init... don't think s/w I/O tlb is needed in Xen
39 //void swiotlb_init(void) { } ...looks like it IS needed
41 long
42 is_platform_hp_ski(void)
43 {
44 int i;
45 long cpuid[6];
47 for (i = 0; i < 5; ++i)
48 cpuid[i] = ia64_get_cpuid(i);
49 if ((cpuid[0] & 0xff) != 'H') return 0;
50 if ((cpuid[3] & 0xff) != 0x4) return 0;
51 if (((cpuid[3] >> 8) & 0xff) != 0x0) return 0;
52 if (((cpuid[3] >> 16) & 0xff) != 0x0) return 0;
53 if (((cpuid[3] >> 24) & 0x7) != 0x7) return 0;
54 return 1;
55 }
57 long
58 platform_is_hp_ski(void)
59 {
60 extern long running_on_sim;
61 return running_on_sim;
62 }
64 /* calls in xen/common code that are unused on ia64 */
66 void sync_lazy_execstate_cpu(unsigned int cpu) {}
68 #ifdef CONFIG_VTI
69 int grant_table_create(struct domain *d) { return 0; }
70 void grant_table_destroy(struct domain *d) { return; }
71 #endif
73 struct pt_regs *guest_cpu_user_regs(void) { return ia64_task_regs(current); }
75 void raise_actimer_softirq(void)
76 {
77 raise_softirq(AC_TIMER_SOFTIRQ);
78 }
80 #ifndef CONFIG_VTI
81 unsigned long
82 __gpfn_to_mfn_foreign(struct domain *d, unsigned long gpfn)
83 {
84 if (d == dom0)
85 return(gpfn);
86 else {
87 unsigned long pte = lookup_domain_mpa(d,gpfn << PAGE_SHIFT);
88 if (!pte) {
89 printk("__gpfn_to_mfn_foreign: bad gpfn. spinning...\n");
90 while(1);
91 return 0;
92 }
93 return ((pte & _PFN_MASK) >> PAGE_SHIFT);
94 }
95 }
97 u32
98 __mfn_to_gpfn(struct domain *d, unsigned long frame)
99 {
100 // FIXME: is this right?
101 if ((frame << PAGE_SHIFT) & _PAGE_PPN_MASK) {
102 printk("__mfn_to_gpfn: bad frame. spinning...\n");
103 while(1);
104 }
105 return frame;
106 }
107 #endif
109 #ifndef CONFIG_VTI
110 unsigned long __hypercall_create_continuation(
111 unsigned int op, unsigned int nr_args, ...)
112 {
113 printf("__hypercall_create_continuation: not implemented!!!\n");
114 }
115 #endif
117 ///////////////////////////////
119 ///////////////////////////////
120 // from arch/x86/apic.c
121 ///////////////////////////////
123 extern unsigned long domain0_ready;
125 int reprogram_ac_timer(s_time_t timeout)
126 {
127 struct vcpu *v = current;
129 #ifdef CONFIG_VTI
130 // if(VMX_DOMAIN(v))
131 return 1;
132 #endif // CONFIG_VTI
133 if (!domain0_ready) return 1;
134 local_cpu_data->itm_next = timeout;
135 if (is_idle_task(v->domain)) vcpu_safe_set_itm(timeout);
136 else vcpu_set_next_timer(current);
137 return 1;
138 }
140 ///////////////////////////////
141 // from arch/ia64/page_alloc.c
142 ///////////////////////////////
143 DEFINE_PER_CPU(struct page_state, page_states) = {0};
144 unsigned long totalram_pages;
146 void __mod_page_state(unsigned offset, unsigned long delta)
147 {
148 unsigned long flags;
149 void* ptr;
151 local_irq_save(flags);
152 ptr = &__get_cpu_var(page_states);
153 *(unsigned long*)(ptr + offset) += delta;
154 local_irq_restore(flags);
155 }
157 ///////////////////////////////
158 // from arch/x86/flushtlb.c
159 ///////////////////////////////
161 u32 tlbflush_clock;
162 u32 tlbflush_time[NR_CPUS];
164 ///////////////////////////////
165 // from arch/x86/memory.c
166 ///////////////////////////////
168 void init_percpu_info(void)
169 {
170 dummy();
171 //memset(percpu_info, 0, sizeof(percpu_info));
172 }
174 void free_page_type(struct pfn_info *page, unsigned int type)
175 {
176 dummy();
177 }
179 ///////////////////////////////
180 //// misc memory stuff
181 ///////////////////////////////
183 unsigned long __get_free_pages(unsigned int mask, unsigned int order)
184 {
185 void *p = alloc_xenheap_pages(order);
187 memset(p,0,PAGE_SIZE<<order);
188 return (unsigned long)p;
189 }
191 void __free_pages(struct page *page, unsigned int order)
192 {
193 if (order) BUG();
194 free_xenheap_page(page);
195 }
197 void *pgtable_quicklist_alloc(void)
198 {
199 return alloc_xenheap_pages(0);
200 }
202 void pgtable_quicklist_free(void *pgtable_entry)
203 {
204 free_xenheap_page(pgtable_entry);
205 }
207 ///////////////////////////////
208 // from arch/ia64/traps.c
209 ///////////////////////////////
211 void show_registers(struct pt_regs *regs)
212 {
213 printf("*** ADD REGISTER DUMP HERE FOR DEBUGGING\n");
214 }
216 int is_kernel_text(unsigned long addr)
217 {
218 extern char _stext[], _etext[];
219 if (addr >= (unsigned long) _stext &&
220 addr <= (unsigned long) _etext)
221 return 1;
223 return 0;
224 }
226 unsigned long kernel_text_end(void)
227 {
228 extern char _etext[];
229 return (unsigned long) _etext;
230 }
232 ///////////////////////////////
233 // from common/keyhandler.c
234 ///////////////////////////////
235 void dump_pageframe_info(struct domain *d)
236 {
237 printk("dump_pageframe_info not implemented\n");
238 }
240 ///////////////////////////////
241 // called from arch/ia64/head.S
242 ///////////////////////////////
244 void console_print(char *msg)
245 {
246 printk("console_print called, how did start_kernel return???\n");
247 }
249 void kernel_thread_helper(void)
250 {
251 printk("kernel_thread_helper not implemented\n");
252 dummy();
253 }
255 void sys_exit(void)
256 {
257 printk("sys_exit not implemented\n");
258 dummy();
259 }
261 ////////////////////////////////////
262 // called from unaligned.c
263 ////////////////////////////////////
265 void die_if_kernel(char *str, struct pt_regs *regs, long err) /* __attribute__ ((noreturn)) */
266 {
267 printk("die_if_kernel: called, not implemented\n");
268 }
270 long
271 ia64_peek (struct task_struct *child, struct switch_stack *child_stack,
272 unsigned long user_rbs_end, unsigned long addr, long *val)
273 {
274 printk("ia64_peek: called, not implemented\n");
275 }
277 long
278 ia64_poke (struct task_struct *child, struct switch_stack *child_stack,
279 unsigned long user_rbs_end, unsigned long addr, long val)
280 {
281 printk("ia64_poke: called, not implemented\n");
282 }
284 void
285 ia64_sync_fph (struct task_struct *task)
286 {
287 printk("ia64_sync_fph: called, not implemented\n");
288 }
290 void
291 ia64_flush_fph (struct task_struct *task)
292 {
293 printk("ia64_flush_fph: called, not implemented\n");
294 }
296 ////////////////////////////////////
297 // called from irq_ia64.c:init_IRQ()
298 // (because CONFIG_IA64_HP_SIM is specified)
299 ////////////////////////////////////
300 void hpsim_irq_init(void) { }
303 // accomodate linux extable.c
304 //const struct exception_table_entry *
305 void *search_module_extables(unsigned long addr) { return NULL; }
306 void *__module_text_address(unsigned long addr) { return NULL; }
307 void *module_text_address(unsigned long addr) { return NULL; }
309 void cs10foo(void) {}
310 void cs01foo(void) {}
312 unsigned long context_switch_count = 0;
314 void context_switch(struct vcpu *prev, struct vcpu *next)
315 {
316 //printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
317 //printk("@@@@@@ context switch from domain %d (%x) to domain %d (%x)\n",
318 //prev->domain->domain_id,(long)prev&0xffffff,next->domain->domain_id,(long)next&0xffffff);
319 //if (prev->domain->domain_id == 1 && next->domain->domain_id == 0) cs10foo();
320 //if (prev->domain->domain_id == 0 && next->domain->domain_id == 1) cs01foo();
321 //printk("@@sw %d->%d\n",prev->domain->domain_id,next->domain->domain_id);
322 #ifdef CONFIG_VTI
323 vtm_domain_out(prev);
324 #endif
325 context_switch_count++;
326 switch_to(prev,next,prev);
327 #ifdef CONFIG_VTI
328 vtm_domain_in(current);
329 #endif
331 // leave this debug for now: it acts as a heartbeat when more than
332 // one domain is active
333 {
334 static long cnt[16] = { 50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50};
335 static int i = 100;
336 int id = ((struct vcpu *)current)->domain->domain_id & 0xf;
337 if (!cnt[id]--) { printk("%x",id); cnt[id] = 500000; }
338 if (!i--) { printk("+",id); i = 1000000; }
339 }
341 #ifdef CONFIG_VTI
342 if (VMX_DOMAIN(current))
343 vmx_load_all_rr(current);
344 #else
345 if (!is_idle_task(current->domain)) {
346 load_region_regs(current);
347 if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
348 }
349 if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
350 #endif
351 }
353 void context_switch_finalise(struct vcpu *next)
354 {
355 /* nothing to do */
356 }
358 void continue_running(struct vcpu *same)
359 {
360 /* nothing to do */
361 }
363 void panic_domain(struct pt_regs *regs, const char *fmt, ...)
364 {
365 va_list args;
366 char buf[128];
367 struct vcpu *v = current;
368 static volatile int test = 1; // so can continue easily in debug
369 extern spinlock_t console_lock;
370 unsigned long flags;
372 loop:
373 printf("$$$$$ PANIC in domain %d (k6=%p): ",
374 v->domain->domain_id,
375 __get_cpu_var(cpu_kr)._kr[IA64_KR_CURRENT]);
376 va_start(args, fmt);
377 (void)vsnprintf(buf, sizeof(buf), fmt, args);
378 va_end(args);
379 printf(buf);
380 if (regs) show_registers(regs);
381 domain_pause_by_systemcontroller(current->domain);
382 v->domain->shutdown_code = SHUTDOWN_crash;
383 set_bit(_DOMF_shutdown, v->domain->domain_flags);
384 if (v->domain->domain_id == 0) {
385 int i = 1000000000L;
386 // if domain0 crashes, just periodically print out panic
387 // message to make post-mortem easier
388 while(i--);
389 goto loop;
390 }
391 }