summaryrefslogtreecommitdiff
path: root/big-little/virtualisor/include
diff options
context:
space:
mode:
authorRobin Randhawa <robin.randhawa@arm.com>2011-10-12 16:07:02 +0100
committerRobin Randhawa <robin.randhawa@arm.com>2011-10-12 16:07:02 +0100
commit0656dea51f48c51a57e77187de4d5f66a6ba1337 (patch)
tree5b93e8967b0aa1cadd2724689346c6251cb47669 /big-little/virtualisor/include
Initial commit of the virtualizer v2.0 release.
This will be the basis for the VSM.
Diffstat (limited to 'big-little/virtualisor/include')
-rw-r--r--big-little/virtualisor/include/cache_geom.h101
-rw-r--r--big-little/virtualisor/include/mem_trap.h47
-rw-r--r--big-little/virtualisor/include/virtualisor.h78
3 files changed, 226 insertions, 0 deletions
diff --git a/big-little/virtualisor/include/cache_geom.h b/big-little/virtualisor/include/cache_geom.h
new file mode 100644
index 0000000..72935f5
--- /dev/null
+++ b/big-little/virtualisor/include/cache_geom.h
@@ -0,0 +1,101 @@
+/*
+ * $Copyright:
+ * ----------------------------------------------------------------
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from ARM Limited
+ * (C) COPYRIGHT 2008-2011 ARM Limited
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from ARM Limited.
+ * ----------------------------------------------------------------
+ * File: kingfisher.h
+ * ----------------------------------------------------------------
+ * $
+ */
+
+#ifndef __CACHE_GEOM_H__
+#define __CACHE_GEOM_H__
+
+#define MAX_CACHE_LEVELS 0x8
+
+/* Target cpu cache relative to host cpu cache size */
+#define TCSZ_EQUAL 0x0
+#define TCSZ_SMALL 0x1
+#define TCSZ_BIG 0x2
+
+#define get_setway_reg(a, b , c, d, e) ((a << __clz(b)) | (c << (d + 4)) | (e << 1))
+#define get_cache_type(clidr, lvl) ((clidr >> (lvl * 0x3)) & 0x7)
+#define get_cache_level(reg) (reg >> 1) & 0x7
+#define get_cache_linesz(cg, lvl) (cg->ccsidr[lvl] & 0x7)
+#define get_cache_assoc(cg, lvl) ((cg->ccsidr[lvl] >> 3) & 0x3ff)
+#define get_cache_numsets(cg, lvl) ((cg->ccsidr[lvl] >> 13) & 0x7fff)
+
+/*
+ * Data structure that stores the foreseeable differences
+ * between the host and target caches at each implemented
+ * cache level.
+ * Absolute cache line numbers are calculated relative to
+ * the cache line size of the smaller cache to get the
+ * maximum granularity.
+ */
+typedef struct cache_diff {
+ /* Stores whether target cache is =,<,> host cache */
+ unsigned csize_diff;
+ /*
+ * Stores factor by which target cache line
+ * has to be multiplied to get absolute line
+ * no.
+ */
+ unsigned tcline_factor;
+ /*
+ * Stores factor by which absolute cache line
+ * no. has to be divided to get host cache line
+ * no.
+ */
+ unsigned hcline_factor;
+ /* Max absolute target cpu cache line number */
+ unsigned tnumabs_clines;
+ /* Max absolute host cpu cache line number */
+ unsigned hnumabs_clines;
+} cache_diff;
+
+/*
+ * Data structure that defines the cache topology of a cpu
+ */
+typedef struct cache_geom {
+ unsigned clidr;
+ /*
+ * One for each cpu to store the cache level
+ * the OS thinks its operating on.
+ */
+ unsigned ccselr;
+ /* One for each cache level */
+ unsigned ccsidr[MAX_CACHE_LEVELS];
+} cache_geometry;
+
+/*
+ * Data structure to hold cache virtualisation statistics.
+ * Reset for each switchover.
+ */
+typedef struct cache_stats {
+ /* Number of cm ops which did not cover the whole cache */
+ unsigned part_cmop_cnt;
+ /* Number of cm ops which spanned the entire cache */
+ unsigned cmpl_cmop_cnt;
+} cache_stats;
+
+extern unsigned map_cache_geometries(cache_geometry *,
+ cache_geometry *,
+ cache_diff *);
+extern void find_cache_geometry(cache_geometry *);
+extern void find_cache_diff(cache_geometry *,
+ cache_geometry *,
+ cache_diff *);
+extern void handle_cm_op(unsigned,
+ void (*) (unsigned),
+ cache_geometry *,
+ cache_geometry *,
+ cache_diff *);
+
+#endif /* __CACHE_GEOM_H__ */
diff --git a/big-little/virtualisor/include/mem_trap.h b/big-little/virtualisor/include/mem_trap.h
new file mode 100644
index 0000000..72afda8
--- /dev/null
+++ b/big-little/virtualisor/include/mem_trap.h
@@ -0,0 +1,47 @@
+/*
+ * $Copyright:
+ * ----------------------------------------------------------------
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from ARM Limited
+ * (C) COPYRIGHT 2008-2011 ARM Limited
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from ARM Limited.
+ * ----------------------------------------------------------------
+ * File: mem_trap.h
+ * ----------------------------------------------------------------
+ * $
+ */
+
+#ifndef __MEM_TRAP_H__
+#define __MEM_TRAP_H__
+
+/*
+ * Data structure that holds info about all traps populated
+ * in the 2nd stage translation tables. It does not need to
+ * interpret the traps but simple save and restore them.
+ * This should prevent the usage of trap specific save/restore
+ * routines.
+ */
+typedef struct trap_data {
+ /* Does this structure contain valid data */
+ unsigned valid;
+ /* Which cluster to save/restore this trap on */
+ unsigned cluster_id;
+ /* Translation table address */
+ unsigned long long table;
+ /* Index corresponding to mapping */
+ unsigned index;
+ /* TODO: Revisit why we need two variables here */
+ /* Original Descriptor */
+ unsigned long long prev_desc;
+ /* Current Descriptor */
+ unsigned long long cur_desc;
+} mem_trap_data;
+
+extern unsigned mem_trap_setup(unsigned, mem_trap_data *);
+extern mem_trap_data s2_trap_section$$Base;
+extern unsigned s2_trap_section$$Length;
+
+#endif /* __MEM_TRAP_H__ */
diff --git a/big-little/virtualisor/include/virtualisor.h b/big-little/virtualisor/include/virtualisor.h
new file mode 100644
index 0000000..fac42e7
--- /dev/null
+++ b/big-little/virtualisor/include/virtualisor.h
@@ -0,0 +1,78 @@
+/*
+ * $Copyright:
+ * ----------------------------------------------------------------
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from ARM Limited
+ * (C) COPYRIGHT 2008-2011 ARM Limited
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from ARM Limited.
+ * ----------------------------------------------------------------
+ * File: virtualisor.h
+ * ----------------------------------------------------------------
+ * $
+ */
+
+#ifndef __VIRTUALISOR_H__
+#define __VIRTUALISOR_H__
+
+#include "misc.h"
+#include "virt_helpers.h"
+
+/*
+ * Data structure that holds a copy of the virtualized regs
+ */
+typedef struct virt_regs {
+ unsigned cluster_id;
+ unsigned mpidr;
+ unsigned midr;
+} virt_reg_data;
+
+/*
+ * Data structure that holds all the trap registers exported
+ * by the Virtualisation Extensions.
+ */
+typedef struct trap_regs {
+ unsigned hcr;
+ unsigned hdcr;
+ unsigned hcptr;
+ unsigned hstr;
+} reg_trap_data;
+
+typedef struct gp_regs {
+ unsigned r[15];
+} gp_regs;
+
+/*
+ * Descriptor exported by each processor describing
+ * which traps it wants to implement along with
+ * handlers for saving and restoring for each conf-
+ * -igured trap.
+ */
+typedef struct virt_desc {
+ /* cpu midr contents */
+ unsigned cpu_no;
+ /*
+ * Bitmask to inidicate that Virtualisor setup has been
+ * done on both host & target cpus.
+ */
+ unsigned char init[NUM_CPUS];
+ unsigned (*trap_setup) (unsigned, unsigned);
+ unsigned (*trap_handle) (gp_regs * regs, unsigned, unsigned);
+ unsigned (*trap_save) (unsigned, unsigned);
+ unsigned (*trap_restore) (unsigned, unsigned);
+} virt_descriptor;
+
+extern void SetupVirtualisor(unsigned);
+extern void SaveVirtualisor(unsigned);
+extern void RestoreVirtualisor(unsigned);
+extern void HandleVirtualisor(gp_regs *);
+extern void handle_vgic_distif_abort(unsigned, unsigned *, unsigned);
+extern unsigned find_sibling_cpu(void);
+extern virt_descriptor virt_desc_section$$Base;
+extern unsigned virt_desc_section$$Length;
+extern unsigned host_cluster;
+extern unsigned switcher;
+
+#endif /* __VIRTUALISOR_H__ */