Changeset 6f9e7fea in mainline for uspace/drv/root/root.c


Ignore:
Timestamp:
2010-11-30T00:24:42Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
178673c
Parents:
0ca16307
Message:

Add root virtual device driver

The driver is meant as a simple way to add virtual devices to the
system (it only passes list of virtual devices to devman which then
decides what drivers to launch).

File:
1 edited

Legend:

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

    r0ca16307 r6f9e7fea  
    5757#define PLATFORM_DEVICE_MATCH_SCORE 100
    5858
     59#define VIRTUAL_DEVICE_NAME "virt"
     60#define VIRTUAL_DEVICE_MATCH_ID "rootvirt"
     61#define VIRTUAL_DEVICE_MATCH_SCORE 100
     62
    5963static int root_add_device(device_t *dev);
    6064
     
    6973        .driver_ops = &root_ops
    7074};
     75
     76/** Create the device which represents the root of virtual device tree.
     77 *
     78 * @param parent Parent of the newly created device.
     79 * @return Error code.
     80 */
     81static int add_virtual_root_child(device_t *parent)
     82{
     83        printf(NAME ": adding new child for virtual devices.\n");
     84        printf(NAME ":   device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME,
     85            VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID);
     86
     87        int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME,
     88            VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE);
     89
     90        return res;
     91}
    7192
    7293/** Create the device which represents the root of HW device tree.
     
    96117        printf(NAME ": root_add_device, device handle = %d\n", dev->handle);
    97118       
     119        /*
     120         * Register virtual devices root.
     121         * We ignore error occurrence because virtual devices shall not be
     122         * vital for the system.
     123         */
     124        add_virtual_root_child(dev);
     125
    98126        /* Register root device's children. */
    99127        int res = add_platform_child(dev);
Note: See TracChangeset for help on using the changeset viewer.