theory Retype_R

lemma createNewCaps_null_filter':
  "\<lbrace>(\<lambda>s. P (null_filter' (ctes_of s)))
      and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz
      and K (range_cover ptr sz (APIType_capBits ty us) n \<and> n \<noteq> 0) \<rbrace>
     createNewCaps ty ptr n us dev
   \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>" apply (rule hoare_gen_asm) apply (simp add: createNewCaps_def toAPIType_def
                   Arch_createNewCaps_def
               split del: if_split cong: option.case_cong) apply (cases ty, simp_all split del: if_split) apply (rename_tac apiobject_type) apply (case_tac apiobject_type, simp_all split del: if_split) apply (rule hoare_pre, wp,simp) apply (simp add: createObjects_def makeObjectKO_def
                              APIType_capBits_def objBits_def pageBits_def
                              archObjSize_def ptBits_def pdBits_def curDomain_def
                              objBits_if_dev
                       split del: if_split
                    | wp createObjects_null_filter'[where ty = "Inr ty" and sz = sz and dev=dev]
                         copyGlobalMappings_ctes_of threadSet_ctes_of mapM_x_wp'
                    | simp add: objBits_simps pteBits_def pdeBits_def
                    | fastforce)+ done

(* Proof state trace *)
proof (prove)
goal (1 subgoal):
 1. \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz and K (range_cover ptr sz (APIType_capBits ty us) n \<and> n \<noteq> 0)\<rbrace> createNewCaps ty ptr n us dev \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace> proof (prove)
goal (1 subgoal):
 1. range_cover ptr sz (APIType_capBits ty us) n \<and> n \<noteq> 0 \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> createNewCaps ty ptr n us dev \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace> proof (prove)
goal (1 subgoal):
 1. range_cover ptr sz (APIType_capBits ty us) n \<and> 0 < n \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> case case ty of APIObjectType a \<Rightarrow> Just a | _ \<Rightarrow> Nothing of None \<Rightarrow> do archCaps <- case ty of APIObjectType apiObject \<Rightarrow> haskell_fail [] | SmallPageObject \<Rightarrow> let Data = if dev then KOUserDataDevice else KOUserData in do addrs <- createObjects ptr n Data 0;
modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr `~elem~` map fromPPtr addrs then Just ARMSmallPage else gsUserPages ks addr\<rparr>);
return $ map (\<lambda>n. arch_capability.PageCap dev (PPtr (fromPPtr n)) VMReadWrite ARMSmallPage Nothing) addrs
od | LargePageObject \<Rightarrow> let Data = if dev then KOUserDataDevice else KOUserData in do addrs <- createObjects ptr n Data 4;
modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr `~elem~` map fromPPtr addrs then Just ARMLargePage else gsUserPages ks addr\<rparr>);
return $ map (\<lambda>n. arch_capability.PageCap dev (PPtr (fromPPtr n)) VMReadWrite ARMLargePage Nothing) addrs
od | SectionObject \<Rightarrow> let Data = if dev then KOUserDataDevice else KOUserData in do addrs <- createObjects ptr n Data 8;
modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr `~elem~` map fromPPtr addrs then Just ARMSection else gsUserPages ks addr\<rparr>);
return $ map (\<lambda>n. arch_capability.PageCap dev (PPtr (fromPPtr n)) VMReadWrite ARMSection Nothing) addrs
od | SuperSectionObject \<Rightarrow> let Data = if dev then KOUserDataDevice else KOUserData in do addrs <- createObjects ptr n Data 12;
modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr `~elem~` map fromPPtr addrs then Just ARMSuperSection else gsUserPages ks addr\<rparr>);
return $ map (\<lambda>n. arch_capability.PageCap dev (PPtr (fromPPtr n)) VMReadWrite ARMSuperSection Nothing) addrs
od | PageTableObject \<Rightarrow> do tableSize <- return (ptBits - objBits makeObject);
addrs <- createObjects ptr n (injectKOS makeObject) tableSize;
pts <- return (map (PPtr \<circ> fromPPtr) addrs);
return ();
return $ map (\<lambda>pt. arch_capability.PageTableCap pt Nothing) pts
od | PageDirectoryObject \<Rightarrow> do tableSize <- return (pdBits - objBits makeObject);
addrs <- createObjects ptr n (injectKOS makeObject) tableSize;
pts <- return (map (PPtr \<circ> fromPPtr) addrs);
do objSize <- return (1 `~shiftL~` pdBits);
mapM_x copyGlobalMappings pts;
doMachineOp $ mapM_x (\<lambda>x. cleanCacheRange_PoU x (x + fromIntegral objSize - 1) (addrFromPPtr x)) pts
od;
return $ map (\<lambda>pt. arch_capability.PageDirectoryCap pt Nothing) pts
od;
return (map capability.ArchObjectCap archCaps)
od | Some ArchTypes_H.apiobject_type.Untyped \<Rightarrow> return $ map (\<lambda>n. capability.UntypedCap dev (ptr + n * 2 ^ fromIntegral us) us 0) [0 .e. fromIntegral n - 1] | Some ArchTypes_H.apiobject_type.TCBObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
curdom <- curDomain;
mapM_x (threadSet (tcbDomain_update (\<lambda>_. curdom))) addrs;
return $ map capability.ThreadCap addrs
od | Some ArchTypes_H.apiobject_type.EndpointObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
return $ map (\<lambda>addr. capability.EndpointCap addr 0 True True True True) addrs
od | Some ArchTypes_H.apiobject_type.NotificationObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
return $ map (\<lambda>addr. capability.NotificationCap addr 0 True True) addrs
od | Some ArchTypes_H.apiobject_type.CapTableObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) us;
modify (\<lambda>ks. ks\<lparr>gsCNodes := \<lambda>addr. if addr `~elem~` map fromPPtr addrs then Just us else gsCNodes ks addr\<rparr>);
return $ map (\<lambda>addr. capability.CNodeCap addr us 0 0) addrs
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace> proof (prove)
goal (7 subgoals):
 1. \<And>x1. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType x1) us) n \<and> 0 < n; ty = APIObjectType x1\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> case x1 of ArchTypes_H.apiobject_type.Untyped \<Rightarrow> return $ map (\<lambda>n. capability.UntypedCap dev (ptr + n * 2 ^ fromIntegral us) us 0) [0 .e. fromIntegral n - 1] | ArchTypes_H.apiobject_type.TCBObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
