Changeset f658458 in mainline for uspace/srv


Ignore:
Timestamp:
2010-05-02T20:49:09Z (16 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bb864a0
Parents:
25a7e11d
Message:

parts of generic char interface, fixed some bugs

Location:
uspace/srv
Files:
3 edited

Legend:

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

    r25a7e11d rf658458  
    679679{
    680680        node_t *dev = tree->root_node;
     681        // relative path to the device from its parent (but with '/' at the beginning)
    681682        char *rel_path = path;
    682683        char *next_path_elem = NULL;
     
    685686       
    686687        while (cont && NULL != dev) {           
    687                 next_path_elem  = get_path_elem_end(rel_path+1);               
     688                next_path_elem  = get_path_elem_end(rel_path + 1);             
    688689                if ('/' == next_path_elem[0]) {
    689690                        cont = true;
     
    693694                }
    694695               
    695                 dev = find_node_child(dev, rel_path);           
     696                dev = find_node_child(dev, rel_path + 1);               
    696697               
    697698                if (cont) {
     699                        // restore the original path
    698700                        next_path_elem[0] = '/';
    699701                }
  • uspace/srv/devman/main.c

    r25a7e11d rf658458  
    291291}
    292292
     293/** Find handle for the device instance identified by the device's path in the device tree.
     294 */
     295static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
     296{
     297        char *pathname;
     298       
     299        /* Get fqdn */
     300        int rc = async_string_receive(&pathname, 0, NULL);
     301        if (rc != EOK) {
     302                ipc_answer_0(iid, rc);
     303                return;
     304        }
     305       
     306        node_t * dev = find_dev_node_by_path(&device_tree, pathname);
     307       
     308        free(pathname);
     309
     310        if (NULL == dev) {
     311                ipc_answer_0(iid, ENOENT);
     312                return;
     313        }
     314       
     315        ipc_answer_1(iid, EOK, dev->handle);
     316}
     317
     318
     319/** Function for handling connections from a client to the device manager.
     320 */
     321static void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall)
     322{
     323        /* Accept connection */
     324        ipc_answer_0(iid, EOK);
     325       
     326        bool cont = true;
     327        while (cont) {
     328                ipc_call_t call;
     329                ipc_callid_t callid = async_get_call(&call);
     330               
     331                switch (IPC_GET_METHOD(call)) {
     332                case IPC_M_PHONE_HUNGUP:
     333                        cont = false;
     334                        continue;
     335                case DEVMAN_DEVICE_GET_HANDLE:
     336                        devman_device_get_handle(callid, &call);
     337                        break;
     338                default:
     339                        if (!(callid & IPC_CALLID_NOTIFICATION))
     340                                ipc_answer_0(callid, ENOENT);
     341                }
     342        }       
     343}
     344
    293345static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent) {   
    294346       
     
    346398                devman_connection_driver(iid, icall);
    347399                break;
    348         /*case DEVMAN_CLIENT:
    349                 devmap_connection_client(iid, icall);
    350                 break;*/
     400        case DEVMAN_CLIENT:
     401                devman_connection_client(iid, icall);
     402                break;
    351403        case DEVMAN_CONNECT_TO_DEVICE:
    352404                // Connect client to selected device
  • uspace/srv/drivers/serial/serial.c

    r25a7e11d rf658458  
    5353
    5454#include <driver.h>
     55#include <char.h>
    5556#include <resource.h>
    5657
     
    9192}
    9293
     94static int serial_read(device_t *dev, char *buf, size_t count)
     95{
     96        printf(NAME ": serial_read %s\n", dev->name);
     97        // TODO
     98        return 0;
     99}
     100
     101static int serial_write(device_t *dev, char *buf, size_t count)
     102{
     103        // TODO
     104        return 0;
     105}
     106
    93107static device_class_t serial_dev_class;
     108
     109static char_iface_t serial_char_iface = {
     110        .read = &serial_read,
     111        .write = &serial_write
     112};
    94113
    95114static int serial_add_device(device_t *dev);
     
    377396                serial_unregister_interrupt_handler(dev);
    378397                return res;
    379         }               
     398        }       
     399       
     400        dev->class = &serial_dev_class;
    380401       
    381402        printf(NAME ": the %s device has been successfully initialized.\n", dev->name);
     
    440461        serial_dev_class.open = &serial_open;
    441462        serial_dev_class.close = &serial_close;
     463       
     464        serial_dev_class.interfaces[CHAR_DEV_IFACE] = &serial_char_iface;
    442465}
    443466
Note: See TracChangeset for help on using the changeset viewer.