Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1342 → Rev 1343

/uspace/trunk/kbd/generic/kbd.c
27,6 → 27,7
*/
 
#include <ipc.h>
#include <services.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
70,7 → 71,7
/* Register service at nameserver */
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;
};
138,7 → 139,7
}
if (! (callid & IPC_CALLID_NOTIFICATION)) {
// printf("%s: Answering\n", NAME);
ipc_answer(callid, retval, arg1, arg2);
ipc_answer_fast(callid, retval, arg1, arg2);
}
}
}
/uspace/trunk/ns/ns.c
71,28 → 71,6
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)
109,18 → 87,15
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(callid, 0,(sysarg_t)(1024*1024), 0);
retval = ipc_answer_fast(callid, 0,(sysarg_t)(1024*1024), 0);
if (!retval) {
printf("Reading shared memory...");
printf("Text: %s", as);
170,8 → 145,8
break;
}
if (! (callid & IPC_CALLID_NOTIFICATION)) {
printf("Answering.\n");
ipc_answer(callid, retval, arg1, arg2);
// printf("Answering.\n");
ipc_answer_fast(callid, retval, arg1, arg2);
}
}
}
227,7 → 202,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/libipc/include/ipc.h
54,8 → 54,9
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(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))
extern void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
/uspace/trunk/libipc/include/services.h
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
/uspace/trunk/libipc/generic/ipc.c
147,13 → 147,37
}
 
 
/** 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 */
static void try_dispatch_queued_calls(void)
{
/uspace/trunk/init/init.c
28,6 → 28,7
 
#include "version.h"
#include <ipc.h>
#include <services.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
39,6 → 40,7
#include <as.h>
#include <ddi.h>
#include <string.h>
#include <errno.h>
#include <kbd.h>
 
int a;
202,7 → 204,7
got_answer_2);
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);
}
300,7 → 302,7
int phoneid;
 
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) {
};
printf("Test: Connected: %d\n", res);
315,6 → 317,14
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;
354,6 → 364,7
// test_hangup();
// test_slam();
// test_as_send();
test_pci();
test_kbd();
 
/*
377,7 → 388,7
}
 
int i;
 
for (i = 0; i < 50000000; i++)
;
400,5 → 411,6
 
printf("Main thread exiting.\n");
*/
 
return 0;
}
/uspace/trunk/pci/libpci/pci.h
49,10 → 49,6
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 */
116,20 → 112,6
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,6 → 14,7
#include <task.h>
#include <stdlib.h>
#include <ipc.h>
#include <services.h>
#include <errno.h>
 
#include "libpci/pci.h"
23,14 → 24,13
 
#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,21 → 52,31
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, 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;
}