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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [ecostest/] [common/] [eCosTestDownloadFilter.h] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
//=================================================================
23
//
24
//        eCosTestDownloadFilter.h
25
//
26
//        Socket/serial download filter class
27
//
28
//=================================================================
29
//=================================================================
30
//#####DESCRIPTIONBEGIN####
31
//
32
// Author(s):     jskov
33
// Contributors:  jskov
34
// Date:          1999-09-20
35
//####DESCRIPTIONEND####
36
#ifndef _CECOSDOWNLOADFILTER_H
37
#define _CECOSDOWNLOADFILTER_H
38
 
39
#include "eCosStd.h"
40
#include "eCosTest.h"
41
#include "eCosSocket.h"
42
#include "eCosSerial.h"
43
 
44
//----------------------------------------------------------------------------
45
// Macros to help extract values from the argument string.
46
// Note: This is probably not an ideal solution, but it was easy to make :)
47
 
48
#define INIT_VALUE(__args)                      unsigned int v; char *__ptr1, *__ptr2 = (__args)
49
 
50
#define SET_VALUE(__type, __slot) {          \
51
    __ptr1 = strchr(__ptr2, (int) ':');      \
52
    if (*__ptr2 == '\0')                     \
53
           (__slot) = (__type)-1;            \
54
    else {                                   \
55
        if (__ptr1)                          \
56
            *__ptr1 = 0;                     \
57
        else                                 \
58
            __ptr1 = strchr( __ptr2, 0) - 1; \
59
        v = atoi(__ptr2);                    \
60
        __ptr2 = __ptr1+1;                   \
61
        (__slot) = (__type) v;               \
62
    }                                        \
63
}
64
 
65
#define SET_STRING(__slot)               {    __ptr1 = strchr(__ptr2, (int) ':'); if (__ptr1) *__ptr1 = 0; __slot = __ptr2; __ptr2 = __ptr1+1; }
66
 
67
 
68
//----------------------------------------------------------------------------
69
// The filter class
70
class CeCosTestDownloadFilter;
71
 
72
class CeCosTestDownloadFilter {
73
public:
74
    // Constructor
75
    CeCosTestDownloadFilter();
76
    ~CeCosTestDownloadFilter();
77
 
78
    // Configuration methods
79
    void SetSerialDebug(bool bSerialDebug)
80
        { m_bOptSerDebug = bSerialDebug; }
81
    void SetFilterTrace(bool bFilterTrace)
82
        { m_bOptFilterTrace = bFilterTrace; }
83
 
84
 
85
    bool ContinueSession()
86
        { bool r = m_bContinueSession; m_bContinueSession = false; return r; }
87
 
88
    bool FilterFunctionProper(void*& pBuf,
89
                              unsigned int& nRead,
90
                              CeCosSerial& serial,
91
                              CeCosSocket& socket);
92
 
93
private:
94
    // If we can guarantee a minimum buffer size in the stub, we can
95
    // increase PBUFSIZE.
96
    enum {MAX_CMD_LEN=128, PBUFSIZ=400};
97
    enum data_origin_t {SF_TARGET=0, SF_FILTER} ;
98
 
99
    // Output methods
100
    void ConsoleWrite(const char* pszStr);
101
    void Trace(const char* pszFormat, ...);
102
 
103
    void PrintHex(const unsigned char* d1, int len,
104
                  data_origin_t origin=SF_TARGET);
105
 
106
    // Target read/write methods
107
    void TargetWrite(CeCosSerial &pSer,
108
                     const unsigned char* buffer, int len);
109
 
110
    // GDB stuff
111
    int tohex(int nib);
112
    int hexnumstr(unsigned char* buf, unsigned long num);
113
    int hexnumlen(unsigned long num);
114
    int put_binary (unsigned char* buf, int cnt, unsigned long dl_address,
115
                    int packet_size, CeCosSerial& serial);
116
 
117
    // Options used for configuring behavior.
118
    bool m_bNullFilter;
119
    bool m_bOptSerDebug;
120
    bool m_bOptFilterTrace;
121
 
122
    // Filter state
123
    int  m_nCmdIndex;
124
    bool m_bCmdFlag;
125
    char m_aCmd[MAX_CMD_LEN];
126
    bool m_bContinueSession;            // set true only after a successfull dl
127
};
128
 
129
extern bool CALLBACK DownloadFilterFunction(void*& pBuf,
130
                                            unsigned int& nRead,
131
                                            CeCosSerial& serial,
132
                                            CeCosSocket& socket,
133
                                            void* pParem);
134
 
135
#endif // _CECOSDOWNLOADFILTER_H

powered by: WebSVN 2.1.0

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