From 8d94ae49601e0e4023bcdc35191669b2c24f6c96 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Mon, 5 Apr 2010 16:56:17 +0200 Subject: More work on IPC. --- .gitignore | 1 + Makefile | 2 +- copy_fdd.sh | 2 +- doc/manager.txt | 17 ++++ menu_fdd.cfg | 1 + src/include/gc/server.h | 1 + src/include/gc/syscall.h | 1 + src/include/gm/method.h | 3 + src/kernel/ipc/request.c | 2 + src/kernel/ipc/request.h | 2 + src/kernel/task/task.c | 12 ++- src/library/Makefile | 4 +- src/library/gc/object.c | 197 ----------------------------------------- src/library/gc/server.c | 206 +++++++++++++++++++++++++++++++++++++++++++ src/library/gc/shm.c | 8 +- src/library/mutex.c | 22 ----- src/library/std/mutex.c | 22 +++++ src/modules/manager/Makefile | 33 +++++++ src/modules/manager/main.c | 23 +++++ src/modules/test/Makefile | 3 +- src/modules/test/main.c | 15 ++-- 21 files changed, 340 insertions(+), 237 deletions(-) create mode 100644 doc/manager.txt delete mode 100644 src/library/gc/object.c create mode 100644 src/library/gc/server.c delete mode 100644 src/library/mutex.c create mode 100644 src/library/std/mutex.c create mode 100644 src/modules/manager/Makefile create mode 100644 src/modules/manager/main.c diff --git a/.gitignore b/.gitignore index c524a07..7896fc9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.swp *.map *.elf +tmp diff --git a/Makefile b/Makefile index 9cfa382..9425023 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: clean, mrproper, Init.rfs, floppy, commit -Projects = kernel library modules/test +Projects = kernel library modules/manager modules/test Floppy = Grapes.fl.img diff --git a/copy_fdd.sh b/copy_fdd.sh index 1372f2c..087939d 100755 --- a/copy_fdd.sh +++ b/copy_fdd.sh @@ -7,7 +7,7 @@ cp menu_fdd.cfg mnt/boot/menu.cfg # copy kernel cp src/kernel/kernel.elf mnt -cp src/modules/test/test.elf mnt +cp src/modules/test/test.elf src/modules/manager/manager.elf mnt #echo "*** Launching a BASH shell, if you want to do any maintenance ***" #bash || exit 0 diff --git a/doc/manager.txt b/doc/manager.txt new file mode 100644 index 0000000..5603ee5 --- /dev/null +++ b/doc/manager.txt @@ -0,0 +1,17 @@ +The manager is a service whose role is to manage all other services. By default, all loaded modules +get a descriptor to the manager service (descriptor 1). + +Each service has a set of ressources that can get a descriptor by openning them. These ressources +are identified by a string, such as : +kbd:readtext +file:root/System/ +console:myuser/main + +To open these objects, a process would call the open() method on the manager object. The manager would +then call the open() method on the corresponding process with the string after the first semicolon +(for example: open("file:root/System") would call file.open("root/System")). + +If the string is just a service name (like open("kbd")), the manager would return a descriptor to the +root object for that service. + +The manager is also the one that handle log entries for services, for the moment by printing them on the screen. diff --git a/menu_fdd.cfg b/menu_fdd.cfg index f6e077f..1d3504c 100644 --- a/menu_fdd.cfg +++ b/menu_fdd.cfg @@ -1,3 +1,4 @@ title Grapes kernel /kernel.elf +module /manager.elf module /test.elf diff --git a/src/include/gc/server.h b/src/include/gc/server.h index b98b4fb..36597c7 100644 --- a/src/include/gc/server.h +++ b/src/include/gc/server.h @@ -74,6 +74,7 @@ void srv_handle(Server* o, int act); Server *srv_create(); void srv_delete(Server *o); +Server *srv_get(int descriptor); void srv_addHandler(Server* o, uint32_t method, method_handler h); #endif diff --git a/src/include/gc/syscall.h b/src/include/gc/syscall.h index c93a523..9ac6748 100644 --- a/src/include/gc/syscall.h +++ b/src/include/gc/syscall.h @@ -15,6 +15,7 @@ typedef unsigned size_t; struct user_request { uint32_t func, params[3], shmsize[3]; int isBlocking; // 1 : blocking request, 0 : nonblocking request (message) + int pid; //pid of caller process }; struct user_sendrequest { diff --git a/src/include/gm/method.h b/src/include/gm/method.h index ac6ab0e..6206f07 100644 --- a/src/include/gm/method.h +++ b/src/include/gm/method.h @@ -19,4 +19,7 @@ /* Checks if object handles that method. In case BIVV, only one method is checked for. * In case BMIV, the [b] methods in shared memory [a] are checked, first one not found returns false. */ +#define M_NOTHING_VVVV (2) +/* This method does nothing, it just checks message transmission to an object. */ + #endif diff --git a/src/kernel/ipc/request.c b/src/kernel/ipc/request.c index 4e8b407..9ca724e 100644 --- a/src/kernel/ipc/request.c +++ b/src/kernel/ipc/request.c @@ -26,6 +26,7 @@ int request_get(int id, uint32_t ptr, int wait) { else p->shmsize[i] = 0; } p->isBlocking = (obj->request->requester != 0); + p->pid = obj->request->pid; //if request is nonblocking and no shm is to be mapped, delete request and unlock objects busymutex, else set it to acknowledged if (p->isBlocking) return 0; for (i = 0; i < 3; i++) { @@ -149,6 +150,7 @@ static struct request *mkrequest(int id, struct thread *requester, rq->func = func; for (i = 0; i < 3; i++) { rq->params[i] = 0; rq->obj_close[i] = 0; rq->shm_sndr[i] = 0; rq->shm_rcv[i] = 0; } rq->acknowledged = RS_PENDING; + rq->pid = current_thread->process->pid; // integers: use as is // objects: open a new descriptor in receiver process (if same process, keep number), put that number as an int // if receiver already had descriptor to this object, use it and set obj_close to 0, else set obj_close to new number diff --git a/src/kernel/ipc/request.h b/src/kernel/ipc/request.h index b08264f..18eaf84 100644 --- a/src/kernel/ipc/request.h +++ b/src/kernel/ipc/request.h @@ -25,11 +25,13 @@ struct request { uint32_t n; } answer; int errcode; //returned when function has finished + int pid; //pid of caller }; struct user_request { uint32_t func, params[3], shmsize[3]; int isBlocking; // 1 : blocking request, 0 : nonblocking request (message) + int pid; //pid of caller process }; struct user_sendrequest { diff --git a/src/kernel/task/task.c b/src/kernel/task/task.c index 9221813..f10ec6f 100644 --- a/src/kernel/task/task.c +++ b/src/kernel/task/task.c @@ -9,6 +9,8 @@ #define KSTACKSIZE 0x8000 +static struct object *manager_object = 0; + //Static routines for handling threads exiting and all cleanup static void thread_exit_stackJmp(uint32_t reason); static void thread_exit2(uint32_t reason); @@ -109,6 +111,7 @@ uint32_t tasking_handleException(struct registers *regs) { "Page Fault","Unknown Interrupt","Coprocessor Fault","Alignment Check","Machine Check"}; monitor_write(exception_messages[regs->int_no]); monitor_write(" at "); monitor_writeHex(regs->eip); + PANIC("kk"); if (regs->int_no == 14) { monitor_write("\n>>> Process exiting.\n"); thread_exit_stackJmp(EX_PR_EXCEPTION); @@ -283,7 +286,10 @@ struct process *process_new(struct process* parent, uint32_t uid, uint32_t privi p->next_objdesc = 0; p->objects = 0; - obj_createP(p); //create process' root object and add descriptor 0 to it + struct object* o = obj_new(p); + if (manager_object == 0) manager_object = o; + objdesc_add(p, o); //create process' root object and add descriptor 0 to it + objdesc_add(p, manager_object); processes = p; return p; @@ -307,8 +313,8 @@ static void process_delete(struct process *pr) { struct thread *it; while (threads != 0 && threads->process == pr) thread_delete(threads); it = threads; - while (it != 0) { - while (it->next->process == pr) thread_delete(it->next); + while (it != 0 && it->next != 0) { + while (it->next != 0 && it->next->process == pr) thread_delete(it->next); it = it->next; } obj_closeall(pr); diff --git a/src/library/Makefile b/src/library/Makefile index b0dac11..f7161b6 100644 --- a/src/library/Makefile +++ b/src/library/Makefile @@ -7,9 +7,9 @@ LD = ld LDFLAGS = -r Library = grapes.o -Objects = gc/syscall.o gc/object.o \ +Objects = gc/syscall.o gc/server.o \ gc/mem.o gc/shm.o \ - mutex.o \ + std/mutex.o \ start.o all: $(Library) diff --git a/src/library/gc/object.c b/src/library/gc/object.c deleted file mode 100644 index 87dafd8..0000000 --- a/src/library/gc/object.c +++ /dev/null @@ -1,197 +0,0 @@ -#include -#include -#include -#include - -Server procServer; -static Server* servers = 0; - -static method_handler getHandler(Server *o, uint32_t m); -static struct method_ret checkIfHandles(struct method_data *d); -static struct method_ret checkIfHandlesMany(struct method_data *d); - -void objsrv_init() { - procServer.id = 0; - procServer.methods = 0; - procServer.next = 0; - procServer.data = 0; - servers = &procServer; - srv_addHandler(&procServer, M_HANDLECHECK_BIVV, checkIfHandles); - srv_addHandler(&procServer, M_HANDLECHECK_BMIV, checkIfHandlesMany); -} - -void srv_handleAll() { - Server *i = servers; - while (i) { - srv_handle(i, HA_ONCE); - i = i->next; - } -} - -void srv_handle(Server *o, int act) { - int i; - - if (act == HA_LOOP) { - while (1) srv_handle(o, HA_WAIT); - } else { - struct user_request rq; - int v = request_get(o->id, &rq, (act == HA_WAIT)); - if (v == 0) { - method_handler m = getHandler(o, rq.func); - if (m == 0) { - if (rq.isBlocking) { - request_answer(o->id, 0, 0, ME_UNHANDLED); - } - } else { - struct method_data md; - md.func = rq.func; - md.blocking = rq.isBlocking; - md.obj = o; - //get parameters - for (i = 0; i < 3; i++) { - md.parameters[i].type = (rq.func >> (28 - (2 * i))) & 3; - switch (md.parameters[i].type) { - case PT_LONG: - case PT_OBJDESC: - md.parameters[i].val.i = rq.params[i]; - break; - case PT_SHM: //all the fuss about keepShm only applies to messages. - md.parameters[i].keepShm = 1; //if local memory or if nothing, do not unmap it - if (rq.params[i] == 0) { //TODO : map shm (shm manager) !!! - void* p = shm_alloc(rq.shmsize[i]); - md.parameters[i].val.p = p; - if (p != 0) { - request_mapShm(o->id, (size_t)p, i); - md.parameters[i].keepShm = 0; //we had to map it, so mark it to be unmapped - } - } else { - md.parameters[i].val.p = (void*)rq.params[i]; - } - break; - } - } - - struct method_ret ret = m(&md); //Call method - if (rq.isBlocking) { - uint32_t a = 0, b = 0; - if (ret.type == PT_OBJDESC || ret.type == PT_LONG) a = ret.i; - if (ret.type == PT_LONGLONG) a = (uint32_t)ret.l, b = (uint32_t)((uint64_t)ret.l >> 32); - request_answer(o->id, a, b, ret.status); - } else { - for (i = 0; i < 3; i++) { - if (md.parameters[i].type == PT_SHM && md.parameters[i].keepShm == 0) { - shm_freeDel(md.parameters[i].val.p); - } - } - } - } - } - } -} - -void srv_addHandler(Server* o, uint32_t method, method_handler h) { - struct method_srv *s = malloc(sizeof(struct method_srv)); - s->id = method; - s->h = h; - s->next = o->methods; - o->methods = s; -} - -Server *srv_create() { - Server *s = malloc(sizeof(Server)); - s->id = object_create(); - s->methods = 0; - s->data = 0; - s->next = servers; - srv_addHandler(s, M_HANDLECHECK_BIVV, checkIfHandles); - srv_addHandler(s, M_HANDLECHECK_BMIV, checkIfHandlesMany); - servers = s; - return s; -} - -void srv_delete(Server* s) { - //remove s from servers - if (servers == s) { - servers = s->next; - } else { - Server *i = servers; - while (i->next != 0) { - if (i->next == s) { - i->next = s->next; - break; - } - i = i->next; - } - } - //close s - object_close(s->id); - //free methods for s - while (s->methods != 0) { - struct method_srv *m = s->methods->next; - free(s->methods); - s->methods = m; - } - //free s - free(s); -} - -// internal use - -method_handler getHandler(Server *o, uint32_t m) { - struct method_srv *i = o->methods; - while (i) { - if (i->id == m) return i->h; - i = i->next; - } - return 0; -} - -struct method_ret checkIfHandles(struct method_data *d) { - if (getHandler(d->obj, d->parameters[0].val.i) == 0) { - return mr_long(0); - } - return mr_long(1); -} - -struct method_ret checkIfHandlesMany(struct method_data *d) { - if (d->parameters[0].type != PT_SHM) return mr_err(-1); - if (d->parameters[1].type != PT_LONG) return mr_err(-1); - uint32_t *data = d->parameters[0].val.p, i; - if (data == 0) return mr_long(0); - for (i = 0; i < d->parameters[1].val.i; i++) { - if (getHandler(d->obj, data[i]) == 0) return mr_long(0); - } - return mr_long(1); -} - -// ***************************** HELPER FUNCTIONS FOR RETRUN VALUES - -struct method_ret mr_long(int val) { - struct method_ret r; r.status = 0; r.type = PT_LONG; r.i = val; - return r; -} - -struct method_ret mr_llong(int64_t val) { - struct method_ret r; r.status = 0; r.type = PT_LONGLONG; r.l = val; - return r; -} - -struct method_ret mr_obj(Object* obj) { - struct method_ret r; r.status = 0; r.type = PT_OBJDESC; r.i = obj->id; - return r; -} - -struct method_ret mr_srv(Server* obj) { - struct method_ret r; r.status = 0; r.type = PT_OBJDESC; r.i = obj->id; - return r; -} - -struct method_ret mr_void() { - struct method_ret r; r.status = 0; r.type = PT_VOID; - return r; -} - -struct method_ret mr_err(int error) { - struct method_ret r; r.status = error; r.type = PT_VOID; r.l = 0; - return r; -} diff --git a/src/library/gc/server.c b/src/library/gc/server.c new file mode 100644 index 0000000..9fd1616 --- /dev/null +++ b/src/library/gc/server.c @@ -0,0 +1,206 @@ +#include +#include +#include +#include + +Server procServer; +static Server* servers = 0; + +static method_handler getHandler(Server *o, uint32_t m); +static struct method_ret checkIfHandles(struct method_data *d); +static struct method_ret checkIfHandlesMany(struct method_data *d); + +void objsrv_init() { + procServer.id = 0; + procServer.methods = 0; + procServer.next = 0; + procServer.data = 0; + servers = &procServer; + srv_addHandler(&procServer, M_HANDLECHECK_BIVV, checkIfHandles); + srv_addHandler(&procServer, M_HANDLECHECK_BMIV, checkIfHandlesMany); +} + +void srv_handleAll() { + Server *i = servers; + while (i) { + srv_handle(i, HA_ONCE); + i = i->next; + } +} + +void srv_handle(Server *o, int act) { + int i; + + if (act == HA_LOOP) { + while (1) srv_handle(o, HA_WAIT); + } else { + struct user_request rq; + int v = request_get(o->id, &rq, (act == HA_WAIT)); + if (v == 0) { + method_handler m = getHandler(o, rq.func); + if (m == 0) { + if (rq.isBlocking) { + request_answer(o->id, 0, 0, ME_UNHANDLED); + } + } else { + struct method_data md; + md.func = rq.func; + md.blocking = rq.isBlocking; + md.obj = o; + //get parameters + for (i = 0; i < 3; i++) { + md.parameters[i].type = (rq.func >> (28 - (2 * i))) & 3; + switch (md.parameters[i].type) { + case PT_LONG: + case PT_OBJDESC: + md.parameters[i].val.i = rq.params[i]; + break; + case PT_SHM: //all the fuss about keepShm only applies to messages. + md.parameters[i].keepShm = 1; //if local memory or if nothing, do not unmap it + if (rq.params[i] == 0) { //TODO : map shm (shm manager) !!! + void* p = shm_alloc(rq.shmsize[i]); + md.parameters[i].val.p = p; + if (p != 0) { + request_mapShm(o->id, (size_t)p, i); + md.parameters[i].keepShm = 0; //we had to map it, so mark it to be unmapped + } + } else { + md.parameters[i].val.p = (void*)rq.params[i]; + } + break; + } + } + + struct method_ret ret = m(&md); //Call method + if (rq.isBlocking) { + uint32_t a = 0, b = 0; + if (ret.type == PT_OBJDESC || ret.type == PT_LONG) a = ret.i; + if (ret.type == PT_LONGLONG) a = (uint32_t)ret.l, b = (uint32_t)((uint64_t)ret.l >> 32); + request_answer(o->id, a, b, ret.status); + } else { + for (i = 0; i < 3; i++) { + if (md.parameters[i].type == PT_SHM && md.parameters[i].keepShm == 0) { + shm_freeDel(md.parameters[i].val.p); + } + } + } + } + } + } +} + +void srv_addHandler(Server* o, uint32_t method, method_handler h) { + struct method_srv *s = malloc(sizeof(struct method_srv)); + s->id = method; + s->h = h; + s->next = o->methods; + o->methods = s; +} + +Server *srv_create() { + Server *s = malloc(sizeof(Server)); + s->id = object_create(); + s->methods = 0; + s->data = 0; + s->next = servers; + srv_addHandler(s, M_HANDLECHECK_BIVV, checkIfHandles); + srv_addHandler(s, M_HANDLECHECK_BMIV, checkIfHandlesMany); + servers = s; + return s; +} + +Server *srv_get(int descriptor) { + Server *s = servers; + while (s) { + if (s->id == descriptor) return s; + s = s->next; + } + return 0; +} + +void srv_delete(Server* s) { + //remove s from servers + if (servers == s) { + servers = s->next; + } else { + Server *i = servers; + while (i->next != 0) { + if (i->next == s) { + i->next = s->next; + break; + } + i = i->next; + } + } + //close s + object_close(s->id); + //free methods for s + while (s->methods != 0) { + struct method_srv *m = s->methods->next; + free(s->methods); + s->methods = m; + } + //free s + free(s); +} + +// internal use + +method_handler getHandler(Server *o, uint32_t m) { + struct method_srv *i = o->methods; + while (i) { + if (i->id == m) return i->h; + i = i->next; + } + return 0; +} + +struct method_ret checkIfHandles(struct method_data *d) { + if (getHandler(d->obj, d->parameters[0].val.i) == 0) { + return mr_long(0); + } + return mr_long(1); +} + +struct method_ret checkIfHandlesMany(struct method_data *d) { + if (d->parameters[0].type != PT_SHM) return mr_err(-1); + if (d->parameters[1].type != PT_LONG) return mr_err(-1); + uint32_t *data = d->parameters[0].val.p, i; + if (data == 0) return mr_long(0); + for (i = 0; i < d->parameters[1].val.i; i++) { + if (getHandler(d->obj, data[i]) == 0) return mr_long(0); + } + return mr_long(1); +} + +// ***************************** HELPER FUNCTIONS FOR RETRUN VALUES + +struct method_ret mr_long(int val) { + struct method_ret r; r.status = 0; r.type = PT_LONG; r.i = val; + return r; +} + +struct method_ret mr_llong(int64_t val) { + struct method_ret r; r.status = 0; r.type = PT_LONGLONG; r.l = val; + return r; +} + +struct method_ret mr_obj(Object* obj) { + struct method_ret r; r.status = 0; r.type = PT_OBJDESC; r.i = obj->id; + return r; +} + +struct method_ret mr_srv(Server* obj) { + struct method_ret r; r.status = 0; r.type = PT_OBJDESC; r.i = obj->id; + return r; +} + +struct method_ret mr_void() { + struct method_ret r; r.status = 0; r.type = PT_VOID; + return r; +} + +struct method_ret mr_err(int error) { + struct method_ret r; r.status = error; r.type = PT_VOID; r.l = 0; + return r; +} diff --git a/src/library/gc/shm.c b/src/library/gc/shm.c index 9e19533..8077352 100644 --- a/src/library/gc/shm.c +++ b/src/library/gc/shm.c @@ -26,10 +26,10 @@ void* shm_alloc(size_t size) { if (blocks == 0) shm_init(); if (size & 0xFFF) size = (size & 0xFFFFF000) + 0x1000; //go through all blocks, get the one with the closest size - struct shm_block *block = blocks; - while (block) { - if (block->size >= size) break; - block = block->next; + struct shm_block *i = blocks, *block = 0; + while (i) { + if (i->size >= size && i->is_hole == 1 && i->size < block->size) block = i; + i = i->next; } if (block == 0) { mutex_unlock(&tMutex); diff --git a/src/library/mutex.c b/src/library/mutex.c deleted file mode 100644 index ac0ee8f..0000000 --- a/src/library/mutex.c +++ /dev/null @@ -1,22 +0,0 @@ -#include - -static uint32_t atomic_exchange(uint32_t* ptr, uint32_t newval) { - uint32_t r; - asm volatile("xchg (%%ecx), %%eax" : "=a"(r) : "c"(ptr), "a"(newval)); - return r; -} - -void mutex_lock(uint32_t* mutex) { - while (atomic_exchange(mutex, MUTEX_LOCKED) == MUTEX_LOCKED) { - thread_sleep(1); - } -} - -int mutex_lockE(uint32_t* mutex) { - if (atomic_exchange(mutex, MUTEX_LOCKED) == MUTEX_LOCKED) return 0; - return 1; -} - -void mutex_unlock(uint32_t* mutex) { - *mutex = MUTEX_UNLOCKED; -} diff --git a/src/library/std/mutex.c b/src/library/std/mutex.c new file mode 100644 index 0000000..ac0ee8f --- /dev/null +++ b/src/library/std/mutex.c @@ -0,0 +1,22 @@ +#include + +static uint32_t atomic_exchange(uint32_t* ptr, uint32_t newval) { + uint32_t r; + asm volatile("xchg (%%ecx), %%eax" : "=a"(r) : "c"(ptr), "a"(newval)); + return r; +} + +void mutex_lock(uint32_t* mutex) { + while (atomic_exchange(mutex, MUTEX_LOCKED) == MUTEX_LOCKED) { + thread_sleep(1); + } +} + +int mutex_lockE(uint32_t* mutex) { + if (atomic_exchange(mutex, MUTEX_LOCKED) == MUTEX_LOCKED) return 0; + return 1; +} + +void mutex_unlock(uint32_t* mutex) { + *mutex = MUTEX_UNLOCKED; +} diff --git a/src/modules/manager/Makefile b/src/modules/manager/Makefile new file mode 100644 index 0000000..87a9590 --- /dev/null +++ b/src/modules/manager/Makefile @@ -0,0 +1,33 @@ +.PHONY: clean, mrproper + +CC = gcc +CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -I ../../include + +LD = ld +LDFLAGS = -T ../../library/link.ld -L ../../library -Map manager.map + +Objects = main.o +Outfile = manager.elf + +all: $(Outfile) + echo "* Done with $(Outfile)" + +rebuild: mrproper all + +$(Outfile): $(Objects) + echo "* Linking $@..." + $(LD) $(LDFLAGS) -o $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + echo "* Removing objects..." + rm *.o || exit 0 + rm *.map || exit 0 + rm $(Objects) || exit 0 + +mrproper: clean + rm *.elf || exit 0 + rm $(Outfile) || exit 0 + diff --git a/src/modules/manager/main.c b/src/modules/manager/main.c new file mode 100644 index 0000000..9e23097 --- /dev/null +++ b/src/modules/manager/main.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +struct method_ret handle_nothing(struct method_data *d) { + if (d->blocking) printk("[manager] Received a {nothing} request.\n"); + else printk("[manager] Received a {nothing} message.\n"); + return mr_void(); +} + +int main() { + printk("[manager] Manager module configuring...\n"); + Server *mgr = srv_get(0); + + srv_addHandler(mgr, M_NOTHING_VVVV, handle_nothing); + + printk("[manager] Manager module configured : starting request handling.\n"); + srv_handle(mgr, HA_LOOP); + + printk("[manager] Manager EPIC FAIL.\n"); + return 0; +} diff --git a/src/modules/test/Makefile b/src/modules/test/Makefile index e571da9..6dd9f80 100644 --- a/src/modules/test/Makefile +++ b/src/modules/test/Makefile @@ -4,7 +4,7 @@ CC = gcc CFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -I ../../include LD = ld -LDFLAGS = -T ../../library/link.ld -L ../../library -Map main.map +LDFLAGS = -T ../../library/link.ld -L ../../library -Map test.map Objects = main.o Outfile = test.elf @@ -24,6 +24,7 @@ $(Outfile): $(Objects) clean: echo "* Removing objects..." rm *.o || exit 0 + rm *.map || exit 0 rm $(Objects) || exit 0 mrproper: clean diff --git a/src/modules/test/main.c b/src/modules/test/main.c index 49dc50e..148490b 100644 --- a/src/modules/test/main.c +++ b/src/modules/test/main.c @@ -1,6 +1,7 @@ #include #include #include +#include #define FACTOR 4 @@ -15,7 +16,7 @@ struct method_ret nulhandle(struct method_data *d) { void thread2(void* d) { printk("[test:2] Creating new object...\n"); Server *s = srv_create(); - srv_addHandler(s, 0x00000010, nulhandle); + srv_addHandler(s, M_NOTHING_VVVV, nulhandle); obj = s->id; while (1) { printk("[test:2] Waiting for a request...\n"); @@ -32,10 +33,12 @@ int main() { while (obj == -1); printk("[test:1] Object was created. Sending request...\n"); struct user_sendrequest sr; - sr.func = 0x00000010; + sr.func = M_NOTHING_VVVV; request(obj, &sr); - printk("[test:1] Got answer. Sending message...\n"); - send_msg(obj, &sr); + printk("[test:1] Got answer. Now sending request to manager...\n"); + request(1, &sr); + printk("[test:1] And now a message to manager...\n"); + send_msg(1, &sr); printk("[test:1] testing malloc and free..."); int* v = malloc(10 * sizeof(int)); @@ -52,7 +55,7 @@ int main() { free(v); free(vv); printk("nothing bad happened :)\n"); - printk("[test:1] HAHA !!! Death in 10 seconds!\n"); - thread_sleep(10000); + printk("[test:1] HAHA !!! Death of [test] in 1 seconds!\n"); + thread_sleep(1000); return 0; } -- cgit v1.2.3