source: mainline/uspace/srv/hw/irc/apic/apic.c@ 124c061

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 124c061 was 124c061, checked in by Jakub Jermar <jakub@…>, 14 years ago

ipc_connect_to_me() now takes one extra argument to store the client task hash.

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[3e5a814]1/*
[acc7ce4]2 * Copyright (c) 2011 Martin Decky
[3e5a814]3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
[acc7ce4]29/** @addtogroup apic
[3e5a814]30 * @{
[acc7ce4]31 */
[3e5a814]32
33/**
[acc7ce4]34 * @file apic.c
35 * @brief APIC driver.
[3e5a814]36 */
37
38#include <ipc/ipc.h>
39#include <ipc/services.h>
[acc7ce4]40#include <ipc/irc.h>
[3e5a814]41#include <ipc/ns.h>
42#include <sysinfo.h>
43#include <as.h>
44#include <ddi.h>
[acc7ce4]45#include <libarch/ddi.h>
[3e5a814]46#include <align.h>
47#include <bool.h>
48#include <errno.h>
49#include <async.h>
50#include <align.h>
51#include <async.h>
52#include <stdio.h>
53#include <ipc/devmap.h>
54
[acc7ce4]55#define NAME "apic"
[3e5a814]56
[acc7ce4]57static int apic_enable_irq(sysarg_t irq)
58{
59 // FIXME: TODO
60 return ENOTSUP;
61}
[3e5a814]62
[acc7ce4]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.
[3e5a814]67 *
68 */
[acc7ce4]69static void apic_connection(ipc_callid_t iid, ipc_call_t *icall)
[3e5a814]70{
71 ipc_callid_t callid;
72 ipc_call_t call;
[acc7ce4]73
[3e5a814]74 /*
75 * Answer the first IPC_M_CONNECT_ME_TO call.
76 */
77 ipc_answer_0(iid, EOK);
78
[acc7ce4]79 while (true) {
[3e5a814]80 callid = async_get_call(&call);
[acc7ce4]81
[228e490]82 switch (IPC_GET_IMETHOD(call)) {
[acc7ce4]83 case IRC_ENABLE_INTERRUPT:
84 ipc_answer_0(callid, apic_enable_irq(IPC_GET_ARG1(call)));
85 break;
86 case IRC_CLEAR_INTERRUPT:
87 /* Noop */
88 ipc_answer_0(callid, EOK);
[3e5a814]89 break;
90 default:
91 ipc_answer_0(callid, EINVAL);
92 break;
93 }
94 }
95}
96
[acc7ce4]97/** Initialize the APIC driver.
[3e5a814]98 *
99 */
[acc7ce4]100static bool apic_init(void)
[3e5a814]101{
[acc7ce4]102 sysarg_t apic;
[3e5a814]103
[acc7ce4]104 if ((sysinfo_get_value("apic", &apic) != EOK) || (!apic)) {
105 printf(NAME ": No APIC found\n");
[3e5a814]106 return false;
107 }
108
[acc7ce4]109 async_set_client_connection(apic_connection);
[124c061]110 ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, NULL, NULL);
[3e5a814]111
112 return true;
113}
114
115int main(int argc, char **argv)
116{
[acc7ce4]117 printf(NAME ": HelenOS APIC driver\n");
[3e5a814]118
[acc7ce4]119 if (!apic_init())
[3e5a814]120 return -1;
121
122 printf(NAME ": Accepting connections\n");
123 async_manager();
[acc7ce4]124
[3e5a814]125 /* Never reached */
126 return 0;
127}
128
129/**
130 * @}
[acc7ce4]131 */
Note: See TracBrowser for help on using the repository browser.