##// END OF EJS Templates
fixed typo.
Jeandet Alexis -
r100:b7137547140e socexplorer-plugins-0.7-7 default draft
parent child
Show More
@@ -1,91 +1,91
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "memchecker.h"
22 #include "memchecker.h"
23 #include <socexplorerengine.h>
23 #include <socexplorerengine.h>
24
24
25 memchecker::memchecker(socexplorerplugin* plugin)
25 memchecker::memchecker(socexplorerplugin* plugin)
26 {
26 {
27 this->plugin = plugin;
27 this->plugin = plugin;
28 }
28 }
29
29
30 QString memchecker::checkmemory(unsigned int address, unsigned int size, bool *success)
30 QString memchecker::checkmemory(unsigned int address, unsigned int size, bool *success)
31 {
31 {
32 *success = true;
32 *success = true;
33 QString repport;
33 QString repport;
34 unsigned int* dataLocal = (unsigned int*)malloc(size);
34 unsigned int* dataLocal = (unsigned int*)malloc(size);
35 unsigned int* dataOnBoard = (unsigned int*)malloc(size);
35 unsigned int* dataOnBoard = (unsigned int*)malloc(size);
36 for(int i=0;(unsigned int)i<(size>>2);i++)
36 for(int i=0;(unsigned int)i<(size>>2);i++)
37 {
37 {
38 dataLocal[i]= (0xFFFF&rand())+(rand()<<16);
38 dataLocal[i]= (0xFFFF&rand())+(rand()<<16);
39 }
39 }
40 plugin->Write(dataLocal,size>>2,address);
40 plugin->Write(dataLocal,size>>2,address);
41 plugin->Read(dataOnBoard,size>>2,address);
41 plugin->Read(dataOnBoard,size>>2,address);
42 for(int i=0;(unsigned int)i<(size>>2);i++)
42 for(int i=0;(unsigned int)i<(size>>2);i++)
43 {
43 {
44 if(dataLocal[i]!=dataOnBoard[i])
44 if(dataLocal[i]!=dataOnBoard[i])
45 *success=false;
45 *success=false;
46 }
46 }
47 free(dataLocal);
47 free(dataLocal);
48 free(dataOnBoard);
48 free(dataOnBoard);
49 return repport;
49 return repport;
50 }
50 }
51
51
52 QString memchecker::checkdatabits(unsigned int address,unsigned int size,bool* success)
52 QString memchecker::checkdatabits(unsigned int address,unsigned int size,bool* success)
53 {
53 {
54 *success = true;
54 *success = true;
55 QString repport;
55 QString repport;
56 return repport;
56 return repport;
57 }
57 }
58
58
59
59
60 unsigned int p_pow2(unsigned int v)
60 unsigned int p_pow2(unsigned int v)
61 {
61 {
62 static const char LogTable256[256] =
62 static const char LogTable256[256] =
63 {
63 {
64 #define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n
64 #define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n
65 -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
65 -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
66 LT(4), LT(5), LT(5), LT(6), LT(6), LT(6), LT(6),
66 LT(4), LT(5), LT(5), LT(6), LT(6), LT(6), LT(6),
67 LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7)
67 LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7), LT(7)
68 };
68 };
69
69
70 unsigned int r; // r will be lg(v)
70 unsigned int r; // r will be lg(v)
71 register unsigned int t, tt; // temporaries
71 register unsigned int t, tt; // temporaries
72
72
73 if (tt = v >> 16)
73 if (tt = v >> 16)
74 {
74 {
75 r = (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt];
75 r = (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt];
76 }
76 }
77 else
77 else
78 {
78 {
79 r = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v];
79 r = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v];
80 }
80 }
81 return r;
81 return r;
82 }
82 }
83
83
84
84
85 unsigned int memchecker::measureMemSize(unsigned int address, unsigned int maxSize)
85 unsigned int memchecker::measureMemSize(unsigned int address, unsigned int maxSize)
86 {
86 {
87 return SocExplorerEngine::memMeasureSize(this->plugin,address,maxSize);
87 return SocExplorerEngine::self()->memMeasureSize(this->plugin,address,maxSize);
88 }
88 }
89
89
90
90
91
91
General Comments 0
You need to be logged in to leave comments. Login now