Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1343 → Rev 1342

/uspace/trunk/kbd/generic/kbd.c
27,7 → 27,6
*/
 
#include <ipc.h>
#include <services.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
71,7 → 70,7
/* Register service at nameserver */
printf("%s: Registering at naming service.\n", NAME);
 
if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, &phonead)) != 0) {
if ((res = ipc_connect_to_me(PHONE_NS, 30, 60, &phonead)) != 0) {
printf("%s: Error: Registering at naming service failed.\n", NAME);
return -1;
};
139,7 → 138,7
}
if (! (callid & IPC_CALLID_NOTIFICATION)) {
// printf("%s: Answering\n", NAME);
ipc_answer_fast(callid, retval, arg1, arg2);
ipc_answer(callid, retval, arg1, arg2);
}
}
}
/uspace/trunk/init/init.c
28,7 → 28,6
 
#include "version.h"
#include <ipc.h>
#include <services.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
40,7 → 39,6
#include <as.h>
#include <ddi.h>
#include <string.h>
#include <errno.h>
#include <kbd.h>
 
int a;
204,7 → 202,7
got_answer_2);
callid = ipc_wait_for_call(&data, NULL);
printf("Received ping\n");
ipc_answer_fast(callid, 0, 0, 0);
ipc_answer(callid, 0, 0, 0);
}
// callid = ipc_wait_for_call(&data, NULL);
}
302,7 → 300,7
int phoneid;
 
printf("Test: Starting connect...\n");
while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
while ((phoneid = ipc_connect_me_to(PHONE_NS, 30, 60)) < 0) {
};
printf("Test: Connected: %d\n", res);
317,14 → 315,6
ipc_hangup(phoneid);
}
 
static void test_pci()
{
int phone;
while ((phone = ipc_connect_me_to(PHONE_NS, SERVICE_PCI, 0)) < 0)
;
printf("Connected to PCI service through phone %d.\n", phone);
}
 
static int test_as_send()
{
char *as;
364,7 → 354,6
// test_hangup();
// test_slam();
// test_as_send();
test_pci();
test_kbd();
 
/*
388,7 → 377,7
}
 
int i;
 
for (i = 0; i < 50000000; i++)
;
411,6 → 400,5
 
printf("Main thread exiting.\n");
*/
 
return 0;
}
/uspace/trunk/ns/ns.c
71,6 → 71,28
ipcarg_t in_phone_hash; /**< Incoming phone hash. */
} hashed_service_t;
 
/*
irq_cmd_t msim_cmds[1] = {
{ CMD_MEM_READ_1, (void *)0xB0000000, 0 }
};
 
irq_code_t msim_kbd = {
1,
msim_cmds
};
*/
/*
irq_cmd_t i8042_cmds[1] = {
{ CMD_PORT_READ_1, (void *)0x60, 0 }
};
 
irq_code_t i8042_kbd = {
1,
i8042_cmds
};
*/
 
 
int static ping_phone;
 
int main(int argc, char **argv)
87,15 → 109,18
printf("%s: cannot create hash table\n", NAME);
return ENOMEM;
}
// ipc_register_irq(2, &msim_kbd);
// ipc_register_irq(1, &i8042_kbd);
while (1) {
callid = ipc_wait_for_call(&call, 0);
// printf("NS: Call in_phone_hash=%lX...", call.in_phone_hash);
printf("NS: Call in_phone_hash=%lX...", call.in_phone_hash);
switch (IPC_GET_METHOD(call)) {
case IPC_M_AS_SEND:
as = (char *)IPC_GET_ARG2(call);
printf("Received as: %P, size:%d\n", as, IPC_GET_ARG3(call));
retval = ipc_answer_fast(callid, 0,(sysarg_t)(1024*1024), 0);
retval = ipc_answer(callid, 0,(sysarg_t)(1024*1024), 0);
if (!retval) {
printf("Reading shared memory...");
printf("Text: %s", as);
145,8 → 170,8
break;
}
if (! (callid & IPC_CALLID_NOTIFICATION)) {
// printf("Answering.\n");
ipc_answer_fast(callid, retval, arg1, arg2);
printf("Answering.\n");
ipc_answer(callid, retval, arg1, arg2);
}
}
}
202,7 → 227,7
hlp = hash_table_find(&ns_hash_table, keys);
if (!hlp) {
// printf("Service %d not registered.\n", service);
printf("Service %d not registered.\n", service);
return ENOENT;
}
hs = hash_table_get_instance(hlp, hashed_service_t, link);
/uspace/trunk/pci/libpci/pci.h
49,6 → 49,10
struct pci_methods *methods;
struct id_entry **id_hash; /* names.c */
struct id_bucket *current_id_bucket;
int fd; /* proc: fd */
int fd_rw; /* proc: fd opened read-write */
struct pci_dev *cached_dev; /* proc: device the fd is for */
int fd_pos; /* proc: current position */
};
 
