Library mcertikos.trap.TrapArgGenSpec

Require Import Coqlib.
Require Import Errors.
Require Import AST.
Require Import Integers.
Require Import Floats.
Require Import Op.
Require Import Asm.
Require Import Events.
Require Import Globalenvs.
Require Import Smallstep.
Require Import Values.
Require Import Memory.
Require Import Maps.
Require Import AuxLemma.
Require Import FlatMemory.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import RealParams.
Require Import AsmImplLemma.
Require Import GenSem.
Require Import PrimSemantics.

Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.compcertx.Stencil.
Require Import liblayers.compcertx.MakeProgram.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import compcert.cfrontend.Ctypes.
Require Import Conventions.
Require Import PIPC.
Require Import ObjArg.
Require Import AbstractDataType.

Require Import GlobalOracleProp.
Require Import SingleOracle.

Local Open Scope string_scope.
Local Open Scope error_monad_scope.
Local Open Scope Z_scope.

Definition of the low level specification

Section SPECIFICATION.

  Context `{single_oracle_prop: SingleOracleProp}.
  Context `{real_params : RealParams}.
  Context `{multi_oracle_prop: MultiOracleProp}.

  Notation LDATAOps := (cdata (cdata_ops := pipcintro_data_ops) RData).

  Inductive uctx_arg1_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_arg1_spec_low_intro s (WB: _Prop) m´0 labd arg:
      uctx_arg1_spec labd = Some (Int.unsigned arg) →
      kernel_mode labd
      high_level_invariant labd
      uctx_arg1_spec_low_step s WB nil (m´0, labd) (Vint arg) (m´0, labd).

  Inductive uctx_arg2_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_arg2_spec_low_intro s (WB: _Prop) m´0 labd arg:
      uctx_arg2_spec labd = Some (Int.unsigned arg) →
      kernel_mode labd
      high_level_invariant labd
      uctx_arg2_spec_low_step s WB nil (m´0, labd) (Vint arg) (m´0, labd).

  Inductive uctx_arg3_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_arg3_spec_low_intro s (WB: _Prop) m´0 labd arg:
      uctx_arg3_spec labd = Some (Int.unsigned arg) →
      kernel_mode labd
      high_level_invariant labd
      uctx_arg3_spec_low_step s WB nil (m´0, labd) (Vint arg) (m´0, labd).

  Inductive uctx_arg4_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_arg4_spec_low_intro s (WB: _Prop) m´0 labd arg:
      uctx_arg4_spec labd = Some (Int.unsigned arg) →
      kernel_mode labd
      high_level_invariant labd
      uctx_arg4_spec_low_step s WB nil (m´0, labd) (Vint arg) (m´0, labd).

  Inductive uctx_set_errno_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_set_errno_spec_low_intro s (WB: _Prop) m´0 labd labd´ arg:
      uctx_set_errno_spec (Int.unsigned arg) labd = Some labd´
      kernel_mode labd
      high_level_invariant labd
      uctx_set_errno_spec_low_step s WB (Vint arg :: nil) (m´0, labd) Vundef (m´0, labd´).

  Inductive uctx_set_retval1_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_set_retval1_spec_low_intro s (WB: _Prop) m´0 labd labd´ arg:
      uctx_set_retval1_spec (Int.unsigned arg) labd = Some labd´
      kernel_mode labd
      high_level_invariant labd
      uctx_set_retval1_spec_low_step s WB (Vint arg :: nil) (m´0, labd) Vundef (m´0, labd´).

  Inductive uctx_set_retval2_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_set_retval2_spec_low_intro s (WB: _Prop) m´0 labd labd´ arg:
      uctx_set_retval2_spec (Int.unsigned arg) labd = Some labd´
      kernel_mode labd
      high_level_invariant labd
      uctx_set_retval2_spec_low_step s WB (Vint arg :: nil) (m´0, labd) Vundef (m´0, labd´).

  Inductive uctx_set_retval3_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | uctx_set_retval3_spec_low_intro s (WB: _Prop) m´0 labd labd´ arg:
      uctx_set_retval3_spec (Int.unsigned arg) labd = Some labd´
      kernel_mode labd
      high_level_invariant labd
      uctx_set_retval3_spec_low_step s WB (Vint arg :: nil) (m´0, labd) Vundef (m´0, labd´).


  Section WITHMEM.

    Context `{Hstencil: Stencil}.
    Context `{Hmem: Mem.MemoryModel}.
    Context `{Hmwd: UseMemWithData mem}.

    Definition uctx_arg1_spec_low: compatsem LDATAOps :=
      csem uctx_arg1_spec_low_step Tnil Tint32.

    Definition uctx_arg2_spec_low: compatsem LDATAOps :=
      csem uctx_arg2_spec_low_step Tnil Tint32.

    Definition uctx_arg3_spec_low: compatsem LDATAOps :=
      csem uctx_arg3_spec_low_step Tnil Tint32.

    Definition uctx_arg4_spec_low: compatsem LDATAOps :=
      csem uctx_arg4_spec_low_step Tnil Tint32.

    Definition uctx_set_errno_spec_low: compatsem LDATAOps :=
      csem uctx_set_errno_spec_low_step (type_of_list_type (Tint32::nil)) Tvoid.

    Definition uctx_set_retval1_spec_low: compatsem LDATAOps :=
      csem uctx_set_retval1_spec_low_step (type_of_list_type (Tint32::nil)) Tvoid.

    Definition uctx_set_retval2_spec_low: compatsem LDATAOps :=
      csem uctx_set_retval2_spec_low_step (type_of_list_type (Tint32::nil)) Tvoid.

    Definition uctx_set_retval3_spec_low: compatsem LDATAOps :=
      csem uctx_set_retval3_spec_low_step (type_of_list_type (Tint32::nil)) Tvoid.


  End WITHMEM.

End SPECIFICATION.