| 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 |
|
|
// SectionRelocationPage.cpp
|
| 28 |
|
|
//
|
| 29 |
|
|
// Memory Layout Tool section relocation 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 |
|
|
// relocation section property selection
|
| 40 |
|
|
// See also: SectionRelocationPage.h
|
| 41 |
|
|
// Known bugs: <UPDATE_ME_AT_RELEASE_TIME>
|
| 42 |
|
|
//
|
| 43 |
|
|
//####DESCRIPTIONEND####
|
| 44 |
|
|
|
| 45 |
|
|
#include "stdafx.h"
|
| 46 |
|
|
#include "ConfigtoolDoc.h"
|
| 47 |
|
|
#include "SectionRelocationPage.h"
|
| 48 |
|
|
#include "ConfigTool.h"
|
| 49 |
|
|
#include "CTUtils.h"
|
| 50 |
|
|
|
| 51 |
|
|
#include "memmap.h"
|
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
#ifdef _DEBUG
|
| 55 |
|
|
#define new DEBUG_NEW
|
| 56 |
|
|
#undef THIS_FILE
|
| 57 |
|
|
static char THIS_FILE[] = __FILE__;
|
| 58 |
|
|
#endif
|
| 59 |
|
|
|
| 60 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
| 61 |
|
|
// CSectionRelocationPage property page
|
| 62 |
|
|
|
| 63 |
|
|
IMPLEMENT_DYNCREATE(CSectionRelocationPage, CeCosPropertyPage)
|
| 64 |
|
|
|
| 65 |
|
|
CSectionRelocationPage::CSectionRelocationPage() : CeCosPropertyPage(CSectionRelocationPage::IDD)
|
| 66 |
|
|
{
|
| 67 |
|
|
//{{AFX_DATA_INIT(CSectionRelocationPage)
|
| 68 |
|
|
m_bRelocates = FALSE;
|
| 69 |
|
|
m_strInitialRelativeName = _T("");
|
| 70 |
|
|
m_strInitialAddress = _T("");
|
| 71 |
|
|
//}}AFX_DATA_INIT
|
| 72 |
|
|
m_bNewSection = FALSE;
|
| 73 |
|
|
}
|
| 74 |
|
|
|
| 75 |
|
|
|
| 76 |
|
|
CSectionRelocationPage::~CSectionRelocationPage()
|
| 77 |
|
|
{
|
| 78 |
|
|
}
|
| 79 |
|
|
|
| 80 |
|
|
|
| 81 |
|
|
void CSectionRelocationPage::DoDataExchange(CDataExchange* pDX)
|
| 82 |
|
|
{
|
| 83 |
|
|
CeCosPropertyPage::DoDataExchange(pDX);
|
| 84 |
|
|
//{{AFX_DATA_MAP(CSectionRelocationPage)
|
| 85 |
|
|
DDX_Control(pDX, IDC_SECTION_RELOCATION_RELOCATES, m_btnRelocates);
|
| 86 |
|
|
DDX_Control(pDX, IDC_SECTION_RELOCATION_INITIAL_RELATIVE, m_btnInitialRelative);
|
| 87 |
|
|
DDX_Control(pDX, IDC_SECTION_RELOCATION_INITIAL_ABSOLUTE, m_btnInitialAbsolute);
|
| 88 |
|
|
DDX_Control(pDX, IDC_SECTION_RELOCATION_INITIAL_ABSOLUTE_ADDRESS, m_edtInitialAddress);
|
| 89 |
|
|
DDX_Control(pDX, IDC_SECTION_RELOCATION_INITIAL_RELATIVE_NAME, m_cboInitialRelativeName);
|
| 90 |
|
|
DDX_Check(pDX, IDC_SECTION_RELOCATION_RELOCATES, m_bRelocates);
|
| 91 |
|
|
DDX_CBString(pDX, IDC_SECTION_RELOCATION_INITIAL_RELATIVE_NAME, m_strInitialRelativeName);
|
| 92 |
|
|
DDX_Text(pDX, IDC_SECTION_RELOCATION_INITIAL_ABSOLUTE_ADDRESS, m_strInitialAddress);
|
| 93 |
|
|
//}}AFX_DATA_MAP
|
| 94 |
|
|
}
|
| 95 |
|
|
|
| 96 |
|
|
|
| 97 |
|
|
BEGIN_MESSAGE_MAP(CSectionRelocationPage, CeCosPropertyPage)
|
| 98 |
|
|
//{{AFX_MSG_MAP(CSectionRelocationPage)
|
| 99 |
|
|
ON_BN_CLICKED(IDC_SECTION_RELOCATION_RELOCATES, OnSectionRelocationRelocates)
|
| 100 |
|
|
ON_BN_CLICKED(IDC_SECTION_RELOCATION_INITIAL_RELATIVE, OnSectionRelocationInitialType)
|
| 101 |
|
|
ON_BN_CLICKED(IDC_SECTION_RELOCATION_INITIAL_ABSOLUTE, OnSectionRelocationInitialType)
|
| 102 |
|
|
//}}AFX_MSG_MAP
|
| 103 |
|
|
END_MESSAGE_MAP()
|
| 104 |
|
|
|
| 105 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
| 106 |
|
|
// CSectionRelocationPage message handlers
|
| 107 |
|
|
|
| 108 |
|
|
void CSectionRelocationPage::OnSectionRelocationRelocates()
|
| 109 |
|
|
{
|
| 110 |
|
|
OnSectionRelocationInitialType ();
|
| 111 |
|
|
}
|
| 112 |
|
|
|
| 113 |
|
|
|
| 114 |
|
|
void CSectionRelocationPage::OnSectionRelocationInitialType()
|
| 115 |
|
|
{
|
| 116 |
|
|
const BOOL bRelocates = m_btnRelocates.GetState() & 0x0003;
|
| 117 |
|
|
|
| 118 |
|
|
m_bInitialAbsolute = m_btnInitialAbsolute.GetState() & 0x0003;
|
| 119 |
|
|
|
| 120 |
|
|
m_btnInitialAbsolute.EnableWindow (bRelocates);
|
| 121 |
|
|
m_btnInitialRelative.EnableWindow (bRelocates && (m_cboInitialRelativeName.GetCount () > 0));
|
| 122 |
|
|
m_edtInitialAddress.EnableWindow (m_bInitialAbsolute && bRelocates);
|
| 123 |
|
|
m_cboInitialRelativeName.EnableWindow (bRelocates && ! m_bInitialAbsolute);
|
| 124 |
|
|
}
|
| 125 |
|
|
|
| 126 |
|
|
|
| 127 |
|
|
BOOL CSectionRelocationPage::OnInitDialog()
|
| 128 |
|
|
{
|
| 129 |
|
|
using namespace std;
|
| 130 |
|
|
CeCosPropertyPage::OnInitDialog();
|
| 131 |
|
|
|
| 132 |
|
|
m_btnInitialAbsolute.SetCheck (1);
|
| 133 |
|
|
|
| 134 |
|
|
mem_map * lpMemoryMap = & CConfigTool::GetConfigToolDoc()->MemoryMap;
|
| 135 |
|
|
|
| 136 |
|
|
// copy section names into the relative name combo box
|
| 137 |
|
|
|
| 138 |
|
|
for (list <mem_region>::iterator region = lpMemoryMap->region_list.begin (); region != lpMemoryMap->region_list.end (); ++region)
|
| 139 |
|
|
if (region->type == read_only) // initial location of relocating section must be in a read-only region
|
| 140 |
|
|
for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
|
| 141 |
|
|
if ((section_view->section != NULL) && (section_view->section_location != final_location) && // not the final location of a relocating section
|
| 142 |
|
|
((section_view->section->size !=0) || (section_view->section->linker_defined)) && // eliminate user-defined sections of unknown size
|
| 143 |
|
|
(m_bNewSection || (section_view->section->initial_location->following_section == NULL)) || // eliminate sections already used as initial anchors unless a new section
|
| 144 |
|
|
((section_view->section != NULL) && (!m_bInitialAbsolute) && (m_strInitialRelativeName == section_view->section->name.c_str()))) // or section name is the current initial relative name
|
| 145 |
|
|
m_cboInitialRelativeName.AddString (CString(section_view->section->name.c_str ()));
|
| 146 |
|
|
|
| 147 |
|
|
if (m_cboInitialRelativeName.GetCount () > 0) // there are anchor sections available
|
| 148 |
|
|
m_cboInitialRelativeName.SetCurSel (0); // select the first item in the combo box (if any)
|
| 149 |
|
|
else // there are no anchor sections available
|
| 150 |
|
|
m_btnInitialRelative.EnableWindow (FALSE); // disable the relative section radio button
|
| 151 |
|
|
|
| 152 |
|
|
m_btnRelocates.SetCheck (m_bRelocates);
|
| 153 |
|
|
m_btnInitialAbsolute.SetCheck (m_bInitialAbsolute);
|
| 154 |
|
|
m_btnInitialRelative.SetCheck (! m_bInitialAbsolute);
|
| 155 |
|
|
OnSectionRelocationRelocates ();
|
| 156 |
|
|
|
| 157 |
|
|
if ((! m_bInitialAbsolute) && (m_bRelocates))
|
| 158 |
|
|
m_cboInitialRelativeName.SetCurSel (m_cboInitialRelativeName.FindString (-1, m_strInitialRelativeName));
|
| 159 |
|
|
else if (m_cboInitialRelativeName.GetCount () > 0) // there are names in the combo box
|
| 160 |
|
|
m_cboInitialRelativeName.SetCurSel (0); // select the first name
|
| 161 |
|
|
else
|
| 162 |
|
|
m_btnInitialRelative.EnableWindow (FALSE); // disable the relative type radio button
|
| 163 |
|
|
|
| 164 |
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
| 165 |
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
| 166 |
|
|
}
|
| 167 |
|
|
|
| 168 |
|
|
|
| 169 |
|
|
BOOL CSectionRelocationPage::OnKillActive()
|
| 170 |
|
|
{
|
| 171 |
|
|
if (! UpdateData (TRUE))
|
| 172 |
|
|
return FALSE;
|
| 173 |
|
|
|
| 174 |
|
|
// convert address to a DWORD representation
|
| 175 |
|
|
|
| 176 |
|
|
if (m_bRelocates && m_bInitialAbsolute)
|
| 177 |
|
|
{
|
| 178 |
|
|
char lpszDummy [2];
|
| 179 |
|
|
if (_stscanf (m_strInitialAddress, _T("%lx%1s"), &m_dwInitialAddress, lpszDummy) != 1)
|
| 180 |
|
|
{
|
| 181 |
|
|
AfxMessageBox (IDS_VALIDATE_SECTION_START_ADDRESS);
|
| 182 |
|
|
m_edtInitialAddress.SetFocus ();
|
| 183 |
|
|
m_edtInitialAddress.SetSel (0, -1); // select all text
|
| 184 |
|
|
return FALSE;
|
| 185 |
|
|
}
|
| 186 |
|
|
}
|
| 187 |
|
|
|
| 188 |
|
|
return CeCosPropertyPage::OnKillActive();
|
| 189 |
|
|
}
|
| 190 |
|
|
|
| 191 |
|
|
|
| 192 |
|
|
BOOL CSectionRelocationPage::OnSetActive()
|
| 193 |
|
|
{
|
| 194 |
|
|
if (m_bRelocates && m_bInitialAbsolute)
|
| 195 |
|
|
m_strInitialAddress.Format (_T("%08lX"), m_dwInitialAddress);
|
| 196 |
|
|
else
|
| 197 |
|
|
m_strInitialAddress = _T("");
|
| 198 |
|
|
|
| 199 |
|
|
if (! UpdateData (FALSE))
|
| 200 |
|
|
return FALSE;
|
| 201 |
|
|
|
| 202 |
|
|
return CeCosPropertyPage::OnSetActive();
|
| 203 |
|
|
}
|
| 204 |
|
|
|