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 30

Go to most recent revision | 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
    //printf( "Файл инициализации: %s\n", fname );
108 19 dsmv
    try
109 2 dsmv
    {
110
        CL_WBPEX *pBrd = &g_Board;
111
 
112
        int ret=pBrd->init();
113
 
114
        if( 0==ret )
115
        {
116 19 dsmv
            BRDC_fprintf( stderr, _BRDC("Board PEXDRV open succesfully\n") );
117 2 dsmv
 
118
 
119
            /*
120
            for( trd=0; trd<8; trd++ )
121
                pBrd->RegPokeInd( trd, 0, 1 );
122
 
123
            for( trd=0; trd<8; trd++ )
124
                for( int ii=1; ii<32; ii++ )
125
                    pBrd->RegPokeInd( trd, ii, 0 );
126
 
127
            for( trd=0; trd<8; trd++ )
128
                pBrd->RegPokeInd( trd, 0, 0 );
129
            */
130
 
131
        } else
132
        {
133 19 dsmv
            BRDC_fprintf( stderr, _BRDC("Error during open PEXDRV: ret=0x%.8X\n"), ret );
134 2 dsmv
            //getch();
135
            exit(-1);
136
        }
137
 
138 19 dsmv
        //printf( "\nShowPldInfo\n" );
139
        ShowWishboneInfo( pBrd );
140
    //}
141 2 dsmv
 
142 19 dsmv
 
143
//#if 0
144 2 dsmv
        if( fname[0]=='o' )
145 19 dsmv
            pTest = new WB_TestStrmOut( fname, pBrd );
146 2 dsmv
        else
147 19 dsmv
            pTest = new WB_TestStrm( fname, pBrd );
148 2 dsmv
 
149
        Sleep( 10 );
150
 
151
        if( fname2 )
152
        {
153
            isTwoTest=1;
154
            if( fname2[0]=='o' )
155 19 dsmv
                pTest2 = new WB_TestStrmOut( fname2, pBrd );
156 2 dsmv
            else
157 19 dsmv
                pTest2 = new WB_TestStrm( fname2, pBrd );
158 2 dsmv
        }
159
 
160
        pTest->Prepare();
161
        if( pTest2 )
162
            pTest2->Prepare();
163
 
164
        Sleep( 10 );
165
        pTest->Start();
166
        Sleep( 10 );
167
        if( pTest2 )
168
            pTest2->Start();
169
 
170
        //int key;
171
        int isFirstCallStep=1;
172 19 dsmv
        int isStopped = 0;
173 2 dsmv
        for( ; ; )
174
        {
175
 
176
 
177 19 dsmv
            if( exit_flag )
178
            {
179
                if(!isStopped) {
180 2 dsmv
                    pTest->Stop();
181 19 dsmv
                    if( pTest2 ) {
182 2 dsmv
                        pTest2->Stop();
183 19 dsmv
                    }
184
                    BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
185
                    isStopped = 1;
186 2 dsmv
                }
187 19 dsmv
            }
188 2 dsmv
 
189 19 dsmv
            if( exit_flag )
190
            {
191
                if(isStopped) {
192 2 dsmv
 
193 19 dsmv
                    if( pTest->isComplete() ) {
194 2 dsmv
 
195 19 dsmv
                        if( pTest2 ) {
196
                            if( pTest2->isComplete() )
197
                                break;
198
                        } else {
199
                            break;
200
                        }
201
                    }
202 2 dsmv
                }
203
            }
204
 
205
 
206
            //SetConsoleCursorPosition(hConsoleOut, rCursorPosition);
207
            if( isFirstCallStep || isTwoTest )
208
            {
209
 
210 19 dsmv
              BRDC_fprintf( stdout, _BRDC("%10s %10s %10s %10s %10s %10s %10s %10s\n"), _BRDC(""), _BRDC("BLOCK_WR"), _BRDC("BLOCK_RD"), _BRDC("BLOCK_OK"), _BRDC("BLOCK_ERR"), _BRDC("SPD_CURR"), _BRDC("SPD_AVR"), _BRDC("STATUS"));
211
              BRDC_fprintf( stdout, _BRDC("\n"));
212 2 dsmv
            }
213
 
214
            if (isFirstCallStep)
215
            {
216
                //CONSOLE_SCREEN_BUFFER_INFO csbInfo;
217
                //hConsoleOut = GetStdHandle( STD_OUTPUT_HANDLE );
218
                //GetConsoleScreenBufferInfo(hConsoleOut, &csbInfo);
219
                //rCursorPosition=csbInfo.dwCursorPosition;
220
                isFirstCallStep=false;
221
 
222
            }
223
 
224
            pTest->Step();
225
            if( isTwoTest )
226
                BRDC_fprintf( stderr, "\n" );
227
            if( pTest2 )
228
                pTest2->Step();
229
            if( isTwoTest )
230
                BRDC_fprintf( stderr, "\n\n" );
231
 
232
            Sleep( 400 );
233
 
234
            fflush( stdout );
235
        }
236
        pTest->GetResult();
237
        if( pTest2 )
238
            pTest2->GetResult();
239
 
240
 
241
        delete pTest; pTest=NULL;
242
        delete pTest2; pTest2=NULL;
243
 
244
    }
