Changeset 973ef9fc in mainline for uspace/drv


Ignore:
Timestamp:
2010-12-25T21:20:28Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
631ee0c
Parents:
1bfd3d3 (diff), 09178b7f (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.

Location:
uspace/drv
Files:
11 added
1 deleted
4 edited
4 moved

Legend:

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

    r1bfd3d3 r973ef9fc  
    282282
    283283                printf(NAME ": added io range (addr=0x%x, size=0x%x) to "
    284                     "device %s\n", addr, len, dev->name);
     284                    "device %s\n", (unsigned int) addr, (unsigned int) len,
     285                    dev->name);
    285286        }
    286287}
     
    489490static int isa_add_device(device_t *dev)
    490491{
    491         printf(NAME ": isa_add_device, device handle = %d\n", dev->handle);
     492        printf(NAME ": isa_add_device, device handle = %d\n",
     493            (int) dev->handle);
    492494
    493495        /* Add child devices. */
    494496        add_legacy_children(dev);
    495         printf(NAME ": finished the enumeration of legacy devices\n",
    496             dev->handle);
     497        printf(NAME ": finished the enumeration of legacy devices\n");
    497498
    498499        return EOK;
  • uspace/drv/ns8250/ns8250.c

    r1bfd3d3 r973ef9fc  
    274274       
    275275        /* Gain control over port's registers. */
    276         if (pio_enable((void *) data->io_addr, REG_COUNT,
     276        if (pio_enable((void *)(uintptr_t) data->io_addr, REG_COUNT,
    277277            (void **) &data->port)) {
    278                 printf(NAME ": error - cannot gain the port %lx for device "
     278                printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "
    279279                    "%s.\n", data->io_addr, dev->name);
    280280                return false;
     
    342342                printf(NAME ": failed to connect to the parent driver of the "
    343343                    "device %s.\n", dev->name);
    344                 ret = EPARTY;   /* FIXME: use another EC */
     344                ret = dev->parent_phone;
    345345                goto failed;
    346346        }
    347347       
    348348        /* Get hw resources. */
    349         if (!get_hw_resources(dev->parent_phone, &hw_resources)) {
     349        ret = get_hw_resources(dev->parent_phone, &hw_resources);
     350        if (ret != EOK) {
    350351                printf(NAME ": failed to get hw resources for the device "
    351352                    "%s.\n", dev->name);
    352                 ret = EPARTY;   /* FIXME: use another EC */
    353353                goto failed;
    354354        }
     
    374374                                printf(NAME ": i/o range assigned to the device "
    375375                                    "%s is too small.\n", dev->name);
    376                                 ret = EPARTY;   /* FIXME: use another EC */
     376                                ret = ELIMIT;
    377377                                goto failed;
    378378                        }
     
    390390                printf(NAME ": missing hw resource(s) for the device %s.\n",
    391391                    dev->name);
    392                 ret = EPARTY;   /* FIXME: use another EC */
     392                ret = ENOENT;
    393393                goto failed;
    394394        }
     
    727727{
    728728        printf(NAME ": ns8250_add_device %s (handle = %d)\n",
    729             dev->name, dev->handle);
     729            dev->name, (int) dev->handle);
    730730       
    731731        int res = ns8250_dev_initialize(dev);
     
    887887    ipc_call_t *call)
    888888{
    889         ipcarg_t method = IPC_GET_METHOD(*call);
     889        sysarg_t method = IPC_GET_IMETHOD(*call);
    890890        int ret;
    891891        unsigned int baud_rate, parity, word_length, stop_bits;
  • uspace/drv/pciintel/pci.c

    r1bfd3d3 r973ef9fc  
    323323        if (range_addr != 0) {
    324324                printf(NAME ": device %s : ", dev->name);
    325                 printf("address = %x", range_addr);
    326                 printf(", size = %x\n", range_size);
     325                printf("address = %" PRIx64, range_addr);
     326                printf(", size = %x\n", (unsigned int) range_size);
    327327        }
    328328       
     
    452452static int pci_add_device(device_t *dev)
    453453{
     454        int rc;
     455
    454456        printf(NAME ": pci_add_device\n");
    455457       
     
    466468                    "parent's driver.\n");
    467469                delete_pci_bus_data(bus_data);
    468                 return EPARTY;  /* FIXME: use another EC */
     470                return dev->parent_phone;
    469471        }
    470472       
    471473        hw_resource_list_t hw_resources;
    472474       
    473         if (!get_hw_resources(dev->parent_phone, &hw_resources)) {
     475        rc = get_hw_resources(dev->parent_phone, &hw_resources);
     476        if (rc != EOK) {
    474477                printf(NAME ": pci_add_device failed to get hw resources for "
    475478                    "the device.\n");
    476479                delete_pci_bus_data(bus_data);
    477480                ipc_hangup(dev->parent_phone);
    478                 return EPARTY;  /* FIXME: use another EC */
     481                return rc;
    479482        }       
    480483       
    481         printf(NAME ": conf_addr = %x.\n",
     484        printf(NAME ": conf_addr = %" PRIx64 ".\n",
    482485            hw_resources.resources[0].res.io_range.address);
    483486       
     
    489492            (uint32_t) hw_resources.resources[0].res.io_range.address;
    490493       
    491         if (pio_enable((void *)bus_data->conf_io_addr, 8,
     494        if (pio_enable((void *)(uintptr_t)bus_data->conf_io_addr, 8,
    492495            &bus_data->conf_addr_port)) {
    493496                printf(NAME ": failed to enable configuration ports.\n");
  • uspace/drv/root/root.c

    r1bfd3d3 r973ef9fc  
    11/*
    22 * Copyright (c) 2010 Lenka Trochtova
     3 * Copyright (c) 2010 Vojtech Horky
    34 * All rights reserved.
    45 *
     
    4546#include <ctype.h>
    4647#include <macros.h>
     48#include <inttypes.h>
     49#include <sysinfo.h>
    4750
    4851#include <driver.h>
     
    5154
    5255#define NAME "root"
     56
     57#define PLATFORM_DEVICE_NAME "hw"
     58#define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s"
     59#define PLATFORM_DEVICE_MATCH_SCORE 100
     60
     61#define VIRTUAL_DEVICE_NAME "virt"
     62#define VIRTUAL_DEVICE_MATCH_ID "rootvirt"
     63#define VIRTUAL_DEVICE_MATCH_SCORE 100
    5364
    5465static int root_add_device(device_t *dev);
     
    6576};
    6677
     78/** Create the device which represents the root of virtual device tree.
     79 *
     80 * @param parent Parent of the newly created device.
     81 * @return Error code.
     82 */
     83static int add_virtual_root_child(device_t *parent)
     84{
     85        printf(NAME ": adding new child for virtual devices.\n");
     86        printf(NAME ":   device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME,
     87            VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID);
     88
     89        int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME,
     90            VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE);
     91
     92        return res;
     93}
     94
    6795/** Create the device which represents the root of HW device tree.
    6896 *
     
    72100static int add_platform_child(device_t *parent)
    73101{
     102        char *match_id;
     103        char *platform;
     104        size_t platform_size;
     105        int res;
     106
     107        /* Get platform name from sysinfo. */
     108
     109        platform = sysinfo_get_data("platform", &platform_size);
     110        if (platform == NULL) {
     111                printf(NAME ": Failed to obtain platform name.\n");
     112                return ENOENT;
     113        }
     114
     115        /* Null-terminate string. */
     116        platform = realloc(platform, platform_size + 1);
     117        if (platform == NULL) {
     118                printf(NAME ": Memory allocation failed.\n");
     119                return ENOMEM;
     120        }
     121
     122        platform[platform_size] = '\0';
     123
     124        /* Construct match ID. */
     125
     126        if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) {
     127                printf(NAME ": Memory allocation failed.\n");
     128                return ENOMEM;
     129        }
     130
     131        /* Add child. */
     132
    74133        printf(NAME ": adding new child for platform device.\n");
    75        
    76         int res = EOK;
    77         device_t *platform = NULL;
    78         match_id_t *match_id = NULL;
    79        
    80         /* Create new device. */
    81         platform = create_device();
    82         if (NULL == platform) {
    83                 res = ENOMEM;
    84                 goto failure;
    85         }       
    86        
    87         platform->name = "hw";
    88         printf(NAME ": the new device's name is %s.\n", platform->name);
    89        
    90         /* Initialize match id list. */
    91         match_id = create_match_id();
    92         if (NULL == match_id) {
    93                 res = ENOMEM;
    94                 goto failure;
    95         }
    96        
    97         /* TODO - replace this with some better solution (sysinfo ?) */
    98         match_id->id = STRING(UARCH);
    99         match_id->score = 100;
    100         add_match_id(&platform->match_ids, match_id);
    101        
    102         /* Register child device. */
    103         res = child_device_register(platform, parent);
    104         if (EOK != res)
    105                 goto failure;
    106        
    107         return res;
    108        
    109 failure:
    110         if (NULL != match_id)
    111                 match_id->id = NULL;
    112        
    113         if (NULL != platform) {
    114                 platform->name = NULL;
    115                 delete_device(platform);
    116         }
    117        
     134        printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
     135            PLATFORM_DEVICE_MATCH_SCORE, match_id);
     136
     137        res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
     138            match_id, PLATFORM_DEVICE_MATCH_SCORE);
     139
    118140        return res;
    119141}
     
    126148static int root_add_device(device_t *dev)
    127149{
    128         printf(NAME ": root_add_device, device handle = %d\n", dev->handle);
     150        printf(NAME ": root_add_device, device handle=%" PRIun "\n",
     151            dev->handle);
    129152       
     153        /*
     154         * Register virtual devices root.
     155         * We ignore error occurrence because virtual devices shall not be
     156         * vital for the system.
     157         */
     158        add_virtual_root_child(dev);
     159
    130160        /* Register root device's children. */
    131161        int res = add_platform_child(dev);
  • uspace/drv/rootpc/Makefile

    r1bfd3d3 r973ef9fc  
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3131EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
    32 BINARY = rootia32
     32BINARY = rootpc
    3333
    3434SOURCES = \
    35         rootia32.c
     35        rootpc.c
    3636
    3737include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/rootpc/rootpc.c

    r1bfd3d3 r973ef9fc  
    2828
    2929/**
    30  * @defgroup root_ia32 Root HW device driver for ia32 platform.
    31  * @brief HelenOS root HW device driver for ia32 platform.
     30 * @defgroup root_pc PC platform driver.
     31 * @brief HelenOS PC platform driver.
    3232 * @{
    3333 */
     
    5353#include <device/hw_res.h>
    5454
    55 #define NAME "rootia32"
    56 
    57 typedef struct rootia32_child_dev_data {
     55#define NAME "rootpc"
     56
     57typedef struct rootpc_child_dev_data {
    5858        hw_resource_list_t hw_resources;
    59 } rootia32_child_dev_data_t;
    60 
    61 static int rootia32_add_device(device_t *dev);
    62 static void root_ia32_init(void);
     59} rootpc_child_dev_data_t;
     60
     61static int rootpc_add_device(device_t *dev);
     62static void root_pc_init(void);
    6363
    6464/** The root device driver's standard operations. */
    65 static driver_ops_t rootia32_ops = {
    66         .add_device = &rootia32_add_device
     65static driver_ops_t rootpc_ops = {
     66        .add_device = &rootpc_add_device
    6767};
    6868
    6969/** The root device driver structure. */
    70 static driver_t rootia32_driver = {
     70static driver_t rootpc_driver = {
    7171        .name = NAME,
    72         .driver_ops = &rootia32_ops
     72        .driver_ops = &rootpc_ops
    7373};
    7474
     
    8282};
    8383
    84 static rootia32_child_dev_data_t pci_data = {
     84static rootpc_child_dev_data_t pci_data = {
    8585        .hw_resources = {
    8686                1,
     
    8989};
    9090
    91 static hw_resource_list_t *rootia32_get_child_resources(device_t *dev)
    92 {
    93         rootia32_child_dev_data_t *data;
    94        
    95         data = (rootia32_child_dev_data_t *) dev->driver_data;
     91static hw_resource_list_t *rootpc_get_child_resources(device_t *dev)
     92{
     93        rootpc_child_dev_data_t *data;
     94       
     95        data = (rootpc_child_dev_data_t *) dev->driver_data;
    9696        if (NULL == data)
    9797                return NULL;
     
    100100}
    101101
    102 static bool rootia32_enable_child_interrupt(device_t *dev)
     102static bool rootpc_enable_child_interrupt(device_t *dev)
    103103{
    104104        /* TODO */
     
    108108
    109109static resource_iface_t child_res_iface = {
    110         &rootia32_get_child_resources,
    111         &rootia32_enable_child_interrupt
    112 };
    113 
    114 /* Initialized in root_ia32_init() function. */
    115 static device_ops_t rootia32_child_ops;
     110        &rootpc_get_child_resources,
     111        &rootpc_enable_child_interrupt
     112};
     113
     114/* Initialized in root_pc_init() function. */
     115static device_ops_t rootpc_child_ops;
    116116
    117117static bool
    118 rootia32_add_child(device_t *parent, const char *name, const char *str_match_id,
    119     rootia32_child_dev_data_t *drv_data)
     118rootpc_add_child(device_t *parent, const char *name, const char *str_match_id,
     119    rootpc_child_dev_data_t *drv_data)
    120120{
    121121        printf(NAME ": adding new child device '%s'.\n", name);
     
    142142       
    143143        /* Set provided operations to the device. */
    144         child->ops = &rootia32_child_ops;
     144        child->ops = &rootpc_child_ops;
    145145       
    146146        /* Register child device. */
     
    164164}
    165165
    166 static bool rootia32_add_children(device_t *dev)
    167 {
    168         return rootia32_add_child(dev, "pci0", "intel_pci", &pci_data);
     166static bool rootpc_add_children(device_t *dev)
     167{
     168        return rootpc_add_child(dev, "pci0", "intel_pci", &pci_data);
    169169}
    170170
     
    175175 * @return              Zero on success, negative error number otherwise.
    176176 */
    177 static int rootia32_add_device(device_t *dev)
    178 {
    179         printf(NAME ": rootia32_add_device, device handle = %d\n", dev->handle);
     177static int rootpc_add_device(device_t *dev)
     178{
     179        printf(NAME ": rootpc_add_device, device handle = %d\n",
     180            (int)dev->handle);
    180181       
    181182        /* Register child devices. */
    182         if (!rootia32_add_children(dev)) {
    183                 printf(NAME ": failed to add child devices for platform "
    184                     "ia32.\n");
     183        if (!rootpc_add_children(dev)) {
     184                printf(NAME ": failed to add child devices for PC platform.\n");
    185185        }
    186186       
     
    188188}
    189189
    190 static void root_ia32_init(void)
    191 {
    192         rootia32_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;
     190static void root_pc_init(void)
     191{
     192        rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;
    193193}
    194194
    195195int main(int argc, char *argv[])
    196196{
    197         printf(NAME ": HelenOS rootia32 device driver\n");
    198         root_ia32_init();
    199         return driver_main(&rootia32_driver);
     197        printf(NAME ": HelenOS PC platform driver\n");
     198        root_pc_init();
     199        return driver_main(&rootpc_driver);
    200200}
    201201
  • uspace/drv/test1/char.c

    r1bfd3d3 r973ef9fc  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2010 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libpacket
    30  * @{
    31  */
    32 
    3329/** @file
    3430 */
    3531
    36 #ifndef LIBPACKET_PACKET_LOCAL_H_
    37 #define LIBPACKET_PACKET_LOCAL_H_
     32#include <assert.h>
     33#include <errno.h>
     34#include <mem.h>
     35#include <char.h>
    3836
    39 #include <net/packet.h>
     37#include "test1.h"
    4038
    41 /** @name Packet local interface
    42  */
    43 /*@{*/
     39static int impl_char_read(device_t *dev, char *buf, size_t count) {
     40        memset(buf, 0, count);
     41        return count;
     42}
    4443
    45 extern int packet_translate_local(int, packet_t *, packet_id_t);
    46 extern packet_t packet_get_4_local(int, size_t, size_t, size_t, size_t);
    47 extern packet_t packet_get_1_local(int, size_t);
    48 extern void pq_release_local(int, packet_id_t);
     44static int imp_char_write(device_t *dev, char *buf, size_t count) {
     45        return count;
     46}
    4947
    50 /*@}*/
     48static char_iface_t char_interface = {
     49        .read = &impl_char_read,
     50        .write = &imp_char_write
     51};
    5152
    52 #endif
     53device_ops_t char_device_ops = {
     54        .interfaces[CHAR_DEV_IFACE] = &char_interface
     55};
    5356
    54 /** @}
    55  */
  • uspace/drv/test1/test1.h

    r1bfd3d3 r973ef9fc  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2010 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
    30  * @{
     29/** @file
    3130 */
     31#ifndef DRV_TEST1_TEST1_H_
     32#define DRV_TEST1_TEST1_H_
    3233
    33 /**
    34  * @file
    35  * @brief Wrapper for explicit 64-bit arguments passed to syscalls.
    36  */
     34#include <driver.h>
    3735
    38 #ifndef KERN_SYSARG64_H_
    39 #define KERN_SYSARG64_H_
     36#define NAME "test1"
    4037
    41 typedef struct {
    42         unsigned long long value;
    43 } sysarg64_t;
     38extern device_ops_t char_device_ops;
    4439
    4540#endif
    46 
    47 /** @}
    48  */
Note: See TracChangeset for help on using the changeset viewer.