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
|
#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
|