Changeset a676574 in mainline for uspace/srv/hw/irc/apic/apic.c
- Timestamp:
- 2011-01-09T12:18:00Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 54de5ebd
- Parents:
- a3eeef45 (diff), 9d12059 (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
ra3eeef45 ra676574 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/ipc.h> 39 #include <ipc/services.h> 40 #include <ipc/irc.h> 41 #include <ipc/ns.h> 42 #include <sysinfo.h> 43 #include <as.h> 44 #include <ddi.h> 45 #include <libarch/ddi.h> 46 #include <align.h> 47 #include <bool.h> 48 #include <errno.h> 49 #include <async.h> 50 #include <align.h> 51 #include <async.h> 30 52 #include <stdio.h> 31 #include <unistd.h> 32 #include <async.h> 33 #include <errno.h> 34 #include "../tester.h" 53 #include <ipc/devmap.h> 35 54 36 #define MAX_CONNECTIONS 5055 #define NAME "apic" 37 56 38 static int connections[MAX_CONNECTIONS]; 57 static int apic_enable_irq(sysarg_t irq) 58 { 59 // FIXME: TODO 60 return ENOTSUP; 61 } 39 62 40 static void client_connection(ipc_callid_t iid, ipc_call_t *icall) 63 /** Handle one connection to APIC. 64 * 65 * @param iid Hash of the request that opened the connection. 66 * @param icall Call data of the request that opened the connection. 67 * 68 */ 69 static void apic_connection(ipc_callid_t iid, ipc_call_t *icall) 41 70 { 42 unsigned int i; 71 ipc_callid_t callid; 72 ipc_call_t call; 43 73 44 TPRINTF("Connected phone %" PRIun " accepting\n", icall->in_phone_hash); 74 /* 75 * Answer the first IPC_M_CONNECT_ME_TO call. 76 */ 45 77 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 }52 78 53 79 while (true) { 54 ipc_call_t call; 55 ipc_callid_t callid = async_get_call(&call); 56 int retval; 80 callid = async_get_call(&call); 57 81 58 82 switch (IPC_GET_IMETHOD(call)) { 59 case IPC_M_PHONE_HUNGUP: 60 TPRINTF("Phone %" PRIun " hung up\n", icall->in_phone_hash); 61 retval = 0; 83 case IRC_ENABLE_INTERRUPT: 84 ipc_answer_0(callid, apic_enable_irq(IPC_GET_ARG1(call))); 62 85 break; 63 case IPC_TEST_METHOD: 64 TPRINTF("Received well known message from %" PRIun ": %" PRIun "\n", 65 icall->in_phone_hash, callid); 86 case IRC_CLEAR_INTERRUPT: 87 /* Noop */ 66 88 ipc_answer_0(callid, EOK); 67 89 break; 68 90 default: 69 TPRINTF("Received unknown message from %" PRIun ": %" PRIun "\n", 70 icall->in_phone_hash, callid); 71 ipc_answer_0(callid, ENOENT); 91 ipc_answer_0(callid, EINVAL); 72 92 break; 73 93 } … … 75 95 } 76 96 77 const char *test_register(void) 97 /** Initialize the APIC driver. 98 * 99 */ 100 static bool apic_init(void) 78 101 { 79 async_set_client_connection(client_connection);102 sysarg_t apic; 80 103 104 if ((sysinfo_get_value("apic", &apic) != EOK) || (!apic)) { 105 printf(NAME ": No APIC found\n"); 106 return false; 107 } 108 109 async_set_client_connection(apic_connection); 81 110 sysarg_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"; 111 ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, &phonead); 85 112 86 TPRINTF("Registered as service %u, accepting connections\n", IPC_TEST_SERVICE); 113 return true; 114 } 115 116 int main(int argc, char **argv) 117 { 118 printf(NAME ": HelenOS APIC driver\n"); 119 120 if (!apic_init()) 121 return -1; 122 123 printf(NAME ": Accepting connections\n"); 87 124 async_manager(); 88 125 89 return NULL; 126 /* Never reached */ 127 return 0; 90 128 } 129 130 /** 131 * @} 132 */
Note:
See TracChangeset
for help on using the changeset viewer.