Ignore:
Timestamp:
2011-11-06T22:21:05Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
Children:
898e847
Parents:
2bdf8313 (diff), 7b5f4c9 (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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.c

    r2bdf8313 rb0f00a9  
    4343#include <ddi.h>
    4444#include <libarch/ddi.h>
    45 #include <devmap.h>
     45#include <loc.h>
    4646#include <sysinfo.h>
    4747#include <errno.h>
     
    5151#include "cuda_adb.h"
    5252
    53 #define NAME "cuda_adb"
    54 
    55 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall);
     53#define NAME  "cuda_adb"
     54
     55static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    5656static int cuda_init(void);
    5757static void cuda_irq_handler(ipc_callid_t iid, ipc_call_t *call);
     
    143143int main(int argc, char *argv[])
    144144{
    145         devmap_handle_t devmap_handle;
     145        service_id_t service_id;
    146146        int rc;
    147147        int i;
     
    150150
    151151        for (i = 0; i < ADB_MAX_ADDR; ++i) {
    152                 adb_dev[i].client_phone = -1;
    153                 adb_dev[i].devmap_handle = 0;
    154         }
    155 
    156         rc = devmap_driver_register(NAME, cuda_connection);
     152                adb_dev[i].client_sess = NULL;
     153                adb_dev[i].service_id = 0;
     154        }
     155
     156        rc = loc_server_register(NAME, cuda_connection);
    157157        if (rc < 0) {
    158                 printf(NAME ": Unable to register driver.\n");
     158                printf(NAME ": Unable to register server.\n");
    159159                return rc;
    160160        }
    161161
    162         rc = devmap_device_register("adb/kbd", &devmap_handle);
     162        rc = loc_service_register("adb/kbd", &service_id);
    163163        if (rc != EOK) {
    164                 printf(NAME ": Unable to register device %s.\n", "adb/kdb");
     164                printf(NAME ": Unable to register service %s.\n", "adb/kdb");
    165165                return rc;
    166166        }
    167167
    168         adb_dev[2].devmap_handle = devmap_handle;
    169         adb_dev[8].devmap_handle = devmap_handle;
    170 
    171         rc = devmap_device_register("adb/mouse", &devmap_handle);
     168        adb_dev[2].service_id = service_id;
     169        adb_dev[8].service_id = service_id;
     170
     171        rc = loc_service_register("adb/mouse", &service_id);
    172172        if (rc != EOK) {
    173                 printf(NAME ": Unable to register device %s.\n", "adb/mouse");
     173                printf(NAME ": Unable to register servise %s.\n", "adb/mouse");
    174174                return rc;
    175175        }
    176176
    177         adb_dev[9].devmap_handle = devmap_handle;
     177        adb_dev[9].service_id = service_id;
    178178
    179179        if (cuda_init() < 0) {
     
    189189
    190190/** Character device connection handler */
    191 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall)
     191static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    192192{
    193193        ipc_callid_t callid;
    194194        ipc_call_t call;
    195195        sysarg_t method;
    196         devmap_handle_t dh;
    197         int retval;
     196        service_id_t dsid;
    198197        int dev_addr, i;
    199198
    200199        /* Get the device handle. */
    201         dh = IPC_GET_ARG1(*icall);
     200        dsid = IPC_GET_ARG1(*icall);
    202201
    203202        /* Determine which disk device is the client connecting to. */
    204203        dev_addr = -1;
    205204        for (i = 0; i < ADB_MAX_ADDR; i++) {
    206                 if (adb_dev[i].devmap_handle == dh)
     205                if (adb_dev[i].service_id == dsid)
    207206                        dev_addr = i;
    208207        }
     
    216215        async_answer_0(iid, EOK);
    217216
    218         while (1) {
     217        while (true) {
    219218                callid = async_get_call(&call);
    220219                method = IPC_GET_IMETHOD(call);
    221                 switch (method) {
    222                 case IPC_M_PHONE_HUNGUP:
     220               
     221                if (!method) {
    223222                        /* The other side has hung up. */
    224223                        async_answer_0(callid, EOK);
    225224                        return;
    226                 case IPC_M_CONNECT_TO_ME:
    227                         if (adb_dev[dev_addr].client_phone != -1) {
    228                                 retval = ELIMIT;
    229                                 break;
    230                         }
    231                         adb_dev[dev_addr].client_phone = IPC_GET_ARG5(call);
    232                         /*
    233                          * A hack so that we send the data to the phone
    234                          * regardless of which address the device is on.
    235                          */
    236                         for (i = 0; i < ADB_MAX_ADDR; ++i) {
    237                                 if (adb_dev[i].devmap_handle == dh) {
    238                                         adb_dev[i].client_phone = IPC_GET_ARG5(call);
     225                }
     226               
     227                async_sess_t *sess =
     228                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     229                if (sess != NULL) {
     230                        if (adb_dev[dev_addr].client_sess == NULL) {
     231                                adb_dev[dev_addr].client_sess = sess;
     232                               
     233                                /*
     234                                 * A hack so that we send the data to the session
     235                                 * regardless of which address the device is on.
     236                                 */
     237                                for (i = 0; i < ADB_MAX_ADDR; ++i) {
     238                                        if (adb_dev[i].service_id == dsid)
     239                                                adb_dev[i].client_sess = sess;
    239240                                }
    240                         }
    241                         retval = 0;
    242                         break;
    243                 default:
    244                         retval = EINVAL;
    245                         break;
    246                 }
    247                 async_answer_0(callid, retval);
     241                               
     242                                async_answer_0(callid, EOK);
     243                        } else
     244                                async_answer_0(callid, ELIMIT);
     245                } else
     246                        async_answer_0(callid, EINVAL);
    248247        }
    249248}
     
    476475        reg_val = ((uint16_t) data[1] << 8) | (uint16_t) data[2];
    477476
    478         if (adb_dev[dev_addr].client_phone == -1)
    479                 return;
    480 
    481         async_msg_1(adb_dev[dev_addr].client_phone, ADB_REG_NOTIF, reg_val);
     477        if (adb_dev[dev_addr].client_sess == NULL)
     478                return;
     479
     480        async_exch_t *exch =
     481            async_exchange_begin(adb_dev[dev_addr].client_sess);
     482        async_msg_1(exch, ADB_REG_NOTIF, reg_val);
     483        async_exchange_end(exch);
    482484}
    483485
Note: See TracChangeset for help on using the changeset viewer.