page_table.hh revision 2665
12379SN/A/*
22379SN/A * Copyright (c) 2003 The Regents of The University of Michigan
32379SN/A * All rights reserved.
42379SN/A *
52379SN/A * Redistribution and use in source and binary forms, with or without
62379SN/A * modification, are permitted provided that the following conditions are
72379SN/A * met: redistributions of source code must retain the above copyright
82379SN/A * notice, this list of conditions and the following disclaimer;
92379SN/A * redistributions in binary form must reproduce the above copyright
102379SN/A * notice, this list of conditions and the following disclaimer in the
112379SN/A * documentation and/or other materials provided with the distribution;
122379SN/A * neither the name of the copyright holders nor the names of its
132379SN/A * contributors may be used to endorse or promote products derived from
142379SN/A * this software without specific prior written permission.
152379SN/A *
162379SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172379SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182379SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192379SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202379SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212379SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222379SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232379SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242379SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252379SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262379SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
292379SN/A */
302379SN/A
312379SN/A/**
322379SN/A * @file
332379SN/A * Declaration of a non-full system Page Table.
342379SN/A */
352379SN/A
362379SN/A#ifndef __PAGE_TABLE__
372379SN/A#define __PAGE_TABLE__
382379SN/A
392379SN/A#include <string>
402379SN/A#include <map>
412379SN/A
422423SN/A#include "arch/isa_traits.hh"
432379SN/A#include "base/trace.hh"
442394SN/A#include "mem/request.hh"
452394SN/A#include "mem/packet.hh"
462379SN/A#include "sim/sim_object.hh"
472379SN/A
482399SN/Aclass System;
492379SN/A
502379SN/A/**
512379SN/A * Page Table Decleration.
522379SN/A */
532399SN/Aclass PageTable
542379SN/A{
552379SN/A  protected:
562379SN/A    std::map<Addr,Addr> pTable;
572379SN/A
582399SN/A    const Addr pageSize;
592399SN/A    const Addr offsetMask;
602399SN/A
612399SN/A    System *system;
622379SN/A
632379SN/A  public:
642379SN/A
652423SN/A    PageTable(System *_system, Addr _pageSize = TheISA::VMPageSize);
662379SN/A
672379SN/A    ~PageTable();
682379SN/A
692399SN/A    Addr pageAlign(Addr a)  { return (a & ~offsetMask); }
702399SN/A    Addr pageOffset(Addr a) { return (a &  offsetMask); }
712379SN/A
722537SN/A    Fault page_check(Addr addr, int size) const;
732379SN/A
742399SN/A    void allocate(Addr vaddr, int size);
752399SN/A
762379SN/A    /**
772379SN/A     * Translate function
782379SN/A     * @param vaddr The virtual address.
792379SN/A     * @return Physical address from translation.
802379SN/A     */
812399SN/A    bool translate(Addr vaddr, Addr &paddr);
822379SN/A
832379SN/A    /**
842399SN/A     * Perform a translation on the memory request, fills in paddr
852399SN/A     * field of mem_req.
862379SN/A     * @param req The memory request.
872379SN/A     */
882532SN/A    Fault translate(RequestPtr &req);
892379SN/A
902379SN/A};
912379SN/A
922379SN/A#endif
93