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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [ecostest/] [common/] [eCosTestDownloadFilter.h] - Blame information for rev 578

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

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

powered by: WebSVN 2.1.0

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