xref: /kvmtool/powerpc/include/kvm/kvm-arch.h (revision c481cfd579e5039b5ed6443c4905a43e53fd91aa)
163e158a0SMatt Evans /*
263e158a0SMatt Evans  * PPC64 architecture-specific definitions
363e158a0SMatt Evans  *
463e158a0SMatt Evans  * Copyright 2011 Matt Evans <matt@ozlabs.org>, IBM Corporation.
563e158a0SMatt Evans  *
663e158a0SMatt Evans  * This program is free software; you can redistribute it and/or modify it
763e158a0SMatt Evans  * under the terms of the GNU General Public License version 2 as published
863e158a0SMatt Evans  * by the Free Software Foundation.
963e158a0SMatt Evans  */
1063e158a0SMatt Evans 
1163e158a0SMatt Evans #ifndef KVM__KVM_ARCH_H
1263e158a0SMatt Evans #define KVM__KVM_ARCH_H
1363e158a0SMatt Evans 
1463e158a0SMatt Evans #include <stdbool.h>
1563e158a0SMatt Evans #include <linux/types.h>
1663e158a0SMatt Evans #include <time.h>
1763e158a0SMatt Evans 
1863e158a0SMatt Evans /*
1963e158a0SMatt Evans  * MMIO lives after RAM, but it'd be nice if it didn't constantly move.
2063e158a0SMatt Evans  * Choose a suitably high address, e.g. 63T...  This limits RAM size.
2163e158a0SMatt Evans  */
2263e158a0SMatt Evans #define PPC_MMIO_START			0x3F0000000000UL
2363e158a0SMatt Evans #define PPC_MMIO_SIZE			0x010000000000UL
2463e158a0SMatt Evans 
2563e158a0SMatt Evans #define KERNEL_LOAD_ADDR        	0x0000000000000000
2663e158a0SMatt Evans #define KERNEL_START_ADDR       	0x0000000000000000
2763e158a0SMatt Evans #define KERNEL_SECONDARY_START_ADDR     0x0000000000000060
2863e158a0SMatt Evans #define INITRD_LOAD_ADDR        	0x0000000002800000
2963e158a0SMatt Evans 
3063e158a0SMatt Evans #define FDT_MAX_SIZE            	0x10000
3163e158a0SMatt Evans #define RTAS_MAX_SIZE           	0x10000
3263e158a0SMatt Evans 
3363e158a0SMatt Evans #define TIMEBASE_FREQ           	512000000ULL
3463e158a0SMatt Evans 
3563e158a0SMatt Evans #define KVM_MMIO_START			PPC_MMIO_START
3663e158a0SMatt Evans 
3763e158a0SMatt Evans /*
3863e158a0SMatt Evans  * This is the address that pci_get_io_space_block() starts allocating
3963e158a0SMatt Evans  * from.  Note that this is a PCI bus address.
4063e158a0SMatt Evans  */
4163e158a0SMatt Evans #define KVM_PCI_MMIO_AREA		0x1000000
4263e158a0SMatt Evans 
43*c481cfd5SMatt Evans struct spapr_phb;
44*c481cfd5SMatt Evans 
4563e158a0SMatt Evans struct kvm {
4663e158a0SMatt Evans 	int			sys_fd;		/* For system ioctls(), i.e. /dev/kvm */
4763e158a0SMatt Evans 	int			vm_fd;		/* For VM ioctls() */
4863e158a0SMatt Evans 	timer_t			timerid;	/* Posix timer for interrupts */
4963e158a0SMatt Evans 
5063e158a0SMatt Evans 	int			nrcpus;		/* Number of cpus to run */
5163e158a0SMatt Evans 
5263e158a0SMatt Evans 	u32			mem_slots;	/* for KVM_SET_USER_MEMORY_REGION */
5363e158a0SMatt Evans 
5463e158a0SMatt Evans 	u64			ram_size;
5563e158a0SMatt Evans 	void			*ram_start;
5663e158a0SMatt Evans 
57df129a0aSMatt Evans 	u64			sdr1;
58d391177aSMatt Evans 	u32			pvr;
59df129a0aSMatt Evans 
6063e158a0SMatt Evans 	bool			nmi_disabled;
6163e158a0SMatt Evans 
6263e158a0SMatt Evans 	bool			single_step;
6363e158a0SMatt Evans 
6463e158a0SMatt Evans 	const char		*vmlinux;
6563e158a0SMatt Evans 	struct disk_image       **disks;
6663e158a0SMatt Evans 	int                     nr_disks;
6763e158a0SMatt Evans 	unsigned long		rtas_gra;
6863e158a0SMatt Evans 	unsigned long		rtas_size;
6963e158a0SMatt Evans 	unsigned long		fdt_gra;
7063e158a0SMatt Evans 	unsigned long		initrd_gra;
7163e158a0SMatt Evans 	unsigned long		initrd_size;
7263e158a0SMatt Evans 	const char		*name;
737021c50bSAsias He 	int			vm_state;
74f17e5a37SMatt Evans 	struct icp_state	*icp;
75*c481cfd5SMatt Evans 	struct spapr_phb	*phb;
7663e158a0SMatt Evans };
7763e158a0SMatt Evans 
78d391177aSMatt Evans /* Helper for the various bits of code that generate FDT nodes */
79d391177aSMatt Evans #define _FDT(exp)							\
80d391177aSMatt Evans 	do {								\
81d391177aSMatt Evans 		int ret = (exp);					\
82d391177aSMatt Evans 		if (ret < 0) {						\
83d391177aSMatt Evans 			die("Error creating device tree: %s: %s\n",	\
84d391177aSMatt Evans 			    #exp, fdt_strerror(ret));			\
85d391177aSMatt Evans 		}							\
86d391177aSMatt Evans 	} while (0)
87d391177aSMatt Evans 
8863e158a0SMatt Evans #endif /* KVM__KVM_ARCH_H */
89