Skip to content

Commit

Permalink
added key field to message header
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbjohnson4224 committed Jan 29, 2012
1 parent 1e9d095 commit d5a5f82
Show file tree
Hide file tree
Showing 37 changed files with 168 additions and 167 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -19,7 +19,7 @@ PP := cpp
CFLAGS := -pipe -Wall -Wextra -pedantic -std=c99 -Werror
CFLAGS += -Wpointer-arith -Wwrite-strings
CFLAGS += -Wno-unused-parameter -Wno-unused-function
CFLAGS += -O0 -fomit-frame-pointer
CFLAGS += -O3 -fomit-frame-pointer
CFLAGS += -I$(BUILDDIR)/inc -ffreestanding -fPIC
LDFLAGS := -L$(BUILDDIR)/lib -Bdynamic
ARFLAGS := rcs
Expand Down
2 changes: 1 addition & 1 deletion daemon/wmanager/main.c
Expand Up @@ -351,7 +351,7 @@ int main(int argc, char **argv) {
if (fork() == 0) {
exec("/sbin/mouse");
}
mwait(PORT_CHILD, 0);
mwait(ACTION_CHILD, 0);

rdi_init();

Expand Down
2 changes: 1 addition & 1 deletion driver/ata/main.c
Expand Up @@ -296,7 +296,7 @@ int main(int argc, char **argv) {

rdi_global_read_hook = ata_read;

msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/biterm/main.c
Expand Up @@ -200,7 +200,7 @@ int main(int argc, char **argv) {
exec("/bin/fish");
}

msendb(getppid(), PORT_CHILD);
msendb(getppid(), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/fbterm/main.c
Expand Up @@ -211,7 +211,7 @@ int main(int argc, char **argv) {
}

// daemonize
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/kbd/main.c
Expand Up @@ -159,7 +159,7 @@ int main(int argc, char **argv) {
fs_plink("/dev/kbd", RP_CONS(getpid(), keyboard->index), NULL);

// daemonize
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/mouse/main.c
Expand Up @@ -147,7 +147,7 @@ int main(int argc, char **argv) {
#endif

fs_plink("/dev/mouse", RP_CONS(getpid(), mouse->index), NULL);
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);

#if USE_IRQ
_done();
Expand Down
2 changes: 1 addition & 1 deletion driver/pci/main.c
Expand Up @@ -139,7 +139,7 @@ int main(int argc, char **argv) {

rdi_global_read_hook = pci_read;

msendb(getppid(), PORT_CHILD);
msendb(getppid(), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/pipe/main.c
Expand Up @@ -161,7 +161,7 @@ int main(int argc, char **argv) {
rdi_global_read_hook = pipe_read;

// daemonize
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/serial/main.c
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char **argv) {
rdi_global_write_hook = serial_write;

// daemonize
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/svga/main.c
Expand Up @@ -169,7 +169,7 @@ int main(int argc, char **argv) {

/* register the driver as /dev/svga0 */
fs_plink("/dev/svga0", RP_CONS(getpid(), canvas->index), NULL);
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/tarfs/main.c
Expand Up @@ -181,7 +181,7 @@ int main(int argc, char **argv) {
rdi_global_cons_link_hook = tarfs_link_cons;

/* daemonize */
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return EXIT_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion driver/time/main.c
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char **argv) {
rdi_global_read_hook = time_read;

// daemonize
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion driver/tmpfs/main.c
Expand Up @@ -132,7 +132,7 @@ int main(int argc, char **argv) {
rdi_global_cons_link_hook = tmpfs_link_cons;

// daemonize
msendb(RP_CONS(getppid(), 0), PORT_CHILD);
msendb(RP_CONS(getppid(), 0), ACTION_CHILD);
_done();

return 0;
Expand Down
59 changes: 30 additions & 29 deletions libc/inc/rho/ipc.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com>
* Copyright (C) 2009-2012 Nick Johnson <nickbjohnson4224 at gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand All @@ -22,45 +22,46 @@
#include <rho/natio.h>
#include <rho/arch.h>

/* port numbers ************************************************************/
/* action numbers ***********************************************************/

// kernel events and signals
#define PORT_QUIT 0
#define PORT_TERM 1
#define PORT_ABORT 2
#define PORT_KILL 3
#define PORT_STOP 4
#define PORT_CONT 5
#define PORT_TRAP 6
#define PORT_INT 7
#define PORT_IRQ 8
#define PORT_ALARM 9
#define PORT_CHILD 10
#define PORT_FLOAT 11
#define PORT_PAGE 12
#define PORT_ILL 13
#define PORT_USER1 14
#define PORT_USER2 15
#define ACTION_QUIT 0
#define ACTION_TERM 1
#define ACTION_ABORT 2
#define ACTION_KILL 3
#define ACTION_STOP 4
#define ACTION_CONT 5
#define ACTION_TRAP 6
#define ACTION_INT 7
#define ACTION_IRQ 8
#define ACTION_ALARM 9
#define ACTION_CHILD 10
#define ACTION_FLOAT 11
#define ACTION_PAGE 12
#define ACTION_ILL 13
#define ACTION_USER1 14
#define ACTION_USER2 15

// I/O and similar
#define PORT_REPLY 16
#define PORT_READ 17
#define PORT_WRITE 18
#define PORT_SYNC 19
#define PORT_RESET 20
#define PORT_SHARE 21
#define PORT_RCALL 22
#define PORT_EVENT 23
#define PORT_CLOSE 24
#define PORT_MMAP 25
#define ACTION_REPLY 16
#define ACTION_READ 17
#define ACTION_WRITE 18
#define ACTION_SYNC 19
#define ACTION_RESET 20
#define ACTION_SHARE 21
#define ACTION_RCALL 22
#define ACTION_EVENT 23
#define ACTION_CLOSE 24
#define ACTION_MMAP 25

/* message structure ********************************************************/

struct msg {
uint64_t source; // resource pointer of source
uint64_t target; // resource pointer of target
uint64_t key; // authentication key for action
uint32_t length; // length of _data_ (not whole message)
uint8_t port; // port (to be) sent to
uint8_t action; // action requested
uint8_t arch; // architecture (i.e. byte order)
uint16_t padding;
uint8_t data[]; // contained data
Expand Down
34 changes: 17 additions & 17 deletions libc/inc/signal.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com>
* Copyright (C) 2009-2012 Nick Johnson <nickbjohnson4224 at gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand All @@ -23,22 +23,22 @@

/* signal numbers */

#define SIGQUIT PORT_QUIT
#define SIGTERM PORT_TERM
#define SIGABRT PORT_ABORT
#define SIGKILL PORT_KILL
#define SIGSTOP PORT_STOP
#define SIGCONT PORT_CONT
#define SIGTRAP PORT_TRAP
#define SIGINT PORT_INT
#define SIGIRQ PORT_IRQ
#define SIGALRM PORT_ALARM
#define SIGCHLD PORT_CHILD
#define SIGFPE PORT_FLOAT
#define SIGSEGV PORT_PAGE
#define SIGILL PORT_ILL
#define SIGUSR1 PORT_USER1
#define SIGUSR2 PORT_USER2
#define SIGQUIT ACTION_QUIT
#define SIGTERM ACTION_TERM
#define SIGABRT ACTION_ABORT
#define SIGKILL ACTION_KILL
#define SIGSTOP ACTION_STOP
#define SIGCONT ACTION_CONT
#define SIGTRAP ACTION_TRAP
#define SIGINT ACTION_INT
#define SIGIRQ ACTION_IRQ
#define SIGALRM ACTION_ALARM
#define SIGCHLD ACTION_CHILD
#define SIGFPE ACTION_FLOAT
#define SIGSEGV ACTION_PAGE
#define SIGILL ACTION_ILL
#define SIGUSR1 ACTION_USER1
#define SIGUSR2 ACTION_USER2
#define SIGNUKE 0xFF

#define SIGMAX 16
Expand Down
24 changes: 12 additions & 12 deletions libc/init/init.c
Expand Up @@ -70,7 +70,7 @@ static void __rcall_handler(struct msg *msg) {
reply->source = msg->target;
reply->target = msg->source;
reply->length = strlen(rets) + 1;
reply->port = PORT_REPLY;
reply->action = ACTION_REPLY;
reply->arch = ARCH_NAT;
strcpy((char*) reply->data, rets);
free(rets);
Expand Down Expand Up @@ -168,19 +168,19 @@ void __libc_init(int (*_main)(int, char**)) {

/* set up signals */
__sig_init();
when(PORT_CHILD, NULL);
when(ACTION_CHILD, NULL);

/* set up I/O handlers */
when(PORT_REPLY, NULL);
when(PORT_READ, __reject);
when(PORT_WRITE, __reject);
when(PORT_SYNC, __reject);
when(PORT_RESET, __reject);
when(PORT_SHARE, __reject);
when(PORT_RCALL, __rcall_handler);
when(PORT_EVENT, __ignore);
when(PORT_CLOSE, __ignore);
when(PORT_CHILD, __reap);
when(ACTION_REPLY, NULL);
when(ACTION_READ, __reject);
when(ACTION_WRITE, __reject);
when(ACTION_SYNC, __reject);
when(ACTION_RESET, __reject);
when(ACTION_SHARE, __reject);
when(ACTION_RCALL, __rcall_handler);
when(ACTION_EVENT, __ignore);
when(ACTION_CLOSE, __ignore);
when(ACTION_CHILD, __reap);

/* set up basic rcall handlers */
rcall_hook("ping", __ping);
Expand Down
8 changes: 4 additions & 4 deletions libc/ipc/event.c
Expand Up @@ -39,7 +39,7 @@ bool m_event_handler;
* virtual packet register and redirects the event to proper event handler.
*/

void on_event(size_t count, uint32_t port, uint32_t source, uint32_t source_idx, uint32_t target_idx) {
void on_event(size_t count, uint32_t action, uint32_t source, uint32_t source_idx, uint32_t target_idx) {
struct msg *msg;

if (count) {
Expand Down Expand Up @@ -75,7 +75,7 @@ void on_event(size_t count, uint32_t port, uint32_t source, uint32_t source_idx,
msg->source = RP_CONS(source, source_idx);
msg->target = RP_CONS(getpid(), target_idx);
msg->length = 0;
msg->port = port;
msg->action = action;
msg->arch = ARCH_NAT;
}

Expand All @@ -85,9 +85,9 @@ void on_event(size_t count, uint32_t port, uint32_t source, uint32_t source_idx,

mutex_spin(&m_event_handler);

if (event_handler[port]) {
if (event_handler[action]) {
mutex_free(&m_event_handler);
event_handler[port](msg);
event_handler[action](msg);
}
else {
mutex_free(&m_event_handler);
Expand Down

0 comments on commit d5a5f82

Please sign in to comment.