source: soft/giet_vm/memo/src/pseg_handler.cpp @ 644

Last change on this file since 644 was 238, checked in by alain, 11 years ago

Major evolution to support physical addresses larger than 32 bits.
The map.xml format has been modified: the vsegs associated to schedulers
are now explicitely defined and mapped in the page tables.

File size: 2.7 KB
RevLine 
[163]1/* -*- c++ -*-
2 *
[238]3 * GIET_VM_LGPL_HEADER_BEGIN
[163]4 *
[238]5 * This file is part of GIET_VM, GNU LGPLv2.1.
[163]6 *
[238]7 * GIET_VM is free software; you can redistribute it and/or modify it
[163]8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; version 2.1 of the License.
10 *
[238]11 * GIET_VM is distributed in the hope that it will be useful, but
[163]12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
[238]17 * License along with GIET_VM; if not, write to the Free Software
[163]18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
[238]21 * GIET_VM_LGPL_HEADER_END
[163]22 *
23 * Copyright (c) UPMC, Lip6, SoC
24 *         Mohamed Lamine Karaoui <Mohamed.Karaoui@lip6.fr>, 2012
25 */
26
27#include <algorithm>
28#include <string.h>
29#include <cassert>
30#include <cstring>
31#include <stdexcept>
32
33#include <iostream>
34#include <iomanip>
35
36#include "pseg_handler.h"
37#include "exception.h"
38
39/*
40 * PSegHandler
41 */
42
[238]43/////////////////////////////////////
[163]44PSeg& PSegHandler::get( size_t pos  )
45{
46    try
47    {
48        return m_pSegs.at( pos );
49
50    }catch (std::out_of_range& oor) {
51        std::cerr << "PSeg "<< pos <<"(id) is missing" << std::endl;
52    }
53    exit(1);
54}
55
[238]56//////////////////////////////////////////////////////////////
[163]57const PSeg& PSegHandler::getByAddr(uintptr_t segAddress) const
58{
59    std::vector<PSeg>::const_iterator it ;
60    for(it = m_pSegs.begin(); it < m_pSegs.end(); it++)
61    {
[238]62        paddr_t lma = (*it).lma();
[163]63        if( lma == segAddress )
64            return *it;
65    }
66
67    std::cerr << "Unfound Physical segment: " 
68              << std::hex << std::showbase
69              << segAddress << std::endl;
70    exit(1);
71}
72
[238]73///////////////////////////////
[163]74void PSegHandler::check() const
75{
76    std::vector<PSeg>::const_iterator it ;
77    for(it = m_pSegs.begin(); it < m_pSegs.end(); it++)
78    {
79        (*it).check();
80    }
81}
82
83void PSegHandler::print( std::ostream &o ) const
84{
85    o << std::dec ; 
86        o << "< " << m_pSegs.size() <<  " Segments (page size = " << PSeg::pageSize() << ") :"<< std::endl;
87    std::vector<PSeg>::const_iterator it ;
88    for(it = m_pSegs.begin(); it < m_pSegs.end(); it++)
89        o << *it << std::endl;
90    o << ">";
91}
92
93PSegHandler::~PSegHandler()
94{
95//    std::cout << "Deleted PSegHandler " << *this << std::endl;
96}
97
98PSegHandler::PSegHandler()
99{
100    //std::cout << "New empty PSegHandler " << *this << std::endl;
101}
102
103
104// Local Variables:
105// tab-width: 4
106// c-basic-offset: 4
107// c-file-offsets:((innamespace . 0)(inline-open . 0))
108// indent-tabs-mode: nil
109// End:
110
111// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
112
Note: See TracBrowser for help on using the repository browser.