Library mcertikos.devdrivers.DHandlerSw
This file defines the abstract data and the primitives for the
ConsoleBufOp layer, which will introduce the primtives of console buffer
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 XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import INVLemmaDriver.
Require Import INVLemmaInterrupt.
Require Import AbstractDataType.
Require Import FutureTactic.
Require Export DHandlerIntro.
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 XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import INVLemmaDriver.
Require Import INVLemmaInterrupt.
Require Import AbstractDataType.
Require Import FutureTactic.
Require Export DHandlerIntro.
Section WITHMEM.
Local Open Scope Z_scope.
Context `{real_params: RealParams}.
Context `{oracle_prop: MultiOracleProp}.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Local Open Scope Z_scope.
Context `{real_params: RealParams}.
Context `{oracle_prop: MultiOracleProp}.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Section INV.
Global Instance serial_intr_handler_sw_inv: PreservesInvariants serial_intr_handler_sw_spec.
Proof.
constructor; simpl; intros; inv_generic_sem H.
- inversion H0. repeat (iinv d); simpl in *; substx; functional inversion H7;
simpl in *; substx; try assumption; constructor; simpl; trivial.
- inversion H0; repeat (iinv d); simpl in *; substx; functional inversion H7;
simpl in *; substx; try assumption; constructor; simpl; intros; try congruence; eauto.
+ rewrite replace_replace. rewrite replace_preserves_Zlength; assumption.
+ assert (Hcase: n = 4%nat ∨ n ≠ 4%nat) by omega. destruct Hcase.
{
rewrite H20. change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gss.
{
split.
× rewrite H20 in Hv. assumption.
× ∃ true. reflexivity.
}
destruct Hb as [b Hb].
eapply nth_error_valid_length. rewrite H20 in Hb.
rewrite nth_error_replace_gss. reflexivity. repeat toZ. omega.
}
{
change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gso.
{
split.
× assumption.
× rewrite nth_error_replace_gso. assumption. omega.
}
apply not_eq_sym. assumption.
}
+ rewrite replace_replace. rewrite replace_preserves_Zlength; assumption.
+ assert (Hcase: n = 4%nat ∨ n ≠ 4%nat) by omega. destruct Hcase.
{
rewrite H20. change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gss.
{
split.
× rewrite H20 in Hv. assumption.
× ∃ true. reflexivity.
}
destruct Hb as [b Hb].
eapply nth_error_valid_length. rewrite H20 in Hb.
rewrite nth_error_replace_gss. reflexivity. repeat toZ. omega.
}
{
change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gso.
{
split.
× assumption.
× rewrite nth_error_replace_gso. assumption. omega.
}
apply not_eq_sym. assumption.
}
- repeat (iinv d); simpl in *; substx; simpl;
functional inversion H7; simpl in *; substx; simpl; try assumption.
Qed.
End INV.
Global Instance serial_intr_handler_sw_inv: PreservesInvariants serial_intr_handler_sw_spec.
Proof.
constructor; simpl; intros; inv_generic_sem H.
- inversion H0. repeat (iinv d); simpl in *; substx; functional inversion H7;
simpl in *; substx; try assumption; constructor; simpl; trivial.
- inversion H0; repeat (iinv d); simpl in *; substx; functional inversion H7;
simpl in *; substx; try assumption; constructor; simpl; intros; try congruence; eauto.
+ rewrite replace_replace. rewrite replace_preserves_Zlength; assumption.
+ assert (Hcase: n = 4%nat ∨ n ≠ 4%nat) by omega. destruct Hcase.
{
rewrite H20. change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gss.
{
split.
× rewrite H20 in Hv. assumption.
× ∃ true. reflexivity.
}
destruct Hb as [b Hb].
eapply nth_error_valid_length. rewrite H20 in Hb.
rewrite nth_error_replace_gss. reflexivity. repeat toZ. omega.
}
{
change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gso.
{
split.
× assumption.
× rewrite nth_error_replace_gso. assumption. omega.
}
apply not_eq_sym. assumption.
}
+ rewrite replace_replace. rewrite replace_preserves_Zlength; assumption.
+ assert (Hcase: n = 4%nat ∨ n ≠ 4%nat) by omega. destruct Hcase.
{
rewrite H20. change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gss.
{
split.
× rewrite H20 in Hv. assumption.
× ∃ true. reflexivity.
}
destruct Hb as [b Hb].
eapply nth_error_valid_length. rewrite H20 in Hb.
rewrite nth_error_replace_gss. reflexivity. repeat toZ. omega.
}
{
change (Pos.to_nat 4) with 4%nat.
generalize (valid_ioapic_state H n v H19). intros [Hv Hb].
rewrite nth_error_replace_gso.
{
split.
× assumption.
× rewrite nth_error_replace_gso. assumption. omega.
}
apply not_eq_sym. assumption.
}
- repeat (iinv d); simpl in *; substx; simpl;
functional inversion H7; simpl in *; substx; simpl; try assumption.
Qed.
End INV.
Definition dhandlersw_fresh : compatlayer (cdata RData) :=
serial_intr_handler_sw ↦ gensem serial_intr_handler_sw_spec.
Definition dhandlersw_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
⊕ set_pg ↦ gensem setPG_spec
⊕ set_cr3 ↦ setCR3_compatsem setCR3_spec
⊕ get_size ↦ gensem MMSize
⊕ is_usable ↦ gensem is_mm_usable_spec
⊕ get_mms ↦ gensem get_mm_s_spec
⊕ get_mml ↦ gensem get_mm_l_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
⊕ release_lock ↦ primcall_release_lock_compatsem release_lock release_lock_spec0
⊕ acquire_lock ↦ primcall_acquire_lock_compatsem acquire_lock_spec0
⊕ ticket_lock_init ↦ gensem ticket_lock_init0_spec
⊕ serial_irq_check ↦ gensem serial_irq_check_spec
⊕ iret ↦ gensem iret_spec
⊕ cli ↦ gensem cli_spec
⊕ sti ↦ gensem sti_spec
⊕ serial_irq_current ↦ gensem serial_irq_current_spec
⊕ ic_intr ↦ gensem ic_intr_spec
⊕ save_context ↦ primcall_save_context_compatsem save_context_spec
⊕ restore_context ↦ primcall_restore_context_compatsem restore_context_spec
⊕ ioapic_mask ↦ gensem ioapic_mask_spec
⊕ ioapic_unmask ↦ gensem ioapic_unmask_spec
⊕ serial_putc ↦ gensem serial_putc_spec
⊕ serial_hw_intr ↦ gensem serial_hw_intr_spec
serial_intr_handler_sw ↦ gensem serial_intr_handler_sw_spec.
Definition dhandlersw_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
⊕ set_pg ↦ gensem setPG_spec
⊕ set_cr3 ↦ setCR3_compatsem setCR3_spec
⊕ get_size ↦ gensem MMSize
⊕ is_usable ↦ gensem is_mm_usable_spec
⊕ get_mms ↦ gensem get_mm_s_spec
⊕ get_mml ↦ gensem get_mm_l_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
⊕ release_lock ↦ primcall_release_lock_compatsem release_lock release_lock_spec0
⊕ acquire_lock ↦ primcall_acquire_lock_compatsem acquire_lock_spec0
⊕ ticket_lock_init ↦ gensem ticket_lock_init0_spec
⊕ serial_irq_check ↦ gensem serial_irq_check_spec
⊕ iret ↦ gensem iret_spec
⊕ cli ↦ gensem cli_spec
⊕ sti ↦ gensem sti_spec
⊕ serial_irq_current ↦ gensem serial_irq_current_spec
⊕ ic_intr ↦ gensem ic_intr_spec
⊕ save_context ↦ primcall_save_context_compatsem save_context_spec
⊕ restore_context ↦ primcall_restore_context_compatsem restore_context_spec
⊕ ioapic_mask ↦ gensem ioapic_mask_spec
⊕ ioapic_unmask ↦ gensem ioapic_unmask_spec
⊕ serial_putc ↦ gensem serial_putc_spec
⊕ serial_hw_intr ↦ gensem serial_hw_intr_spec
serial device
⊕ 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
⊕ accessors ↦ {| exec_load := (@exec_loadex _ _ _ _ _ Hmwd);
exec_store := (@exec_storeex _ _ _ _ _ Hmwd) |}.
Definition dhandlersw : compatlayer (cdata RData) :=
dhandlersw_fresh ⊕ dhandlersw_passthrough.
End WITHMEM.
⊕ 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
⊕ accessors ↦ {| exec_load := (@exec_loadex _ _ _ _ _ Hmwd);
exec_store := (@exec_storeex _ _ _ _ _ Hmwd) |}.
Definition dhandlersw : compatlayer (cdata RData) :=
dhandlersw_fresh ⊕ dhandlersw_passthrough.
End WITHMEM.