Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b2d06fa in mainline


Ignore:
Timestamp:
2010-12-25T17:14:36Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
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.

Files:
5 added
3 deleted
46 edited
1 moved

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r59e9398b rb2d06fa  
    140140        $(USPACE_PATH)/app/stats/stats \
    141141        $(USPACE_PATH)/app/tasks/tasks \
    142         $(USPACE_PATH)/app/top/top
     142        $(USPACE_PATH)/app/top/top \
     143        $(USPACE_PATH)/app/sysinfo/sysinfo
    143144
    144145ifneq ($(CONFIG_BAREBONE),y)
  • kernel/arch/amd64/src/amd64.c

    r59e9398b rb2d06fa  
    199199void arch_post_smp_init(void)
    200200{
     201        /* Currently the only supported platform for amd64 is 'pc'. */
     202        static const char *platform = "pc";
     203
     204        sysinfo_set_item_data("platform", NULL, (void *) platform,
     205            str_size(platform));
     206
    201207#ifdef CONFIG_PC_KBD
    202208        /*
  • kernel/arch/arm32/include/mach/integratorcp/integratorcp.h

    r59e9398b rb2d06fa  
    106106extern void icp_frame_init(void);
    107107extern size_t icp_get_irq_count(void);
     108extern const char *icp_get_platform_name(void);
    108109
    109110extern struct arm_machine_ops icp_machine_ops;
  • kernel/arch/arm32/include/mach/testarm/testarm.h

    r59e9398b rb2d06fa  
    7474extern void gxemul_frame_init(void);
    7575extern size_t gxemul_get_irq_count(void);
     76extern const char *gxemul_get_platform_name(void);
    7677
    7778extern struct arm_machine_ops gxemul_machine_ops;
  • kernel/arch/arm32/include/machine_func.h

    r59e9398b rb2d06fa  
    5656        void (*machine_input_init)(void);
    5757        size_t (*machine_get_irq_count)(void);
     58        const char *(*machine_get_platform_name)(void);
    5859};
    5960
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    r59e9398b rb2d06fa  
    7171static void gta02_input_init(void);
    7272static size_t gta02_get_irq_count(void);
     73static const char *gta02_get_platform_name(void);
    7374
    7475static void gta02_timer_irq_init(void);
     
    9293        gta02_output_init,
    9394        gta02_input_init,
    94         gta02_get_irq_count
     95        gta02_get_irq_count,
     96        gta02_get_platform_name
    9597};
    9698
     
    235237}
    236238
     239const char *gta02_get_platform_name(void)
     240{
     241        return "gta02";
     242}
     243
    237244static void gta02_timer_irq_init(void)
    238245{
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    r59e9398b rb2d06fa  
    6565        icp_output_init,
    6666        icp_input_init,
    67         icp_get_irq_count
     67        icp_get_irq_count,
     68        icp_get_platform_name
    6869};
    6970
     
    342343}
    343344
     345const char *icp_get_platform_name(void)
     346{
     347        return "integratorcp";
     348}
     349
    344350/** @}
    345351 */
  • kernel/arch/arm32/src/mach/testarm/testarm.c

    r59e9398b rb2d06fa  
    6565        gxemul_output_init,
    6666        gxemul_input_init,
    67         gxemul_get_irq_count
     67        gxemul_get_irq_count,
     68        gxemul_get_platform_name
    6869};
    6970
     
    132133}
    133134
     135const char *gxemul_get_platform_name(void)
     136{
     137        return "gxemul";
     138}
     139
    134140/** Starts gxemul Real Time Clock device, which asserts regular interrupts.
    135141 *
  • kernel/arch/ia32/src/ia32.c

    r59e9398b rb2d06fa  
    157157void arch_post_smp_init(void)
    158158{
     159        /* Currently the only supported platform for ia32 is 'pc'. */
     160        static const char *platform = "pc";
     161
     162        sysinfo_set_item_data("platform", NULL, (void *) platform,
     163            str_size(platform));
     164
    159165#ifdef CONFIG_PC_KBD
    160166        /*
  • kernel/arch/ia64/src/ia64.c

    r59e9398b rb2d06fa  
    147147void arch_post_smp_init(void)
    148148{
     149        static const char *platform;
     150
     151        /* Set platform name. */
     152#ifdef MACHINE_ski
     153        platform = "pc";
     154#endif
     155#ifdef MACHINE_i460GX
     156        platform = "i460GX";
     157#endif
     158        sysinfo_set_item_data("platform", NULL, (void *) platform,
     159            str_size(platform));
     160
    149161#ifdef MACHINE_ski
    150162        ski_instance_t *ski_instance = skiin_init();
  • kernel/arch/mips32/src/mips32.c

    r59e9398b rb2d06fa  
    168168void arch_post_smp_init(void)
    169169{
     170        static const char *platform;
     171
     172        /* Set platform name. */
     173#ifdef MACHINE_msim
     174        platform = "msim";
     175#endif
     176#ifdef MACHINE_bgxemul
     177        platform = "gxemul";
     178#endif
     179#ifdef MACHINE_lgxemul
     180        platform = "gxemul";
     181#endif
     182        sysinfo_set_item_data("platform", NULL, (void *) platform,
     183            str_size(platform));
     184
    170185#ifdef CONFIG_MIPS_KBD
    171186        /*
  • kernel/arch/ppc32/src/ppc32.c

    r59e9398b rb2d06fa  
    249249void arch_post_smp_init(void)
    250250{
     251        /* Currently the only supported platform for ppc32 is 'mac'. */
     252        static const char *platform = "mac";
     253
     254        sysinfo_set_item_data("platform", NULL, (void *) platform,
     255            str_size(platform));
     256
    251257        ofw_tree_walk_by_device_type("mac-io", macio_register, NULL);
    252258}
  • kernel/arch/sparc64/src/sun4u/sparc64.c

    r59e9398b rb2d06fa  
    5050#include <ddi/irq.h>
    5151#include <str.h>
     52#include <sysinfo/sysinfo.h>
    5253
    5354memmap_t memmap;
     
    111112void arch_post_smp_init(void)
    112113{
     114        /* Currently the only supported platform for sparc64/sun4u is 'sun4u'. */
     115        static const char *platform = "sun4u";
     116
     117        sysinfo_set_item_data("platform", NULL, (void *) platform,
     118            str_size(platform));
     119
    113120        standalone_sparc64_console_init();
    114121}
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    r59e9398b rb2d06fa  
    5252#include <str.h>
    5353#include <arch/drivers/niagara.h>
     54#include <sysinfo/sysinfo.h>
    5455
    5556memmap_t memmap;
     
    109110void arch_post_smp_init(void)
    110111{
     112        /* Currently the only supported platform for sparc64/sun4v is 'sun4v'. */
     113        static const char *platform = "sun4v";
     114
     115        sysinfo_set_item_data("platform", NULL, (void *) platform,
     116            str_size(platform));
     117
    111118        niagarain_init();
    112119}
  • kernel/generic/include/ddi/irq.h

    r59e9398b rb2d06fa  
    189189extern hash_table_t irq_uspace_hash_table;
    190190
     191extern inr_t last_inr;
     192
    191193extern void irq_init(size_t, size_t);
    192194extern void irq_initialize(irq_t *);
  • kernel/generic/src/ddi/irq.c

    r59e9398b rb2d06fa  
    136136static size_t buckets;
    137137
     138/** Last valid INR. */
     139inr_t last_inr = 0;
     140
    138141/** Initialize IRQ subsystem.
    139142 *
     
    145148{
    146149        buckets = chains;
     150        last_inr = inrs - 1;
     151
    147152        /*
    148153         * Be smart about the choice of the hash table operations.
  • kernel/generic/src/ipc/irq.c

    r59e9398b rb2d06fa  
    131131/** Register an answerbox as a receiving end for IRQ notifications.
    132132 *
    133  * @param box     Receiving answerbox.
    134  * @param inr     IRQ number.
    135  * @param devno   Device number.
    136  * @param imethod Interface and method to be associated
    137  *                with the notification.
    138  * @param ucode   Uspace pointer to top-half pseudocode.
    139  *
    140  * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.
     133 * @param box           Receiving answerbox.
     134 * @param inr           IRQ number.
     135 * @param devno         Device number.
     136 * @param imethod       Interface and method to be associated with the
     137 *                      notification.
     138 * @param ucode         Uspace pointer to top-half pseudocode.
     139 * @return              EOK on success or a negative error code.
    141140 *
    142141 */
     
    148147                (sysarg_t) devno
    149148        };
     149
     150        if ((inr < 0) || (inr > last_inr))
     151                return ELIMIT;
    150152       
    151153        irq_code_t *code;
     
    208210/** Unregister task from IRQ notification.
    209211 *
    210  * @param box   Answerbox associated with the notification.
    211  * @param inr   IRQ number.
    212  * @param devno Device number.
    213  *
     212 * @param box           Answerbox associated with the notification.
     213 * @param inr           IRQ number.
     214 * @param devno         Device number.
     215 * @return              EOK on success or a negative error code.
    214216 */
    215217int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
     
    219221                (sysarg_t) devno
    220222        };
     223
     224        if ((inr < 0) || (inr > last_inr))
     225                return ELIMIT;
    221226       
    222227        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
  • uspace/Makefile

    r59e9398b rb2d06fa  
    5353        app/nettest2 \
    5454        app/ping \
     55        app/sysinfo \
    5556        srv/clip \
    5657        srv/devmap \
  • uspace/app/init/init.c

    r59e9398b rb2d06fa  
    5757#define DEVFS_MOUNT_POINT  "/dev"
    5858
    59 #define SCRATCH_FS_TYPE      "tmpfs"
    60 #define SCRATCH_MOUNT_POINT  "/scratch"
     59#define TMPFS_FS_TYPE      "tmpfs"
     60#define TMPFS_MOUNT_POINT  "/tmp"
    6161
    6262#define DATA_FS_TYPE      "fat"
     
    235235}
    236236
    237 static bool mount_scratch(void)
    238 {
    239         int rc = mount(SCRATCH_FS_TYPE, SCRATCH_MOUNT_POINT, "", "", 0);
    240         return mount_report("Scratch filesystem", SCRATCH_MOUNT_POINT,
    241             SCRATCH_FS_TYPE, NULL, rc);
     237static bool mount_tmpfs(void)
     238{
     239        int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0);
     240        return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT,
     241            TMPFS_FS_TYPE, NULL, rc);
    242242}
    243243
     
    271271        }
    272272       
    273         mount_scratch();
     273        mount_tmpfs();
    274274       
    275275        spawn("/srv/fhc");
  • uspace/app/tester/Makefile

    r59e9398b rb2d06fa  
    4747        vfs/vfs1.c \
    4848        ipc/ping_pong.c \
    49         ipc/register.c \
    50         ipc/connect.c \
    5149        loop/loop1.c \
    5250        mm/malloc1.c \
     51        hw/misc/virtchar1.c \
    5352        hw/serial/serial1.c
    5453
  • uspace/app/tester/tester.c

    r59e9398b rb2d06fa  
    6060#include "vfs/vfs1.def"
    6161#include "ipc/ping_pong.def"
    62 #include "ipc/register.def"
    63 #include "ipc/connect.def"
    6462#include "loop/loop1.def"
    6563#include "mm/malloc1.def"
    6664#include "hw/serial/serial1.def"
     65#include "hw/misc/virtchar1.def"
    6766        {NULL, NULL, NULL, false}
    6867};
  • uspace/app/tester/tester.h

    r59e9398b rb2d06fa  
    7777extern const char *test_vfs1(void);
    7878extern const char *test_ping_pong(void);
    79 extern const char *test_register(void);
    80 extern const char *test_connect(void);
    8179extern const char *test_loop1(void);
    8280extern const char *test_malloc1(void);
    8381extern const char *test_serial1(void);
     82extern const char *test_virtchar1(void);
    8483
    8584extern test_t tests[];
  • uspace/app/tester/vfs/vfs1.c

    r59e9398b rb2d06fa  
    4040#include "../tester.h"
    4141
    42 #define FS_TYPE      "tmpfs"
    43 #define MOUNT_POINT  "/tmp"
    44 #define OPTIONS      ""
    45 #define FLAGS        0
    46 
    47 #define TEST_DIRECTORY  MOUNT_POINT "/testdir"
     42#define TEST_DIRECTORY  "/tmp/testdir"
    4843#define TEST_FILE       TEST_DIRECTORY "/testfile"
    4944#define TEST_FILE2      TEST_DIRECTORY "/nextfile"
     
    7570const char *test_vfs1(void)
    7671{
    77         if (mkdir(MOUNT_POINT, 0) != 0)
     72        int rc;
     73        if ((rc = mkdir(TEST_DIRECTORY, 0)) != 0) {
     74                TPRINTF("rc=%d\n", rc);
    7875                return "mkdir() failed";
    79         TPRINTF("Created directory %s\n", MOUNT_POINT);
    80        
    81         int rc = mount(FS_TYPE, MOUNT_POINT, "", OPTIONS, FLAGS);
    82         switch (rc) {
    83         case EOK:
    84                 TPRINTF("Mounted %s on %s\n", FS_TYPE, MOUNT_POINT);
    85                 break;
    86         case EBUSY:
    87                 TPRINTF("(INFO) Filesystem already mounted on %s\n", MOUNT_POINT);
    88                 break;
    89         default:
    90                 TPRINTF("(ERR) IPC returned errno %d (is tmpfs loaded?)\n", rc);
    91                 return "mount() failed";
    9276        }
    93        
    94         if (mkdir(TEST_DIRECTORY, 0) != 0)
    95                 return "mkdir() failed";
    9677        TPRINTF("Created directory %s\n", TEST_DIRECTORY);
    9778       
  • 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 
  • uspace/lib/c/generic/async_rel.c

    r59e9398b rb2d06fa  
    239239                 */
    240240retry:
    241                 rel_phone = ipc_connect_me_to(key_phone, 0, 0, 0);
     241                rel_phone = async_connect_me_to(key_phone, 0, 0, 0);
    242242                if (rel_phone >= 0) {
    243243                        /* success, do nothing */
  • uspace/lib/c/generic/device/hw_res.c

    r59e9398b rb2d06fa  
    3838#include <malloc.h>
    3939
    40 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
     40int get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
    4141{
    4242        sysarg_t count = 0;
    4343        int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
    4444        hw_resources->count = count;
    45         if (EOK != rc) {
    46                 return false;
    47         }
     45        if (rc != EOK)
     46                return rc;
    4847       
    4948        size_t size = count * sizeof(hw_resource_t);
    5049        hw_resources->resources = (hw_resource_t *)malloc(size);
    51         if (NULL == hw_resources->resources) {
    52                 return false;
    53         }
     50        if (!hw_resources->resources)
     51                return ENOMEM;
    5452       
    5553        rc = async_data_read_start(dev_phone, hw_resources->resources, size);
    56         if (EOK != rc) {
     54        if (rc != EOK) {
    5755                free(hw_resources->resources);
    5856                hw_resources->resources = NULL;
    59                 return false;
     57                return rc;
    6058        }
    6159                 
    62         return true;     
     60        return EOK;
    6361}
    6462
  • uspace/lib/c/generic/devmap.c

    r59e9398b rb2d06fa  
    127127/** Register new device.
    128128 *
    129  * @param namespace Namespace name.
     129 * The @p interface is used when forwarding connection to the driver.
     130 * If not 0, the first argument is the interface and the second argument
     131 * is the devmap handle of the device.
     132 * When the interface is zero (default), the first argument is directly
     133 * the handle (to ensure backward compatibility).
     134 *
     135 * @param fqdn Fully qualified device name.
     136 * @param[out] handle Handle to the created instance of device.
     137 * @param interface Interface when forwarding.
     138 *
     139 */
     140int devmap_device_register_with_iface(const char *fqdn,
     141    devmap_handle_t *handle, sysarg_t interface)
     142{
     143        int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
     144       
     145        if (phone < 0)
     146                return phone;
     147       
     148        async_serialize_start();
     149       
     150        ipc_call_t answer;
     151        aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, interface, 0,
     152            &answer);
     153       
     154        sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
     155        if (retval != EOK) {
     156                async_wait_for(req, NULL);
     157                async_serialize_end();
     158                return retval;
     159        }
     160       
     161        async_wait_for(req, &retval);
     162       
     163        async_serialize_end();
     164       
     165        if (retval != EOK) {
     166                if (handle != NULL)
     167                        *handle = -1;
     168                return retval;
     169        }
     170       
     171        if (handle != NULL)
     172                *handle = (devmap_handle_t) IPC_GET_ARG1(answer);
     173       
     174        return retval;
     175}
     176
     177/** Register new device.
     178 *
    130179 * @param fqdn      Fully qualified device name.
    131180 * @param handle    Output: Handle to the created instance of device.
     
    134183int devmap_device_register(const char *fqdn, devmap_handle_t *handle)
    135184{
    136         int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
    137        
    138         if (phone < 0)
    139                 return phone;
    140        
    141         async_serialize_start();
    142        
    143         ipc_call_t answer;
    144         aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, 0, 0,
    145             &answer);
    146        
    147         sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
    148         if (retval != EOK) {
    149                 async_wait_for(req, NULL);
    150                 async_serialize_end();
    151                 return retval;
    152         }
    153        
    154         async_wait_for(req, &retval);
    155        
    156         async_serialize_end();
    157        
    158         if (retval != EOK) {
    159                 if (handle != NULL)
    160                         *handle = -1;
    161                 return retval;
    162         }
    163        
    164         if (handle != NULL)
    165                 *handle = (devmap_handle_t) IPC_GET_ARG1(answer);
    166        
    167         return retval;
    168 }
     185        return devmap_device_register_with_iface(fqdn, handle, 0);
     186}
     187
    169188
    170189int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle, unsigned int flags)
     
    260279       
    261280        if (flags & IPC_FLAG_BLOCKING) {
    262                 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
     281                phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
    263282                    DEVMAP_CONNECT_TO_DEVICE, handle);
    264283        } else {
    265                 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
     284                phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
    266285                    DEVMAP_CONNECT_TO_DEVICE, handle);
    267286        }
  • uspace/lib/c/generic/fibril_synch.c

    r59e9398b rb2d06fa  
    139139static void _fibril_mutex_unlock_unsafe(fibril_mutex_t *fm)
    140140{
    141         assert(fm->counter <= 0);
    142141        if (fm->counter++ < 0) {
    143142                link_t *tmp;
     
    165164void fibril_mutex_unlock(fibril_mutex_t *fm)
    166165{
     166        assert(fibril_mutex_is_locked(fm));
    167167        futex_down(&async_futex);
    168168        _fibril_mutex_unlock_unsafe(fm);
    169169        futex_up(&async_futex);
     170}
     171
     172bool fibril_mutex_is_locked(fibril_mutex_t *fm)
     173{
     174        bool locked = false;
     175       
     176        futex_down(&async_futex);
     177        if (fm->counter <= 0)
     178                locked = true;
     179        futex_up(&async_futex);
     180       
     181        return locked;
    170182}
    171183
     
    230242{
    231243        futex_down(&async_futex);
    232         assert(frw->readers || (frw->writers == 1));
    233244        if (frw->readers) {
    234245                if (--frw->readers) {
     
    296307void fibril_rwlock_read_unlock(fibril_rwlock_t *frw)
    297308{
     309        assert(fibril_rwlock_is_read_locked(frw));
    298310        _fibril_rwlock_common_unlock(frw);
    299311}
     
    301313void fibril_rwlock_write_unlock(fibril_rwlock_t *frw)
    302314{
     315        assert(fibril_rwlock_is_write_locked(frw));
    303316        _fibril_rwlock_common_unlock(frw);
     317}
     318
     319bool fibril_rwlock_is_read_locked(fibril_rwlock_t *frw)
     320{
     321        bool locked = false;
     322
     323        futex_down(&async_futex);
     324        if (frw->readers)
     325                locked = true;
     326        futex_up(&async_futex);
     327
     328        return locked;
     329}
     330
     331bool fibril_rwlock_is_write_locked(fibril_rwlock_t *frw)
     332{
     333        bool locked = false;
     334
     335        futex_down(&async_futex);
     336        if (frw->writers) {
     337                assert(frw->writers == 1);
     338                locked = true;
     339        }
     340        futex_up(&async_futex);
     341
     342        return locked;
     343}
     344
     345bool fibril_rwlock_is_locked(fibril_rwlock_t *frw)
     346{
     347        return fibril_rwlock_is_read_locked(frw) ||
     348            fibril_rwlock_is_write_locked(frw);
    304349}
    305350
     
    314359{
    315360        awaiter_t wdata;
     361
     362        assert(fibril_mutex_is_locked(fm));
    316363
    317364        if (timeout < 0)
  • uspace/lib/c/include/device/hw_res.h

    r59e9398b rb2d06fa  
    9595
    9696
    97 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources);
    98 
    99 bool enable_interrupt(int dev_phone);
     97extern int get_hw_resources(int, hw_resource_list_t *);
     98extern bool enable_interrupt(int);
    10099
    101100
  • uspace/lib/c/include/devmap.h

    r59e9398b rb2d06fa  
    4545extern int devmap_driver_register(const char *, async_client_conn_t);
    4646extern int devmap_device_register(const char *, devmap_handle_t *);
     47extern int devmap_device_register_with_iface(const char *, devmap_handle_t *, sysarg_t);
    4748
    4849extern int devmap_device_get_handle(const char *, devmap_handle_t *, unsigned int);
  • uspace/lib/c/include/fibril_synch.h

    r59e9398b rb2d06fa  
    105105extern bool fibril_mutex_trylock(fibril_mutex_t *);
    106106extern void fibril_mutex_unlock(fibril_mutex_t *);
     107extern bool fibril_mutex_is_locked(fibril_mutex_t *);
    107108
    108109extern void fibril_rwlock_initialize(fibril_rwlock_t *);
     
    111112extern void fibril_rwlock_read_unlock(fibril_rwlock_t *);
    112113extern void fibril_rwlock_write_unlock(fibril_rwlock_t *);
     114extern bool fibril_rwlock_is_read_locked(fibril_rwlock_t *);
     115extern bool fibril_rwlock_is_write_locked(fibril_rwlock_t *);
     116extern bool fibril_rwlock_is_locked(fibril_rwlock_t *);
    113117
    114118extern void fibril_condvar_initialize(fibril_condvar_t *);
  • uspace/lib/c/include/ipc/devman.h

    r59e9398b rb2d06fa  
    123123        DEVMAN_CLIENT,
    124124        DEVMAN_CONNECT_TO_DEVICE,
     125        DEVMAN_CONNECT_FROM_DEVMAP,
    125126        DEVMAN_CONNECT_TO_PARENTS_DEVICE
    126127} devman_interface_t;
  • uspace/lib/packet/generic/packet_server.c

    r59e9398b rb2d06fa  
    135135/** Creates a new packet of dimensions at least as given.
    136136 *
    137  * Should be used only when the global data are locked.
    138  *
    139137 * @param[in] length    The total length of the packet, including the header,
    140138 *                      the addresses and the data of the packet.
     
    153151        packet_t *packet;
    154152        int rc;
     153
     154        assert(fibril_mutex_is_locked(&ps_globals.lock));
    155155
    156156        // already locked
     
    233233/** Release the packet and returns it to the appropriate free packet queue.
    234234 *
    235  * Should be used only when the global data are locked.
    236  *
    237235 * @param[in] packet    The packet to be released.
    238236 *
     
    242240        int index;
    243241        int result;
     242
     243        assert(fibril_mutex_is_locked(&ps_globals.lock));
    244244
    245245        for (index = 0; (index < FREE_QUEUES_COUNT - 1) &&
  • uspace/srv/devman/devman.c

    r59e9398b rb2d06fa  
    6262}
    6363
     64static int devmap_devices_class_compare(unsigned long key[], hash_count_t keys,
     65    link_t *item)
     66{
     67        dev_class_info_t *class_info
     68            = hash_table_get_instance(item, dev_class_info_t, devmap_link);
     69        assert(class_info != NULL);
     70
     71        return (class_info->devmap_handle == (devmap_handle_t) key[0]);
     72}
     73
    6474static void devices_remove_callback(link_t *item)
    6575{
     
    7585        .hash = devices_hash,
    7686        .compare = devmap_devices_compare,
     87        .remove_callback = devices_remove_callback
     88};
     89
     90static hash_table_operations_t devmap_devices_class_ops = {
     91        .hash = devices_hash,
     92        .compare = devmap_devices_class_compare,
    7793        .remove_callback = devices_remove_callback
    7894};
     
    368384        printf(NAME ": create_root_node\n");
    369385
     386        fibril_rwlock_write_lock(&tree->rwlock);
    370387        node = create_dev_node();
    371388        if (node != NULL) {
     
    377394                tree->root_node = node;
    378395        }
     396        fibril_rwlock_write_unlock(&tree->rwlock);
    379397
    380398        return node != NULL;
     
    439457/** Start a driver
    440458 *
    441  * The driver's mutex is assumed to be locked.
    442  *
    443459 * @param drv           The driver's structure.
    444460 * @return              True if the driver's task is successfully spawned, false
     
    449465        int rc;
    450466
     467        assert(fibril_mutex_is_locked(&drv->driver_mutex));
     468       
    451469        printf(NAME ": start_driver '%s'\n", drv->name);
    452470       
     
    670688        }
    671689       
    672         devmap_device_register(devmap_pathname, &node->devmap_handle);
     690        devmap_device_register_with_iface(devmap_pathname,
     691            &node->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    673692       
    674693        tree_add_devmap_device(tree, node);
     
    842861/** Find the device node structure of the device witch has the specified handle.
    843862 *
    844  * Device tree's rwlock should be held at least for reading.
    845  *
    846863 * @param tree          The device tree where we look for the device node.
    847864 * @param handle        The handle of the device.
     
    851868{
    852869        unsigned long key = handle;
    853         link_t *link = hash_table_find(&tree->devman_devices, &key);
     870        link_t *link;
     871       
     872        assert(fibril_rwlock_is_locked(&tree->rwlock));
     873       
     874        link = hash_table_find(&tree->devman_devices, &key);
    854875        return hash_table_get_instance(link, node_t, devman_link);
    855876}
     
    907928/** Insert new device into device tree.
    908929 *
    909  * The device tree's rwlock should be already held exclusively when calling this
    910  * function.
    911  *
    912930 * @param tree          The device tree.
    913931 * @param node          The newly added device node.
     
    924942        assert(tree != NULL);
    925943        assert(dev_name != NULL);
     944        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    926945       
    927946        node->name = dev_name;
     
    10421061       
    10431062        info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t));
    1044         if (info != NULL)
     1063        if (info != NULL) {
    10451064                memset(info, 0, sizeof(dev_class_info_t));
     1065                list_initialize(&info->dev_classes);
     1066                list_initialize(&info->devmap_link);
     1067                list_initialize(&info->link);
     1068        }
    10461069       
    10471070        return info;
     
    11671190        fibril_rwlock_initialize(&class_list->rwlock);
    11681191        hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1,
    1169             &devmap_devices_ops);
     1192            &devmap_devices_class_ops);
    11701193}
    11711194
     
    12151238        hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link);
    12161239        fibril_rwlock_write_unlock(&class_list->rwlock);
     1240
     1241        assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL);
    12171242}
    12181243
  • uspace/srv/devman/main.c

    r59e9398b rb2d06fa  
    281281         * handle.
    282282         */
    283         devmap_device_register(devmap_pathname, &cli->devmap_handle);
     283        devmap_device_register_with_iface(devmap_pathname,
     284            &cli->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    284285       
    285286        /*
     
    486487static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
    487488{
    488         devmap_handle_t devmap_handle = IPC_GET_IMETHOD(*icall);
     489        devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
    489490        node_t *dev;
    490491
     
    503504        }
    504505       
    505         printf(NAME ": devman_connection_devmapper: forward connection to "
    506             "device %s to driver %s.\n", dev->pathname, dev->drv->name);
    507506        ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
    508507            IPC_FF_NONE);
     508        printf(NAME ": devman_connection_devmapper: forwarded connection to "
     509            "device %s to driver %s.\n", dev->pathname, dev->drv->name);
    509510}
    510511
     
    512513static void devman_connection(ipc_callid_t iid, ipc_call_t *icall)
    513514{
    514         /*
    515          * Silly hack to enable the device manager to register as a driver by
    516          * the device mapper. If the ipc method is not IPC_M_CONNECT_ME_TO, this
    517          * is not the forwarded connection from naming service, so it must be a
    518          * connection from the devmapper which thinks this is a devmapper-style
    519          * driver. So pretend this is a devmapper-style driver. (This does not
    520          * work for device with handle == IPC_M_CONNECT_ME_TO, because devmapper
    521          * passes device handle to the driver as an ipc method.)
    522          */
    523         if (IPC_GET_IMETHOD(*icall) != IPC_M_CONNECT_ME_TO)
    524                 devman_connection_devmapper(iid, icall);
    525 
    526         /*
    527          * ipc method is IPC_M_CONNECT_ME_TO, so this is forwarded connection
    528          * from naming service by which we registered as device manager, so be
    529          * device manager.
    530          */
    531        
    532515        /* Select interface. */
    533516        switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
     
    542525                devman_forward(iid, icall, false);
    543526                break;
     527        case DEVMAN_CONNECT_FROM_DEVMAP:
     528                /* Someone connected through devmap node. */
     529                devman_connection_devmapper(iid, icall);
     530                break;
    544531        case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
    545532                /* Connect client to selected device. */
  • uspace/srv/devmap/devmap.c

    r59e9398b rb2d06fa  
    4646#include <str.h>
    4747#include <ipc/devmap.h>
     48#include <assert.h>
    4849
    4950#define NAME          "devmap"
     
    99100        /** Device driver handling this device */
    100101        devmap_driver_t *driver;
     102        /** Use this interface when forwarding to driver. */
     103        sysarg_t forward_interface;
    101104} devmap_device_t;
    102105
     
    206209}
    207210
    208 /** Find namespace with given name.
    209  *
    210  * The devices_list_mutex should be already held when
    211  * calling this function.
    212  *
    213  */
     211/** Find namespace with given name. */
    214212static devmap_namespace_t *devmap_namespace_find_name(const char *name)
    215213{
    216214        link_t *item;
     215       
     216        assert(fibril_mutex_is_locked(&devices_list_mutex));
     217       
    217218        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    218219                devmap_namespace_t *namespace =
     
    227228/** Find namespace with given handle.
    228229 *
    229  * The devices_list_mutex should be already held when
    230  * calling this function.
    231  *
    232230 * @todo: use hash table
    233231 *
     
    236234{
    237235        link_t *item;
     236       
     237        assert(fibril_mutex_is_locked(&devices_list_mutex));
     238       
    238239        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    239240                devmap_namespace_t *namespace =
     
    246247}
    247248
    248 /** Find device with given name.
    249  *
    250  * The devices_list_mutex should be already held when
    251  * calling this function.
    252  *
    253  */
     249/** Find device with given name. */
    254250static devmap_device_t *devmap_device_find_name(const char *ns_name,
    255251    const char *name)
    256252{
    257253        link_t *item;
     254       
     255        assert(fibril_mutex_is_locked(&devices_list_mutex));
     256       
    258257        for (item = devices_list.next; item != &devices_list; item = item->next) {
    259258                devmap_device_t *device =
     
    269268/** Find device with given handle.
    270269 *
    271  * The devices_list_mutex should be already held when
    272  * calling this function.
    273  *
    274270 * @todo: use hash table
    275271 *
     
    278274{
    279275        link_t *item;
     276       
     277        assert(fibril_mutex_is_locked(&devices_list_mutex));
     278       
    280279        for (item = devices_list.next; item != &devices_list; item = item->next) {
    281280                devmap_device_t *device =
     
    288287}
    289288
    290 /** Create a namespace (if not already present)
    291  *
    292  * The devices_list_mutex should be already held when
    293  * calling this function.
    294  *
    295  */
     289/** Create a namespace (if not already present). */
    296290static devmap_namespace_t *devmap_namespace_create(const char *ns_name)
    297291{
    298         devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name);
     292        devmap_namespace_t *namespace;
     293       
     294        assert(fibril_mutex_is_locked(&devices_list_mutex));
     295       
     296        namespace = devmap_namespace_find_name(ns_name);
    299297        if (namespace != NULL)
    300298                return namespace;
     
    321319}
    322320
    323 /** Destroy a namespace (if it is no longer needed)
    324  *
    325  * The devices_list_mutex should be already held when
    326  * calling this function.
    327  *
    328  */
     321/** Destroy a namespace (if it is no longer needed). */
    329322static void devmap_namespace_destroy(devmap_namespace_t *namespace)
    330323{
     324        assert(fibril_mutex_is_locked(&devices_list_mutex));
     325
    331326        if (namespace->refcnt == 0) {
    332327                list_remove(&(namespace->namespaces));
     
    337332}
    338333
    339 /** Increase namespace reference count by including device
    340  *
    341  * The devices_list_mutex should be already held when
    342  * calling this function.
    343  *
    344  */
     334/** Increase namespace reference count by including device. */
    345335static void devmap_namespace_addref(devmap_namespace_t *namespace,
    346336    devmap_device_t *device)
    347337{
     338        assert(fibril_mutex_is_locked(&devices_list_mutex));
     339
    348340        device->namespace = namespace;
    349341        namespace->refcnt++;
    350342}
    351343
    352 /** Decrease namespace reference count
    353  *
    354  * The devices_list_mutex should be already held when
    355  * calling this function.
    356  *
    357  */
     344/** Decrease namespace reference count. */
    358345static void devmap_namespace_delref(devmap_namespace_t *namespace)
    359346{
     347        assert(fibril_mutex_is_locked(&devices_list_mutex));
     348
    360349        namespace->refcnt--;
    361350        devmap_namespace_destroy(namespace);
    362351}
    363352
    364 /** Unregister device and free it
    365  *
    366  * The devices_list_mutex should be already held when
    367  * calling this function.
    368  *
    369  */
     353/** Unregister device and free it. */
    370354static void devmap_device_unregister_core(devmap_device_t *device)
    371355{
     356        assert(fibril_mutex_is_locked(&devices_list_mutex));
     357
    372358        devmap_namespace_delref(device->namespace);
    373359        list_remove(&(device->devices));
     
    517503        }
    518504       
     505        /* Set the interface, if any. */
     506        device->forward_interface = IPC_GET_ARG1(*icall);
     507
    519508        /* Get fqdn */
    520509        char *fqdn;
     
    566555        /* Get unique device handle */
    567556        device->handle = devmap_create_handle();
    568        
     557
    569558        devmap_namespace_addref(namespace, device);
    570559        device->driver = driver;
     
    617606        }
    618607       
    619         ipc_forward_fast(callid, dev->driver->phone, dev->handle,
    620             IPC_GET_ARG3(*call), 0, IPC_FF_NONE);
     608        if (dev->forward_interface == 0) {
     609                ipc_forward_fast(callid, dev->driver->phone,
     610                    dev->handle, 0, 0,
     611                    IPC_FF_NONE);
     612        } else {
     613                ipc_forward_fast(callid, dev->driver->phone,
     614                    dev->forward_interface, dev->handle, 0,
     615                    IPC_FF_NONE);
     616        }
    621617       
    622618        fibril_mutex_unlock(&devices_list_mutex);
  • uspace/srv/fs/devfs/devfs_ops.c

    r59e9398b rb2d06fa  
    6060typedef struct {
    6161        devmap_handle_t handle;
    62         int phone;
     62        int phone;              /**< When < 0, the structure is incomplete. */
    6363        size_t refcount;
    6464        link_t link;
     65        fibril_condvar_t cv;    /**< Broadcast when completed. */
    6566} device_t;
    6667
     
    227228                        [DEVICES_KEY_HANDLE] = (unsigned long) node->handle
    228229                };
    229                
     230                link_t *lnk;
     231
    230232                fibril_mutex_lock(&devices_mutex);
    231                 link_t *lnk = hash_table_find(&devices, key);
     233restart:
     234                lnk = hash_table_find(&devices, key);
    232235                if (lnk == NULL) {
    233236                        device_t *dev = (device_t *) malloc(sizeof(device_t));
     
    237240                        }
    238241                       
     242                        dev->handle = node->handle;
     243                        dev->phone = -1;        /* mark as incomplete */
     244                        dev->refcount = 1;
     245                        fibril_condvar_initialize(&dev->cv);
     246
     247                        /*
     248                         * Insert the incomplete device structure so that other
     249                         * fibrils will not race with us when we drop the mutex
     250                         * below.
     251                         */
     252                        hash_table_insert(&devices, key, &dev->link);
     253
     254                        /*
     255                         * Drop the mutex to allow recursive devfs requests.
     256                         */
     257                        fibril_mutex_unlock(&devices_mutex);
     258
    239259                        int phone = devmap_device_connect(node->handle, 0);
     260
     261                        fibril_mutex_lock(&devices_mutex);
     262
     263                        /*
     264                         * Notify possible waiters about this device structure
     265                         * being completed (or destroyed).
     266                         */
     267                        fibril_condvar_broadcast(&dev->cv);
     268
    240269                        if (phone < 0) {
     270                                /*
     271                                 * Connecting failed, need to remove the
     272                                 * entry and free the device structure.
     273                                 */
     274                                hash_table_remove(&devices, key, DEVICES_KEYS);
    241275                                fibril_mutex_unlock(&devices_mutex);
     276
    242277                                free(dev);
    243278                                return ENOENT;
    244279                        }
    245280                       
    246                         dev->handle = node->handle;
     281                        /* Set the correct phone. */
    247282                        dev->phone = phone;
    248                         dev->refcount = 1;
    249                        
    250                         hash_table_insert(&devices, key, &dev->link);
    251283                } else {
    252284                        device_t *dev = hash_table_get_instance(lnk, device_t, link);
     285
     286                        if (dev->phone < 0) {
     287                                /*
     288                                 * Wait until the device structure is completed
     289                                 * and start from the beginning as the device
     290                                 * structure might have entirely disappeared
     291                                 * while we were not holding the mutex in
     292                                 * fibril_condvar_wait().
     293                                 */
     294                                fibril_condvar_wait(&dev->cv, &devices_mutex);
     295                                goto restart;
     296                        }
     297
    253298                        dev->refcount++;
    254299                }
     
    564609               
    565610                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     611                assert(dev->phone >= 0);
    566612               
    567613                ipc_callid_t callid;
     
    627673               
    628674                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     675                assert(dev->phone >= 0);
    629676               
    630677                ipc_callid_t callid;
     
    696743               
    697744                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     745                assert(dev->phone >= 0);
    698746                dev->refcount--;
    699747               
     
    743791               
    744792                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     793                assert(dev->phone >= 0);
    745794               
    746795                /* Make a request at the driver */
  • uspace/srv/net/tl/tcp/tcp.c

    r59e9398b rb2d06fa  
    18031803                        fibril_rwlock_write_unlock(socket_data->local_lock);
    18041804
     1805                        socket_data->state = TCP_SOCKET_SYN_SENT;
     1806
    18051807                        /* Send the packet */
    18061808                        printf("connecting %d\n", packet_get_id(packet));
     
    20852087        if (!fibril) {
    20862088                free(operation_timeout);
    2087                 return EPARTY;  /* FIXME: use another EC */
    2088         }
     2089                return ENOMEM;
     2090        }
     2091
    20892092//      fibril_mutex_lock(&socket_data->operation.mutex);
    20902093        /* Start the timeout fibril */
  • uspace/srv/vfs/vfs_lookup.c

    r59e9398b rb2d06fa  
    179179        fibril_mutex_unlock(&plb_mutex);
    180180       
    181         if (((int) rc < EOK) || (!result))
     181        if ((int) rc < EOK)
    182182                return (int) rc;
     183
     184        if (!result)
     185                return EOK;
    183186       
    184187        result->triplet.fs_handle = (fs_handle_t) rc;
Note: See TracChangeset for help on using the changeset viewer.