Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1362 → Rev 1363

/uspace/trunk/ns/ns.c
45,6 → 45,8
 
#define NS_HASH_TABLE_CHAINS 20
 
extern int __DONT_OPEN_STDIO__=1;
 
static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call);
static int connect_to_service(ipcarg_t service, ipc_call_t *call, ipc_callid_t callid);
 
81,10 → 83,10
ipcarg_t retval, arg1, arg2;
 
printf("%s: Naming service started.\n", NAME);
// printf("%s: Naming service started.\n", NAME);
if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3, &ns_hash_table_ops)) {
printf("%s: cannot create hash table\n", NAME);
// printf("%s: cannot create hash table\n", NAME);
return ENOMEM;
}
94,20 → 96,20
switch (IPC_GET_METHOD(call)) {
case IPC_M_AS_AREA_SEND:
as_area = (char *)IPC_GET_ARG2(call);
printf("Received as_area: %P, size:%d\n", as_area, IPC_GET_ARG3(call));
// printf("Received as_area: %P, size:%d\n", as_area, IPC_GET_ARG3(call));
retval = ipc_answer_fast(callid, 0,(sysarg_t)(1024*1024), 0);
if (!retval) {
printf("Reading shared memory...");
printf("Text: %s", as_area);
// printf("Reading shared memory...");
// printf("Text: %s", as_area);
} else
printf("Failed answer: %d\n", retval);
// printf("Failed answer: %d\n", retval);
continue;
break;
case IPC_M_INTERRUPT:
printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call));
// printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call));
break;
case IPC_M_PHONE_HUNGUP:
printf("Phone hung up.\n");
// printf("Phone hung up.\n");
retval = 0;
break;
case IPC_M_CONNECT_TO_ME:
124,23 → 126,23
retval = connect_to_service(IPC_GET_ARG1(call), &call, callid);
break;
case NS_HANGUP:
printf("Closing connection.\n");
// printf("Closing connection.\n");
retval = EHANGUP;
break;
case NS_PING:
printf("Ping...%P %P\n", IPC_GET_ARG1(call),
IPC_GET_ARG2(call));
// printf("Ping...%P %P\n", IPC_GET_ARG1(call),
// IPC_GET_ARG2(call));
retval = 0;
arg1 = 0xdead;
arg2 = 0xbeef;
break;
case NS_PING_SVC:
printf("NS:Pinging service %d\n", ping_phone);
// printf("NS:Pinging service %d\n", ping_phone);
ipc_call_sync(ping_phone, NS_PING, 0xbeef, 0);
printf("NS:Got pong\n");
// printf("NS:Got pong\n");
break;
default:
printf("Unknown method: %zd\n", IPC_GET_METHOD(call));
// printf("Unknown method: %zd\n", IPC_GET_METHOD(call));
retval = ENOENT;
break;
}
164,16 → 166,16
unsigned long keys[3] = { service, call->in_phone_hash, 0 };
hashed_service_t *hs;
printf("Registering service %d on phone %d...", service, phone);
// printf("Registering service %d on phone %d...", service, phone);
 
if (hash_table_find(&ns_hash_table, keys)) {
printf("Service %d already registered.\n", service);
// printf("Service %d already registered.\n", service);
return EEXISTS;
}
hs = (hashed_service_t *) malloc(sizeof(hashed_service_t));
if (!hs) {
printf("Failed to register service %d.\n", service);
// printf("Failed to register service %d.\n", service);
return ENOMEM;
}
206,7 → 208,7
return ENOENT;
}
hs = hash_table_get_instance(hlp, hashed_service_t, link);
printf("Connecting in_phone_hash=%lX to service at phone %d...", call->in_phone_hash, hs->phone);
// printf("Connecting in_phone_hash=%lX to service at phone %d...", call->in_phone_hash, hs->phone);
return ipc_forward_fast(callid, hs->phone, 0, 0);
}