Delete all Trailing spaces in code.
[reactos.git] / rosapps / devutils / cputointel / ConvertingProcess.c
1 #include <windows.h>
2 #include <winnt.h>
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include "misc.h"
8 #include "any_op.h"
9
10 /* hack should be in misc.h*/
11
12
13 CPU_INT ConvertProcess(FILE *outfp, CPU_INT FromCpuid, CPU_INT ToCpuid)
14 {
15 CPU_INT ret=0;
16 CPU_INT regbits=-1;
17 CPU_INT HowManyRegInUse = 0;
18 CPU_INT RegTableCount[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
19 CPU_INT t;
20 PMYBrainAnalys pMystart = pStartMyBrainAnalys;
21 PMYBrainAnalys pMyend = pMyBrainAnalys;
22
23 PMYBrainAnalys ptmpMystart = pStartMyBrainAnalys;
24 PMYBrainAnalys ptmpMyend = pMyBrainAnalys;
25
26 if ( (FromCpuid == IMAGE_FILE_MACHINE_POWERPC) ||
27 (FromCpuid == IMAGE_FILE_MACHINE_I386))
28 {
29 regbits = 32 / 8;
30 }
31
32 /* FIXME calc where todo first split */
33
34 /* count how many register we got */
35 ptmpMystart = pMystart;
36 ptmpMyend = pMyend;
37 while (ptmpMystart!=NULL)
38 {
39 if ((ptmpMystart->type & 2) == 2)
40 RegTableCount[ptmpMystart->src]++;
41
42 if ((ptmpMystart->type & 8) == 8)
43 RegTableCount[ptmpMystart->dst]++;
44
45 if ((ptmpMystart->type & 32) == 32)
46 RegTableCount[ptmpMystart->src]++;
47
48 if ((ptmpMystart->type & 64) == 64)
49 RegTableCount[ptmpMystart->dst]++;
50
51 if (ptmpMystart == ptmpMyend)
52 ptmpMystart=NULL;
53 else
54 ptmpMystart = (PMYBrainAnalys) ptmpMystart->ptr_next;
55 }
56
57 for (t=0;t<=31;t++)
58 {
59 if (RegTableCount[t]!=0)
60 {
61 HowManyRegInUse++;
62 RegTableCount[t]=t;
63 }
64 }
65
66
67 /* switch to the acual converting now */
68 switch (ToCpuid)
69 {
70 case IMAGE_FILE_MACHINE_I386:
71 ret = ConvertToIA32Process( outfp, pMystart,
72 pMyend, regbits,
73 HowManyRegInUse,
74 RegTableCount);
75 if (ret !=0)
76 {
77 printf("should not happen contact a devloper, x86 fail\n");
78 return -1;
79 }
80 break;
81
82 case IMAGE_FILE_MACHINE_POWERPC:
83 ret = ConvertToPPCProcess( outfp, pMystart,
84 pMyend, regbits,
85 HowManyRegInUse,
86 RegTableCount);
87 if (ret !=0)
88 {
89 printf("should not happen contact a devloper, x86 fail\n");
90 return -1;
91 }
92 break;
93
94 default:
95 printf("should not happen contact a devloper, unknown fail\n");
96 return -1;
97 }
98
99 return ret;
100 }