Changeset 21c5d41 in mainline


Ignore:
Timestamp:
2008-06-03T15:07:52Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bd80465
Parents:
6c89f20
Message:

remove extensive debugging output
remove private devmap.h

Location:
uspace/srv/devmap
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devmap/devmap.c

    r6c89f20 r21c5d41  
    4545#include <stdlib.h>
    4646#include <string.h>
    47 
    48 #include "devmap.h"
     47#include <ipc/devmap.h>
     48
     49#define NAME "devmap"
    4950
    5051
     
    113114        }
    114115
    115         if (item == &devices_list) {
    116                 printf("DEVMAP: no device named %s.\n", name);
     116        if (item == &devices_list)
    117117                return NULL;
    118         }
    119118
    120119        device = list_get_instance(item, devmap_device_t, devices);
     
    204203         */
    205204        if (!ipc_data_write_receive(&callid, &name_size)) {
    206                 printf("Unexpected request.\n");
    207205                free(driver);
    208206                ipc_answer_0(callid, EREFUSED);
     
    212210
    213211        if (name_size > DEVMAP_NAME_MAXLEN) {
    214                 printf("Too logn name: %u: maximum is %u.\n", name_size,
    215                     DEVMAP_NAME_MAXLEN);
    216212                free(driver);
    217213                ipc_answer_0(callid, EINVAL);
     
    224220         */
    225221        if (NULL == (driver->name = (char *)malloc(name_size + 1))) {
    226                 printf("Cannot allocate space for driver name.\n");
    227222                free(driver);
    228223                ipc_answer_0(callid, ENOMEM);
     
    235230         */
    236231        if (EOK != ipc_data_write_finalize(callid, driver->name, name_size)) {
    237                 printf("Cannot read driver name.\n");
    238232                free(driver->name);
    239233                free(driver);
     
    244238        driver->name[name_size] = 0;
    245239
    246         printf("Read driver name: '%s'.\n", driver->name);
    247 
    248240        /* Initialize futex for list of devices owned by this driver */
    249241        futex_initialize(&(driver->devices_futex), 1);
     
    260252
    261253        if (IPC_M_CONNECT_TO_ME != IPC_GET_METHOD(call)) {
    262                 printf("DEVMAP: Unexpected method: %u.\n",
    263                     IPC_GET_METHOD(call));
    264254                ipc_answer_0(callid, ENOTSUP);
    265255               
     
    289279       
    290280        ipc_answer_0(iid, EOK);
    291         printf("Driver registered.\n");
    292281
    293282        *odriver = driver;
    294         return;
    295283}
    296284
     
    302290        devmap_device_t *device;
    303291
    304         if (NULL == driver) {
    305                 printf("Error: driver == NULL.\n");
     292        if (NULL == driver)
    306293                return EEXISTS;
    307         }
    308 
    309         printf("Unregister driver '%s'.\n", driver->name);
     294       
    310295        futex_down(&drivers_list_futex);       
    311296
     
    323308                device = list_get_instance(driver->devices.next,
    324309                    devmap_device_t, driver_devices);
    325                 printf("Unregister device '%s'.\n", device->name);
    326310                devmap_device_unregister_core(device);
    327311        }
     
    338322        free(driver);
    339323
    340         printf("Driver unregistered.\n");
    341 
    342324        return EOK;
    343325}
     
    355337
    356338        if (NULL == driver) {
    357                 printf("Invalid driver registration.\n");
    358339                ipc_answer_0(iid, EREFUSED);
    359340                return;
     
    362343        /* Create new device entry */
    363344        if (NULL ==
    364             (device = (devmap_device_t *)malloc(sizeof(devmap_device_t)))) {
    365                 printf("Cannot allocate new device.\n");
     345            (device = (devmap_device_t *) malloc(sizeof(devmap_device_t)))) {
    366346                ipc_answer_0(iid, ENOMEM);
    367347                return;
     
    371351        if (!ipc_data_write_receive(&callid, &size)) {
    372352                free(device);
    373                 printf("Cannot read device name.\n");
    374353                ipc_answer_0(iid, EREFUSED);
    375354                return;
     
    377356
    378357        if (size > DEVMAP_NAME_MAXLEN) {
    379                 printf("Too long device name: %u.\n", size);
    380358                free(device);
    381359                ipc_answer_0(callid, EINVAL);
     
    383361                return;
    384362        }
    385 
    386                 /* +1 for terminating \0 */
    387         device->name = (char *)malloc(size + 1);
     363       
     364        /* +1 for terminating \0 */
     365        device->name = (char *) malloc(size + 1);
    388366
    389367        if (NULL == device->name) {
    390                 printf("Cannot read device name.\n");
    391368                free(device);
    392369                ipc_answer_0(callid, ENOMEM);
     
    405382        /* Check that device with such name is not already registered */
    406383        if (NULL != devmap_device_find_name(device->name)) {
    407                 printf("Device '%s' already registered.\n", device->name);
     384                printf(NAME ": Device '%s' already registered\n", device->name);
    408385                futex_up(&devices_list_futex); 
    409386                free(device->name);
     
    429406        futex_up(&devices_list_futex); 
    430407
    431         printf("Device '%s' registered.\n", device->name);     
    432408        ipc_answer_1(iid, EOK, device->handle);
    433 
    434         return;
    435409}
    436410
     
    462436
    463437        if (NULL == dev) {
    464                 printf("DEVMAP: No registered device with handle %d.\n",
    465                     handle);
    466438                ipc_answer_0(callid, ENOENT);
    467439                return;
     
    470442        ipc_forward_fast(callid, dev->driver->phone, (ipcarg_t)(dev->handle),
    471443            IPC_GET_ARG3(*call), 0, IPC_FF_NONE);
    472         return;
    473444}
    474445
     
    485456        ipcarg_t retval;
    486457       
    487        
    488458        /*
    489459         * Wait for incoming message with device name (but do not
     
    529499         */
    530500        if (NULL == dev) {
    531                 printf("DEVMAP: device %s has not been registered.\n", name);
    532501                ipc_answer_0(iid, ENOENT);
    533502                return;
    534503        }
    535504
    536         printf("DEVMAP: device %s has handler %d.\n", name, dev->handle);
    537                
    538505        ipc_answer_1(iid, EOK, dev->handle);
    539 
    540         return;
    541506}
    542507
     
    575540*/     
    576541        /* TODO: send name in response */
    577 
    578         return;
    579542}
    580543
     
    582545 *
    583546 */
    584 static void
    585 devmap_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
     547static void devmap_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
    586548{
    587549        ipc_callid_t callid;
     
    594556        devmap_driver_register(&driver);
    595557
    596         if (NULL == driver) {
    597                 printf("DEVMAP: driver registration failed.\n");
    598                 return;
    599         }
     558        if (NULL == driver)
     559                return;
    600560       
    601561        while (cont) {
     
    604564                switch (IPC_GET_METHOD(call)) {
    605565                case IPC_M_PHONE_HUNGUP:
    606                         printf("DEVMAP: connection hung up.\n");
    607566                        cont = false;
    608567                        continue; /* Exit thread */
    609568                case DEVMAP_DRIVER_UNREGISTER:
    610                         printf("DEVMAP: unregister driver.\n");
    611569                        if (NULL == driver) {
    612                                 printf("DEVMAP: driver was not registered!\n");
    613570                                ipc_answer_0(callid, ENOENT);
    614571                        } else {
     
    650607 *
    651608 */
    652 static void
    653 devmap_connection_client(ipc_callid_t iid, ipc_call_t *icall)
     609static void devmap_connection_client(ipc_callid_t iid, ipc_call_t *icall)
    654610{
    655611        ipc_callid_t callid;
     
    664620                switch (IPC_GET_METHOD(call)) {
    665621                case IPC_M_PHONE_HUNGUP:
    666                         printf("DEVMAP: connection hung up.\n");
    667622                        cont = false;
    668623                        continue; /* Exit thread */
     
    687642 *
    688643 */
    689 static void
    690 devmap_connection(ipc_callid_t iid, ipc_call_t *icall)
    691 {
    692 
    693         printf("DEVMAP: new connection.\n");
    694 
    695                 /* Select interface */
    696         switch ((ipcarg_t)(IPC_GET_ARG1(*icall))) {
     644static void devmap_connection(ipc_callid_t iid, ipc_call_t *icall)
     645{
     646        /* Select interface */
     647        switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
    697648        case DEVMAP_DRIVER:
    698649                devmap_connection_driver(iid, icall);
     
    702653                break;
    703654        case DEVMAP_CONNECT_TO_DEVICE:
    704                         /* Connect client to selected device */
    705                 printf("DEVMAP: connect to device %d.\n",
    706                     IPC_GET_ARG2(*icall));
     655                /* Connect client to selected device */
    707656                devmap_forward(iid, icall);
    708657                break;
    709658        default:
    710659                ipc_answer_0(iid, ENOENT); /* No such interface */
    711                 printf("DEVMAP: Unknown interface %u.\n",
    712                     (ipcarg_t)(IPC_GET_ARG1(*icall)));
    713660        }
    714661
    715662        /* Cleanup */
    716        
    717         printf("DEVMAP: connection closed.\n");
    718         return;
    719663}
    720664
     
    724668int main(int argc, char *argv[])
    725669{
     670        printf(NAME ": HelenOS Device Mapper\n");
     671       
    726672        ipcarg_t phonead;
    727673
    728         printf("DEVMAP: HelenOS device mapper.\n");
    729 
    730674        if (devmap_init() != 0) {
    731                 printf("Error while initializing DEVMAP service.\n");
     675                printf(NAME ": Error while initializing service\n");
    732676                return -1;
    733677        }
    734 
    735                 /* Set a handler of incomming connections */
     678       
     679        /* Set a handler of incomming connections */
    736680        async_set_client_connection(devmap_connection);
    737681
     
    740684                return -1;
    741685       
     686        printf(NAME ": Accepting connections\n");
    742687        async_manager();
    743688        /* Never reached */
     
    748693 * @}
    749694 */
    750 
Note: See TracChangeset for help on using the changeset viewer.