Changeset eb1a2f4 in mainline for uspace/drv/test2/test2.c


Ignore:
Timestamp:
2011-02-22T23:30:56Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3b5d1535, a9c674e0
Parents:
dbe25f1 (diff), 664af708 (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 (DDF refactoring)

This merge includes DDF refactoring that brought multifunctional devices
(i.e. ddf_dev_t and ddf_fun_t). Please, see ticket #295 at HelenOS
upstream Trac.

The conflicts themselves were easy to solve (merely several renamings).

Changes to USB subsystem:

  • drivers uses ddf_dev_t and ddf_fun_t
  • different signatures of many library functions
  • several hacks around communication with parent device (now the communication is clearer and somehow what we have now is hack about other hacks)
    • will repair and clean later
  • maybe added some extra debugging messages (the diff has about 240K, and I admit I have no energy to double check that)

WARNING:

  • the diff is VERY long, recommended is viewing partial diffs of the merge (i.e. merges in mainline branch that lead to the parent one)
  • merging with your branches might involve huge renamings, sorry, no other way is possible

BUGS:

  • hub driver will not work (no function created)

GOOD NEWS:

  • QEMU keyboard seems to work with QEMU 0.13 and 0.14
  • we are up-to-date with mainline again
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/test2/test2.c

    rdbe25f1 reb1a2f4  
    3131
    3232#include <assert.h>
     33#include <async.h>
    3334#include <stdio.h>
    3435#include <errno.h>
    3536#include <str_error.h>
    36 #include <driver.h>
     37#include <ddf/driver.h>
    3738
    3839#define NAME "test2"
    3940
    40 static int add_device(device_t *dev);
     41static int test2_add_device(ddf_dev_t *dev);
    4142
    4243static driver_ops_t driver_ops = {
    43         .add_device = &add_device
     44        .add_device = &test2_add_device
    4445};
    4546
    46 static driver_t the_driver = {
     47static driver_t test2_driver = {
    4748        .name = NAME,
    4849        .driver_ops = &driver_ops
     
    5758 * @param score Device match score.
    5859 */
    59 static void register_child_verbose(device_t *parent, const char *message,
     60static int register_fun_verbose(ddf_dev_t *parent, const char *message,
    6061    const char *name, const char *match_id, int match_score)
    6162{
    62         printf(NAME ": registering child device `%s': %s.\n",
    63            name, message);
     63        ddf_fun_t *fun;
     64        int rc;
    6465
    65         int rc = child_device_register_wrapper(parent, name,
    66             match_id, match_score, NULL);
     66        printf(NAME ": registering function `%s': %s.\n", name, message);
    6767
    68         if (rc == EOK) {
    69                 printf(NAME ": registered child device `%s'.\n", name);
    70         } else {
    71                 printf(NAME ": failed to register child `%s' (%s).\n",
    72                     name, str_error(rc));
     68        fun = ddf_fun_create(parent, fun_inner, name);
     69        if (fun == NULL) {
     70                printf(NAME ": error creating function %s\n", name);
     71                return ENOMEM;
    7372        }
     73
     74        rc = ddf_fun_add_match_id(fun, match_id, match_score);
     75        if (rc != EOK) {
     76                printf(NAME ": error adding match IDs to function %s\n", name);
     77                ddf_fun_destroy(fun);
     78                return rc;
     79        }
     80
     81        rc = ddf_fun_bind(fun);
     82        if (rc != EOK) {
     83                printf(NAME ": error binding function %s: %s\n", name,
     84                    str_error(rc));
     85                ddf_fun_destroy(fun);
     86                return rc;
     87        }
     88
     89        printf(NAME ": registered child device `%s'\n", name);
     90        return EOK;
    7491}
    7592
    7693/** Add child devices after some sleep.
    7794 *
    78  * @param arg Parent device structure (device_t *).
     95 * @param arg Parent device structure (ddf_dev_t *).
    7996 * @return Always EOK.
    8097 */
    8198static int postponed_birth(void *arg)
    8299{
    83         device_t *dev = (device_t *) arg;
     100        ddf_dev_t *dev = (ddf_dev_t *) arg;
     101        ddf_fun_t *fun_a;
     102        int rc;
    84103
    85104        async_usleep(1000);
    86105
    87         register_child_verbose(dev, "child driven by the same task",
     106        (void) register_fun_verbose(dev, "child driven by the same task",
    88107            "child", "virtual&test2", 10);
    89         register_child_verbose(dev, "child driven by test1",
     108        (void) register_fun_verbose(dev, "child driven by test1",
    90109            "test1", "virtual&test1", 10);
    91110
    92         add_device_to_class(dev, "virtual");
     111        fun_a = ddf_fun_create(dev, fun_exposed, "a");
     112        if (fun_a == NULL) {
     113                printf(NAME ": error creating function 'a'.\n");
     114                return ENOMEM;
     115        }
     116
     117        rc = ddf_fun_bind(fun_a);
     118        if (rc != EOK) {
     119                printf(NAME ": error binding function 'a'.\n");
     120                return rc;
     121        }
     122
     123        ddf_fun_add_to_class(fun_a, "virtual");
    93124
    94125        return EOK;
    95126}
    96127
    97 
    98 static int add_device(device_t *dev)
     128static int test2_add_device(ddf_dev_t *dev)
    99129{
    100         printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
     130        printf(NAME ": test2_add_device(name=\"%s\", handle=%d)\n",
    101131            dev->name, (int) dev->handle);
    102132
    103         if (dev->parent == NULL) {
     133        if (str_cmp(dev->name, "child") != 0) {
    104134                fid_t postpone = fibril_create(postponed_birth, dev);
    105135                if (postpone == 0) {
     
    109139                fibril_add_ready(postpone);
    110140        } else {
    111                 register_child_verbose(dev, "child without available driver",
     141                (void) register_fun_verbose(dev, "child without available driver",
    112142                    "ERROR", "non-existent.match.id", 10);
    113143        }
     
    119149{
    120150        printf(NAME ": HelenOS test2 virtual device driver\n");
    121         return driver_main(&the_driver);
     151        return ddf_driver_main(&test2_driver);
    122152}
    123153
Note: See TracChangeset for help on using the changeset viewer.