Changeset b2d06fa in mainline for uspace/drv


Ignore:
Timestamp:
2010-12-25T17:14:36Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
092e4f1
Parents:
59e9398b (diff), 3ac66f69 (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:
1 added
8 edited
1 moved

Legend:

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

    r59e9398b rb2d06fa  
    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        }
  • uspace/drv/pciintel/pci.c

    r59e9398b rb2d06fa  
    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       
  • uspace/drv/root/root.c

    r59e9398b rb2d06fa  
    4747#include <macros.h>
    4848#include <inttypes.h>
     49#include <sysinfo.h>
    4950
    5051#include <driver.h>
     
    5556
    5657#define PLATFORM_DEVICE_NAME "hw"
    57 #define PLATFORM_DEVICE_MATCH_ID STRING(UARCH)
     58#define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s"
    5859#define PLATFORM_DEVICE_MATCH_SCORE 100
    5960
     
    99100static int add_platform_child(device_t *parent)
    100101{
     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
    101133        printf(NAME ": adding new child for platform device.\n");
    102134        printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
    103             PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID);
    104        
    105         int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
    106             PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE);
     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);
    107139
    108140        return res;
  • uspace/drv/rootpc/rootpc.c

    r59e9398b rb2d06fa  
    2828
    2929/**
    30  * @defgroup root_pc Root HW device driver for ia32 and amd64 platform.
    31  * @brief HelenOS root HW device driver for ia32 and amd64 platform.
     30 * @defgroup root_pc PC platform driver.
     31 * @brief HelenOS PC platform driver.
    3232 * @{
    3333 */
     
    182182        /* Register child devices. */
    183183        if (!rootpc_add_children(dev)) {
    184                 printf(NAME ": failed to add child devices for platform "
    185                     "ia32.\n");
     184                printf(NAME ": failed to add child devices for PC platform.\n");
    186185        }
    187186       
     
    196195int main(int argc, char *argv[])
    197196{
    198         printf(NAME ": HelenOS rootpc device driver\n");
     197        printf(NAME ": HelenOS PC platform driver\n");
    199198        root_pc_init();
    200199        return driver_main(&rootpc_driver);
  • uspace/drv/rootpc/rootpc.ma

    r59e9398b rb2d06fa  
    1 10 ia32
    2 10 amd64
     110 platform/pc
  • uspace/drv/rootvirt/devices.def

    r59e9398b rb2d06fa  
    1717        .match_id = "virtual&test2"
    1818},
     19{
     20        .name = "null",
     21        .match_id = "virtual&test1"
     22},
    1923#endif
  • uspace/drv/test1/Makefile

    r59e9398b rb2d06fa  
    3333
    3434SOURCES = \
     35        char.c \
    3536        test1.c
    3637
  • uspace/drv/test1/char.c

    r59e9398b rb2d06fa  
    11/*
    2  * Copyright (c) 2006 Ondrej Palkovsky
     2 * Copyright (c) 2010 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #include <stdio.h>
    30 #include <unistd.h>
    31 #include <atomic.h>
    32 #include "../tester.h"
     29/** @file
     30 */
    3331
    34 static atomic_t finish;
     32#include <assert.h>
     33#include <errno.h>
     34#include <mem.h>
     35#include <char.h>
    3536
    36 static void callback(void *priv, int retval, ipc_call_t *data)
    37 {
    38         atomic_set(&finish, 1);
     37#include "test1.h"
     38
     39static int impl_char_read(device_t *dev, char *buf, size_t count) {
     40        memset(buf, 0, count);
     41        return count;
    3942}
    4043
    41 const char *test_connect(void)
    42 {
    43         TPRINTF("Connecting to %u...", IPC_TEST_SERVICE);
    44         int phone = ipc_connect_me_to(PHONE_NS, IPC_TEST_SERVICE, 0, 0);
    45         if (phone > 0) {
    46                 TPRINTF("phoneid %d\n", phone);
    47         } else {
    48                 TPRINTF("\n");
    49                 return "ipc_connect_me_to() failed";
    50         }
    51        
    52         printf("Sending synchronous message...\n");
    53         int retval = ipc_call_sync_0_0(phone, IPC_TEST_METHOD);
    54         TPRINTF("Received response to synchronous message\n");
    55        
    56         TPRINTF("Sending asynchronous message...\n");
    57         atomic_set(&finish, 0);
    58         ipc_call_async_0(phone, IPC_TEST_METHOD, NULL, callback, 1);
    59         while (atomic_get(&finish) != 1)
    60                 TPRINTF(".");
    61         TPRINTF("Received response to asynchronous message\n");
    62        
    63         TPRINTF("Hanging up...");
    64         retval = ipc_hangup(phone);
    65         if (retval == 0) {
    66                 TPRINTF("OK\n");
    67         } else {
    68                 TPRINTF("\n");
    69                 return "ipc_hangup() failed";
    70         }
    71        
    72         return NULL;
     44static int imp_char_write(device_t *dev, char *buf, size_t count) {
     45        return count;
    7346}
     47
     48static char_iface_t char_interface = {
     49        .read = &impl_char_read,
     50        .write = &imp_char_write
     51};
     52
     53device_ops_t char_device_ops = {
     54        .interfaces[CHAR_DEV_IFACE] = &char_interface
     55};
     56
  • uspace/drv/test1/test1.c

    r59e9398b rb2d06fa  
    3434#include <errno.h>
    3535#include <str_error.h>
    36 #include <driver.h>
    37 
    38 #define NAME "test1"
     36#include "test1.h"
    3937
    4038static int add_device(device_t *dev);
     
    9896        add_device_to_class(dev, "virtual");
    9997
    100         if (dev->parent == NULL) {
     98        if (str_cmp(dev->name, "null") == 0) {
     99                dev->ops = &char_device_ops;
     100                add_device_to_class(dev, "virt-null");
     101        } else if (dev->parent == NULL) {
    101102                register_child_verbose(dev, "cloning myself ;-)", "clone",
    102103                    "virtual&test1", 10);
     
    117118}
    118119
    119 
Note: See TracChangeset for help on using the changeset viewer.