fs_translating_port_proxy.hh revision 14009:a4b36ce75361
112239Sandreas.sandberg@arm.com/*
212239Sandreas.sandberg@arm.com * Copyright (c) 2011 ARM Limited
312239Sandreas.sandberg@arm.com * All rights reserved
412239Sandreas.sandberg@arm.com *
512239Sandreas.sandberg@arm.com * The license below extends only to copyright in the software and shall
612239Sandreas.sandberg@arm.com * not be construed as granting a license to any other intellectual
712239Sandreas.sandberg@arm.com * property including but not limited to intellectual property relating
812239Sandreas.sandberg@arm.com * to a hardware implementation of the functionality of the software
912239Sandreas.sandberg@arm.com * licensed hereunder.  You may use the software subject to the license
1012239Sandreas.sandberg@arm.com * terms below provided that you ensure that this notice is replicated
1112239Sandreas.sandberg@arm.com * unmodified and in its entirety in all distributions of the software,
1212239Sandreas.sandberg@arm.com * modified or unmodified, in source code or in binary form.
1312239Sandreas.sandberg@arm.com *
1412239Sandreas.sandberg@arm.com * Copyright (c) 2006 The Regents of The University of Michigan
1512239Sandreas.sandberg@arm.com * All rights reserved.
1612239Sandreas.sandberg@arm.com *
1712239Sandreas.sandberg@arm.com * Redistribution and use in source and binary forms, with or without
1812239Sandreas.sandberg@arm.com * modification, are permitted provided that the following conditions are
1912239Sandreas.sandberg@arm.com * met: redistributions of source code must retain the above copyright
2012239Sandreas.sandberg@arm.com * notice, this list of conditions and the following disclaimer;
2112239Sandreas.sandberg@arm.com * redistributions in binary form must reproduce the above copyright
2212239Sandreas.sandberg@arm.com * notice, this list of conditions and the following disclaimer in the
2312239Sandreas.sandberg@arm.com * documentation and/or other materials provided with the distribution;
2412239Sandreas.sandberg@arm.com * neither the name of the copyright holders nor the names of its
2512239Sandreas.sandberg@arm.com * contributors may be used to endorse or promote products derived from
2612239Sandreas.sandberg@arm.com * this software without specific prior written permission.
2712239Sandreas.sandberg@arm.com *
2812239Sandreas.sandberg@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2912239Sandreas.sandberg@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3012239Sandreas.sandberg@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3112239Sandreas.sandberg@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3212239Sandreas.sandberg@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3312239Sandreas.sandberg@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3412239Sandreas.sandberg@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3512239Sandreas.sandberg@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3612239Sandreas.sandberg@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3712239Sandreas.sandberg@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3812239Sandreas.sandberg@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3912239Sandreas.sandberg@arm.com *
4012239Sandreas.sandberg@arm.com * Authors: Ali Saidi
4112239Sandreas.sandberg@arm.com *          Andreas Hansson
4212239Sandreas.sandberg@arm.com */
4312239Sandreas.sandberg@arm.com
4412239Sandreas.sandberg@arm.com/**
4512239Sandreas.sandberg@arm.com * @file
4612239Sandreas.sandberg@arm.com * TranslatingPortProxy Object Declaration for FS.
4712239Sandreas.sandberg@arm.com *
4812239Sandreas.sandberg@arm.com * Port proxies are used when non structural entities need access to
4912239Sandreas.sandberg@arm.com * the memory system. Proxy objects replace the previous
5012239Sandreas.sandberg@arm.com * FunctionalPort, TranslatingPort and VirtualPort objects, which
5112239Sandreas.sandberg@arm.com * provided the same functionality as the proxies, but were instances
5212239Sandreas.sandberg@arm.com * of ports not corresponding to real structural ports of the
5312239Sandreas.sandberg@arm.com * simulated system. Via the port proxies all the accesses go through
5412239Sandreas.sandberg@arm.com * an actual port and thus are transparent to a potentially
5512239Sandreas.sandberg@arm.com * distributed memory and automatically adhere to the memory map of
5612239Sandreas.sandberg@arm.com * the system.
5712239Sandreas.sandberg@arm.com */
5812239Sandreas.sandberg@arm.com
5912239Sandreas.sandberg@arm.com#ifndef __MEM_FS_TRANSLATING_PORT_PROXY_HH__
6012239Sandreas.sandberg@arm.com#define __MEM_FS_TRANSLATING_PORT_PROXY_HH__
6112239Sandreas.sandberg@arm.com
6212239Sandreas.sandberg@arm.com#include "mem/port_proxy.hh"
6312239Sandreas.sandberg@arm.com
6412239Sandreas.sandberg@arm.comclass ThreadContext;
6512239Sandreas.sandberg@arm.com
6612239Sandreas.sandberg@arm.com/**
6712239Sandreas.sandberg@arm.com * A TranslatingPortProxy in FS mode translates a virtual address to a
6812239Sandreas.sandberg@arm.com * physical address and then calls the read/write functions of the
6912239Sandreas.sandberg@arm.com * port. If a thread context is provided the address can alway be
7012239Sandreas.sandberg@arm.com * translated, If not it can only be translated if it is a simple
7112239Sandreas.sandberg@arm.com * address masking operation (such as alpha super page accesses).
7212239Sandreas.sandberg@arm.com */
7312239Sandreas.sandberg@arm.comclass FSTranslatingPortProxy : public PortProxy
7412239Sandreas.sandberg@arm.com{
7512239Sandreas.sandberg@arm.com  private:
7612239Sandreas.sandberg@arm.com    ThreadContext* _tc;
7712239Sandreas.sandberg@arm.com
7812239Sandreas.sandberg@arm.com  public:
7912239Sandreas.sandberg@arm.com
8012239Sandreas.sandberg@arm.com    FSTranslatingPortProxy(ThreadContext* tc);
8112239Sandreas.sandberg@arm.com
8212239Sandreas.sandberg@arm.com    FSTranslatingPortProxy(MasterPort &port, unsigned int cacheLineSize);
8312239Sandreas.sandberg@arm.com
8412239Sandreas.sandberg@arm.com    ~FSTranslatingPortProxy() {}
8512239Sandreas.sandberg@arm.com
8612239Sandreas.sandberg@arm.com    /** Version of tryReadblob that translates virt->phys and deals
8712239Sandreas.sandberg@arm.com      * with page boundries. */
8812239Sandreas.sandberg@arm.com    bool tryReadBlob(Addr addr, void *p, int size) const override;
8912239Sandreas.sandberg@arm.com
9012239Sandreas.sandberg@arm.com    /** Version of tryWriteBlob that translates virt->phys and deals
9112239Sandreas.sandberg@arm.com      * with page boundries. */
9212239Sandreas.sandberg@arm.com    bool tryWriteBlob(Addr addr, const void *p, int size) const override;
9312239Sandreas.sandberg@arm.com
9412239Sandreas.sandberg@arm.com    /**
9512239Sandreas.sandberg@arm.com     * Fill size bytes starting at addr with byte value val.
9612239Sandreas.sandberg@arm.com     */
9712239Sandreas.sandberg@arm.com    bool tryMemsetBlob(Addr address, uint8_t  v, int size) const override;
9812239Sandreas.sandberg@arm.com};
9912239Sandreas.sandberg@arm.com
10012239Sandreas.sandberg@arm.comvoid CopyOut(ThreadContext *tc, void *dest, Addr src, size_t cplen);
10112239Sandreas.sandberg@arm.comvoid CopyIn(ThreadContext *tc, Addr dest, const void *source, size_t cplen);
10212239Sandreas.sandberg@arm.comvoid CopyStringOut(ThreadContext *tc, char *dst, Addr vaddr, size_t maxlen);
10312239Sandreas.sandberg@arm.comvoid CopyStringIn(ThreadContext *tc, const char *src, Addr vaddr);
10412239Sandreas.sandberg@arm.com
10512239Sandreas.sandberg@arm.com#endif //__MEM_FS_TRANSLATING_PORT_PROXY_HH__
10612239Sandreas.sandberg@arm.com