summaryrefslogtreecommitdiff
path: root/big-little/secure_world/secure_world.h
blob: d46645295994f23702f4f464d016d6c1a0d8adc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Copyright (c) 2012, ARM Limited. All rights reserved.
 *       
 * Redistribution and use in source and binary forms, with
 * or without modification, are permitted provided that the
 * following conditions are met:
 *     
 * Redistributions of source code must retain the above
 * copyright notice, this list of conditions and the 
 * following disclaimer.
 *
 * Redistributions in binary form must reproduce the
 * above copyright notice, this list of conditions and 
 * the following disclaimer in the documentation 
 * and/or other materials provided with the distribution.
 *      
 * Neither the name of ARM nor the names of its
 * contributors may be used to endorse or promote products
 * derived from this software without specific prior written
 * permission.                        
 */

#ifndef __SECURE_WORLD_H__
#define __SECURE_WORLD_H__

#include "hyp_types.h"
#include "virt_helpers.h"
#include "events.h"
#include "misc.h"
#include "gic_registers.h"
#include "hyp_vmmap.h"

/* Definitions for creating a 4K page table entry */
#define PAGE_SHIFT              12
#define PAGE_SIZE               (1UL << PAGE_SHIFT)
#define PAGE_MASK               (~(PAGE_SIZE-1))
#define PAGE_ALIGN(x)           (x & PAGE_MASK)

#define MB_SHIFT                20
#define MB_SIZE                 (1UL << MB_SHIFT)
#define MB_MASK                 (~(MB_SIZE-1))
#define MB_ALIGN(x)             (x & MB_MASK)

#define SP_L1_BASE_SHIFT        10
#define SP_L1_BASE_MASK         (~((1UL << SP_L1_BASE_SHIFT) - 1))

/* Definitions for first level small page descriptors */
#define SMALL_PAGE      (1 << 0)
#define SMALL_PAGE_NS   (1 << 3)

/* Definitions for second level small page descriptors */
#define SP_XN           (1 << 0)
#define SP_SBO          (1 << 1)
#define SP_BUFFERABLE   (1 << 2)
#define SP_CACHEABLE    (1 << 3)
#define SP_AP0          (1 << 4)
#define SP_AP1          (1 << 5)
#define SP_AP2          (1 << 9)
#define SP_TEX0         (1 << 6)
#define SP_TEX1         (1 << 7)
#define SP_TEX2         (1 << 8)
#define SP_SHARED       (1 << 10)
#define SP_GLOBAL       (1 << 11)

typedef struct sec_stack {
	unsigned stack[STACK_SIZE];
} sec_stack;

typedef struct sec_context {
	unsigned sctlr;
	unsigned actlr;
	unsigned cpacr;
	unsigned nsacr;
	unsigned scr;
	unsigned vbar;
	unsigned mvbar;
	unsigned cntfrq;
	unsigned cci_sar;
	unsigned vgic_icdisr0;
	unsigned vgic_iccpmr;
} sec_context;

extern void enable_caches(void);
extern void secure_context_restore(void);
extern void secure_context_save(unsigned);

#endif				/* __SECURE_WORLD_H__ */