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 19

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

powered by: WebSVN 2.1.0

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