Giter Club home page Giter Club logo

qemu_arm's Introduction

Content

1. ARM assembly. Building binary

    1) For cross-compile use this toolchain https://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
    If there is an ARM board use default tools for compile (as, ld, etc...)
    
    2) There is a simple assembly module (add two numbers)
    simple.s
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@
                .text
        start:                       @ Label, not really required
                mov   r0, #5         @ Load register r0 with the value 5
                mov   r1, #4         @ Load register r1 with the value 4
                add   r2, r1, r0     @ Add r0 and r1 and store in r2

        stop:   b stop               @ INfinity loop. Or use bx lr    
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@
    
    3) Script for compile (on ARM)
        #!/bin/bash
        as -o out.o "$1"
        ld -Ttext=0x0 -o out.elf out.o
        objcopy -O binary out.elf out.bin

    
2. QEMU running
    #!/bin/bash
    dd if=/dev/zero of=flash.bin bs=4096 count 4096
    dd if=out.bin of=flash.bin bs=4096 conv=notrunc
    qemu-system-arm -M connex -pflash flash.bin -nographic -serial /dev/null -D ~/qemu.log -d in_asm,out_asm,op
    
    QEMU options
        -M model
        -pflash flash memory
        -serial i/o device
        -D path to log file
        -d log option
        -s wait for gdb connection
        -S set breakpoint before first code line
        
3. GDB
    if qemu is ran with -s option we can connect with gdb for remote debugging (default port 1234). 
    (gdb) target remote localhost:1234
    
    
4. PROCESS
    
    generation of intermediate code.
    
    cpu-exec.c: int cpu_exec(CPUState *env)
                static void cpu_exec_nocache(CPUState *env, int max_cycles,
                             TranslationBlock *orig_tb)

        exec.c: TranslationBlock *tb_gen_code(CPUState *env,
                                  target_ulong pc, target_ulong cs_base,
                                  int flags, int cflags)    
                                  
          translate-all.c: int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)
                           //gen target mashine code
                           cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)
            
            target-arm/translate.c: static inline void gen_intermediate_code_internal(CPUState *env,
                                                      TranslationBlock *tb,
                                                      int search_pc)
                                                      
                                    static void disas_arm_insn(CPUState * env, DisasContext *s)
                                    
                                    
5. ADDITION
    Translation stops when a conditional branch is encountered. Otherwise the subsequent code could get translated several times.
    Also stop translation when a page boundary is reached.  This ensures prefetch aborts occur at the right place.
        

qemu_arm's People

Contributors

arhangeldim avatar

Stargazers

Evgeny Gavrin avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.