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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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