ia64/xen-unstable

view tools/libxc/xc_dom_ia64.c @ 14132:9f199e1fd929

libxc, ia64: Added new arch_hook for registering ia64 big endian images.
Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
author kfraser@localhost.localdomain
date Mon Feb 26 10:18:52 2007 +0000 (2007-02-26)
parents c051ed67258a
children 2734b64255b3
line source
1 /*
2 * Xen domain builder -- ia64 bits.
3 *
4 * Most architecture-specific code for ia64 goes here.
5 * - fill architecture-specific structs.
6 *
7 * This code is licenced under the GPL.
8 * written 2006 by Gerd Hoffmann <kraxel@suse.de>.
9 *
10 */
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <inttypes.h>
16 #include <xen/xen.h>
17 #include <xen/foreign/ia64.h>
19 #include "xg_private.h"
20 #include "xc_dom.h"
22 /* ------------------------------------------------------------------------ */
24 static int alloc_magic_pages(struct xc_dom_image *dom)
25 {
26 /* allocate special pages */
27 dom->console_pfn = dom->total_pages -1;
28 dom->xenstore_pfn = dom->total_pages -2;
29 dom->start_info_pfn = dom->total_pages -3;
30 return 0;
31 }
33 static int start_info_ia64(struct xc_dom_image *dom)
34 {
35 start_info_ia64_t *start_info =
36 xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1);
37 struct xen_ia64_boot_param_ia64 *bp =
38 (struct xen_ia64_boot_param_ia64 *)(start_info + 1);
40 xc_dom_printf("%s\n", __FUNCTION__);
42 memset(start_info, 0, sizeof(*start_info));
43 sprintf(start_info->magic, dom->guest_type);
44 start_info->flags = dom->flags;
45 start_info->nr_pages = dom->total_pages;
46 start_info->store_mfn = dom->xenstore_pfn;
47 start_info->store_evtchn = dom->xenstore_evtchn;
48 start_info->console.domU.mfn = dom->console_pfn;
49 start_info->console.domU.evtchn = dom->console_evtchn;
51 if ( dom->ramdisk_blob )
52 {
53 start_info->mod_start = dom->ramdisk_seg.vstart;
54 start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
55 bp->initrd_start = start_info->mod_start;
56 bp->initrd_size = start_info->mod_len;
57 }
58 bp->command_line = (dom->start_info_pfn << PAGE_SHIFT_IA64)
59 + offsetof(start_info_t, cmd_line);
60 if ( dom->cmdline )
61 {
62 strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
63 start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
64 }
65 return 0;
66 }
68 static int shared_info_ia64(struct xc_dom_image *dom, void *ptr)
69 {
70 shared_info_ia64_t *shared_info = ptr;
71 int i;
73 xc_dom_printf("%s: called\n", __FUNCTION__);
75 memset(shared_info, 0, sizeof(*shared_info));
76 for (i = 0; i < MAX_VIRT_CPUS; i++)
77 shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
78 shared_info->arch.start_info_pfn = dom->start_info_pfn;
79 return 0;
80 }
82 extern unsigned long xc_ia64_fpsr_default(void);
84 static int vcpu_ia64(struct xc_dom_image *dom, void *ptr)
85 {
86 vcpu_guest_context_ia64_t *ctxt = ptr;
88 xc_dom_printf("%s: called\n", __FUNCTION__);
90 /* clear everything */
91 memset(ctxt, 0, sizeof(*ctxt));
93 ctxt->flags = 0;
94 ctxt->user_regs.cr_ipsr = 0; /* all necessary bits filled by hypervisor */
95 ctxt->user_regs.cr_iip = dom->parms.virt_entry;
96 ctxt->user_regs.cr_ifs = (uint64_t) 1 << 63;
97 #ifdef __ia64__ /* FIXME */
98 ctxt->user_regs.ar_fpsr = xc_ia64_fpsr_default();
99 #endif
100 ctxt->user_regs.r28 = (dom->start_info_pfn << PAGE_SHIFT_IA64)
101 + sizeof(start_info_ia64_t);
102 return 0;
103 }
105 /* ------------------------------------------------------------------------ */
107 static struct xc_dom_arch xc_dom_arch = {
108 .guest_type = "xen-3.0-ia64",
109 .page_shift = PAGE_SHIFT_IA64,
110 .alloc_magic_pages = alloc_magic_pages,
111 .start_info = start_info_ia64,
112 .shared_info = shared_info_ia64,
113 .vcpu = vcpu_ia64,
114 };
116 static struct xc_dom_arch xc_dom_arch_ia64be = {
117 .guest_type = "xen-3.0-ia64be",
118 .page_shift = PAGE_SHIFT_IA64,
119 .alloc_magic_pages = alloc_magic_pages,
120 .start_info = start_info_ia64,
121 .shared_info = shared_info_ia64,
122 .vcpu = vcpu_ia64,
123 };
125 static void __init register_arch_hooks(void)
126 {
127 xc_dom_register_arch_hooks(&xc_dom_arch);
128 xc_dom_register_arch_hooks(&xc_dom_arch_ia64be);
129 }
131 /*
132 * Local variables:
133 * mode: C
134 * c-set-style: "BSD"
135 * c-basic-offset: 4
136 * tab-width: 4
137 * indent-tabs-mode: nil
138 * End:
139 */