forked from chipsalliance/VeeR-ISS
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSession.hpp
118 lines (88 loc) · 3.98 KB
/
Session.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright 2020 Western Digital Corporation or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Copyright 2024 Tenstorrent Corporation or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <memory> // For shared_ptr
#include "System.hpp"
#include "Args.hpp"
namespace WdRiscv
{
/// Manage a whisper session.
template <typename URV>
class Session
{
public:
Session();
std::shared_ptr<System<URV>>
defineSystem(const Args& args, const HartConfig& config);
bool configureSystem(const Args& args, const HartConfig& config);
bool run(const Args& args);
bool cleanup(const Args& args);
/// Obtain integer-register width (xlen). Command line has top priority, then config
/// file, then ELF file.
static
unsigned determineRegisterWidth(const Args& args, const HartConfig& config);
protected:
bool getPrimaryConfigParameters(const Args& args, const HartConfig& config,
unsigned& hartsPerCore, unsigned& coreCount,
size_t& pageSize, size_t& memorySize);
/// Santize memory parameters. Page/region sizes must be greater and equal to 4 and
/// must be powers of 2. Region size must be a multiple of page size. Memory size
/// must be a multiple of region size. Return true if given parameters are
/// good. False if any parameters is changed to meet expectation.
bool checkAndRepairMemoryParams(size_t& memSize, size_t& pageSize);
/// Open the trace-file, command-log and console-output files specified on the command
/// line. Return true if successful or false if any specified file fails to open.
bool openUserFiles(const Args& args);
/// Close files opened by openUserFiles.
void closeUserFiles();
/// Check if running an app linked with newlib/linuux CLIB.
void checkForNewlibOrLinux(const Args& args, bool& newlib, bool& linux);
/// Check if running an app that uses openMp.
bool checkForOpenMp(const Args& args);
bool determineIsa(const HartConfig& config, const Args& args, bool clib,
std::string& isa);
bool getElfFilesIsaString(const Args& args, std::string& isaString);
bool applyCmdLineArgs(const Args& args, Hart<URV>& hart, const HartConfig& config,
bool clib);
/// Open a server socket and put opened socket information (hostname and port number)
/// in the given server file. Wait for one connection. Service connection. Return true
/// on success and false on failure.
bool runServer(const std::string& serverFile);
/// Open a shared memory region and write name to given server file. Return true on
/// success and false on failure.
bool runServerShm(const std::string& serverFile);
bool runInteractive();
private:
std::vector<FILE*> traceFiles_;
FILE* commandLog_ = nullptr;
FILE* consoleOut_ = nullptr;
FILE* bblockFile_ = nullptr;
FILE* initStateFile_ = nullptr;
bool doGzip_ = false;
std::shared_ptr<System<URV>> system_;
};
}