diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2010-06-24 15:51:29 -0500 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2010-06-24 15:51:29 -0500 |
commit | 8085c7634979f38c1b152d0a35b98c2447ce497a (patch) | |
tree | 844b3527d7b1e8770540f77d1f95c59254aaca60 /src/lib | |
parent | f760d7d1b0a7872228870b84ebfa85ab9999eb54 (diff) | |
download | blackbird-hostboot-8085c7634979f38c1b152d0a35b98c2447ce497a.tar.gz blackbird-hostboot-8085c7634979f38c1b152d0a35b98c2447ce497a.zip |
Add messaging
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/makefile | 2 | ||||
-rw-r--r-- | src/lib/string.c | 21 | ||||
-rw-r--r-- | src/lib/syscall_msg.C | 65 |
3 files changed, 87 insertions, 1 deletions
diff --git a/src/lib/makefile b/src/lib/makefile index 718a8219e..febe3f27f 100644 --- a/src/lib/makefile +++ b/src/lib/makefile @@ -2,7 +2,7 @@ OBJDIR = ../../obj include ../../config.mk OBJS = string.o stdlib.o -OBJS += syscall_stub.o syscall_task.o syscall_mutex.o +OBJS += syscall_stub.o syscall_task.o syscall_mutex.o syscall_msg.o OBJECTS = $(addprefix ${OBJDIR}/, ${OBJS}) all: ${OBJECTS} diff --git a/src/lib/string.c b/src/lib/string.c index b84de213f..fb4d435ae 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -9,3 +9,24 @@ void* memset(void* s, int c, size_t n) _s++; n--; } } + +int strcmp(const char* a, const char* b) +{ + while((*a != '\0') && (*b != '\0')) + { + if (*a == *b) + { + a++; b++; + } + else + { + return (*a > *b) ? 1 : -1; + } + } + if (*a == *b) + return 0; + if (*a == '\0') + return -1; + else + return 1; +} diff --git a/src/lib/syscall_msg.C b/src/lib/syscall_msg.C new file mode 100644 index 000000000..774ddb0bb --- /dev/null +++ b/src/lib/syscall_msg.C @@ -0,0 +1,65 @@ +#include <sys/msg.h> +#include <sys/syscall.h> + +#include <string.h> + +using namespace Systemcalls; + +const char* VFS_ROOT = "/"; // TODO. + +msg_q_t msg_q_create() +{ + return (msg_q_t) _syscall0(MSGQ_CREATE); +} + +int msg_q_destroy(msg_q_t q) +{ + return (int64_t)_syscall1(MSGQ_DESTROY, q); +} + +int msg_q_register(msg_q_t q, char* name) +{ + if (0 == strcmp(VFS_ROOT, name)) + { + return (int64_t)_syscall1(MSGQ_REGISTER_ROOT, q); + } + else + { + // TODO. + return -1; + } +} + +msg_q_t msg_q_resolve(char* name) +{ + if (0 == strcmp(VFS_ROOT, name)) + { + return (msg_q_t)_syscall0(MSGQ_RESOLVE_ROOT); + } + else + { + // TODO. + return NULL; + } +} + +int msg_send(msg_q_t q, msg_t* msg) +{ + return (int64_t)_syscall2(MSG_SEND, q, msg); +} + +int msg_sendrecv(msg_q_t q, msg_t* msg) +{ + return (int64_t)_syscall2(MSG_SENDRECV, q, msg); +} + +int msg_respond(msg_q_t q, msg_t* msg) +{ + return (int64_t)_syscall2(MSG_RESPOND, q, msg); +} + +msg_t* msg_wait(msg_q_t q) +{ + return (msg_t*)_syscall1(MSG_WAIT, q); +} + |