Library mcertikos.proc.PAbQueueAtomic
This file defines the abstract data and the primitives for the PAbQueue layer,
which will introduce abstraction of kernel context
Require Import Coqlib.
Require Import Maps.
Require Import ASTExtra.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Memory.
Require Import Events.
Require Import Stacklayout.
Require Import Globalenvs.
Require Import AsmX.
Require Import Smallstep.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import FlatMemory.
Require Import CommonTactic.
Require Import AuxLemma.
Require Import RealParams.
Require Import PrimSemantics.
Require Import LAsm.
Require Import LoadStoreSem2.
Require Import XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import CalRealPTPool.
Require Import CalRealPT.
Require Import CalRealIDPDE.
Require Import CalRealInitPTE.
Require Import CalRealSMSPool.
Require Import CalRealProcModule.
Require Import INVLemmaContainer.
Require Import INVLemmaMemory.
Require Import INVLemmaThread.
Require Import AbstractDataType.
Require Import CalTicketLock.
Require Import INVLemmaQLock.
Require Import INVLemmaInterrupt.
Require Import INVLemmaDriver.
Require Import DeviceStateDataType.
Require Import FutureTactic.
Require Export PAbQueue.
Require Import Maps.
Require Import ASTExtra.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Memory.
Require Import Events.
Require Import Stacklayout.
Require Import Globalenvs.
Require Import AsmX.
Require Import Smallstep.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import FlatMemory.
Require Import CommonTactic.
Require Import AuxLemma.
Require Import RealParams.
Require Import PrimSemantics.
Require Import LAsm.
Require Import LoadStoreSem2.
Require Import XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import CalRealPTPool.
Require Import CalRealPT.
Require Import CalRealIDPDE.
Require Import CalRealInitPTE.
Require Import CalRealSMSPool.
Require Import CalRealProcModule.
Require Import INVLemmaContainer.
Require Import INVLemmaMemory.
Require Import INVLemmaThread.
Require Import AbstractDataType.
Require Import CalTicketLock.
Require Import INVLemmaQLock.
Require Import INVLemmaInterrupt.
Require Import INVLemmaDriver.
Require Import DeviceStateDataType.
Require Import FutureTactic.
Require Export PAbQueue.
Section WITHMEM.
Local Open Scope Z_scope.
Context `{oracle_prop: MultiOracleProp}.
Context `{real_params: RealParams}.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Local Open Scope Z_scope.
Context `{oracle_prop: MultiOracleProp}.
Context `{real_params: RealParams}.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Section INV.
Section QUEUE_ATOMIC.
Lemma enqueue_atomic_high_level_inv:
∀ d d´ i n,
enqueue_atomic_spec n i d = Some d´ →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_high_level_inv; eauto.
eapply enqueue_high_level_inv; eauto.
eapply acquire_lock_ABTCB_high_level_inv; eauto.
Qed.
Lemma enqueue_atomic_low_level_inv:
∀ d d´ i n n´,
enqueue_atomic_spec n i d = Some d´ →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_low_level_inv; eauto.
eapply enqueue_low_level_inv; eauto.
eapply acquire_lock_ABTCB_low_level_inv; eauto.
Qed.
Lemma enqueue_atomic_kernel_mode:
∀ d d´ n i,
enqueue_atomic_spec n i d = Some d´ →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
unfold release_lock_ABTCB_spec in ×.
subdestruct; inv H1; simpl; eauto.
Qed.
Global Instance enqueue_atomic_inv: PreservesInvariants enqueue_atomic_spec.
Proof.
preserves_invariants_simpl´.
- eapply enqueue_atomic_low_level_inv; eassumption.
- eapply enqueue_atomic_high_level_inv; eassumption.
- eapply enqueue_atomic_kernel_mode; eassumption.
Qed.
Lemma dequeue_atomic_high_level_inv:
∀ d d´ i n,
dequeue_atomic_spec n d = Some (d´, i) →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_high_level_inv; eauto.
eapply dequeue_high_level_inv; eauto.
eapply acquire_lock_ABTCB_high_level_inv; eauto.
Qed.
Lemma dequeue_atomic_low_level_inv:
∀ d d´ i n n´,
dequeue_atomic_spec n d = Some (d´, i) →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_low_level_inv; eauto.
eapply dequeue_low_level_inv; eauto.
eapply acquire_lock_ABTCB_low_level_inv; eauto.
Qed.
Lemma dequeue_atomic_kernel_mode:
∀ d d´ n i,
dequeue_atomic_spec n d = Some (d´, i) →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
unfold release_lock_ABTCB_spec in ×.
subdestruct; inv H5; simpl; eauto.
Qed.
Global Instance dequeue_atomic_inv: PreservesInvariants dequeue_atomic_spec.
Proof.
preserves_invariants_simpl´.
- eapply dequeue_atomic_low_level_inv; eassumption.
- eapply dequeue_atomic_high_level_inv; eassumption.
- eapply dequeue_atomic_kernel_mode; eassumption.
Qed.
End QUEUE_ATOMIC.
End INV.
Definition pabqueue_atomic_fresh : compatlayer (cdata RData) :=
enqueue_atomic ↦ gensem enqueue_atomic_spec
⊕ dequeue_atomic ↦ gensem dequeue_atomic_spec
.
Section QUEUE_ATOMIC.
Lemma enqueue_atomic_high_level_inv:
∀ d d´ i n,
enqueue_atomic_spec n i d = Some d´ →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_high_level_inv; eauto.
eapply enqueue_high_level_inv; eauto.
eapply acquire_lock_ABTCB_high_level_inv; eauto.
Qed.
Lemma enqueue_atomic_low_level_inv:
∀ d d´ i n n´,
enqueue_atomic_spec n i d = Some d´ →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_low_level_inv; eauto.
eapply enqueue_low_level_inv; eauto.
eapply acquire_lock_ABTCB_low_level_inv; eauto.
Qed.
Lemma enqueue_atomic_kernel_mode:
∀ d d´ n i,
enqueue_atomic_spec n i d = Some d´ →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
unfold release_lock_ABTCB_spec in ×.
subdestruct; inv H1; simpl; eauto.
Qed.
Global Instance enqueue_atomic_inv: PreservesInvariants enqueue_atomic_spec.
Proof.
preserves_invariants_simpl´.
- eapply enqueue_atomic_low_level_inv; eassumption.
- eapply enqueue_atomic_high_level_inv; eassumption.
- eapply enqueue_atomic_kernel_mode; eassumption.
Qed.
Lemma dequeue_atomic_high_level_inv:
∀ d d´ i n,
dequeue_atomic_spec n d = Some (d´, i) →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_high_level_inv; eauto.
eapply dequeue_high_level_inv; eauto.
eapply acquire_lock_ABTCB_high_level_inv; eauto.
Qed.
Lemma dequeue_atomic_low_level_inv:
∀ d d´ i n n´,
dequeue_atomic_spec n d = Some (d´, i) →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
eapply release_lock_ABTCB_low_level_inv; eauto.
eapply dequeue_low_level_inv; eauto.
eapply acquire_lock_ABTCB_low_level_inv; eauto.
Qed.
Lemma dequeue_atomic_kernel_mode:
∀ d d´ n i,
dequeue_atomic_spec n d = Some (d´, i) →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
unfold release_lock_ABTCB_spec in ×.
subdestruct; inv H5; simpl; eauto.
Qed.
Global Instance dequeue_atomic_inv: PreservesInvariants dequeue_atomic_spec.
Proof.
preserves_invariants_simpl´.
- eapply dequeue_atomic_low_level_inv; eassumption.
- eapply dequeue_atomic_high_level_inv; eassumption.
- eapply dequeue_atomic_kernel_mode; eassumption.
Qed.
End QUEUE_ATOMIC.
End INV.
Definition pabqueue_atomic_fresh : compatlayer (cdata RData) :=
enqueue_atomic ↦ gensem enqueue_atomic_spec
⊕ dequeue_atomic ↦ gensem dequeue_atomic_spec
.
Definition pabqueue_atomic_passthrough : compatlayer (cdata RData) :=
fload ↦ gensem fload_spec
⊕ fstore ↦ gensem fstore_spec
⊕ page_copy ↦ gensem page_copy_spec
⊕ page_copy_back ↦ gensem page_copy_back_spec
⊕ vmxinfo_get ↦ gensem vmxinfo_get_spec
⊕ palloc ↦ gensem palloc_spec
⊕ set_pt ↦ gensem setPT_spec
⊕ pt_read ↦ gensem ptRead_spec
⊕ pt_resv ↦ gensem ptResv_spec
⊕ kctxt_new ↦ dnew_compatsem ObjThread.kctxt_new_spec
⊕ shared_mem_status ↦ gensem shared_mem_status_spec
⊕ offer_shared_mem ↦ gensem offer_shared_mem_spec
⊕ get_state ↦ gensem get_state0_spec
⊕ set_state ↦ gensem set_state0_spec
⊕ tcb_get_CPU_ID ↦ gensem get_abtcb_CPU_ID_spec
⊕ tcb_set_CPU_ID ↦ gensem set_abtcb_CPU_ID_spec
⊕ acquire_lock_TCB ↦ gensem acquire_lock_ABTCB_spec
⊕ release_lock_TCB ↦ gensem release_lock_ABTCB_spec
⊕ tdqueue_init ↦ gensem tdqueue_init0_spec
⊕ enqueue ↦ gensem enqueue0_spec
⊕ dequeue ↦ gensem dequeue0_spec
⊕ pt_in ↦ primcall_general_compatsem´ ptin_spec (prim_ident:= pt_in)
⊕ pt_out ↦ primcall_general_compatsem´ ptout_spec (prim_ident:= pt_out)
⊕ container_get_nchildren ↦ gensem container_get_nchildren_spec
⊕ container_get_quota ↦ gensem container_get_quota_spec
⊕ container_get_usage ↦ gensem container_get_usage_spec
⊕ container_can_consume ↦ gensem container_can_consume_spec
⊕ get_CPU_ID ↦ gensem get_CPU_ID_spec
⊕ get_curid ↦ gensem get_curid_spec
⊕ set_curid ↦ gensem set_curid_spec
⊕ set_curid_init ↦ gensem set_curid_init_spec
⊕ sleeper_inc ↦ gensem sleeper_inc_spec
⊕ sleeper_dec ↦ gensem sleeper_dec_spec
⊕ sleeper_zzz ↦ gensem sleeper_zzz_spec
⊕ release_lock ↦ primcall_release_lock_compatsem release_lock release_lock_spec2
⊕ acquire_lock ↦ primcall_acquire_lock_compatsem acquire_lock_spec2
⊕ cli ↦ gensem cli_spec
⊕ sti ↦ gensem sti_spec
⊕ serial_intr_disable ↦ gensem serial_intr_disable_spec
⊕ serial_intr_enable ↦ gensem serial_intr_enable_spec
⊕ serial_putc ↦ gensem serial_putc_spec
⊕ cons_buf_read ↦ gensem cons_buf_read_spec
⊕ trap_in ↦ primcall_general_compatsem trapin_spec
⊕ trap_out ↦ primcall_general_compatsem trapout_spec
⊕ host_in ↦ primcall_general_compatsem hostin_spec
⊕ host_out ↦ primcall_general_compatsem hostout_spec
⊕ proc_create_postinit ↦ gensem proc_create_postinit_spec
⊕ trap_get ↦ primcall_trap_info_get_compatsem trap_info_get_spec
⊕ trap_set ↦ primcall_trap_info_ret_compatsem trap_info_ret_spec
⊕ kctxt_switch ↦ primcall_kctxt_switch_compatsem kctxt_switch_spec
⊕ accessors ↦ {| exec_load := (@exec_loadex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd);
exec_store := (@exec_storeex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd) |}.
Definition pabqueue_atomic : compatlayer (cdata RData) := pabqueue_atomic_fresh ⊕ pabqueue_atomic_passthrough.
End WITHMEM.
fload ↦ gensem fload_spec
⊕ fstore ↦ gensem fstore_spec
⊕ page_copy ↦ gensem page_copy_spec
⊕ page_copy_back ↦ gensem page_copy_back_spec
⊕ vmxinfo_get ↦ gensem vmxinfo_get_spec
⊕ palloc ↦ gensem palloc_spec
⊕ set_pt ↦ gensem setPT_spec
⊕ pt_read ↦ gensem ptRead_spec
⊕ pt_resv ↦ gensem ptResv_spec
⊕ kctxt_new ↦ dnew_compatsem ObjThread.kctxt_new_spec
⊕ shared_mem_status ↦ gensem shared_mem_status_spec
⊕ offer_shared_mem ↦ gensem offer_shared_mem_spec
⊕ get_state ↦ gensem get_state0_spec
⊕ set_state ↦ gensem set_state0_spec
⊕ tcb_get_CPU_ID ↦ gensem get_abtcb_CPU_ID_spec
⊕ tcb_set_CPU_ID ↦ gensem set_abtcb_CPU_ID_spec
⊕ acquire_lock_TCB ↦ gensem acquire_lock_ABTCB_spec
⊕ release_lock_TCB ↦ gensem release_lock_ABTCB_spec
⊕ tdqueue_init ↦ gensem tdqueue_init0_spec
⊕ enqueue ↦ gensem enqueue0_spec
⊕ dequeue ↦ gensem dequeue0_spec
⊕ pt_in ↦ primcall_general_compatsem´ ptin_spec (prim_ident:= pt_in)
⊕ pt_out ↦ primcall_general_compatsem´ ptout_spec (prim_ident:= pt_out)
⊕ container_get_nchildren ↦ gensem container_get_nchildren_spec
⊕ container_get_quota ↦ gensem container_get_quota_spec
⊕ container_get_usage ↦ gensem container_get_usage_spec
⊕ container_can_consume ↦ gensem container_can_consume_spec
⊕ get_CPU_ID ↦ gensem get_CPU_ID_spec
⊕ get_curid ↦ gensem get_curid_spec
⊕ set_curid ↦ gensem set_curid_spec
⊕ set_curid_init ↦ gensem set_curid_init_spec
⊕ sleeper_inc ↦ gensem sleeper_inc_spec
⊕ sleeper_dec ↦ gensem sleeper_dec_spec
⊕ sleeper_zzz ↦ gensem sleeper_zzz_spec
⊕ release_lock ↦ primcall_release_lock_compatsem release_lock release_lock_spec2
⊕ acquire_lock ↦ primcall_acquire_lock_compatsem acquire_lock_spec2
⊕ cli ↦ gensem cli_spec
⊕ sti ↦ gensem sti_spec
⊕ serial_intr_disable ↦ gensem serial_intr_disable_spec
⊕ serial_intr_enable ↦ gensem serial_intr_enable_spec
⊕ serial_putc ↦ gensem serial_putc_spec
⊕ cons_buf_read ↦ gensem cons_buf_read_spec
⊕ trap_in ↦ primcall_general_compatsem trapin_spec
⊕ trap_out ↦ primcall_general_compatsem trapout_spec
⊕ host_in ↦ primcall_general_compatsem hostin_spec
⊕ host_out ↦ primcall_general_compatsem hostout_spec
⊕ proc_create_postinit ↦ gensem proc_create_postinit_spec
⊕ trap_get ↦ primcall_trap_info_get_compatsem trap_info_get_spec
⊕ trap_set ↦ primcall_trap_info_ret_compatsem trap_info_ret_spec
⊕ kctxt_switch ↦ primcall_kctxt_switch_compatsem kctxt_switch_spec
⊕ accessors ↦ {| exec_load := (@exec_loadex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd);
exec_store := (@exec_storeex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd) |}.
Definition pabqueue_atomic : compatlayer (cdata RData) := pabqueue_atomic_fresh ⊕ pabqueue_atomic_passthrough.
End WITHMEM.