OpenCores
URL https://opencores.org/ocsvn/pcie_ds_dma/pcie_ds_dma/trunk

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [soft/] [linux/] [application/] [wb_test/] [src/] [work/] [main.cpp] - Blame information for rev 31

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
 
2
/*
3
#ifndef __PEX_H__
4
    #include "pex.h"
5
#endif
6
*/
7
 
8
#include <cassert>
9
#include <cstdlib>
10
#include <cstring>
11
#include <iostream>
12
#include <iomanip>
13
#include <climits>
14
//#include <conio.h>
15
 
16
//-----------------------------------------------------------------------------
17
 
18
using namespace std;
19
 
20
//-----------------------------------------------------------------------------
21
/*
22
int main(int argc, char *argv[])
23
{
24
 
25
    if(argc == 1) {
26
        std::cerr << "usage: %s <device name>" << argv[0] << endl;
27
        return -1;
28
    }
29
 
30
    std ::cout << "Start testing device " << argv[1] << endl;
31
 
32
    board *brd = new pex_board();
33
 
34
    brd->brd_open(argv[1]);
35
    brd->brd_init();
36
    brd->brd_board_info();
37
    brd->brd_pld_info();
38
 
39
    for(int i=0; i<16; i++)
40
        std ::cout << "BAR0[" << i << "] = 0x" << hex << brd->brd_bar0_read(i) << dec << endl;
41
 
42
    brd->brd_close();
43
 
44
    delete brd;
45
 
46
 
47
    return 0;
48
}
49
*/
50
// FP_PEX8_TEST.cpp : Defines the entry point for the console application.
51
//
52
#include <locale.h>
53
#include <unistd.h>
54
#include <stdlib.h>
55
#include <stdio.h>
56 30 dsmv
#include <signal.h>
57 2 dsmv
 
58
#include "cl_wbpex.h"
59
//#include "tf_test.h"
60
//#include "tf_teststrm.h"
61
//#include "tf_teststrmout.h"
62
//#include "useful.h"
63 19 dsmv
#include "wb_teststrm.h"
64
#include "wb_teststrmout.h"
65 2 dsmv
 
66
CL_WBPEX    g_Board;
67
 
68
U32 isTwoTest=0;
69
 
70 19 dsmv
static volatile int exit_flag = 0;
71 2 dsmv
 
72 19 dsmv
void signa_handler(int signo)
73
{
74
    exit_flag = 1;
75
}
76
 
77
 
78
void ShowWishboneInfo( CL_WBPEX *pBrd );
79
 
80 2 dsmv
//
81
//=== Console
82
//
83
//HANDLE        hConsoleOut;
84
 
85
 
