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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [ecostest/] [common/] [ResetAttributes.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
//#####DESCRIPTIONBEGIN####
24
//
25
// Author(s):     sdf
26
// Contributors:  sdf
27
// Date:          1999-04-01
28
// Description:   Holds information related to target reset.
29
// Usage:
30
//
31
//####DESCRIPTIONEND####
32
 
33
#ifndef _RESETATTRIBUTES_H
34
#define _RESETATTRIBUTES_H
35
 
36
#include "Collections.h"
37
#include "eCosStd.h"
38
#include "eCosSerial.h"
39
#include "eCosSocket.h"
40
#include "Properties.h"
41
 
42
//=================================================================
43
// This class deals with resetting a target.
44
// The ctor accepts the "reset string" this is something like
45
//    expect($T05,#) 3(off(ginga:5000,a1) delay(2000) on(,..com2,38400))
46
// and is parsed to generate the commands to reset the target.
47
// The syntax is:
48
//    resetstring :== [directive | <integer>(resetstring)] * 
49
//    directive   :== id(arg[,arg]*)
50
//    directive   :== port | action | delay | expect
51
//
52
// The <integer>(string) syntax repeats argument its until reset is achieved.
53
// Each directive is given by example below:
54
// expect: 
55
//   Expected string(s).            e.g. expect(str1,str2,...).
56
//   Arguments:
57
//     The string(s) expected to be output by a target after reset.
58
//     *all* supplied strings must be present *in order* in the reset string for a reset to be recognized as valid.
59
// port:
60
//   Provide port information to apply to all subsequent off|on|on_off|off_on actions until overwritten.
61
//   e.g. port(com1,38400,1000)
62
//   Arguments:
63
//     0. Port
64
//     1. Baud
65
//     2. Read timeout
66
//   These have the meanings described under off|on|on_off|off_on.
67
// off|on|on_off|off_on:
68
//   Request a reset host to perform a "power cycle" (or its logical equivalent - 
69
//   the meanings of "off" and "on" may depend on the reset host)
70
//   e.g. off_on(ginga:500,A4,com1,38400,10000,1000)
71
//   Arguments:
72
//     0. Reset host:port
73
//     1. Control string (meaning known to the reset host)
74
//     2. Port (from which to read startup output)
75
//     3. Baud for the above
76
//     4. Read timeout
77
//     5. Delay (between off and on or vice versa)
78
// delay:
79
//   Delay for a given time right now.      
80
//   e.g. delay(1000)
81
//   Arguments:
82
//     0. msec to delay
83
//=================================================================
84
 
85
class CResetAttributes {
86
public:
87
  CResetAttributes(LPCTSTR psz=_T(""));
88
 
89
        //bool IsValid();
90
 
91
  const LPCTSTR Image() const { return m_str; }
92
 
93
  bool IsNull() const { return m_str.empty(); }
94
  static const CResetAttributes NoReset;
95
 
96
  enum ResetResult {INVALID_STRING=-1,RESET_OK=0,NOT_RESET=1,
97
    RESET_ILLEGAL_DEVICE_CODE=30000,RESET_NO_REPLY, RESET_BAD_CHECKSUM, RESET_BAD_ACK, RESET_UNKNOWN_ERROR};
98
 
99
  // Perform the reset, sending the output to the log function supplied as parameter.
100
  ResetResult Reset (LogFunc *pfnLog=0, void *pfnLogparam=0,bool bCheckOnly=false);
101
 
102
  enum Action {OFF=0,ON=1,OFF_ON=2,ON_OFF=3};
103
 
104
protected:
105
 
106
  // This function determines whether the board startup has output all that is required
107
  // All the strings of m_arValidResetStrings [arguments of expect() in the reset string] must be present
108
  bool IsValidReset();
109
 
110
  Time m_tResetOccurred;
111
 
112
  // The log function.
113
  LogFunc *m_pfnReset;
114
  void *m_pfnResetparam;
115
  // Log some output to the reset log function.
116
  void ResetLog(LPCTSTR psz);
117
 
118
  CeCosSerial m_Serial;
119
  CeCosSocket m_Socket;
120
 
121
  const TCHAR *GetIdAndArg (LPCTSTR psz,String &strID,String &strArg);
122
  ResetResult Parse (LPCTSTR psz,bool bCheckOnly=false);
123
  bool Reset (Action action,bool bCheckOutput);
124
 
125
  void SuckThreadFunc ();
126
  static void CALLBACK SSuckThreadFunc (void *pParam) { ((CResetAttributes*)pParam)->SuckThreadFunc(); }
127
 
128
  String m_str;           // Here is the reset string.  Could be const, but avoid the assignment operator warnings
129
 
130
  // These members hold the information we extract by parsing the string:
131
 
132
        StringArray m_arValidResetStrings;
133
  String m_strHostPort;     // host we talk to
134
  String m_strControl;      // Control string
135
  int m_nDelay;             // Delay between power off and power on
136
  String m_strAuxPort;      // Auxiliary port (serial port to listen on if primary port is TCP/IP)
137
  int m_nReadTimeout;       // mSec to wait for board to say something
138
  int m_nBaud;              // Baud rate
139
 
140
  String m_strResetOutput;  // The output we get
141
};
142
 
143
#endif

powered by: WebSVN 2.1.0

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