summaryrefslogtreecommitdiff
path: root/src/kernel/Object/Object.h
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-01 23:48:56 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-01 23:48:56 +0200
commit43d0bb8e3997022e5270f7f75f615a47819c929e (patch)
tree937992d286966edecf81b405e414230c85d19bad /src/kernel/Object/Object.h
parente9683297bf480f9590b0e5796f4520fb430e2e03 (diff)
downloadTCE-43d0bb8e3997022e5270f7f75f615a47819c929e.tar.gz
TCE-43d0bb8e3997022e5270f7f75f615a47819c929e.zip
Basic object system - THIS IS STILL A LONG WAY TO GO!!
Diffstat (limited to 'src/kernel/Object/Object.h')
-rw-r--r--src/kernel/Object/Object.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/kernel/Object/Object.h b/src/kernel/Object/Object.h
new file mode 100644
index 0000000..1b0daec
--- /dev/null
+++ b/src/kernel/Object/Object.h
@@ -0,0 +1,78 @@
+#ifndef DEF_INTERFACE_H
+#define DEF_INTERFACE_H
+
+#include <types.h>
+#include <task/task.h>
+
+#include <tce/Object_common.h>
+
+struct _Object;
+struct _NumberedMethod;
+
+typedef struct _Interface {
+ char* name;
+ int method_count;
+ int public_method_count;
+
+ struct _NumberedMethod *numberedMethods;
+ int *methodNumbers;
+} Interface;
+
+typedef struct _NumberedMethod {
+ Interface *iface;
+ int numberInIface;
+} NumberedMethod;
+
+typedef int (*MethodPtr)(struct _Object* object, struct process* process, size_t a, size_t b, size_t c, size_t d);
+typedef struct _Object* (*FindChildPtr)(struct _Object *object, const char* name);
+typedef int (*OpenPtr)(struct _Object *object, struct process *process);
+typedef void (*ClosedPtr)(struct _Object *object);
+typedef void (*DeletePtr)(struct _Object *object);
+
+typedef struct _InterfaceImpl {
+ Interface *interface;
+ MethodPtr *methods;
+} InterfaceImpl;
+
+// ==
+
+typedef struct _Class {
+ char *name;
+ FindChildPtr findChild;
+ OpenPtr open; // optionnal - if 0, always success
+ ClosedPtr closed; // optionnal
+ DeletePtr deleted; // optionnal but should be implemented
+ InterfaceImpl interfaces[]; // zero-terminated list
+} Class;
+
+typedef struct _Object {
+ Class *_class;
+ void *data;
+ int handles; // reference counter
+} Object;
+
+//
+
+void setup_object_system();
+
+void Class_setup(Class* _class);
+void Interface_setup(Interface* iface);
+
+MethodPtr* Class_getInterfaceImpl(Class *_class, Interface *iface);
+
+Object* Object_get(Object *parent, char *path);
+
+Object *rootObject, *deviceListObject;
+
+// syscalls
+int open(char* name);
+int open_relative(char* name, int root_handle);
+void close(size_t handle);
+int get_methods(char* iface_name, int* whereto);
+
+Object* read_handle(struct process *proc, size_t handle);
+void do_method_call(struct registers *regs);
+
+
+#endif
+