-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiscMachine_A.thy
65 lines (53 loc) · 1.75 KB
/
MiscMachine_A.thy
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
(*
* Copyright 2014, General Dynamics C4 Systems
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
*)
(*
Utilities for the machine level which are not machine-dependent.
*)
chapter "Machine Accessor Functions"
theory MiscMachine_A
imports ARM_Machine_A
begin
text {* Miscellaneous definitions of constants used in modelling machine
operations. *}
definition
nat_to_cref :: "nat \<Rightarrow> nat \<Rightarrow> cap_ref" where
"nat_to_cref ln n \<equiv> drop (word_bits - ln)
(to_bl (of_nat n :: machine_word))"
type_synonym user_context = "register \<Rightarrow> data"
type_synonym 'a user_monad = "(user_context, 'a) nondet_monad"
definition
"msg_info_register \<equiv> msgInfoRegister"
definition
"msg_registers \<equiv> msgRegisters"
definition
"cap_register \<equiv> capRegister"
definition
"badge_register \<equiv> badgeRegister"
definition
"frame_registers \<equiv> frameRegisters"
definition
"gp_registers \<equiv> gpRegisters"
definition
"exception_message \<equiv> exceptionMessage"
definition
"syscall_message \<equiv> syscallMessage"
definition
new_context :: "user_context" where
"new_context \<equiv> (\<lambda>r. 0) (CPSR := 0x150)"
definition
get_register :: "register \<Rightarrow> data user_monad" where
"get_register r \<equiv> gets (\<lambda>uc. uc r)"
definition
set_registers :: "(register \<Rightarrow> data) \<Rightarrow> unit user_monad" where
"set_registers \<equiv> put"
definition
set_register :: "register \<Rightarrow> data \<Rightarrow> unit user_monad" where
"set_register r v \<equiv> modify (\<lambda>uc. uc (r := v))"
end