Changeset bda60d9 in mainline for uspace/srv/devman/devman.h


Ignore:
Timestamp:
2010-03-19T14:40:14Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d347b53
Parents:
7707954
Message:

adding child device - parts of code

File:
1 edited

Legend:

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

    r7707954 rbda60d9  
    4040#include <adt/list.h>
    4141#include <ipc/ipc.h>
     42#include <ipc/devman.h>
    4243#include <fibril_synch.h>
    4344#include <atomic.h>
     
    4849
    4950#define MATCH_EXT ".ma"
     51#define MAX_DEV 256
    5052
    5153struct node;
    5254
    5355typedef struct node node_t;
    54 
    55 /** Ids of device models used for device-to-driver matching.
    56  */
    57 typedef struct match_id {
    58         /** Pointers to next and previous ids.
    59          */
    60         link_t link;
    61         /** Id of device model.
    62          */
    63         const char *id;
    64         /** Relevancy of device-to-driver match.
    65          * The higher is the product of scores specified for the device by the bus driver and by the leaf driver,
    66          * the more suitable is the leaf driver for handling the device.
    67          */
    68         unsigned int score;
    69 } match_id_t;
    70 
    71 /** List of ids for matching devices to drivers sorted
    72  * according to match scores in descending order.
    73  */
    74 typedef struct match_id_list {
    75         link_t ids;
    76 } match_id_list_t;
    7756
    7857typedef enum {
     
    11796struct node {
    11897        /** The global unique identifier of the device.*/
    119         long handle;
     98        device_handle_t handle;
     99        /** The name of the device specified by its parent. */
     100        char *name;
     101        /** Full path and name of the device in device hierarchi (i. e. in full path in device tree).*/
     102        char *pathname;
    120103        /** The node of the parent device. */
    121104        node_t *parent;
     
    140123        /** Root device node. */
    141124        node_t *root_node;
     125        /** The next available handle - handles are assigned in a sequential manner.*/
    142126        atomic_t current_handle;
     127        /** Handle-to-node mapping. */
     128        node_t * node_map[MAX_DEV];
    143129} dev_tree_t;
    144130
     
    152138bool read_match_ids(const char *conf_path, match_id_list_t *ids);
    153139char * read_id(const char **buf) ;
    154 void add_match_id(match_id_list_t *ids, match_id_t *id);
    155 
    156 void clean_match_ids(match_id_list_t *ids);
    157 
    158 
    159 static inline match_id_t * create_match_id()
    160 {
    161         match_id_t *id = malloc(sizeof(match_id_t));
    162         memset(id, 0, sizeof(match_id_t));
    163         return id;
    164 }
    165 
    166 static inline void delete_match_id(match_id_t *id)
    167 {
    168         if (id) {
    169                 free_not_null(id->id);
    170                 free(id);
    171         }
    172 }
    173 
    174 
    175 
    176 
    177140
    178141// Drivers
     
    248211}
    249212
    250 static inline void insert_dev_node(dev_tree_t *tree, node_t *node, node_t *parent)
    251 {
    252         assert(NULL != node && NULL != tree);
    253        
    254         node->handle = atomic_postinc(&tree->current_handle);
    255 
    256         node->parent = parent;
    257         if (NULL != parent) {
    258                 fibril_mutex_lock(&parent->children_mutex);
    259                 list_append(&node->sibling, &parent->children);
    260                 fibril_mutex_unlock(&parent->children_mutex);
     213static inline node_t * find_dev_node(dev_tree_t *tree, long handle)
     214{
     215        if (handle < MAX_DEV) {
     216                return tree->node_map[handle];
    261217        }
    262 }
    263 
     218        return NULL;
     219}
    264220
    265221// Device tree
     
    267223bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list);
    268224bool create_root_node(dev_tree_t *tree);
    269 
     225bool insert_dev_node(dev_tree_t *tree, node_t *node, const char *dev_name, node_t *parent);
    270226
    271227#endif
Note: See TracChangeset for help on using the changeset viewer.