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