From 4ffa7852606ff38d1fe37f9910413ef004a67dc2 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sat, 13 Jan 2007 10:39:12 +0000 Subject: [PATCH] 1. last move is done arm to From folder 2. remove some include in CpuToIntel.c file they are not longer need it. svn path=/trunk/; revision=25436 --- rosapps/devutils/cputointel/CpuToIntel.c | 3 - rosapps/devutils/cputointel/From/ARM/ARM.h | 17 +++++ .../devutils/cputointel/From/ARM/ARMBrain.c | 72 +++++++++++++++++++ .../devutils/cputointel/From/ARM/ARMBrain.h | 12 ++++ .../devutils/cputointel/From/ARM/ARMopcode.c | 39 ++++++++++ rosapps/devutils/cputointel/ImageLoader.c | 2 +- rosapps/devutils/cputointel/cputointel.rbuild | 4 +- rosapps/devutils/cputointel/misc.c | 2 +- 8 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 rosapps/devutils/cputointel/From/ARM/ARM.h create mode 100644 rosapps/devutils/cputointel/From/ARM/ARMBrain.c create mode 100644 rosapps/devutils/cputointel/From/ARM/ARMBrain.h create mode 100644 rosapps/devutils/cputointel/From/ARM/ARMopcode.c diff --git a/rosapps/devutils/cputointel/CpuToIntel.c b/rosapps/devutils/cputointel/CpuToIntel.c index 196350f99f9..40dfd910533 100644 --- a/rosapps/devutils/cputointel/CpuToIntel.c +++ b/rosapps/devutils/cputointel/CpuToIntel.c @@ -3,9 +3,6 @@ #include #include #include -#include "ARM/ARM.h" -#include "From/m68k/m68k.h" -#include "From/PPC/PPC.h" #include "misc.h" int main(int argc, char * argv[]) diff --git a/rosapps/devutils/cputointel/From/ARM/ARM.h b/rosapps/devutils/cputointel/From/ARM/ARM.h new file mode 100644 index 00000000000..9ed48f207ac --- /dev/null +++ b/rosapps/devutils/cputointel/From/ARM/ARM.h @@ -0,0 +1,17 @@ + +#include "../../misc.h" + +CPU_INT ARMBrain( CPU_BYTE *cpu_buffer, + CPU_UNINT cpu_pos, + CPU_UNINT cpu_size, + CPU_UNINT BaseAddress, + CPU_UNINT cpuarch, + FILE *outfp); + +/* here we put the prototype for the opcode api that brain need we show a example for it */ +CPU_INT ARM_(FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch); + + +/* Export comment thing see m68k for example + * in dummy we do not show it, for it is diffent for each cpu + */ diff --git a/rosapps/devutils/cputointel/From/ARM/ARMBrain.c b/rosapps/devutils/cputointel/From/ARM/ARMBrain.c new file mode 100644 index 00000000000..1a570eaeb79 --- /dev/null +++ b/rosapps/devutils/cputointel/From/ARM/ARMBrain.c @@ -0,0 +1,72 @@ + +#include +#include +#include "ARMBrain.h" +#include "ARM.h" +#include "../../misc.h" + +/* retun + * 0 : Ok + * 1 : unimplemt + * 2 : Unkonwn Opcode + * 3 : unimplement cpu + * 4 : unknown machine + */ + +CPU_INT ARMBrain( CPU_BYTE *cpu_buffer, + CPU_UNINT cpu_pos, + CPU_UNINT cpu_size, + CPU_UNINT BaseAddress, + CPU_UNINT cpuarch, + FILE *outfp) +{ + CPU_UNINT cpu_oldpos; + CPU_INT cpuint; + CPU_INT retcode = 0; + CPU_INT retsize; + + + /* now we start the process */ + while (cpu_pos=cpu_size) + { + break; + } + + /* Check if we have found a cpu opcode */ + if (cpu_oldpos == cpu_pos) + { + if (retcode == 0) + { + /* no unimplement error where found so we return a msg for unknown opcode */ + printf("Unkonwn Opcode found at 0x%8x opcode 0x%2x\n",cpu_oldpos+BaseAddress,(unsigned int)cpu_buffer[cpu_oldpos]); + retcode = 2; + } + } + + /* Erorro Found ? */ + if (retcode!=0) + { + /* Erorro Found break and return the error code */ + break; + } + } + return retcode; +} diff --git a/rosapps/devutils/cputointel/From/ARM/ARMBrain.h b/rosapps/devutils/cputointel/From/ARM/ARMBrain.h new file mode 100644 index 00000000000..93ef2b8ae32 --- /dev/null +++ b/rosapps/devutils/cputointel/From/ARM/ARMBrain.h @@ -0,0 +1,12 @@ + +#include "../../misc.h" + + +/* example how setup a opcode, this opcode is 16bit long (taken from M68K) + * 0 and 1 mean normal bit, 2 mean mask bit the bit that are determent diffent + * thing in the opcode, example which reg so on, it can be etither 0 or 1 in + * the opcode. but a opcode have also normal bit that is always been set to + * same. thuse bit are always 0 or 1 + */ +CPU_BYTE cpuARMInit_[32] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}; + diff --git a/rosapps/devutils/cputointel/From/ARM/ARMopcode.c b/rosapps/devutils/cputointel/From/ARM/ARMopcode.c new file mode 100644 index 00000000000..eb6cd6bb339 --- /dev/null +++ b/rosapps/devutils/cputointel/From/ARM/ARMopcode.c @@ -0,0 +1,39 @@ + +#include +#include +#include "../../misc.h" + + +/* cpuDummyInit_Add + * Input param : + * out : The file pointer that we write to (the output file to intel asm) + * cpu_buffer : The memory buffer we have our binary code that we whant convert + * cpu_pos : Current positions in the cpu_buffer + * cpu_size : The memory size of the cpu_buffer + * BaseAddress : The base address you whant the binay file should run from + * cpuarch : if it exists diffent cpu from a manufactor like pentium, + * pentinum-mmx so on, use this flag to specify which type + * of cpu you whant or do not use it if it does not exists + * other or any sub model. + * + * Return value : + * value -1 : unimplement + * value 0 : wrong opcode or not vaild opcode + * value +1 and higher : who many byte we should add to cpu_pos + */ + +CPU_INT ARM_( FILE *out, CPU_BYTE * cpu_buffer, CPU_UNINT cpu_pos, + CPU_UNINT cpu_size, CPU_UNINT BaseAddress, CPU_UNINT cpuarch) + +{ + /* + * ConvertBitToByte() is perfect to use to get the bit being in use from a bit array + * GetMaskByte() is perfect if u whant known which bit have been mask out + * see M68kopcode.c and how it use the ConvertBitToByte() + */ + + fprintf(out,"Line_0x%8x :\n",BaseAddress + cpu_pos); + + printf(";Add unimplement\n"); + return -1; +} diff --git a/rosapps/devutils/cputointel/ImageLoader.c b/rosapps/devutils/cputointel/ImageLoader.c index 7570745e45c..03d05f965bd 100644 --- a/rosapps/devutils/cputointel/ImageLoader.c +++ b/rosapps/devutils/cputointel/ImageLoader.c @@ -5,7 +5,7 @@ #include #include #include "misc.h" -#include "ARM/ARM.h" +#include "From/ARM/ARM.h" #include "From/m68k/m68k.h" #include "From/PPC/PPC.h" diff --git a/rosapps/devutils/cputointel/cputointel.rbuild b/rosapps/devutils/cputointel/cputointel.rbuild index 68288bbf0d1..ad6b6d0853f 100644 --- a/rosapps/devutils/cputointel/cputointel.rbuild +++ b/rosapps/devutils/cputointel/cputointel.rbuild @@ -10,8 +10,8 @@ ImageLoader.c misc.c - ARM/ARMBrain.c - ARM/ARMopcode.c + From/ARM/ARMBrain.c + From/ARM/ARMopcode.c From/m68k/M68kBrain.c From/m68k/M68kopcode.c diff --git a/rosapps/devutils/cputointel/misc.c b/rosapps/devutils/cputointel/misc.c index f291b76ad21..c93dca9b06f 100644 --- a/rosapps/devutils/cputointel/misc.c +++ b/rosapps/devutils/cputointel/misc.c @@ -7,7 +7,7 @@ #include #include #include "misc.h" -#include "ARM/ARM.h" +#include "From/ARM/ARM.h" #include "From/m68k/m68k.h" #include "From/PPC/PPC.h"