2007-06-03 01:57:37 +00:00
|
|
|
#ifndef SYSTEM_H
|
|
|
|
#define SYSTEM_H
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2007-06-18 19:23:44 +00:00
|
|
|
namespace vm {
|
|
|
|
|
2007-06-03 01:57:37 +00:00
|
|
|
class System {
|
|
|
|
public:
|
|
|
|
typedef int Status;
|
|
|
|
|
|
|
|
class Thread {
|
|
|
|
public:
|
|
|
|
virtual ~Thread() { }
|
|
|
|
virtual void run() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Monitor {
|
|
|
|
public:
|
|
|
|
virtual ~Monitor() { }
|
2007-06-15 00:50:55 +00:00
|
|
|
virtual bool tryAcquire(void* id) = 0;
|
|
|
|
virtual void acquire(void* id) = 0;
|
|
|
|
virtual void release(void* id) = 0;
|
|
|
|
virtual void wait(void* id) = 0;
|
|
|
|
virtual void notify(void* id) = 0;
|
|
|
|
virtual void notifyAll(void* id) = 0;
|
2007-06-03 01:57:37 +00:00
|
|
|
virtual void dispose() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class File {
|
|
|
|
public:
|
|
|
|
virtual ~File() { }
|
|
|
|
virtual Status read(uint8_t* data, unsigned* size) = 0;
|
|
|
|
virtual Status write(const uint8_t* data, unsigned size) = 0;
|
|
|
|
virtual Status close() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const int ReadOnly = 00;
|
|
|
|
static const int WriteOnly = 01;
|
|
|
|
static const int ReadWrite = 02;
|
|
|
|
static const int Append = 02000;
|
|
|
|
static const int Create = 0100;
|
|
|
|
|
|
|
|
static const int UserRead = 0400;
|
|
|
|
static const int UserWrite = 0200;
|
|
|
|
static const int UserExecute = 0100;
|
|
|
|
static const int GroupRead = 040;
|
|
|
|
static const int GroupWrite = 020;
|
|
|
|
static const int GroupExecute = 010;
|
|
|
|
static const int OtherRead = 04;
|
|
|
|
static const int OtherWrite = 02;
|
|
|
|
static const int OtherExecute = 01;
|
|
|
|
|
|
|
|
virtual ~System() { }
|
|
|
|
|
|
|
|
virtual bool success(Status) = 0;
|
|
|
|
virtual void* allocate(unsigned size) = 0;
|
|
|
|
virtual void free(void*) = 0;
|
|
|
|
virtual Status start(Thread*) = 0;
|
|
|
|
virtual Status make(Monitor**) = 0;
|
|
|
|
virtual Status open(File**, const char* path, int flags, int mode) = 0;
|
2007-06-18 04:25:42 +00:00
|
|
|
virtual void abort() = 0;
|
2007-06-03 01:57:37 +00:00
|
|
|
};
|
|
|
|
|
2007-06-18 19:23:44 +00:00
|
|
|
} // namespace vm
|
|
|
|
|
2007-06-03 01:57:37 +00:00
|
|
|
#endif//SYSTEM_H
|