curdom <- curDomain;
mapM_x (threadSet (tcbDomain_update (\<lambda>_. curdom))) addrs;
return $ map capability.ThreadCap addrs
od | ArchTypes_H.apiobject_type.EndpointObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
return $ map (\<lambda>addr. capability.EndpointCap addr 0 True True True True) addrs
od | ArchTypes_H.apiobject_type.NotificationObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
return $ map (\<lambda>addr. capability.NotificationCap addr 0 True True) addrs
od | ArchTypes_H.apiobject_type.CapTableObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) us;
modify (\<lambda>ks. ks\<lparr>gsCNodes := \<lambda>addr. if addr `~elem~` map fromPPtr addrs then Just us else gsCNodes ks addr\<rparr>);
return $ map (\<lambda>addr. capability.CNodeCap addr us 0 0) addrs
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 2. \<lbrakk>range_cover ptr sz (APIType_capBits SmallPageObject us) n \<and> 0 < n; ty = SmallPageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 0;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSmallPage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSmallPage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 3. \<lbrakk>range_cover ptr sz (APIType_capBits LargePageObject us) n \<and> 0 < n; ty = LargePageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 4;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMLargePage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMLargePage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 4. \<lbrakk>range_cover ptr sz (APIType_capBits SectionObject us) n \<and> 0 < n; ty = SectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 8;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 5. \<lbrakk>range_cover ptr sz (APIType_capBits SuperSectionObject us) n \<and> 0 < n; ty = SuperSectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 12;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSuperSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSuperSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 6. \<lbrakk>range_cover ptr sz (APIType_capBits PageTableObject us) n \<and> 0 < n; ty = PageTableObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOArch (KOPTE makeObject)) (ptBits - objBits makeObject);
return (map (capability.ArchObjectCap \<circ> (\<lambda>pt. arch_capability.PageTableCap pt None)) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 7. \<lbrakk>range_cover ptr sz (APIType_capBits PageDirectoryObject us) n \<and> 0 < n; ty = PageDirectoryObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (KOArch (KOPDE makeObject)) (pdBits - objBits makeObject);
y <- do y <- mapM_x copyGlobalMappings addrs;
doMachineOp (mapM_x (\<lambda>x. cleanCacheRange_PoU x (x + word_of_nat (shiftL (Suc 0) pdBits) - 1) (addrFromPPtr x)) addrs)
od;
return (map (\<lambda>pt. arch_capability.PageDirectoryCap pt None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace> proof (prove)
goal (7 subgoals):
 1. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType apiobject_type) us) n \<and> 0 < n; ty = APIObjectType apiobject_type\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> case apiobject_type of ArchTypes_H.apiobject_type.Untyped \<Rightarrow> return $ map (\<lambda>n. capability.UntypedCap dev (ptr + n * 2 ^ fromIntegral us) us 0) [0 .e. fromIntegral n - 1] | ArchTypes_H.apiobject_type.TCBObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
curdom <- curDomain;
mapM_x (threadSet (tcbDomain_update (\<lambda>_. curdom))) addrs;
return $ map capability.ThreadCap addrs
od | ArchTypes_H.apiobject_type.EndpointObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
return $ map (\<lambda>addr. capability.EndpointCap addr 0 True True True True) addrs
od | ArchTypes_H.apiobject_type.NotificationObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) 0;
return $ map (\<lambda>addr. capability.NotificationCap addr 0 True True) addrs
od | ArchTypes_H.apiobject_type.CapTableObject \<Rightarrow> do addrs <- createObjects ptr n (injectKOS makeObject) us;
modify (\<lambda>ks. ks\<lparr>gsCNodes := \<lambda>addr. if addr `~elem~` map fromPPtr addrs then Just us else gsCNodes ks addr\<rparr>);
return $ map (\<lambda>addr. capability.CNodeCap addr us 0 0) addrs
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 2. \<lbrakk>range_cover ptr sz (APIType_capBits SmallPageObject us) n \<and> 0 < n; ty = SmallPageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 0;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSmallPage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSmallPage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 3. \<lbrakk>range_cover ptr sz (APIType_capBits LargePageObject us) n \<and> 0 < n; ty = LargePageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 4;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMLargePage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMLargePage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 4. \<lbrakk>range_cover ptr sz (APIType_capBits SectionObject us) n \<and> 0 < n; ty = SectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 8;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 5. \<lbrakk>range_cover ptr sz (APIType_capBits SuperSectionObject us) n \<and> 0 < n; ty = SuperSectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 12;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSuperSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSuperSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 6. \<lbrakk>range_cover ptr sz (APIType_capBits PageTableObject us) n \<and> 0 < n; ty = PageTableObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOArch (KOPTE makeObject)) (ptBits - objBits makeObject);
return (map (capability.ArchObjectCap \<circ> (\<lambda>pt. arch_capability.PageTableCap pt None)) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 7. \<lbrakk>range_cover ptr sz (APIType_capBits PageDirectoryObject us) n \<and> 0 < n; ty = PageDirectoryObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (KOArch (KOPDE makeObject)) (pdBits - objBits makeObject);
y <- do y <- mapM_x copyGlobalMappings addrs;
doMachineOp (mapM_x (\<lambda>x. cleanCacheRange_PoU x (x + word_of_nat (shiftL (Suc 0) pdBits) - 1) (addrFromPPtr x)) addrs)
od;
return (map (\<lambda>pt. arch_capability.PageDirectoryCap pt None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace> proof (prove)
goal (11 subgoals):
 1. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.Untyped) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.Untyped; apiobject_type = ArchTypes_H.apiobject_type.Untyped\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> return (map (\<lambda>n. capability.UntypedCap dev (ptr + n * 2 ^ us) us 0) [0 .e. word_of_nat n - 1]) \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 2. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.TCBObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.TCBObject; apiobject_type = ArchTypes_H.apiobject_type.TCBObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOTCB makeObject) 0;
curdom <- curDomain;
y <- mapM_x (threadSet (tcbDomain_update (\<lambda>_. curdom))) addrs;
return (map capability.ThreadCap addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 3. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.EndpointObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.EndpointObject; apiobject_type = ArchTypes_H.apiobject_type.EndpointObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOEndpoint makeObject) 0;
return (map (\<lambda>addr. capability.EndpointCap addr 0 True True True True) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 4. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.NotificationObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.NotificationObject; apiobject_type = ArchTypes_H.apiobject_type.NotificationObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KONotification makeObject) 0;
return (map (\<lambda>addr. capability.NotificationCap addr 0 True True) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 5. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.CapTableObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.CapTableObject; apiobject_type = ArchTypes_H.apiobject_type.CapTableObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOCTE makeObject) us;
y <- modify (\<lambda>ks. ks\<lparr>gsCNodes := \<lambda>addr. if addr \<in> set addrs then Just us else gsCNodes ks addr\<rparr>);
return (map (\<lambda>addr. capability.CNodeCap addr us 0 0) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 6. \<lbrakk>range_cover ptr sz (APIType_capBits SmallPageObject us) n \<and> 0 < n; ty = SmallPageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 0;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSmallPage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSmallPage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 7. \<lbrakk>range_cover ptr sz (APIType_capBits LargePageObject us) n \<and> 0 < n; ty = LargePageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 4;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMLargePage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMLargePage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 8. \<lbrakk>range_cover ptr sz (APIType_capBits SectionObject us) n \<and> 0 < n; ty = SectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 8;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 9. \<lbrakk>range_cover ptr sz (APIType_capBits SuperSectionObject us) n \<and> 0 < n; ty = SuperSectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 12;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSuperSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSuperSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 10. \<lbrakk>range_cover ptr sz (APIType_capBits PageTableObject us) n \<and> 0 < n; ty = PageTableObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOArch (KOPTE makeObject)) (ptBits - objBits makeObject);
return (map (capability.ArchObjectCap \<circ> (\<lambda>pt. arch_capability.PageTableCap pt None)) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
A total of 11 subgoals... proof (prove)
goal (10 subgoals):
 1. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.TCBObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.TCBObject; apiobject_type = ArchTypes_H.apiobject_type.TCBObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOTCB makeObject) 0;
curdom <- curDomain;
y <- mapM_x (threadSet (tcbDomain_update (\<lambda>_. curdom))) addrs;
return (map capability.ThreadCap addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 2. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.EndpointObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.EndpointObject; apiobject_type = ArchTypes_H.apiobject_type.EndpointObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOEndpoint makeObject) 0;
return (map (\<lambda>addr. capability.EndpointCap addr 0 True True True True) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 3. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.NotificationObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.NotificationObject; apiobject_type = ArchTypes_H.apiobject_type.NotificationObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KONotification makeObject) 0;
return (map (\<lambda>addr. capability.NotificationCap addr 0 True True) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 4. \<And>apiobject_type. \<lbrakk>range_cover ptr sz (APIType_capBits (APIObjectType ArchTypes_H.apiobject_type.CapTableObject) us) n \<and> 0 < n; ty = APIObjectType ArchTypes_H.apiobject_type.CapTableObject; apiobject_type = ArchTypes_H.apiobject_type.CapTableObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOCTE makeObject) us;
y <- modify (\<lambda>ks. ks\<lparr>gsCNodes := \<lambda>addr. if addr \<in> set addrs then Just us else gsCNodes ks addr\<rparr>);
return (map (\<lambda>addr. capability.CNodeCap addr us 0 0) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 5. \<lbrakk>range_cover ptr sz (APIType_capBits SmallPageObject us) n \<and> 0 < n; ty = SmallPageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 0;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSmallPage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSmallPage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 6. \<lbrakk>range_cover ptr sz (APIType_capBits LargePageObject us) n \<and> 0 < n; ty = LargePageObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 4;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMLargePage else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMLargePage None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 7. \<lbrakk>range_cover ptr sz (APIType_capBits SectionObject us) n \<and> 0 < n; ty = SectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 8;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 8. \<lbrakk>range_cover ptr sz (APIType_capBits SuperSectionObject us) n \<and> 0 < n; ty = SuperSectionObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (if dev then KOUserDataDevice else KOUserData) 12;
y <- modify (\<lambda>ks. ks\<lparr>gsUserPages := \<lambda>addr. if addr \<in> set addrs then Just ARMSuperSection else gsUserPages ks addr\<rparr>);
return (map (\<lambda>n. arch_capability.PageCap dev n VMReadWrite ARMSuperSection None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 9. \<lbrakk>range_cover ptr sz (APIType_capBits PageTableObject us) n \<and> 0 < n; ty = PageTableObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do addrs <- createObjects ptr n (KOArch (KOPTE makeObject)) (ptBits - objBits makeObject);
return (map (capability.ArchObjectCap \<circ> (\<lambda>pt. arch_capability.PageTableCap pt None)) addrs)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace>
 10. \<lbrakk>range_cover ptr sz (APIType_capBits PageDirectoryObject us) n \<and> 0 < n; ty = PageDirectoryObject\<rbrakk> \<Longrightarrow> \<lbrace>(\<lambda>s. P (null_filter' (ctes_of s))) and pspace_aligned' and pspace_distinct' and pspace_no_overlap' ptr sz\<rbrace> do archCaps <- do addrs <- createObjects ptr n (KOArch (KOPDE makeObject)) (pdBits - objBits makeObject);
y <- do y <- mapM_x copyGlobalMappings addrs;
doMachineOp (mapM_x (\<lambda>x. cleanCacheRange_PoU x (x + word_of_nat (shiftL (Suc 0) pdBits) - 1) (addrFromPPtr x)) addrs)
od;
return (map (\<lambda>pt. arch_capability.PageDirectoryCap pt None) addrs)
od;
return (map capability.ArchObjectCap archCaps)
od \<lbrace>\<lambda>_ s. P (null_filter' (ctes_of s))\<rbrace> proof (prove)
goal:
No subgoals!