2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
22 void alloc_guest_devices(struct virt_sys
*sys
)
27 INIT_LIST_HEAD(&sys
->virt_devs
);
29 for(i
=0; sys
->directory
->devices
[i
].type
!= VDEV_INVAL
; i
++) {
30 ret
= alloc_virt_dev(sys
, &sys
->directory
->devices
[i
],
33 con_printf(sys
->con
, "Failed to allocate vdev %04X, SCH = %05X (%s)\n",
34 sys
->directory
->devices
[i
].vdev
,
35 0x10000 + i
, errstrings
[-ret
]);
39 int alloc_guest_storage(struct virt_sys
*sys
)
41 u64 pages
= sys
->directory
->storage_size
>> PAGE_SHIFT
;
44 INIT_LIST_HEAD(&sys
->guest_pages
);
47 p
= alloc_pages(0, ZONE_NORMAL
);
51 list_add(&p
->guest
, &sys
->guest_pages
);
55 dat_insert_page(&sys
->as
, (u64
) page_to_addr(p
),
62 int alloc_vcpu(struct virt_sys
*sys
)
67 page
= alloc_pages(0, ZONE_NORMAL
);
71 cpu
= page_to_addr(page
);
73 memset(cpu
, 0, PAGE_SIZE
);
74 INIT_LIST_HEAD(&cpu
->int_io
[0]);
75 INIT_LIST_HEAD(&cpu
->int_io
[1]);
76 INIT_LIST_HEAD(&cpu
->int_io
[2]);
77 INIT_LIST_HEAD(&cpu
->int_io
[3]);
78 INIT_LIST_HEAD(&cpu
->int_io
[4]);
79 INIT_LIST_HEAD(&cpu
->int_io
[5]);
80 INIT_LIST_HEAD(&cpu
->int_io
[6]);
81 INIT_LIST_HEAD(&cpu
->int_io
[7]);
83 cpu
->cpuid
= getcpuid() | 0xFF00000000000000ULL
;
85 cpu
->sie_cb
.gmsor
= 0;
86 cpu
->sie_cb
.gmslm
= sys
->directory
->storage_size
;
89 cpu
->sie_cb
.eca
= 0xC1002001U
;
91 * TODO: What about ->scaoh and ->scaol?
98 void free_vcpu(struct virt_sys
*sys
)
100 struct virt_cpu
*cpu
= sys
->task
->cpu
;
102 BUG_ON(!list_empty(&cpu
->int_io
[0]));
103 BUG_ON(!list_empty(&cpu
->int_io
[1]));
104 BUG_ON(!list_empty(&cpu
->int_io
[2]));
105 BUG_ON(!list_empty(&cpu
->int_io
[3]));
106 BUG_ON(!list_empty(&cpu
->int_io
[4]));
107 BUG_ON(!list_empty(&cpu
->int_io
[5]));
108 BUG_ON(!list_empty(&cpu
->int_io
[6]));
109 BUG_ON(!list_empty(&cpu
->int_io
[7]));
113 sys
->task
->cpu
= NULL
;