Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1342 → Rev 1343

//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;
}