xref: /kvmtool/powerpc/include/kvm/kvm-arch.h (revision 2df530136dc0eb700348e806e262a9aaf71067d0)
1 /*
2  * PPC64 architecture-specific definitions
3  *
4  * Copyright 2011 Matt Evans <matt@ozlabs.org>, IBM Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published
8  * by the Free Software Foundation.
9  */
10 
11 #ifndef KVM__KVM_ARCH_H
12 #define KVM__KVM_ARCH_H
13 
14 #include <stdbool.h>
15 #include <linux/types.h>
16 #include <time.h>
17 
18 /*
19  * MMIO lives after RAM, but it'd be nice if it didn't constantly move.
20  * Choose a suitably high address, e.g. 63T...  This limits RAM size.
21  */
22 #define PPC_MMIO_START			0x3F0000000000UL
23 #define PPC_MMIO_SIZE			0x010000000000UL
24 
25 #define KERNEL_LOAD_ADDR        	0x0000000000000000
26 #define KERNEL_START_ADDR       	0x0000000000000000
27 #define KERNEL_SECONDARY_START_ADDR     0x0000000000000060
28 #define INITRD_LOAD_ADDR        	0x0000000002800000
29 
30 #define FDT_MAX_SIZE            	0x10000
31 #define RTAS_MAX_SIZE           	0x10000
32 
33 #define TIMEBASE_FREQ           	512000000ULL
34 
35 #define KVM_MMIO_START			PPC_MMIO_START
36 
37 /*
38  * This is the address that pci_get_io_space_block() starts allocating
39  * from.  Note that this is a PCI bus address.
40  */
41 #define KVM_PCI_MMIO_AREA		0x1000000
42 #define KVM_VIRTIO_MMIO_AREA		0x2000000
43 
44 struct spapr_phb;
45 
46 struct kvm {
47 	int			sys_fd;		/* For system ioctls(), i.e. /dev/kvm */
48 	int			vm_fd;		/* For VM ioctls() */
49 	timer_t			timerid;	/* Posix timer for interrupts */
50 
51 	int			nrcpus;		/* Number of cpus to run */
52 
53 	u32			mem_slots;	/* for KVM_SET_USER_MEMORY_REGION */
54 
55 	u64			ram_size;
56 	void			*ram_start;
57 
58 	u64			sdr1;
59 	u32			pvr;
60 
61 	bool			nmi_disabled;
62 
63 	bool			single_step;
64 
65 	const char		*vmlinux;
66 	struct disk_image       **disks;
67 	int                     nr_disks;
68 	unsigned long		rtas_gra;
69 	unsigned long		rtas_size;
70 	unsigned long		fdt_gra;
71 	unsigned long		initrd_gra;
72 	unsigned long		initrd_size;
73 	char			*name;
74 	int			vm_state;
75 	struct icp_state	*icp;
76 	struct spapr_phb	*phb;
77 };
78 
79 /* Helper for the various bits of code that generate FDT nodes */
80 #define _FDT(exp)							\
81 	do {								\
82 		int ret = (exp);					\
83 		if (ret < 0) {						\
84 			die("Error creating device tree: %s: %s\n",	\
85 			    #exp, fdt_strerror(ret));			\
86 		}							\
87 	} while (0)
88 
89 #endif /* KVM__KVM_ARCH_H */
90