18#include <FreeNOS/System.h>
48 ERROR(
"failed to retrieve ProcessInfo for PID " << msg->
pid <<
49 ": result = " << (
int)result);
60 ERROR(
"failed to stop PID " << msg->
pid <<
61 ": result = " << (
int) result);
74 ERROR(
"failed to read command string from PID " << msg->
pid <<
75 ": result = " << (
int) result);
79 cmd[
sizeof(cmd) - 1] = 0;
83 if (progpath.count() == 0)
85 ERROR(
"failed to find program path for PID " << msg->
pid);
93 ERROR(
"failed to reload PID " << msg->
pid <<
94 " from " << *progpath[0] <<
95 ": result = " << (
int) result);
104 ERROR(
"failed to resume PID " << msg->
pid <<
105 ": result = " << (
int) result);
115 const char *path)
const
121 DEBUG(
"pid = " << pid <<
" path = " << path);
127 ERROR(
"failed to statFile() for " << path <<
": result = " << (
int) statResult);
142 ERROR(
"failed to map compressed memory: result = " << (
int) mapResult);
150 ERROR(
"failed to openFile() for " << path <<
151 ": result = " << (
int) openResult);
161 ERROR(
"failed to readFile() for " << path <<
162 ": result = " << (
int) readResult <<
", num = " << num);
171 ERROR(
"failed to closeFile() for " << path <<
172 ": result = " << (
int) closeResult);
182 ERROR(
"failed to initialize LZ4 decompressor: result = " << (
int) lz4Result);
198 ERROR(
"failed to map uncompressed memory: result = " << (
int) mapResult);
207 ERROR(
"failed to decompress file: result = " << (
int) lz4Result);
216 ERROR(
"failed to cleanup program data for PID " << pid);
225 ERROR(
"failed to reset data for PID " << pid);
235 DEBUG(
"failed to release compressed memory: result = " << (
int) releaseResult);
243 DEBUG(
"failed to release uncompressed memory: result = " << (
int) releaseResult);
256 DEBUG(
"pid = " << pid);
262 ERROR(
"failed to release UserData region in PID " << pid <<
263 ": result = " << (
int) dataResult);
271 ERROR(
"failed to release UserHeap region in PID " << pid <<
272 ": result = " << (
int) heapResult);
280 ERROR(
"failed to release UserPrivate region in PID " << pid <<
281 ": result = " << (
int) privResult);
290 const Size size)
const
296 Size numRegions = 16;
299 DEBUG(
"pid = " << pid <<
" program = " << (
void *) program <<
" size = " << size);
307 ERROR(
"failed to parse executable: result = " << (
int) execResult);
315 ERROR(
"failed to retrieve entry point: result = " << (
int) entryResult);
324 ERROR(
"failed to retrieve regions: result = " << (
int) regionResult);
333 for (
Size i = 0; i < numRegions; i++)
345 ERROR(
"failed to map " << (
void *) regions[i].virt <<
346 " in PID " << pid <<
": result = " << (
int) mapResult);
355 ERROR(
"failed to map " << (
void *) regions[i].virt <<
356 ": result = " << (
int) selfResult);
365 if (regions[i].memorySize > regions[i].dataSize)
375 ERROR(
"failed to unmap " << (
void *) regions[i].virt <<
376 ": result = " << (
int) unmapResult);
385 ERROR(
"failed to reset PID " << pid <<
386 ": result = " << (
int) resetResult);
Result
Enumeration of generic kernel API result codes.
Memory mapping for the kernel and user processes on the ARM architecture.
Template class which serves incoming messages from Channels using MessageHandlers.
void addIPCHandler(const Size slot, IPCHandlerFunction h, const bool sendReply=true)
Register a new IPC message action handler.
FileSystemClient provides a simple interface to a FileSystemServer.
FileSystem::Result closeFile(const Size descriptor) const
Close a file.
FileSystem::Result statFile(const char *path, FileSystem::FileStat *st) const
Retrieve status of a file.
FileSystem::Result readFile(const Size descriptor, void *buf, Size *size) const
Read a file.
FileSystem::Result openFile(const char *path, Size &descriptor) const
Open a file.
Simple linked list template class.
Decompress data using the LZ4 algorithm created by Yann Collet.
Result initialize()
Initialize the decompressor.
u64 getUncompressedSize() const
Get size of the uncompressed data.
Result read(void *buffer, const Size size) const
Reads compressed data.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
@ UserData
< User program data from libexec, e.g.
@ UserArgs
< Used for copying program arguments and file descriptors
@ UserPrivate
< User private dynamic memory mappings
Memory::Range range(Region region) const
Get memory range for the given region.
bool rewriteProgram(const ProcessID pid, const Address program, const Size size) const
Overwrite process with given program data.
void restartProcess(RecoveryMessage *msg)
Restart a process.
bool cleanupProgram(const ProcessID pid) const
Release and unmap program data.
RecoveryServer()
Class constructor function.
bool reloadProgram(const ProcessID pid, const char *path) const
Overwrite the given process by fetching a fresh program data copy.
List< String > split(const char delimiter) const
Split the String into parts separated by a delimiter.
#define MAX_PROCS
Maximum number of processes.
API::Result VMCopy(const ProcessID proc, const API::Operation how, const Address ours, const Address theirs, const Size sz)
Prototype for user applications.
API::Result ProcessCtl(const ProcessID proc, const ProcessOperation op, const Address addr=0, const Address output=0)
Prototype for user applications.
API::Result VMCtl(const ProcessID procID, const MemoryOperation op, Memory::Range *range=ZERO)
Prototype for user applications.
u32 ProcessID
Process Identification Number.
unsigned long Address
A memory address.
#define ERROR(msg)
Output an error message.
unsigned int Size
Any sane size indicator cannot go negative.
#define DEBUG(msg)
Output a debug message to standard output.
unsigned char u8
Unsigned 8-bit number.
Result
Result code for filesystem Actions.
Contains file information.
Size size
< File access permission bits.
Size size
Size in number of bytes.
Address phys
Physical address.
Address virt
Virtual address.
Access access
Page access flags.
Process information structure, used for Info.
ProcessID pid
Process identifier of target process.
Recovery::Result result
Result of action.