• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
          • Dynamic-instrumentation
          • Initialize-x86-state
          • Binary-file-load-fn
          • Read-channel-into-memory
          • Setting-up-page-tables
          • Read-channel-into-byte-list
          • Init-zero-page
          • Linux-load
          • Read-file-into-memory
            • Read-file-into-byte-list
            • Init-sys-view
            • Load-elf-sections
            • Chars-to-c-str
            • String-to-c-str
            • Pack-u64
            • Pack-u32
            • Concrete-simulation-examples
            • Gdt-entry
          • Sdm-instruction-set-summary
          • Tlb
          • Running-linux
          • Introduction
          • Asmtest
          • X86isa-build-instructions
          • Publications
          • Contributors
          • Machine
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Program-execution

    Read-file-into-memory

    Signature
    (read-file-into-memory filename ptr x86 state) 
      → 
    (mv bytes-read x86 state)
    Arguments
    filename — Guard (stringp filename).
    ptr — Guard (canonical-address-p ptr).
    Returns
    bytes-read — Type (natp bytes-read), given (and (stringp filename) (canonical-address-p ptr) (state-p1 state)).
    x86 — Type (x86p x86), given (x86p x86).
    state — Type (state-p1 state), given (and (stringp filename) (state-p1 state)).

    Definitions and Theorems

    Function: read-file-into-memory

    (defun read-file-into-memory (filename ptr x86 state)
      (declare (xargs :stobjs (x86 state)))
      (declare (xargs :guard (and (stringp filename)
                                  (canonical-address-p ptr))))
      (let ((__function__ 'read-file-into-memory))
        (declare (ignorable __function__))
        (b* (((mv channel state)
              (open-input-channel filename
                                  :byte state))
             ((when (not channel)) (mv 0 x86 state))
             ((mv bytes-read x86 state)
              (read-channel-into-memory channel ptr 0 x86 state))
             (state (close-input-channel channel state)))
          (mv bytes-read x86 state))))

    Theorem: natp-of-read-file-into-memory.bytes-read

    (defthm natp-of-read-file-into-memory.bytes-read
      (implies (and (stringp filename)
                    (canonical-address-p ptr)
                    (state-p1 state))
               (b* (((mv ?bytes-read ?x86 acl2::?state)
                     (read-file-into-memory filename ptr x86 state)))
                 (natp bytes-read)))
      :rule-classes :rewrite)

    Theorem: x86p-of-read-file-into-memory.x86

    (defthm x86p-of-read-file-into-memory.x86
      (implies (x86p x86)
               (b* (((mv ?bytes-read ?x86 acl2::?state)
                     (read-file-into-memory filename ptr x86 state)))
                 (x86p x86)))
      :rule-classes :rewrite)

    Theorem: state-p1-of-read-file-into-memory.state

    (defthm state-p1-of-read-file-into-memory.state
      (implies (and (stringp filename)
                    (state-p1 state))
               (b* (((mv ?bytes-read ?x86 acl2::?state)
                     (read-file-into-memory filename ptr x86 state)))
                 (state-p1 state)))
      :rule-classes :rewrite)