/* Initialize PCI access */
112,6 → 116,20
void pci_setup_cache(struct pci_dev *, u8 * cache, int len);
 
/*
* Filters
*/
 
struct pci_filter {
int domain, bus, slot, func; /* -1 = ANY */
int vendor, device;
};
 
void pci_filter_init(struct pci_access *, struct pci_filter *);
char *pci_filter_parse_slot(struct pci_filter *, char *);
char *pci_filter_parse_id(struct pci_filter *, char *);
int pci_filter_match(struct pci_filter *, struct pci_dev *);
 
/*
* Conversion of PCI ID's to names (according to the pci.ids file)
*
* Call pci_lookup_name() to identify different types of ID's:
/uspace/trunk/pci/pci.c
14,7 → 14,6
#include <task.h>
#include <stdlib.h>
#include <ipc.h>
#include <services.h>
#include <errno.h>
 
#include "libpci/pci.h"
24,13 → 23,14
 
#define NAME "PCI"
 
static struct pci_access *pacc;
 
int main(int argc, char *argv[])
{
struct pci_access *pacc;
struct pci_dev *dev;
unsigned int c;
char buf[80];
 
int ipc_res;
ipcarg_t ns_in_phone_hash;
 
printf("%s: HelenOS PCI driver\n", NAME);
52,31 → 52,21
printf("\t%s\n", pci_lookup_name(pacc, buf, sizeof(buf), PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE,
dev->vendor_id, dev->device_id));
}
pci_cleanup(pacc); /* Close everything */
 
printf("%s: registering at naming service.\n", NAME);
if (ipc_connect_to_me(PHONE_NS, SERVICE_PCI, 0, &ns_in_phone_hash) != 0) {
if (ipc_connect_to_me(PHONE_NS, 40, 70, &ns_in_phone_hash) != 0) {
printf("Failed to register %s at naming service.\n", NAME);
return -1;
}
 
printf("%s: accepting connections\n", NAME);
while (1) {
while (1) {
ipc_call_t call;
ipc_callid_t callid;
int retval;
 
callid = ipc_wait_for_call(&call, 0);
switch(IPC_GET_METHOD(call)) {
case IPC_M_CONNECT_ME_TO:
IPC_SET_RETVAL(call, 0);
break;
}
if (! (callid & IPC_CALLID_NOTIFICATION)) {
ipc_answer(callid, &call);
}
printf("%s: received call from %lX\n", NAME, call.in_phone_hash);
ipc_answer(callid, EHANGUP, 0, 0);
}
 
pci_cleanup(pacc);
return 0;
}
/uspace/trunk/libipc/include/services.h
File deleted
/uspace/trunk/libipc/include/ipc.h
54,9 → 54,8
extern int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t *result);
extern ipc_callid_t ipc_wait_for_call(ipc_call_t *data, int flags);
extern ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
extern ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
ipcarg_t arg2);
extern ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call);
 
#define ipc_call_async(phoneid,method,arg1,private, callback) (ipc_call_async_2(phoneid, method, arg1, 0, private, callback))
extern void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
/uspace/trunk/libipc/generic/ipc.c
147,37 → 147,13
}
 
 
/** Send a fast answer to a received call.
*
* The fast answer makes use of passing retval and first two arguments in registers.
* If you need to return more, use the ipc_answer() instead.
*
* @param callid ID of the call being answered.
* @param retval Return value.
* @param arg1 First return argument.
* @param arg2 Second return argument.
*
* @return Zero on success or a value from @ref errno.h on failure.
*/
ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
/** Send answer to a received call */
ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
ipcarg_t arg2)
{
return __SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2);
}
 
/** Send a full answer to a received call.
*
* @param callid ID of the call being answered.
* @param call Call data. Must be already initialized by the responder.
*
* @return Zero on success or a value from @ref errno.h on failure.
*/
ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call)
{
return __SYSCALL2(SYS_IPC_ANSWER, callid, (sysarg_t) call);
}
 
 
/** Try to dispatch queed calls from async queue */
static void try_dispatch_queued_calls(void)
{