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 |
|
|
// RegionGeneralPage.cpp
|
28 |
|
|
//
|
29 |
|
|
// Memory Layout Tool region general property page class
|
30 |
|
|
//
|
31 |
|
|
//=================================================================
|
32 |
|
|
//#####DESCRIPTIONBEGIN####
|
33 |
|
|
//
|
34 |
|
|
// Author(s): John Dallaway
|
35 |
|
|
// Contact(s): jld
|
36 |
|
|
// Date: 1998/07/29 $RcsDate$ {or whatever}
|
37 |
|
|
// Version: 0.00+ $RcsVersion$ {or whatever}
|
38 |
|
|
// Purpose: Provides a derivation of the MFC CeCosPropertyPage class for
|
39 |
|
|
// general region property selection
|
40 |
|
|
// See also: RegionGeneralPage.h
|
41 |
|
|
// Known bugs: <UPDATE_ME_AT_RELEASE_TIME>
|
42 |
|
|
//
|
43 |
|
|
//####DESCRIPTIONEND####
|
44 |
|
|
|
45 |
|
|
#include "stdafx.h"
|
46 |
|
|
#include "RegionGeneralPage.h"
|
47 |
|
|
#include "ConfigTool.h"
|
48 |
|
|
#include "memmap.h"
|
49 |
|
|
|
50 |
|
|
#ifdef _DEBUG
|
51 |
|
|
#define new DEBUG_NEW
|
52 |
|
|
#undef THIS_FILE
|
53 |
|
|
static char THIS_FILE[] = __FILE__;
|
54 |
|
|
#endif
|
55 |
|
|
|
56 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
57 |
|
|
// CRegionGeneralPage property page
|
58 |
|
|
|
59 |
|
|
IMPLEMENT_DYNCREATE(CRegionGeneralPage, CeCosPropertyPage)
|
60 |
|
|
|
61 |
|
|
CRegionGeneralPage::CRegionGeneralPage() : CeCosPropertyPage(CRegionGeneralPage::IDD)
|
62 |
|
|
{
|
63 |
|
|
//{{AFX_DATA_INIT(CRegionGeneralPage)
|
64 |
|
|
m_strRegionName = _T("");
|
65 |
|
|
m_bRegionReadOnly = FALSE;
|
66 |
|
|
m_strRegionStartAddress = _T("");
|
67 |
|
|
m_strRegionSize = _T("");
|
68 |
|
|
//}}AFX_DATA_INIT
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
CRegionGeneralPage::~CRegionGeneralPage()
|
72 |
|
|
{
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
void CRegionGeneralPage::DoDataExchange(CDataExchange* pDX)
|
76 |
|
|
{
|
77 |
|
|
CeCosPropertyPage::DoDataExchange(pDX);
|
78 |
|
|
//{{AFX_DATA_MAP(CRegionGeneralPage)
|
79 |
|
|
DDX_Control(pDX, IDC_REGION_GENERAL_SIZE, m_edtRegionSize);
|
80 |
|
|
DDX_Control(pDX, IDC_REGION_GENERAL_START_ADDRESS, m_edtRegionStartAddress);
|
81 |
|
|
DDX_Control(pDX, IDC_REGION_GENERAL_NAME, m_edtRegionName);
|
82 |
|
|
DDX_Text(pDX, IDC_REGION_GENERAL_NAME, m_strRegionName);
|
83 |
|
|
DDX_Check(pDX, IDC_REGION_GENERAL_READ_ONLY, m_bRegionReadOnly);
|
84 |
|
|
DDX_Text(pDX, IDC_REGION_GENERAL_START_ADDRESS, m_strRegionStartAddress);
|
85 |
|
|
DDX_Text(pDX, IDC_REGION_GENERAL_SIZE, m_strRegionSize);
|
86 |
|
|
//}}AFX_DATA_MAP
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
BEGIN_MESSAGE_MAP(CRegionGeneralPage, CeCosPropertyPage)
|
91 |
|
|
//{{AFX_MSG_MAP(CRegionGeneralPage)
|
92 |
|
|
// NOTE: the ClassWizard will add message map macros here
|
93 |
|
|
//}}AFX_MSG_MAP
|
94 |
|
|
END_MESSAGE_MAP()
|
95 |
|
|
|
96 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
97 |
|
|
// CRegionGeneralPage message handlers
|
98 |
|
|
|
99 |
|
|
BOOL CRegionGeneralPage::OnKillActive()
|
100 |
|
|
{
|
101 |
|
|
if (! UpdateData (TRUE))
|
102 |
|
|
return FALSE;
|
103 |
|
|
|
104 |
|
|
if ((m_strRegionName == _T("")) || (m_strRegionName.FindOneOf (LD_ILLEGAL_CHARS) != -1))
|
105 |
|
|
{
|
106 |
|
|
AfxMessageBox (IDS_VALIDATE_REGION_NAME);
|
107 |
|
|
m_edtRegionName.SetFocus ();
|
108 |
|
|
return FALSE;
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
// convert address and size information to a DWORD representation
|
112 |
|
|
|
113 |
|
|
TCHAR strDummy [2]; // holds any stray character following a hex value
|
114 |
|
|
|
115 |
|
|
if (_stscanf (m_strRegionStartAddress, _T("%lx%1s"), &m_dwRegionStartAddress, strDummy) != 1)
|
116 |
|
|
{
|
117 |
|
|
AfxMessageBox (IDS_VALIDATE_REGION_START_ADDRESS);
|
118 |
|
|
m_edtRegionStartAddress.SetFocus ();
|
119 |
|
|
m_edtRegionStartAddress.SetSel (0, -1); // select all text
|
120 |
|
|
return FALSE;
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
if ((_stscanf (m_strRegionSize, _T("%lx%1s"), &m_dwRegionSize, strDummy) != 1) || (m_dwRegionSize < 1))
|
124 |
|
|
{
|
125 |
|
|
AfxMessageBox (IDS_VALIDATE_REGION_SIZE);
|
126 |
|
|
m_edtRegionSize.SetFocus ();
|
127 |
|
|
m_edtRegionSize.SetSel (0, -1); // select all text
|
128 |
|
|
return FALSE;
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
return CeCosPropertyPage::OnKillActive();
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
BOOL CRegionGeneralPage::OnSetActive()
|
135 |
|
|
{
|
136 |
|
|
// generate hex strings for display
|
137 |
|
|
|
138 |
|
|
if (m_dwRegionSize == 0) // a new region
|
139 |
|
|
{
|
140 |
|
|
m_strRegionStartAddress = _T("");
|
141 |
|
|
m_strRegionSize = _T("");
|
142 |
|
|
}
|
143 |
|
|
else // modify an existing region
|
144 |
|
|
{
|
145 |
|
|
m_strRegionStartAddress.Format (_T("%08lX"), m_dwRegionStartAddress);
|
146 |
|
|
m_strRegionSize.Format (_T("%lX"), m_dwRegionSize);
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
if (! UpdateData (FALSE))
|
150 |
|
|
return FALSE;
|
151 |
|
|
|
152 |
|
|
return CeCosPropertyPage::OnSetActive();
|
153 |
|
|
}
|
154 |
|
|
|