Skip to content

arhangeldim/qemu_arm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
        

About

arm on arm qemu optimization

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
GPL-2.0
COPYING
LGPL-2.1
COPYING.LIB

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published