Index: init/init.c
===================================================================
--- init/init.c	(revision 51d6f807ff440a0a2def34523275bd9c5cdd6493)
+++ init/init.c	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -29,4 +29,5 @@
 #include "version.h"
 #include <ipc.h>
+#include <services.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -40,4 +41,5 @@
 #include <ddi.h>
 #include <string.h>
+#include <errno.h>
 #include <kbd.h>
 
@@ -203,5 +205,5 @@
 		callid = ipc_wait_for_call(&data, NULL);
 		printf("Received ping\n");
-		ipc_answer(callid, 0, 0, 0);
+		ipc_answer_fast(callid, 0, 0, 0);
 	}
 //	callid = ipc_wait_for_call(&data, NULL);
@@ -301,5 +303,5 @@
 
 	printf("Test: Starting connect...\n");
-	while ((phoneid = ipc_connect_me_to(PHONE_NS, 30, 60)) < 0) {
+	while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
 	};
 	
@@ -314,4 +316,12 @@
 	printf("Test: Hangin up\n");
 	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);
 }
 
@@ -355,4 +365,5 @@
 //	test_slam();
 //	test_as_send();
+	test_pci();
 	test_kbd();
 
@@ -378,5 +389,5 @@
 
 	int i;
-	
+
 	for (i = 0; i < 50000000; i++)
 		;
@@ -401,4 +412,5 @@
 	printf("Main thread exiting.\n");
 */
+
 	return 0;
 }
Index: kbd/generic/kbd.c
===================================================================
--- kbd/generic/kbd.c	(revision 51d6f807ff440a0a2def34523275bd9c5cdd6493)
+++ kbd/generic/kbd.c	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -28,4 +28,5 @@
 
 #include <ipc.h>
+#include <services.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -71,5 +72,5 @@
 	printf("%s: Registering at naming service.\n", NAME);
 
-	if ((res = ipc_connect_to_me(PHONE_NS, 30, 60, &phonead)) != 0) {
+	if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, &phonead)) != 0) {
 		printf("%s: Error: Registering at naming service failed.\n", NAME);
 		return -1;
@@ -139,5 +140,5 @@
 		if (! (callid & IPC_CALLID_NOTIFICATION)) {
 		//	printf("%s: Answering\n", NAME);
-			ipc_answer(callid, retval, arg1, arg2);
+			ipc_answer_fast(callid, retval, arg1, arg2);
 		}
 	}
Index: libipc/generic/ipc.c
===================================================================
--- libipc/generic/ipc.c	(revision 51d6f807ff440a0a2def34523275bd9c5cdd6493)
+++ libipc/generic/ipc.c	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -148,10 +148,34 @@
 
 
-/** Send answer to a received call */
-ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
+/** 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,
 		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 */
Index: libipc/include/ipc.h
===================================================================
--- libipc/include/ipc.h	(revision 51d6f807ff440a0a2def34523275bd9c5cdd6493)
+++ libipc/include/ipc.h	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -55,6 +55,7 @@
 			 ipcarg_t *result);
 extern ipc_callid_t ipc_wait_for_call(ipc_call_t *data, int flags);
-extern ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
+extern ipcarg_t ipc_answer_fast(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))
Index: libipc/include/services.h
===================================================================
--- libipc/include/services.h	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
+++ libipc/include/services.h	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file	services.h
+ * @brief	List of all known services and their codes.
+ */
+
+#ifndef __LIBIPC__SERVICES_H__
+#define __LIBIPC__SERVICES_H__
+
+#define SERVICE_PCI		1
+#define SERVICE_FRAME_BUFFER	2
+#define SERVICE_KEYBOARD	3
+
+#endif
Index: ns/ns.c
===================================================================
--- ns/ns.c	(revision 51d6f807ff440a0a2def34523275bd9c5cdd6493)
+++ ns/ns.c	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -72,26 +72,4 @@
 } 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;
 
@@ -110,16 +88,13 @@
 		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(callid, 0,(sysarg_t)(1024*1024), 0);
+			retval = ipc_answer_fast(callid, 0,(sysarg_t)(1024*1024), 0);
 			if (!retval) {
 				printf("Reading shared memory...");
@@ -171,6 +146,6 @@
 		}
 		if (! (callid & IPC_CALLID_NOTIFICATION)) {
-			printf("Answering.\n");
-			ipc_answer(callid, retval, arg1, arg2);
+//			printf("Answering.\n");
+			ipc_answer_fast(callid, retval, arg1, arg2);
 		}
 	}
@@ -228,5 +203,5 @@
 	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;
 	}
Index: pci/libpci/pci.h
===================================================================
--- pci/libpci/pci.h	(revision 51d6f807ff440a0a2def34523275bd9c5cdd6493)
+++ pci/libpci/pci.h	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -50,8 +50,4 @@
 	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 */
 };
 
@@ -117,18 +113,4 @@
 
 /*
- *	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)
  *
Index: pci/pci.c
===================================================================
--- pci/pci.c	(revision 51d6f807ff440a0a2def34523275bd9c5cdd6493)
+++ pci/pci.c	(revision 250717cc879c7f068fa71fc6aab936263ef42849)
@@ -15,4 +15,5 @@
 #include <stdlib.h>
 #include <ipc.h>
+#include <services.h>
 #include <errno.h>
 
@@ -24,12 +25,11 @@
 #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;
 
@@ -53,20 +53,30 @@
 			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, 40, 70, &ns_in_phone_hash) != 0) {
+	if (ipc_connect_to_me(PHONE_NS, SERVICE_PCI, 0, &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);
-		ipc_answer(callid, EHANGUP, 0, 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);
 	}
+
+	pci_cleanup(pacc);
 	return 0;
 }
