Rev 1336 | Rev 1353 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1336 | Rev 1343 | ||
|---|---|---|---|
| Line 12... | Line 12... | ||
| 12 | #include <stdio.h> |
12 | #include <stdio.h> |
| 13 | #include <ddi.h> |
13 | #include <ddi.h> |
| 14 | #include <task.h> |
14 | #include <task.h> |
| 15 | #include <stdlib.h> |
15 | #include <stdlib.h> |
| 16 | #include <ipc.h> |
16 | #include <ipc.h> |
| - | 17 | #include <services.h> |
|
| 17 | #include <errno.h> |
18 | #include <errno.h> |
| 18 | 19 | ||
| 19 | #include "libpci/pci.h" |
20 | #include "libpci/pci.h" |
| 20 | 21 | ||
| 21 | #define PCI_CONF1 0xcf8 |
22 | #define PCI_CONF1 0xcf8 |
| 22 | #define PCI_CONF1_SIZE 8 |
23 | #define PCI_CONF1_SIZE 8 |
| 23 | 24 | ||
| 24 | #define NAME "PCI" |
25 | #define NAME "PCI" |
| 25 | 26 | ||
| - | 27 | static struct pci_access *pacc; |
|
| - | 28 | ||
| 26 | int main(int argc, char *argv[]) |
29 | int main(int argc, char *argv[]) |
| 27 | { |
30 | { |
| 28 | struct pci_access *pacc; |
- | |
| 29 | struct pci_dev *dev; |
31 | struct pci_dev *dev; |
| 30 | unsigned int c; |
32 | unsigned int c; |
| 31 | char buf[80]; |
33 | char buf[80]; |
| 32 | - | ||
| 33 | int ipc_res; |
- | |
| 34 | ipcarg_t ns_in_phone_hash; |
34 | ipcarg_t ns_in_phone_hash; |
| 35 | 35 | ||
| 36 | printf("%s: HelenOS PCI driver\n", NAME); |
36 | printf("%s: HelenOS PCI driver\n", NAME); |
| 37 | 37 | ||
| 38 | /* |
38 | /* |
| Line 50... | Line 50... | ||
| 50 | dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id, |
50 | dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id, |
| 51 | c, dev->irq, dev->base_addr[0]); |
51 | c, dev->irq, dev->base_addr[0]); |
| 52 | printf("\t%s\n", pci_lookup_name(pacc, buf, sizeof(buf), PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE, |
52 | printf("\t%s\n", pci_lookup_name(pacc, buf, sizeof(buf), PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE, |
| 53 | dev->vendor_id, dev->device_id)); |
53 | dev->vendor_id, dev->device_id)); |
| 54 | } |
54 | } |
| 55 | pci_cleanup(pacc); /* Close everything */ |
- | |
| 56 | 55 | ||
| 57 | printf("%s: registering at naming service.\n", NAME); |
56 | printf("%s: registering at naming service.\n", NAME); |
| 58 | if (ipc_connect_to_me(PHONE_NS, 40, 70, &ns_in_phone_hash) != 0) { |
57 | if (ipc_connect_to_me(PHONE_NS, SERVICE_PCI, 0, &ns_in_phone_hash) != 0) { |
| 59 | printf("Failed to register %s at naming service.\n", NAME); |
58 | printf("Failed to register %s at naming service.\n", NAME); |
| 60 | return -1; |
59 | return -1; |
| 61 | } |
60 | } |
| 62 | 61 | ||
| 63 | printf("%s: accepting connections\n", NAME); |
62 | printf("%s: accepting connections\n", NAME); |
| 64 | while (1) { |
63 | while (1) { |
| 65 | ipc_call_t call; |
64 | ipc_call_t call; |
| 66 | ipc_callid_t callid; |
65 | ipc_callid_t callid; |
| - | 66 | int retval; |
|
| 67 | 67 | ||
| 68 | callid = ipc_wait_for_call(&call, 0); |
68 | callid = ipc_wait_for_call(&call, 0); |
| - | 69 | switch(IPC_GET_METHOD(call)) { |
|
| - | 70 | case IPC_M_CONNECT_ME_TO: |
|
| - | 71 | IPC_SET_RETVAL(call, 0); |
|
| - | 72 | break; |
|
| - | 73 | } |
|
| - | 74 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
|
| 69 | ipc_answer(callid, EHANGUP, 0, 0); |
75 | ipc_answer(callid, &call); |
| - | 76 | } |
|
| - | 77 | printf("%s: received call from %lX\n", NAME, call.in_phone_hash); |
|
| 70 | } |
78 | } |
| - | 79 | ||
| - | 80 | pci_cleanup(pacc); |
|
| 71 | return 0; |
81 | return 0; |
| 72 | } |
82 | } |