86
int BRDC_main(int argc, BRDCHAR* argv[])
87
{
88
    // анализ командной строки
89
    setlocale( LC_ALL, "Russian" );
90 30 dsmv
    signal(SIGINT, signa_handler);
91 2 dsmv
 
92 19 dsmv
    TF_Test  *pTest=NULL;
93
    TF_Test  *pTest2=NULL;
94 2 dsmv
 
95
    BRDCHAR* fname = argv[1];
96
    BRDCHAR* fname2=NULL;
97
    if( argc<2 )
98
    {
99
        fname=(BRDCHAR*)_BRDC("");
100
    }
101
    if( argc==3 )
102
    {
103
        fname2=argv[2];
104
    }
105
 
106
 
107 19 dsmv
    try
108 2 dsmv
    {
109
        CL_WBPEX *pBrd = &g_Board;
110
 
111
        int ret=pBrd->init();
112
 
113
        if( 0==ret )
114
        {
115 19 dsmv
            BRDC_fprintf( stderr, _BRDC("Board PEXDRV open succesfully\n") );
116 2 dsmv
 
117
 
118
 
119
        } else
120
        {
121 19 dsmv
            BRDC_fprintf( stderr, _BRDC("Error during open PEXDRV: ret=0x%.8X\n"), ret );
122 2 dsmv
            //getch();
123
            exit(-1);
124
        }
125
 
126 19 dsmv
        ShowWishboneInfo( pBrd );
127 2 dsmv
 
128 19 dsmv
 
129 2 dsmv
        if( fname[0]=='o' )
130 19 dsmv
            pTest = new WB_TestStrmOut( fname, pBrd );
131 2 dsmv
        else
132 19 dsmv
            pTest = new WB_TestStrm( fname, pBrd );
133 2 dsmv
 
134
        Sleep( 10 );
135
 
136
        if( fname2 )
137
        {
138
            isTwoTest=1;
139
            if( fname2[0]=='o' )
140 19 dsmv
                pTest2 = new WB_TestStrmOut( fname2, pBrd );
141 2 dsmv
            else
142 19 dsmv
                pTest2 = new WB_TestStrm( fname2, pBrd );
143 2 dsmv
        }
144
 
145
        pTest->Prepare();
146
        if( pTest2 )
147
            pTest2->Prepare();
148
 
149
        Sleep( 10 );
150
        pTest->Start();
151
        Sleep( 10 );
152
        if( pTest2 )
153
            pTest2->Start();
154
 
155
        //int key;
156
        int isFirstCallStep=1;
157 19 dsmv
        int isStopped = 0;
158 2 dsmv
        for( ; ; )
159
        {
160
 
161
 
162 19 dsmv
            if( exit_flag )
163
            {
164
                if(!isStopped) {
165 2 dsmv
                    pTest->Stop();
166 19 dsmv
                    if( pTest2 ) {
167 2 dsmv
                        pTest2->Stop();
168 19 dsmv
                    }
169
                    BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
170
                    isStopped = 1;
171 2 dsmv
                }
172 19 dsmv
            }
173 2 dsmv
 
174 19 dsmv
            if( exit_flag )
175
            {
176
                if(isStopped) {
177 2 dsmv
 
178 19 dsmv
                    if( pTest->isComplete() ) {
179 2 dsmv
 
180 19 dsmv
                        if( pTest2 ) {
181
                            if( pTest2->isComplete() )
182
                                break;
183
                        } else {
184
                            break;
185
                        }
186
                    }
187 2 dsmv
                }
188
            }
189
 
190
 
191
            //SetConsoleCursorPosition(hConsoleOut, rCursorPosition);
192
            if( isFirstCallStep || isTwoTest )
193
            {
194
 
195 31 dsmv
              BRDC_fprintf( stdout, _BRDC("%10s %10s %10s %10s %10s %10s %10s %10s  %-10s  %-6s\n"), _BRDC(""), _BRDC("BLOCK_WR"), _BRDC("BLOCK_RD"), _BRDC("BLOCK_OK"), _BRDC("BLOCK_ERR"), _BRDC("SPD_CURR"), _BRDC("SPD_AVR"), _BRDC("STATUS"), _BRDC("SIG"), _BRDC("TIME"));
196 19 dsmv
              BRDC_fprintf( stdout, _BRDC("\n"));
197 2 dsmv
            }
198
 
199
            if (isFirstCallStep)
200
            {
201
                //CONSOLE_SCREEN_BUFFER_INFO csbInfo;
202
                //hConsoleOut = GetStdHandle( STD_OUTPUT_HANDLE );
203
                //GetConsoleScreenBufferInfo(hConsoleOut, &csbInfo);
204
                //rCursorPosition=csbInfo.dwCursorPosition;
205
                isFirstCallStep=false;
206
 
207
            }
208
 
209
            pTest->Step();
210
            if( isTwoTest )
211
                BRDC_fprintf( stderr, "\n" );
212
            if( pTest2 )
213
                pTest2->Step();
214
            if( isTwoTest )
215
                BRDC_fprintf( stderr, "\n\n" );
216
 
217
            Sleep( 400 );
218
 
219
            fflush( stdout );
220
        }
221
        pTest->GetResult();
222
        if( pTest2 )
223
            pTest2->GetResult();
224
 
225
 
226
        delete pTest; pTest=NULL;
227
        delete pTest2; pTest2=NULL;
228
 
229
    }
230
    catch( BRDCHAR* str )
231
    {
232
        BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
233
    }
234
    catch( ... )
235
    {
236
        BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
237
    }
238
 
239
 
240
    BRDC_fprintf( stderr, "\n Press any key\n" );
241
    //getch();
242
 
243
//}
244
    return 0;
245 19 dsmv
//#endif
246
}
247 2 dsmv
 
