Changeset 9d9ffdd in mainline for uspace/drv/usbmouse/main.c


Ignore:
Timestamp:
2011-03-11T15:42:43Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0bd4810c
Parents:
60a228f (diff), a8def7d (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 with hidd

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmouse/main.c

    r60a228f r9d9ffdd  
    11/*
    2  * Copyright (c) 2011 Matus Dekanek
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef USBMEM_H
    30 #define USBMEM_H
    31 
    32 
    33 // group should be changed - this is not usb specific
    34 /** @addtogroup usb
     29/** @addtogroup drvusbmouse
    3530 * @{
    3631 */
    37 /** @file definitions of memory management with address translation, used mostly in usb stack
     32/**
     33 * @file
     34 * Main routines of USB boot protocol mouse driver.
     35 */
     36#include "mouse.h"
     37#include <usb/debug.h>
     38#include <errno.h>
     39#include <str_error.h>
     40
     41/** Callback when new mouse device is attached and recognised by DDF.
    3842 *
    39  * USB HCD needs traslation between physical and virtual addresses. These
    40  * functions implement such functionality. For each allocated virtual address
    41  * the memory manager gets also it`s physical translation and remembers it.
    42  * Addresses allocated byt this manager can be therefore translated from and to
    43  * physical addresses.
    44  * Typical use:
    45  * void * address = mman_malloc(some_size);
    46  * void * physical_address = mman_getPA(address);
    47  * void * the_same_address = mman_getVA(physical_address);
    48  * void * null_address = mman_getPA(non_existing_address);
    49  * mman_free(address);
    50  * // physical_address, adress and the_same_address are no longer valid here
    51  *
    52  *
    53  * @note Addresses allocated by this memory manager should be as well
    54  * deallocated byt it.
    55  *
     43 * @param dev Representation of a generic DDF device.
     44 * @return Error code.
    5645 */
     46static int usbmouse_add_device(ddf_dev_t *dev)
     47{
     48        int rc = usb_mouse_create(dev);
     49        if (rc != EOK) {
     50                usb_log_error("Failed to initialize device driver: %s.\n",
     51                    str_error(rc));
     52                return rc;
     53        }
    5754
    58 #include <sys/types.h>
     55        fid_t poll_fibril = fibril_create(usb_mouse_polling_fibril, dev);
     56        if (poll_fibril == 0) {
     57                usb_log_error("Failed to initialize polling fibril.\n");
     58                /* FIXME: free allocated resources. */
     59                return ENOMEM;
     60        }
    5961
    60 extern void * mman_malloc(
    61     size_t size,
    62     size_t alignment,
    63     unsigned long max_physical_address);
     62        fibril_add_ready(poll_fibril);
    6463
    65 extern void * mman_getVA(void * addr);
     64        usb_log_info("controlling new mouse (handle %llu).\n",
     65            dev->handle);
    6666
    67 extern void * mman_getPA(void * addr);
     67        return EOK;
     68}
    6869
    69 extern void mman_free(void * addr);
     70/** USB mouse driver ops. */
     71static driver_ops_t mouse_driver_ops = {
     72        .add_device = usbmouse_add_device,
     73};
    7074
     75/** USB mouse driver. */
     76static driver_t mouse_driver = {
     77        .name = NAME,
     78        .driver_ops = &mouse_driver_ops
     79};
    7180
     81int main(int argc, char *argv[])
     82{
     83        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    7284
     85        return ddf_driver_main(&mouse_driver);
     86}
    7387
    74 
    75 
    76 /** @}
     88/**
     89 * @}
    7790 */
    78 
    79 
    80 #endif  /* USBMEM_H */
    81 
Note: See TracChangeset for help on using the changeset viewer.