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. --- src/modules/manager/Makefile | 33 +++++++++++++++++++++++++++++++++ src/modules/manager/main.c | 23 +++++++++++++++++++++++ src/modules/test/Makefile | 3 ++- src/modules/test/main.c | 15 +++++++++------ 4 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 src/modules/manager/Makefile create mode 100644 src/modules/manager/main.c (limited to 'src/modules') 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