page_table.hh revision 2665
12381SN/A/*
22592SN/A * Copyright (c) 2003 The Regents of The University of Michigan
37465Ssteve.reinhardt@amd.com * All rights reserved.
42381SN/A *
52381SN/A * Redistribution and use in source and binary forms, with or without
62381SN/A * modification, are permitted provided that the following conditions are
72381SN/A * met: redistributions of source code must retain the above copyright
82381SN/A * notice, this list of conditions and the following disclaimer;
92381SN/A * redistributions in binary form must reproduce the above copyright
102381SN/A * notice, this list of conditions and the following disclaimer in the
112381SN/A * documentation and/or other materials provided with the distribution;
122381SN/A * neither the name of the copyright holders nor the names of its
132381SN/A * contributors may be used to endorse or promote products derived from
142381SN/A * this software without specific prior written permission.
152381SN/A *
162381SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272381SN/A *
282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
292665Ssaidi@eecs.umich.edu */
302665Ssaidi@eecs.umich.edu
312665Ssaidi@eecs.umich.edu/**
322381SN/A * @file
332381SN/A * Declaration of a non-full system Page Table.
342381SN/A */
352381SN/A
362662Sstever@eecs.umich.edu#ifndef __PAGE_TABLE__
372381SN/A#define __PAGE_TABLE__
382381SN/A
392381SN/A#include <string>
402381SN/A#include <map>
412381SN/A
423348Sbinkertn@umich.edu#include "arch/isa_traits.hh"
433348Sbinkertn@umich.edu#include "base/trace.hh"
444022Sstever@eecs.umich.edu#include "mem/request.hh"
453348Sbinkertn@umich.edu#include "mem/packet.hh"
465735Snate@binkert.org#include "sim/sim_object.hh"
474024Sbinkertn@umich.edu
484610Ssaidi@eecs.umich.educlass System;
495735Snate@binkert.org
503940Ssaidi@eecs.umich.edu/**
515314Sstever@gmail.com * Page Table Decleration.
526216Snate@binkert.org */
532392SN/Aclass PageTable
544167Sbinkertn@umich.edu{
552394SN/A  protected:
562394SN/A    std::map<Addr,Addr> pTable;
573349Sbinkertn@umich.edu
582394SN/A    const Addr pageSize;
592812Srdreslin@umich.edu    const Addr offsetMask;
602812Srdreslin@umich.edu
614022Sstever@eecs.umich.edu    System *system;
624022Sstever@eecs.umich.edu
635735Snate@binkert.org  public:
645735Snate@binkert.org
654022Sstever@eecs.umich.edu    PageTable(System *_system, Addr _pageSize = TheISA::VMPageSize);
665735Snate@binkert.org
675735Snate@binkert.org    ~PageTable();
685735Snate@binkert.org
694022Sstever@eecs.umich.edu    Addr pageAlign(Addr a)  { return (a & ~offsetMask); }
704022Sstever@eecs.umich.edu    Addr pageOffset(Addr a) { return (a &  offsetMask); }
714022Sstever@eecs.umich.edu
724022Sstever@eecs.umich.edu    Fault page_check(Addr addr, int size) const;
734473Sstever@eecs.umich.edu
745319Sstever@gmail.com    void allocate(Addr vaddr, int size);
754022Sstever@eecs.umich.edu
764022Sstever@eecs.umich.edu    /**
774022Sstever@eecs.umich.edu     * Translate function
784022Sstever@eecs.umich.edu     * @param vaddr The virtual address.
794022Sstever@eecs.umich.edu     * @return Physical address from translation.
804022Sstever@eecs.umich.edu     */
814022Sstever@eecs.umich.edu    bool translate(Addr vaddr, Addr &paddr);
824022Sstever@eecs.umich.edu
834022Sstever@eecs.umich.edu    /**
844022Sstever@eecs.umich.edu     * Perform a translation on the memory request, fills in paddr
857465Ssteve.reinhardt@amd.com     * field of mem_req.
864628Sstever@eecs.umich.edu     * @param req The memory request.
877465Ssteve.reinhardt@amd.com     */
887465Ssteve.reinhardt@amd.com    Fault translate(RequestPtr &req);
894022Sstever@eecs.umich.edu
904022Sstever@eecs.umich.edu};
914626Sstever@eecs.umich.edu
924626Sstever@eecs.umich.edu#endif
934626Sstever@eecs.umich.edu