Changeset cf2af94 in mainline for uspace/srv/hw/irc/apic/apic.c
- Timestamp:
- 2011-02-09T11:46:47Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cb15135a
- Parents:
- a49c4002 (diff), 0b37882 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/irc/apic/apic.c
ra49c4002 rcf2af94 1 1 /* 2 * Copyright (c) 20 06 Ondrej Palkovsky2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <inttypes.h> 29 /** @addtogroup apic 30 * @{ 31 */ 32 33 /** 34 * @file apic.c 35 * @brief APIC driver. 36 */ 37 38 #include <ipc/services.h> 39 #include <ipc/irc.h> 40 #include <ipc/ns.h> 41 #include <sysinfo.h> 42 #include <as.h> 43 #include <ddi.h> 44 #include <libarch/ddi.h> 45 #include <align.h> 46 #include <bool.h> 47 #include <errno.h> 48 #include <async.h> 49 #include <align.h> 50 #include <async.h> 30 51 #include <stdio.h> 31 #include <unistd.h> 32 #include <async.h> 33 #include <errno.h> 34 #include "../tester.h" 52 #include <ipc/devmap.h> 35 53 36 #define MAX_CONNECTIONS 5054 #define NAME "apic" 37 55 38 static int connections[MAX_CONNECTIONS]; 56 static int apic_enable_irq(sysarg_t irq) 57 { 58 // FIXME: TODO 59 return ENOTSUP; 60 } 39 61 40 static void client_connection(ipc_callid_t iid, ipc_call_t *icall) 62 /** Handle one connection to APIC. 63 * 64 * @param iid Hash of the request that opened the connection. 65 * @param icall Call data of the request that opened the connection. 66 * 67 */ 68 static void apic_connection(ipc_callid_t iid, ipc_call_t *icall) 41 69 { 42 unsigned int i; 70 ipc_callid_t callid; 71 ipc_call_t call; 43 72 44 TPRINTF("Connected phone %" PRIun " accepting\n", icall->in_phone_hash); 45 ipc_answer_0(iid, EOK); 46 for (i = 0; i < MAX_CONNECTIONS; i++) { 47 if (!connections[i]) { 48 connections[i] = icall->in_phone_hash; 49 break; 50 } 51 } 73 /* 74 * Answer the first IPC_M_CONNECT_ME_TO call. 75 */ 76 async_answer_0(iid, EOK); 52 77 53 78 while (true) { 54 ipc_call_t call; 55 ipc_callid_t callid = async_get_call(&call); 56 int retval; 79 callid = async_get_call(&call); 57 80 58 switch (IPC_GET_METHOD(call)) { 59 case IPC_M_PHONE_HUNGUP: 60 TPRINTF("Phone %" PRIun " hung up\n", icall->in_phone_hash); 61 retval = 0; 81 switch (IPC_GET_IMETHOD(call)) { 82 case IRC_ENABLE_INTERRUPT: 83 async_answer_0(callid, apic_enable_irq(IPC_GET_ARG1(call))); 62 84 break; 63 case IPC_TEST_METHOD: 64 TPRINTF("Received well known message from %" PRIun ": %" PRIun "\n", 65 icall->in_phone_hash, callid); 66 ipc_answer_0(callid, EOK); 85 case IRC_CLEAR_INTERRUPT: 86 /* Noop */ 87 async_answer_0(callid, EOK); 67 88 break; 68 89 default: 69 TPRINTF("Received unknown message from %" PRIun ": %" PRIun "\n", 70 icall->in_phone_hash, callid); 71 ipc_answer_0(callid, ENOENT); 90 async_answer_0(callid, EINVAL); 72 91 break; 73 92 } … … 75 94 } 76 95 77 const char *test_register(void) 96 /** Initialize the APIC driver. 97 * 98 */ 99 static bool apic_init(void) 78 100 { 79 async_set_client_connection(client_connection);101 sysarg_t apic; 80 102 81 i pcarg_t phonead;82 int res = ipc_connect_to_me(PHONE_NS, IPC_TEST_SERVICE, 0, 0, &phonead);83 if (res != 0)84 return "Failed registering IPC service";103 if ((sysinfo_get_value("apic", &apic) != EOK) || (!apic)) { 104 printf(NAME ": No APIC found\n"); 105 return false; 106 } 85 107 86 TPRINTF("Registered as service %u, accepting connections\n", IPC_TEST_SERVICE); 108 async_set_client_connection(apic_connection); 109 service_register(SERVICE_APIC); 110 111 return true; 112 } 113 114 int main(int argc, char **argv) 115 { 116 printf(NAME ": HelenOS APIC driver\n"); 117 118 if (!apic_init()) 119 return -1; 120 121 printf(NAME ": Accepting connections\n"); 87 122 async_manager(); 88 123 89 return NULL; 124 /* Never reached */ 125 return 0; 90 126 } 127 128 /** 129 * @} 130 */
Note:
See TracChangeset
for help on using the changeset viewer.