From ee348973b0cb0f6481e4fd6e7494c63167c9759c Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Wed, 7 Apr 2010 11:37:21 +0200 Subject: More work on manager --- src/include/gc/obj.h | 6 +----- src/include/gc/server.h | 14 ++++++++++++-- src/include/gm/call.h | 18 ++++++++++++++++++ src/include/gm/call/manager.h | 14 ++++++++++++++ src/include/gm/method.h | 2 ++ src/include/gm/method/manager.h | 20 ++++++++++++++++++++ src/include/stdlib.h | 5 +++++ src/include/string.h | 7 +++++++ 8 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 src/include/gm/call.h create mode 100644 src/include/gm/call/manager.h create mode 100644 src/include/gm/method/manager.h (limited to 'src/include') diff --git a/src/include/gc/obj.h b/src/include/gc/obj.h index 10651f5..fcb60cd 100644 --- a/src/include/gc/obj.h +++ b/src/include/gc/obj.h @@ -5,10 +5,6 @@ #define ME_UNHANDLED -32767 #define ME_INTERRUPTED -32766 -struct object_cli { - int id; -}; - -typedef struct object_cli Object; +typedef int Object; #endif diff --git a/src/include/gc/server.h b/src/include/gc/server.h index 36597c7..3612a1d 100644 --- a/src/include/gc/server.h +++ b/src/include/gc/server.h @@ -16,11 +16,13 @@ struct method_data { union { int i; void* p; - } val; + }; int type; int keepShm; //for messages : keep shared memory segment after return or unmap ? (default : 0 = unmap) + size_t shmsize; } parameters[3]; uint32_t func; + int pid; int blocking; //1 : blocking request, 0 : message struct object_srv *obj; }; @@ -37,11 +39,19 @@ struct method_ret { //helper function for creating return values struct method_ret mr_long(int val); struct method_ret mr_llong(int64_t val); -struct method_ret mr_obj(Object* obj); +struct method_ret mr_obj(Object obj); struct method_ret mr_srv(struct object_srv* obj); struct method_ret mr_void(); struct method_ret mr_err(int error); +// for checking if a string passed in shared memory is valid +#define CHKSSTR(md, n) { size_t _i, _ok = 0; if (md->parameters[n].p == 0) return mr_err(-1); \ + for (_i = 0; _i < md->parameters[n].shmsize; _i++) { \ + if (*((char*)md->parameters[n].p + _i) == 0) { \ + _ok = 1; break; \ + } } \ + if (!_ok && md->parameters[n].shmsize != 0) return mr_err(-1); } + typedef struct method_ret (*method_handler)(struct method_data*); struct method_srv { diff --git a/src/include/gm/call.h b/src/include/gm/call.h new file mode 100644 index 0000000..5c3849d --- /dev/null +++ b/src/include/gm/call.h @@ -0,0 +1,18 @@ +#ifndef DEF_CALL_H +#define DEF_CALL_H + +/* + * This file and all files in include/call/ define prototypes to helper functions for calling methods on objects. + */ + +#include + +#define _CHP Object o, int block +#define _CHC if (block) request(o, &sr); else send_msg(o, &sr); + +int c_handleCheck(_CHP, int method); +int c_handleCheckA(_CHP, int* methods, int number); + +int c_nothing(_CHP); + +#endif diff --git a/src/include/gm/call/manager.h b/src/include/gm/call/manager.h new file mode 100644 index 0000000..49aafe7 --- /dev/null +++ b/src/include/gm/call/manager.h @@ -0,0 +1,14 @@ +#ifndef DEF_CALL_MANAGER_H +#define DEF_CALL_MANAGER_H + +#include +#include + +Object c_open(_CHP, char *c); +Object open(char *c); //calls c_open with object 1 + +void c_registerSvc(char *name); //automatically calls with objecct id 0 + +void c_logSvc(char *log, int level); + +#endif diff --git a/src/include/gm/method.h b/src/include/gm/method.h index 6206f07..13d3f16 100644 --- a/src/include/gm/method.h +++ b/src/include/gm/method.h @@ -22,4 +22,6 @@ #define M_NOTHING_VVVV (2) /* This method does nothing, it just checks message transmission to an object. */ +#include "method/manager.h" + #endif diff --git a/src/include/gm/method/manager.h b/src/include/gm/method/manager.h new file mode 100644 index 0000000..2066093 --- /dev/null +++ b/src/include/gm/method/manager.h @@ -0,0 +1,20 @@ +#ifdef DEF_METHOD_H + +#define M_OPEN_OMVV (10 | MP(1, 3, 0, 0)) +/* This function opens a distant ressource. Example : open("file:Root/Public/test.txt"); */ + +#define M_REGISTERSVC_VMOV (11 | MP(0, 3, 1, 0)) +/* This function registers a service. + * parameter 1 : service name; + * parameter 2 : service root object. */ + +#define M_LOGSVC_VMIV (12 | MP(0, 3, 2, 0)) +/* This parameters logs an entry for service with corresponding PID. Parameter 2 is : */ +#define LL_CRITICAL 0 +#define LL_ERROR 1 +#define LL_WARNING 2 +#define LL_NOTICE 3 +#define LL_STATUS 4 +#define LL_DEBUG 5 + +#endif diff --git a/src/include/stdlib.h b/src/include/stdlib.h index b232649..3a2b42c 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -1,7 +1,12 @@ #ifndef _DEF_STDLIB_H #define _DEF_STDLIB_H +#define NULL 0 + //includes malloc/free #include +void printk_int(int number); +void printk_hex(unsigned number); + #endif diff --git a/src/include/string.h b/src/include/string.h index 15ec3f3..24ac216 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -2,10 +2,17 @@ #define _DEF_STRING_H #include +#include void *memcpy(void *dest, const void *src, int count); uint8_t *memset(uint8_t *dest, uint8_t val, int count); uint16_t *memsetw(uint16_t *dest, uint16_t val, int count); + int strlen(const char *str); +char *strcpy(char *dest, const char *src); +char *strdup(const char *src); +char *strchr(const char *str, char c); +char *strcat(char *dest, const char *src); +int strcmp(const char *s1, const char *s2); #endif -- cgit v1.2.3