Changeset cf2af94 in mainline for uspace/srv/hw/irc/apic/apic.c


Ignore:
Timestamp:
2011-02-09T11:46:47Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
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.
Message:

Merge mainline changes

Local modifications:

  • change pipefs and ext2 to build again (use async_* calls instead of ipc_*)
File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/irc/apic/apic.c

    ra49c4002 rcf2af94  
    11/*
    2  * Copyright (c) 2006 Ondrej Palkovsky
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    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>
    3051#include <stdio.h>
    31 #include <unistd.h>
    32 #include <async.h>
    33 #include <errno.h>
    34 #include "../tester.h"
     52#include <ipc/devmap.h>
    3553
    36 #define MAX_CONNECTIONS  50
     54#define NAME  "apic"
    3755
    38 static int connections[MAX_CONNECTIONS];
     56static int apic_enable_irq(sysarg_t irq)
     57{
     58        // FIXME: TODO
     59        return ENOTSUP;
     60}
    3961
    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 */
     68static void apic_connection(ipc_callid_t iid, ipc_call_t *icall)
    4169{
    42         unsigned int i;
     70        ipc_callid_t callid;
     71        ipc_call_t call;
    4372       
    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);
    5277       
    5378        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);
    5780               
    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)));
    6284                        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);
    6788                        break;
    6889                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);
    7291                        break;
    7392                }
     
    7594}
    7695
    77 const char *test_register(void)
     96/** Initialize the APIC driver.
     97 *
     98 */
     99static bool apic_init(void)
    78100{
    79         async_set_client_connection(client_connection);
     101        sysarg_t apic;
    80102       
    81         ipcarg_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        }
    85107       
    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
     114int 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");
    87122        async_manager();
    88123       
    89         return NULL;
     124        /* Never reached */
     125        return 0;
    90126}
     127
     128/**
     129 * @}
     130 */
Note: See TracChangeset for help on using the changeset viewer.