248
 
249
 
250 19 dsmv
void ShowWishboneInfo( CL_WBPEX *pBrd )
251 2 dsmv
{
252
 
253
 
254
    {
255
        U32 d, d1, d2, d3, d4, d5, ii;
256
        U32 block_id, block_id_mod;
257
        U32 block_ver_major, block_ver_minor;
258
        const char *str;
259
 
260 19 dsmv
        BRDC_fprintf( stderr, _BRDC("FPGA WB\r\n")  );
261 2 dsmv
 
262
 
263
/*
264
        d=pBrd->RegPeekInd( 0, 0x108 );
265
        if( d==0x4953 ) {
266
            BRDC_fprintf( stderr, _BRDC("  SIG= 0x%.4X - Ok     \n"), d );
267
        } else {
268
            BRDC_fprintf( stderr, _BRDC("  SIG= 0x%.4X - Ошибка, ожидается 0x4953        \n"), d );
269
            throw( 1 );
270
        }
271
 
272
        d=pBrd->RegPeekInd( 0, 0x109 );  BRDC_fprintf( stderr, "   Версия интерфейса ADM:  %d.%d\n", d>>8, d&0xFF );
273
        d=pBrd->RegPeekInd( 0, 0x110 ); d1=pBrd->RegPeekInd( 0, 0x111 );
274
        BRDC_fprintf( stderr, "   Базовый модуль: 0x%.4X  v%d.%d\n", d, d1>>8, d1&0xFF );
275
 
276
        d=pBrd->RegPeekInd( 0, 0x112 ); d1=pBrd->RegPeekInd( 0, 0x113 );
277
        BRDC_fprintf( stderr, "   Субмодуль:      0x%.4X  v%d.%d\n", d, d1>>8, d1&0xFF );
278
 
279
        d=pBrd->RegPeekInd( 0, 0x10B );  BRDC_fprintf( stderr, "   Модификация прошивки ПЛИС:  %d \n", d );
280
        d=pBrd->RegPeekInd( 0, 0x10A );  BRDC_fprintf( stderr, "   Версия прошивки ПЛИС:       %d.%d\n", d>>8, d&0xFF );
281
        d=pBrd->RegPeekInd( 0, 0x114 );  BRDC_fprintf( stderr, "   Номер сборки прошивки ПЛИС: 0x%.4X\n", d );
282
*/
283
 
284 19 dsmv
        BRDC_fprintf( stderr, "\nWB block info:\n\n" );
285 2 dsmv
        for( ii=0; ii<2; ii++ ) {
286
 
287
            d= pBrd->wb_block_read( ii, 0 );
288
                block_id = d & 0xFFF; block_id_mod=(d>>12) & 0xF;
289
 
290
           d1=pBrd->wb_block_read( ii, 1 );
291
                block_ver_major=(d1>>8) & 0xFF;
292
                block_ver_minor=d1&0xFF;
293
            /*
294
            d2=pBrd->RegPeekInd( ii, 0x102 );
295
            d3=pBrd->RegPeekInd( ii, 0x103 );
296
            d4=pBrd->RegPeekInd( ii, 0x104 );
297
            d5=pBrd->RegPeekInd( ii, 0x105 );
298
            */
299
 
300
            switch( d ) {
301
                case 0x1A: str="TEST_CHECK    "; break;
302
                case 0x1B: str="TEST_GENERATE "; break;
303
 
304
 
305
            default: str="UNKNOW        "; break;
306
            }
307 19 dsmv
            //BRDC_fprintf( stderr, " %d  0x%.8X 0x%.8X \n", ii, d, d1 );
308
 
309 2 dsmv
            BRDC_fprintf( stderr, " %d  0x%.4X %s ", ii, block_id, str );
310
            if( block_id>0 ) {
311 19 dsmv
                BRDC_fprintf( stderr, " MOD: %-2d VER: %d.%d \n", block_id_mod, block_ver_major, block_ver_minor );
312 2 dsmv
            } else {
313
                BRDC_fprintf( stderr, "\n" );
314
            }
315
 
316
        }
317
 
318
 
319
        BRDC_fprintf( stderr, "\r\n" );
320
 
321
    }
322
}
323
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.