245
    catch( BRDCHAR* str )
246
    {
247
        BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
248
    }
249
    catch( ... )
250
    {
251
        BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
252
    }
253
 
254
 
255
    BRDC_fprintf( stderr, "\n Press any key\n" );
256
    //getch();
257
 
258
//}
259
    return 0;
260 19 dsmv
//#endif
261
}
262 2 dsmv
 
263
 
264
 
265 19 dsmv
void ShowWishboneInfo( CL_WBPEX *pBrd )
266 2 dsmv
{
267
 
268
 
269
    {
270
        U32 d, d1, d2, d3, d4, d5, ii;
271
        U32 block_id, block_id_mod;
272
        U32 block_ver_major, block_ver_minor;
273
        const char *str;
274
 
275 19 dsmv
        BRDC_fprintf( stderr, _BRDC("FPGA WB\r\n")  );
276 2 dsmv
 
277
 
278
/*
279
        d=pBrd->RegPeekInd( 0, 0x108 );
280
        if( d==0x4953 ) {
281
            BRDC_fprintf( stderr, _BRDC("  SIG= 0x%.4X - Ok     \n"), d );
282
        } else {
283
            BRDC_fprintf( stderr, _BRDC("  SIG= 0x%.4X - Ошибка, ожидается 0x4953        \n"), d );
284
            throw( 1 );
285
        }
286
 
287
        d=pBrd->RegPeekInd( 0, 0x109 );  BRDC_fprintf( stderr, "   Версия интерфейса ADM:  %d.%d\n", d>>8, d&0xFF );
288
        d=pBrd->RegPeekInd( 0, 0x110 ); d1=pBrd->RegPeekInd( 0, 0x111 );
289
        BRDC_fprintf( stderr, "   Базовый модуль: 0x%.4X  v%d.%d\n", d, d1>>8, d1&0xFF );
290
 
291
        d=pBrd->RegPeekInd( 0, 0x112 ); d1=pBrd->RegPeekInd( 0, 0x113 );
292
        BRDC_fprintf( stderr, "   Субмодуль:      0x%.4X  v%d.%d\n", d, d1>>8, d1&0xFF );
293
 
294
        d=pBrd->RegPeekInd( 0, 0x10B );  BRDC_fprintf( stderr, "   Модификация прошивки ПЛИС:  %d \n", d );
295
        d=pBrd->RegPeekInd( 0, 0x10A );  BRDC_fprintf( stderr, "   Версия прошивки ПЛИС:       %d.%d\n", d>>8, d&0xFF );
296
        d=pBrd->RegPeekInd( 0, 0x114 );  BRDC_fprintf( stderr, "   Номер сборки прошивки ПЛИС: 0x%.4X\n", d );
297
*/
298
 
299 19 dsmv
        BRDC_fprintf( stderr, "\nWB block info:\n\n" );
300 2 dsmv
        for( ii=0; ii<2; ii++ ) {
301
 
302
            d= pBrd->wb_block_read( ii, 0 );
303
                block_id = d & 0xFFF; block_id_mod=(d>>12) & 0xF;
304
 
305
           d1=pBrd->wb_block_read( ii, 1 );
306
                block_ver_major=(d1>>8) & 0xFF;
307
                block_ver_minor=d1&0xFF;
308
            /*
309
            d2=pBrd->RegPeekInd( ii, 0x102 );
310
            d3=pBrd->RegPeekInd( ii, 0x103 );
311
            d4=pBrd->RegPeekInd( ii, 0x104 );
312
            d5=pBrd->RegPeekInd( ii, 0x105 );
313
            */
314
 
315
            switch( d ) {
316
                case 0x1A: str="TEST_CHECK    "; break;
317
                case 0x1B: str="TEST_GENERATE "; break;
318
 
319
 
320
            default: str="UNKNOW        "; break;
321
            }
322 19 dsmv
            //BRDC_fprintf( stderr, " %d  0x%.8X 0x%.8X \n", ii, d, d1 );
323
 
324 2 dsmv
            BRDC_fprintf( stderr, " %d  0x%.4X %s ", ii, block_id, str );
325
            if( block_id>0 ) {
326 19 dsmv
                BRDC_fprintf( stderr, " MOD: %-2d VER: %d.%d \n", block_id_mod, block_ver_major, block_ver_minor );
327 2 dsmv
            } else {
328
                BRDC_fprintf( stderr, "\n" );
329
            }
330
 
331
        }
332
 
333
 
334
        BRDC_fprintf( stderr, "\r\n" );
335
 
336
    }
337
}
338
 

powered by: WebSVN 2.1.0

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