process.hh (2665:a124942bacb8) process.hh (2680:246e7104f744)
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 33 unchanged lines hidden (view full) ---

42#if !FULL_SYSTEM
43
44#include <vector>
45
46#include "base/statistics.hh"
47#include "sim/sim_object.hh"
48
49class CPUExecContext;
1/*
2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 33 unchanged lines hidden (view full) ---

42#if !FULL_SYSTEM
43
44#include <vector>
45
46#include "base/statistics.hh"
47#include "sim/sim_object.hh"
48
49class CPUExecContext;
50class ExecContext;
50class ThreadContext;
51class SyscallDesc;
52class PageTable;
53class TranslatingPort;
54class System;
55
56void
57copyStringArray(std::vector<std::string> &strings, Addr array_ptr,
58 Addr data_ptr, TranslatingPort* memPort);
59
60class Process : public SimObject
61{
62 public:
63
64 /// Pointer to object representing the system this process is
65 /// running on.
66 System *system;
67
51class SyscallDesc;
52class PageTable;
53class TranslatingPort;
54class System;
55
56void
57copyStringArray(std::vector<std::string> &strings, Addr array_ptr,
58 Addr data_ptr, TranslatingPort* memPort);
59
60class Process : public SimObject
61{
62 public:
63
64 /// Pointer to object representing the system this process is
65 /// running on.
66 System *system;
67
68 // have we initialized an execution context from this process? If
68 // have we initialized a thread context from this process? If
69 // yes, subsequent contexts are assumed to be for dynamically
70 // created threads and are not initialized.
71 bool initialContextLoaded;
72
69 // yes, subsequent contexts are assumed to be for dynamically
70 // created threads and are not initialized.
71 bool initialContextLoaded;
72
73 // execution contexts associated with this process
74 std::vector<ExecContext *> execContexts;
73 // thread contexts associated with this process
74 std::vector<ThreadContext *> threadContexts;
75
76 // number of CPUs (esxec contexts, really) assigned to this process.
75
76 // number of CPUs (esxec contexts, really) assigned to this process.
77 unsigned int numCpus() { return execContexts.size(); }
77 unsigned int numCpus() { return threadContexts.size(); }
78
79 // record of blocked context
80 struct WaitRec
81 {
82 Addr waitChan;
78
79 // record of blocked context
80 struct WaitRec
81 {
82 Addr waitChan;
83 ExecContext *waitingContext;
83 ThreadContext *waitingContext;
84
84
85 WaitRec(Addr chan, ExecContext *ctx)
85 WaitRec(Addr chan, ThreadContext *ctx)
86 : waitChan(chan), waitingContext(ctx)
87 { }
88 };
89
90 // list of all blocked contexts
91 std::list<WaitRec> waitList;
92
93 Addr brk_point; // top of the data segment

--- 44 unchanged lines hidden (view full) ---

138 public:
139 // static helper functions to generate file descriptors for constructor
140 static int openInputFile(const std::string &filename);
141 static int openOutputFile(const std::string &filename);
142
143 // override of virtual SimObject method: register statistics
144 virtual void regStats();
145
86 : waitChan(chan), waitingContext(ctx)
87 { }
88 };
89
90 // list of all blocked contexts
91 std::list<WaitRec> waitList;
92
93 Addr brk_point; // top of the data segment

--- 44 unchanged lines hidden (view full) ---

138 public:
139 // static helper functions to generate file descriptors for constructor
140 static int openInputFile(const std::string &filename);
141 static int openOutputFile(const std::string &filename);
142
143 // override of virtual SimObject method: register statistics
144 virtual void regStats();
145
146 // register an execution context for this process.
147 // returns xc's cpu number (index into execContexts[])
148 int registerExecContext(ExecContext *xc);
146 // register a thread context for this process.
147 // returns tc's cpu number (index into threadContexts[])
148 int registerThreadContext(ThreadContext *tc);
149
150
149
150
151 void replaceExecContext(ExecContext *xc, int xcIndex);
151 void replaceThreadContext(ThreadContext *tc, int tcIndex);
152
153 // map simulator fd sim_fd to target fd tgt_fd
154 void dup_fd(int sim_fd, int tgt_fd);
155
156 // generate new target fd for sim_fd
157 int alloc_fd(int sim_fd);
158
159 // free target fd (e.g., after close)
160 void free_fd(int tgt_fd);
161
162 // look up simulator fd for given target fd
163 int sim_fd(int tgt_fd);
164
152
153 // map simulator fd sim_fd to target fd tgt_fd
154 void dup_fd(int sim_fd, int tgt_fd);
155
156 // generate new target fd for sim_fd
157 int alloc_fd(int sim_fd);
158
159 // free target fd (e.g., after close)
160 void free_fd(int tgt_fd);
161
162 // look up simulator fd for given target fd
163 int sim_fd(int tgt_fd);
164
165 virtual void syscall(int64_t callnum, ExecContext *xc) = 0;
165 virtual void syscall(int64_t callnum, ThreadContext *tc) = 0;
166};
167
168//
169// "Live" process with system calls redirected to host system
170//
171class ObjectFile;
172class LiveProcess : public Process
173{

--- 5 unchanged lines hidden (view full) ---

179 LiveProcess(const std::string &nm, ObjectFile *objFile,
180 System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
181 std::vector<std::string> &argv,
182 std::vector<std::string> &envp);
183
184 virtual void argsInit(int intSize, int pageSize);
185
186 public:
166};
167
168//
169// "Live" process with system calls redirected to host system
170//
171class ObjectFile;
172class LiveProcess : public Process
173{

--- 5 unchanged lines hidden (view full) ---

179 LiveProcess(const std::string &nm, ObjectFile *objFile,
180 System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
181 std::vector<std::string> &argv,
182 std::vector<std::string> &envp);
183
184 virtual void argsInit(int intSize, int pageSize);
185
186 public:
187 virtual void syscall(int64_t callnum, ExecContext *xc);
187 virtual void syscall(int64_t callnum, ThreadContext *tc);
188
189 virtual SyscallDesc* getDesc(int callnum) = 0;
190};
191
192
193#endif // !FULL_SYSTEM
194
195#endif // __PROCESS_HH__
188
189 virtual SyscallDesc* getDesc(int callnum) = 0;
190};
191
192
193#endif // !FULL_SYSTEM
194
195#endif // __PROCESS_HH__