113883Sdavid.hashe@amd.com/*
213883Sdavid.hashe@amd.com * Copyright (c) 2015 Advanced Micro Devices, Inc.
313883Sdavid.hashe@amd.com * All rights reserved.
413883Sdavid.hashe@amd.com *
513883Sdavid.hashe@amd.com * Redistribution and use in source and binary forms, with or without
613883Sdavid.hashe@amd.com * modification, are permitted provided that the following conditions are
713883Sdavid.hashe@amd.com * met: redistributions of source code must retain the above copyright
813883Sdavid.hashe@amd.com * notice, this list of conditions and the following disclaimer;
913883Sdavid.hashe@amd.com * redistributions in binary form must reproduce the above copyright
1013883Sdavid.hashe@amd.com * notice, this list of conditions and the following disclaimer in the
1113883Sdavid.hashe@amd.com * documentation and/or other materials provided with the distribution;
1213883Sdavid.hashe@amd.com * neither the name of the copyright holders nor the names of its
1313883Sdavid.hashe@amd.com * contributors may be used to endorse or promote products derived from
1413883Sdavid.hashe@amd.com * this software without specific prior written permission.
1513883Sdavid.hashe@amd.com *
1613883Sdavid.hashe@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1713883Sdavid.hashe@amd.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1813883Sdavid.hashe@amd.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1913883Sdavid.hashe@amd.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2013883Sdavid.hashe@amd.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2113883Sdavid.hashe@amd.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2213883Sdavid.hashe@amd.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2313883Sdavid.hashe@amd.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2413883Sdavid.hashe@amd.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2513883Sdavid.hashe@amd.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2613883Sdavid.hashe@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2713883Sdavid.hashe@amd.com *
2813883Sdavid.hashe@amd.com * Authors: David Hashe
2913883Sdavid.hashe@amd.com */
3013883Sdavid.hashe@amd.com
3113883Sdavid.hashe@amd.com#ifndef __SIM_REDIRECT_PATH_HH__
3213883Sdavid.hashe@amd.com#define __SIM_REDIRECT_PATH_HH__
3313883Sdavid.hashe@amd.com
3413883Sdavid.hashe@amd.com#include <string>
3513883Sdavid.hashe@amd.com#include <vector>
3613883Sdavid.hashe@amd.com
3713883Sdavid.hashe@amd.com#include "params/RedirectPath.hh"
3813883Sdavid.hashe@amd.com#include "sim/sim_object.hh"
3913883Sdavid.hashe@amd.com
4013883Sdavid.hashe@amd.com/**
4113883Sdavid.hashe@amd.com * RedirectPath stores a mapping from one 'appPath' to a vector of
4213883Sdavid.hashe@amd.com * 'hostPath'. Each 'appPath' and 'hostPath' is a filesystem path.
4313883Sdavid.hashe@amd.com * Used by process.cc to redirect syscall accesses to different directories.
4413883Sdavid.hashe@amd.com */
4513883Sdavid.hashe@amd.comclass RedirectPath : public SimObject
4613883Sdavid.hashe@amd.com{
4713883Sdavid.hashe@amd.com  public:
4813883Sdavid.hashe@amd.com    RedirectPath(const RedirectPathParams *p);
4913883Sdavid.hashe@amd.com
5013883Sdavid.hashe@amd.com    const std::string& appPath() { return _appPath; };
5113883Sdavid.hashe@amd.com    const std::vector<std::string>& hostPaths() { return _hostPaths; };
5213883Sdavid.hashe@amd.com
5313883Sdavid.hashe@amd.com  protected:
5413883Sdavid.hashe@amd.com    /**
5513883Sdavid.hashe@amd.com     * An appPath is a path which needs to be redirected and replaced
5613883Sdavid.hashe@amd.com     * by one of the corresponding hostPath (when accessing files on the host
5713883Sdavid.hashe@amd.com     * filesystem.)
5813883Sdavid.hashe@amd.com     */
5913883Sdavid.hashe@amd.com     // _appPath holds the path as it would appear from an app's perspective.
6013883Sdavid.hashe@amd.com    std::string _appPath;
6113883Sdavid.hashe@amd.com     // _hostPaths holds a set of host filesystem paths
6213883Sdavid.hashe@amd.com    std::vector<std::string> _hostPaths;
6313883Sdavid.hashe@amd.com};
6413883Sdavid.hashe@amd.com
6513883Sdavid.hashe@amd.com#endif
66