Changes in / [5f7d96e:e080332] in mainline


Ignore:
Files:
4 added
2 deleted
45 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r5f7d96e re080332  
    5252./uspace/app/ping/ping
    5353./uspace/app/redir/redir
    54 ./uspace/app/sysinfo/sysinfo
    5554./uspace/app/sbi/sbi
    5655./uspace/app/stats/stats
  • boot/Makefile.common

    r5f7d96e re080332  
    144144        $(USPACE_PATH)/app/ping/ping \
    145145        $(USPACE_PATH)/app/stats/stats \
    146         $(USPACE_PATH)/app/sysinfo/sysinfo \
    147146        $(USPACE_PATH)/app/tasks/tasks \
    148147        $(USPACE_PATH)/app/top/top \
  • kernel/arch/amd64/src/amd64.c

    r5f7d96e re080332  
    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 
    207201#ifdef CONFIG_PC_KBD
    208202        /*
  • kernel/arch/arm32/include/mach/integratorcp/integratorcp.h

    r5f7d96e re080332  
    106106extern void icp_frame_init(void);
    107107extern size_t icp_get_irq_count(void);
    108 extern const char *icp_get_platform_name(void);
    109108
    110109extern struct arm_machine_ops icp_machine_ops;
  • kernel/arch/arm32/include/mach/testarm/testarm.h

    r5f7d96e re080332  
    7474extern void gxemul_frame_init(void);
    7575extern size_t gxemul_get_irq_count(void);
    76 extern const char *gxemul_get_platform_name(void);
    7776
    7877extern struct arm_machine_ops gxemul_machine_ops;
  • kernel/arch/arm32/include/machine_func.h

    r5f7d96e re080332  
    5656        void (*machine_input_init)(void);
    5757        size_t (*machine_get_irq_count)(void);
    58         const char *(*machine_get_platform_name)(void);
    5958};
    6059
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    r5f7d96e re080332  
    7171static void gta02_input_init(void);
    7272static size_t gta02_get_irq_count(void);
    73 static const char *gta02_get_platform_name(void);
    7473
    7574static void gta02_timer_irq_init(void);
     
    9392        gta02_output_init,
    9493        gta02_input_init,
    95         gta02_get_irq_count,
    96         gta02_get_platform_name
     94        gta02_get_irq_count
    9795};
    9896
     
    237235}
    238236
    239 const char *gta02_get_platform_name(void)
    240 {
    241         return "gta02";
    242 }
    243 
    244237static void gta02_timer_irq_init(void)
    245238{
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    r5f7d96e re080332  
    6565        icp_output_init,
    6666        icp_input_init,
    67         icp_get_irq_count,
    68         icp_get_platform_name
     67        icp_get_irq_count
    6968};
    7069
     
    343342}
    344343
    345 const char *icp_get_platform_name(void)
    346 {
    347         return "integratorcp";
    348 }
    349 
    350344/** @}
    351345 */
  • kernel/arch/arm32/src/mach/testarm/testarm.c

    r5f7d96e re080332  
    6565        gxemul_output_init,
    6666        gxemul_input_init,
    67         gxemul_get_irq_count,
    68         gxemul_get_platform_name
     67        gxemul_get_irq_count
    6968};
    7069
     
    133132}
    134133
    135 const char *gxemul_get_platform_name(void)
    136 {
    137         return "gxemul";
    138 }
    139 
    140134/** Starts gxemul Real Time Clock device, which asserts regular interrupts.
    141135 *
  • kernel/arch/ia32/src/ia32.c

    r5f7d96e re080332  
    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 
    165159#ifdef CONFIG_PC_KBD
    166160        /*
  • kernel/arch/ia64/src/ia64.c

    r5f7d96e re080332  
    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 
    161149#ifdef MACHINE_ski
    162150        ski_instance_t *ski_instance = skiin_init();
  • kernel/arch/mips32/src/mips32.c

    r5f7d96e re080332  
    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 
    185170#ifdef CONFIG_MIPS_KBD
    186171        /*
  • kernel/arch/ppc32/src/ppc32.c

    r5f7d96e re080332  
    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 
    257251        ofw_tree_walk_by_device_type("mac-io", macio_register, NULL);
    258252}
  • kernel/arch/sparc64/src/sun4u/sparc64.c

    r5f7d96e re080332  
    5050#include <ddi/irq.h>
    5151#include <str.h>
    52 #include <sysinfo/sysinfo.h>
    5352
    5453memmap_t memmap;
     
    112111void arch_post_smp_init(void)
    113112{
    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 
    120113        standalone_sparc64_console_init();
    121114}
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    r5f7d96e re080332  
    5252#include <str.h>
    5353#include <arch/drivers/niagara.h>
    54 #include <sysinfo/sysinfo.h>
    5554
    5655memmap_t memmap;
     
    110109void arch_post_smp_init(void)
    111110{
    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 
    118111        niagarain_init();
    119112}
  • kernel/generic/include/ddi/irq.h

    r5f7d96e re080332  
    189189extern hash_table_t irq_uspace_hash_table;
    190190
    191 extern inr_t last_inr;
    192 
    193191extern void irq_init(size_t, size_t);
    194192extern void irq_initialize(irq_t *);
  • kernel/generic/src/ddi/irq.c

    r5f7d96e re080332  
    136136static size_t buckets;
    137137
    138 /** Last valid INR. */
    139 inr_t last_inr = 0;
    140 
    141138/** Initialize IRQ subsystem.
    142139 *
     
    148145{
    149146        buckets = chains;
    150         last_inr = inrs - 1;
    151 
    152147        /*
    153148         * Be smart about the choice of the hash table operations.
  • kernel/generic/src/ipc/irq.c

    r5f7d96e re080332  
    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 with the
    137  *                      notification.
    138  * @param ucode         Uspace pointer to top-half pseudocode.
    139  * @return              EOK on success or a negative error code.
     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.
    140141 *
    141142 */
     
    147148                (sysarg_t) devno
    148149        };
    149 
    150         if ((inr < 0) || (inr > last_inr))
    151                 return ELIMIT;
    152150       
    153151        irq_code_t *code;
     
    210208/** Unregister task from IRQ notification.
    211209 *
    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.
     210 * @param box   Answerbox associated with the notification.
     211 * @param inr   IRQ number.
     212 * @param devno Device number.
     213 *
    216214 */
    217215int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
     
    221219                (sysarg_t) devno
    222220        };
    223 
    224         if ((inr < 0) || (inr > last_inr))
    225                 return ELIMIT;
    226221       
    227222        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
  • uspace/Makefile

    r5f7d96e re080332  
    5555        app/nettest2 \
    5656        app/ping \
    57         app/sysinfo \
    5857        srv/clip \
    5958        srv/devmap \
  • uspace/app/init/init.c

    r5f7d96e re080332  
    5757#define DEVFS_MOUNT_POINT  "/dev"
    5858
    59 #define TMPFS_FS_TYPE      "tmpfs"
    60 #define TMPFS_MOUNT_POINT  "/tmp"
     59#define SCRATCH_FS_TYPE      "tmpfs"
     60#define SCRATCH_MOUNT_POINT  "/scratch"
    6161
    6262#define DATA_FS_TYPE      "fat"
     
    235235}
    236236
    237 static 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);
     237static 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);
    242242}
    243243
     
    271271        }
    272272       
    273         mount_tmpfs();
     273        mount_scratch();
    274274       
    275275        spawn("/srv/fhc");
  • uspace/app/tester/Makefile

    r5f7d96e re080332  
    5151        vfs/vfs1.c \
    5252        ipc/ping_pong.c \
     53        ipc/register.c \
     54        ipc/connect.c \
    5355        loop/loop1.c \
    5456        mm/malloc1.c \
  • uspace/app/tester/tester.c

    r5f7d96e re080332  
    6060#include "vfs/vfs1.def"
    6161#include "ipc/ping_pong.def"
     62#include "ipc/register.def"
     63#include "ipc/connect.def"
    6264#include "loop/loop1.def"
    6365#include "mm/malloc1.def"
  • uspace/app/tester/tester.h

    r5f7d96e re080332  
    7777extern const char *test_vfs1(void);
    7878extern const char *test_ping_pong(void);
     79extern const char *test_register(void);
     80extern const char *test_connect(void);
    7981extern const char *test_loop1(void);
    8082extern const char *test_malloc1(void);
  • uspace/app/tester/vfs/vfs1.c

    r5f7d96e re080332  
    4040#include "../tester.h"
    4141
    42 #define TEST_DIRECTORY  "/tmp/testdir"
     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"
    4348#define TEST_FILE       TEST_DIRECTORY "/testfile"
    4449#define TEST_FILE2      TEST_DIRECTORY "/nextfile"
     
    7075const char *test_vfs1(void)
    7176{
    72         int rc;
    73         if ((rc = mkdir(TEST_DIRECTORY, 0)) != 0) {
    74                 TPRINTF("rc=%d\n", rc);
     77        if (mkdir(MOUNT_POINT, 0) != 0)
    7578                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";
    7692        }
     93       
     94        if (mkdir(TEST_DIRECTORY, 0) != 0)
     95                return "mkdir() failed";
    7796        TPRINTF("Created directory %s\n", TEST_DIRECTORY);
    7897       
  • uspace/drv/ns8250/ns8250.c

    r5f7d96e re080332  
    342342                printf(NAME ": failed to connect to the parent driver of the "
    343343                    "device %s.\n", dev->name);
    344                 ret = dev->parent_phone;
     344                ret = EPARTY;   /* FIXME: use another EC */
    345345                goto failed;
    346346        }
    347347       
    348348        /* Get hw resources. */
    349         ret = get_hw_resources(dev->parent_phone, &hw_resources);
    350         if (ret != EOK) {
     349        if (!get_hw_resources(dev->parent_phone, &hw_resources)) {
    351350                printf(NAME ": failed to get hw resources for the device "
    352351                    "%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 = ELIMIT;
     376                                ret = EPARTY;   /* FIXME: use another EC */
    377377                                goto failed;
    378378                        }
     
    390390                printf(NAME ": missing hw resource(s) for the device %s.\n",
    391391                    dev->name);
    392                 ret = ENOENT;
     392                ret = EPARTY;   /* FIXME: use another EC */
    393393                goto failed;
    394394        }
  • uspace/drv/pciintel/pci.c

    r5f7d96e re080332  
    452452static int pci_add_device(device_t *dev)
    453453{
    454         int rc;
    455 
    456454        printf(NAME ": pci_add_device\n");
    457455       
     
    468466                    "parent's driver.\n");
    469467                delete_pci_bus_data(bus_data);
    470                 return dev->parent_phone;
     468                return EPARTY;  /* FIXME: use another EC */
    471469        }
    472470       
    473471        hw_resource_list_t hw_resources;
    474472       
    475         rc = get_hw_resources(dev->parent_phone, &hw_resources);
    476         if (rc != EOK) {
     473        if (!get_hw_resources(dev->parent_phone, &hw_resources)) {
    477474                printf(NAME ": pci_add_device failed to get hw resources for "
    478475                    "the device.\n");
    479476                delete_pci_bus_data(bus_data);
    480477                ipc_hangup(dev->parent_phone);
    481                 return rc;
     478                return EPARTY;  /* FIXME: use another EC */
    482479        }       
    483480       
  • uspace/drv/root/root.c

    r5f7d96e re080332  
    4747#include <macros.h>
    4848#include <inttypes.h>
    49 #include <sysinfo.h>
    5049
    5150#include <driver.h>
     
    5655
    5756#define PLATFORM_DEVICE_NAME "hw"
    58 #define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s"
     57#define PLATFORM_DEVICE_MATCH_ID STRING(UARCH)
    5958#define PLATFORM_DEVICE_MATCH_SCORE 100
    6059
     
    101100static int add_platform_child(device_t *parent)
    102101{
    103         char *match_id;
    104         char *platform;
    105         size_t platform_size;
    106         int res;
    107 
    108         /* Get platform name from sysinfo. */
    109 
    110         platform = sysinfo_get_data("platform", &platform_size);
    111         if (platform == NULL) {
    112                 printf(NAME ": Failed to obtain platform name.\n");
    113                 return ENOENT;
    114         }
    115 
    116         /* Null-terminate string. */
    117         platform = realloc(platform, platform_size + 1);
    118         if (platform == NULL) {
    119                 printf(NAME ": Memory allocation failed.\n");
    120                 return ENOMEM;
    121         }
    122 
    123         platform[platform_size] = '\0';
    124 
    125         /* Construct match ID. */
    126 
    127         if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) {
    128                 printf(NAME ": Memory allocation failed.\n");
    129                 return ENOMEM;
    130         }
    131 
    132         /* Add child. */
    133 
    134102        printf(NAME ": adding new child for platform device.\n");
    135103        printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
    136             PLATFORM_DEVICE_MATCH_SCORE, match_id);
    137 
    138         res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
    139             match_id, PLATFORM_DEVICE_MATCH_SCORE, NULL);
     104            PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID);
     105       
     106        int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
     107            PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE,
     108            NULL);
    140109
    141110        return res;
  • uspace/drv/rootpc/rootpc.c

    r5f7d96e re080332  
    2828
    2929/**
    30  * @defgroup root_pc PC platform driver.
    31  * @brief HelenOS PC platform driver.
     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.
    3232 * @{
    3333 */
     
    182182        /* Register child devices. */
    183183        if (!rootpc_add_children(dev)) {
    184                 printf(NAME ": failed to add child devices for PC platform.\n");
     184                printf(NAME ": failed to add child devices for platform "
     185                    "ia32.\n");
    185186        }
    186187       
     
    195196int main(int argc, char *argv[])
    196197{
    197         printf(NAME ": HelenOS PC platform driver\n");
     198        printf(NAME ": HelenOS rootpc device driver\n");
    198199        root_pc_init();
    199200        return driver_main(&rootpc_driver);
  • uspace/drv/rootpc/rootpc.ma

    r5f7d96e re080332  
    1 10 platform/pc
     110 ia32
     210 amd64
  • uspace/drv/usbkbd/main.c

    r5f7d96e re080332  
    2929#include <driver.h>
    3030#include <ipc/driver.h>
    31 #include <ipc/kbd.h>
    32 #include <io/keycode.h>
    33 #include <io/console.h>
    3431#include <errno.h>
    3532#include <fibril.h>
     
    4441#define GUESSED_POLL_ENDPOINT 1
    4542
    46 static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
    47 static device_ops_t keyboard_ops = {
    48         .default_handler = default_connection_handler
    49 };
    50 
    51 static int console_callback_phone = -1;
    52 
    53 /** Default handler for IPC methods not handled by DDF.
    54  *
    55  * @param dev Device handling the call.
    56  * @param icallid Call id.
    57  * @param icall Call data.
    58  */
    59 void default_connection_handler(device_t *dev,
    60     ipc_callid_t icallid, ipc_call_t *icall)
    61 {
    62         sysarg_t method = IPC_GET_IMETHOD(*icall);
    63 
    64         if (method == IPC_M_CONNECT_TO_ME) {
    65                 int callback = IPC_GET_ARG5(*icall);
    66 
    67                 if (console_callback_phone != -1) {
    68                         ipc_answer_0(icallid, ELIMIT);
    69                         return;
    70                 }
    71 
    72                 console_callback_phone = callback;
    73                 ipc_answer_0(icallid, EOK);
    74                 return;
    75         }
    76 
    77         ipc_answer_0(icallid, EINVAL);
    78 }
    79 
    80 static void send_key(int key, int type, wchar_t c) {
    81         async_msg_4(console_callback_phone, KBD_EVENT, type, key,
    82             KM_NUM_LOCK, c);
    83 }
    84 
    85 static void send_alnum(int key, wchar_t c) {
    86         printf(NAME ": sending key '%lc' to console\n", (wint_t) c);
    87         send_key(key, KEY_PRESS, c);
    88         send_key(key, KEY_RELEASE, c);
    89 }
    90 
    9143/*
    9244 * Callbacks for parser
     
    231183                sizeof(usb_hid_report_in_callbacks_t));
    232184        callbacks->keyboard = usbkbd_process_keycodes;
    233 
    234         if (console_callback_phone != -1) {
    235                 static size_t counter = 0;
    236                 counter++;
    237                 if (counter > 3) {
    238                         counter = 0;
    239                         send_alnum(KC_A, L'a');
    240                 }
    241         }
    242185
    243186        usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks,
     
    346289        fibril_add_ready(fid);
    347290
    348         dev->ops = &keyboard_ops;
    349 
    350         add_device_to_class(dev, "keyboard");
    351 
    352291        /*
    353292         * Hurrah, device is initialized.
  • uspace/drv/vhc/hcd.c

    r5f7d96e re080332  
    7272
    7373        /*
     74         * Initialize address management.
     75         */
     76        address_init();
     77
     78        /*
    7479         * Initialize our hub and announce its presence.
    7580         */
     
    103108        printf(NAME ": virtual USB host controller driver.\n");
    104109
    105         /*
    106          * Initialize address management.
    107          */
    108         address_init();
    109 
    110         /*
    111          * Run the transfer scheduler.
    112          */
    113110        hc_manager();
    114111
    115         /*
    116          * We are also a driver within devman framework.
    117          */
    118112        return driver_main(&vhc_driver);
    119113}
  • uspace/lib/c/generic/async_rel.c

    r5f7d96e re080332  
    239239                 */
    240240retry:
    241                 rel_phone = async_connect_me_to(key_phone, 0, 0, 0);
     241                rel_phone = ipc_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

    r5f7d96e re080332  
    3838#include <malloc.h>
    3939
    40 int get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
     40bool 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 (rc != EOK)
    46                 return rc;
     45        if (EOK != rc) {
     46                return false;
     47        }
    4748       
    4849        size_t size = count * sizeof(hw_resource_t);
    4950        hw_resources->resources = (hw_resource_t *)malloc(size);
    50         if (!hw_resources->resources)
    51                 return ENOMEM;
     51        if (NULL == hw_resources->resources) {
     52                return false;
     53        }
    5254       
    5355        rc = async_data_read_start(dev_phone, hw_resources->resources, size);
    54         if (rc != EOK) {
     56        if (EOK != rc) {
    5557                free(hw_resources->resources);
    5658                hw_resources->resources = NULL;
    57                 return rc;
     59                return false;
    5860        }
    5961                 
    60         return EOK;
     62        return true;     
    6163}
    6264
  • uspace/lib/c/generic/devmap.c

    r5f7d96e re080332  
    279279       
    280280        if (flags & IPC_FLAG_BLOCKING) {
    281                 phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
     281                phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
    282282                    DEVMAP_CONNECT_TO_DEVICE, handle);
    283283        } else {
    284                 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
     284                phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
    285285                    DEVMAP_CONNECT_TO_DEVICE, handle);
    286286        }
  • uspace/lib/c/generic/fibril_synch.c

    r5f7d96e re080332  
    139139static void _fibril_mutex_unlock_unsafe(fibril_mutex_t *fm)
    140140{
     141        assert(fm->counter <= 0);
    141142        if (fm->counter++ < 0) {
    142143                link_t *tmp;
     
    164165void fibril_mutex_unlock(fibril_mutex_t *fm)
    165166{
    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 
    172 bool 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;
    182170}
    183171
     
    242230{
    243231        futex_down(&async_futex);
     232        assert(frw->readers || (frw->writers == 1));
    244233        if (frw->readers) {
    245234                if (--frw->readers) {
     
    307296void fibril_rwlock_read_unlock(fibril_rwlock_t *frw)
    308297{
    309         assert(fibril_rwlock_is_read_locked(frw));
    310298        _fibril_rwlock_common_unlock(frw);
    311299}
     
    313301void fibril_rwlock_write_unlock(fibril_rwlock_t *frw)
    314302{
    315         assert(fibril_rwlock_is_write_locked(frw));
    316303        _fibril_rwlock_common_unlock(frw);
    317 }
    318 
    319 bool 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 
    331 bool 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 
    345 bool fibril_rwlock_is_locked(fibril_rwlock_t *frw)
    346 {
    347         return fibril_rwlock_is_read_locked(frw) ||
    348             fibril_rwlock_is_write_locked(frw);
    349304}
    350305
     
    359314{
    360315        awaiter_t wdata;
    361 
    362         assert(fibril_mutex_is_locked(fm));
    363316
    364317        if (timeout < 0)
  • uspace/lib/c/include/device/hw_res.h

    r5f7d96e re080332  
    9595
    9696
    97 extern int get_hw_resources(int, hw_resource_list_t *);
    98 extern bool enable_interrupt(int);
     97bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources);
     98
     99bool enable_interrupt(int dev_phone);
    99100
    100101
  • uspace/lib/c/include/fibril_synch.h

    r5f7d96e re080332  
    105105extern bool fibril_mutex_trylock(fibril_mutex_t *);
    106106extern void fibril_mutex_unlock(fibril_mutex_t *);
    107 extern bool fibril_mutex_is_locked(fibril_mutex_t *);
    108107
    109108extern void fibril_rwlock_initialize(fibril_rwlock_t *);
     
    112111extern void fibril_rwlock_read_unlock(fibril_rwlock_t *);
    113112extern void fibril_rwlock_write_unlock(fibril_rwlock_t *);
    114 extern bool fibril_rwlock_is_read_locked(fibril_rwlock_t *);
    115 extern bool fibril_rwlock_is_write_locked(fibril_rwlock_t *);
    116 extern bool fibril_rwlock_is_locked(fibril_rwlock_t *);
    117113
    118114extern void fibril_condvar_initialize(fibril_condvar_t *);
  • uspace/lib/c/include/ipc/kbd.h

    r5f7d96e re080332  
    3939
    4040#include <ipc/ipc.h>
    41 #include <ipc/dev_iface.h>
    4241
    4342typedef enum {
    44         KBD_YIELD = DEV_FIRST_CUSTOM_METHOD,
     43        KBD_YIELD = IPC_FIRST_USER_METHOD,
    4544        KBD_RECLAIM
    4645} kbd_request_t;
  • uspace/lib/packet/generic/packet_server.c

    r5f7d96e re080332  
    135135/** Creates a new packet of dimensions at least as given.
    136136 *
     137 * Should be used only when the global data are locked.
     138 *
    137139 * @param[in] length    The total length of the packet, including the header,
    138140 *                      the addresses and the data of the packet.
     
    151153        packet_t *packet;
    152154        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 *
    235237 * @param[in] packet    The packet to be released.
    236238 *
     
    240242        int index;
    241243        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

    r5f7d96e re080332  
    392392        printf(NAME ": create_root_node\n");
    393393
    394         fibril_rwlock_write_lock(&tree->rwlock);
    395394        node = create_dev_node();
    396395        if (node != NULL) {
     
    402401                tree->root_node = node;
    403402        }
    404         fibril_rwlock_write_unlock(&tree->rwlock);
    405403
    406404        return node != NULL;
     
    465463/** Start a driver
    466464 *
     465 * The driver's mutex is assumed to be locked.
     466 *
    467467 * @param drv           The driver's structure.
    468468 * @return              True if the driver's task is successfully spawned, false
     
    473473        int rc;
    474474
    475         assert(fibril_mutex_is_locked(&drv->driver_mutex));
    476        
    477475        printf(NAME ": start_driver '%s'\n", drv->name);
    478476       
     
    869867/** Find the device node structure of the device witch has the specified handle.
    870868 *
     869 * Device tree's rwlock should be held at least for reading.
     870 *
    871871 * @param tree          The device tree where we look for the device node.
    872872 * @param handle        The handle of the device.
     
    876876{
    877877        unsigned long key = handle;
    878         link_t *link;
    879        
    880         assert(fibril_rwlock_is_locked(&tree->rwlock));
    881        
    882         link = hash_table_find(&tree->devman_devices, &key);
     878        link_t *link = hash_table_find(&tree->devman_devices, &key);
    883879        return hash_table_get_instance(link, node_t, devman_link);
    884880}
     
    936932/** Insert new device into device tree.
    937933 *
     934 * The device tree's rwlock should be already held exclusively when calling this
     935 * function.
     936 *
    938937 * @param tree          The device tree.
    939938 * @param node          The newly added device node.
     
    950949        assert(tree != NULL);
    951950        assert(dev_name != NULL);
    952         assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    953951       
    954952        node->name = dev_name;
  • uspace/srv/devmap/devmap.c

    r5f7d96e re080332  
    4646#include <str.h>
    4747#include <ipc/devmap.h>
    48 #include <assert.h>
    4948
    5049#define NAME          "devmap"
     
    209208}
    210209
    211 /** Find namespace with given name. */
     210/** Find namespace with given name.
     211 *
     212 * The devices_list_mutex should be already held when
     213 * calling this function.
     214 *
     215 */
    212216static devmap_namespace_t *devmap_namespace_find_name(const char *name)
    213217{
    214218        link_t *item;
    215        
    216         assert(fibril_mutex_is_locked(&devices_list_mutex));
    217        
    218219        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    219220                devmap_namespace_t *namespace =
     
    228229/** Find namespace with given handle.
    229230 *
     231 * The devices_list_mutex should be already held when
     232 * calling this function.
     233 *
    230234 * @todo: use hash table
    231235 *
     
    234238{
    235239        link_t *item;
    236        
    237         assert(fibril_mutex_is_locked(&devices_list_mutex));
    238        
    239240        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    240241                devmap_namespace_t *namespace =
     
    247248}
    248249
    249 /** Find device with given name. */
     250/** Find device with given name.
     251 *
     252 * The devices_list_mutex should be already held when
     253 * calling this function.
     254 *
     255 */
    250256static devmap_device_t *devmap_device_find_name(const char *ns_name,
    251257    const char *name)
    252258{
    253259        link_t *item;
    254        
    255         assert(fibril_mutex_is_locked(&devices_list_mutex));
    256        
    257260        for (item = devices_list.next; item != &devices_list; item = item->next) {
    258261                devmap_device_t *device =
     
    268271/** Find device with given handle.
    269272 *
     273 * The devices_list_mutex should be already held when
     274 * calling this function.
     275 *
    270276 * @todo: use hash table
    271277 *
     
    274280{
    275281        link_t *item;
    276        
    277         assert(fibril_mutex_is_locked(&devices_list_mutex));
    278        
    279282        for (item = devices_list.next; item != &devices_list; item = item->next) {
    280283                devmap_device_t *device =
     
    287290}
    288291
    289 /** Create a namespace (if not already present). */
     292/** Create a namespace (if not already present)
     293 *
     294 * The devices_list_mutex should be already held when
     295 * calling this function.
     296 *
     297 */
    290298static devmap_namespace_t *devmap_namespace_create(const char *ns_name)
    291299{
    292         devmap_namespace_t *namespace;
    293        
    294         assert(fibril_mutex_is_locked(&devices_list_mutex));
    295        
    296         namespace = devmap_namespace_find_name(ns_name);
     300        devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name);
    297301        if (namespace != NULL)
    298302                return namespace;
     
    319323}
    320324
    321 /** Destroy a namespace (if it is no longer needed). */
     325/** Destroy a namespace (if it is no longer needed)
     326 *
     327 * The devices_list_mutex should be already held when
     328 * calling this function.
     329 *
     330 */
    322331static void devmap_namespace_destroy(devmap_namespace_t *namespace)
    323332{
    324         assert(fibril_mutex_is_locked(&devices_list_mutex));
    325 
    326333        if (namespace->refcnt == 0) {
    327334                list_remove(&(namespace->namespaces));
     
    332339}
    333340
    334 /** Increase namespace reference count by including device. */
     341/** Increase namespace reference count by including device
     342 *
     343 * The devices_list_mutex should be already held when
     344 * calling this function.
     345 *
     346 */
    335347static void devmap_namespace_addref(devmap_namespace_t *namespace,
    336348    devmap_device_t *device)
    337349{
    338         assert(fibril_mutex_is_locked(&devices_list_mutex));
    339 
    340350        device->namespace = namespace;
    341351        namespace->refcnt++;
    342352}
    343353
    344 /** Decrease namespace reference count. */
     354/** Decrease namespace reference count
     355 *
     356 * The devices_list_mutex should be already held when
     357 * calling this function.
     358 *
     359 */
    345360static void devmap_namespace_delref(devmap_namespace_t *namespace)
    346361{
    347         assert(fibril_mutex_is_locked(&devices_list_mutex));
    348 
    349362        namespace->refcnt--;
    350363        devmap_namespace_destroy(namespace);
    351364}
    352365
    353 /** Unregister device and free it. */
     366/** Unregister device and free it
     367 *
     368 * The devices_list_mutex should be already held when
     369 * calling this function.
     370 *
     371 */
    354372static void devmap_device_unregister_core(devmap_device_t *device)
    355373{
    356         assert(fibril_mutex_is_locked(&devices_list_mutex));
    357 
    358374        devmap_namespace_delref(device->namespace);
    359375        list_remove(&(device->devices));
  • uspace/srv/fs/devfs/devfs_ops.c

    r5f7d96e re080332  
    6060typedef struct {
    6161        devmap_handle_t handle;
    62         int phone;              /**< When < 0, the structure is incomplete. */
     62        int phone;
    6363        size_t refcount;
    6464        link_t link;
    65         fibril_condvar_t cv;    /**< Broadcast when completed. */
    6665} device_t;
    6766
     
    228227                        [DEVICES_KEY_HANDLE] = (unsigned long) node->handle
    229228                };
    230                 link_t *lnk;
    231 
     229               
    232230                fibril_mutex_lock(&devices_mutex);
    233 restart:
    234                 lnk = hash_table_find(&devices, key);
     231                link_t *lnk = hash_table_find(&devices, key);
    235232                if (lnk == NULL) {
    236233                        device_t *dev = (device_t *) malloc(sizeof(device_t));
     
    240237                        }
    241238                       
    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 
    259239                        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 
    269240                        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);
    275241                                fibril_mutex_unlock(&devices_mutex);
    276 
    277242                                free(dev);
    278243                                return ENOENT;
    279244                        }
    280245                       
    281                         /* Set the correct phone. */
     246                        dev->handle = node->handle;
    282247                        dev->phone = phone;
     248                        dev->refcount = 1;
     249                       
     250                        hash_table_insert(&devices, key, &dev->link);
    283251                } else {
    284252                        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 
    298253                        dev->refcount++;
    299254                }
     
    609564               
    610565                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    611                 assert(dev->phone >= 0);
    612566               
    613567                ipc_callid_t callid;
     
    673627               
    674628                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    675                 assert(dev->phone >= 0);
    676629               
    677630                ipc_callid_t callid;
     
    743696               
    744697                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    745                 assert(dev->phone >= 0);
    746698                dev->refcount--;
    747699               
     
    791743               
    792744                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    793                 assert(dev->phone >= 0);
    794745               
    795746                /* Make a request at the driver */
  • uspace/srv/hid/console/console.c

    r5f7d96e re080332  
    317317static void change_console(console_t *cons)
    318318{
    319         if (cons == active_console) {
     319        if (cons == active_console)
    320320                return;
    321         }
    322321       
    323322        fb_pending_flush();
     
    459458                        if (IPC_GET_ARG1(call) == 1) {
    460459                                int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call));
    461                                 if (newcon != -1) {
     460                                if (newcon != -1)
    462461                                        change_console(&consoles[newcon]);
    463                                 }
    464462                        }
    465463                        retval = 0;
     
    712710}
    713711
    714 static int connect_keyboard(char *path)
    715 {
    716         int fd = open(path, O_RDONLY);
    717         if (fd < 0) {
    718                 return fd;
    719         }
    720        
    721         int phone = fd_phone(fd);
    722         if (phone < 0) {
     712static bool console_init(char *input)
     713{
     714        /* Connect to input device */
     715        int input_fd = open(input, O_RDONLY);
     716        if (input_fd < 0) {
     717                printf(NAME ": Failed opening %s\n", input);
     718                return false;
     719        }
     720       
     721        kbd_phone = fd_phone(input_fd);
     722        if (kbd_phone < 0) {
    723723                printf(NAME ": Failed to connect to input device\n");
    724                 return phone;
     724                return false;
    725725        }
    726726       
    727727        /* NB: The callback connection is slotted for removal */
    728728        sysarg_t phonehash;
    729         int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE,
    730             0, 0, NULL, NULL, NULL, NULL, &phonehash);
    731         if (rc != EOK) {
     729        if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
    732730                printf(NAME ": Failed to create callback from input device\n");
    733                 return rc;
     731                return false;
    734732        }
    735733       
    736734        async_new_connection(phonehash, 0, NULL, keyboard_events);
    737 
    738         printf(NAME ": we got a hit (new keyboard \"%s\").\n", path);
    739 
    740         return phone;
    741 }
    742 
    743 
    744 static int check_new_keyboards(void *arg)
    745 {
    746         char *class_name = (char *) arg;
    747 
    748         int index = 1;
    749 
    750         while (true) {
    751                 async_usleep(1 * 500 * 1000);
    752                 char *path;
    753                 int rc = asprintf(&path, "/dev/class/%s\\%d", class_name, index);
    754                 if (rc < 0) {
    755                         continue;
    756                 }
    757                 rc = 0;
    758                 rc = connect_keyboard(path);
    759                 if (rc > 0) {
    760                         /* We do not allow unplug. */
    761                         index++;
    762                 }
    763 
    764                 free(path);
    765         }
    766 
    767         return EOK;
    768 }
    769 
    770 
    771 /** Start a fibril monitoring hot-plugged keyboards.
    772  */
    773 static void check_new_keyboards_in_background()
    774 {
    775         fid_t fid = fibril_create(check_new_keyboards, (void *)"keyboard");
    776         if (!fid) {
    777                 printf(NAME ": failed to create hot-plug-watch fibril.\n");
    778                 return;
    779         }
    780         fibril_add_ready(fid);
    781 }
    782 
    783 static bool console_init(char *input)
    784 {
    785         /* Connect to input device */
    786         kbd_phone = connect_keyboard(input);
    787         if (kbd_phone < 0) {
    788                 return false;
    789         }
    790 
     735       
    791736        /* Connect to mouse device */
    792737        mouse_phone = -1;
     
    804749        }
    805750       
    806         sysarg_t phonehash;
    807751        if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
    808752                printf(NAME ": Failed to create callback from mouse device\n");
     
    897841        async_set_interrupt_received(interrupt_received);
    898842       
    899         /* Start fibril for checking on hot-plugged keyboards. */
    900         check_new_keyboards_in_background();
    901 
    902843        return true;
    903844}
     
    919860        if (!console_init(argv[1]))
    920861                return -1;
    921 
     862       
    922863        printf(NAME ": Accepting connections\n");
    923864        async_manager();
  • uspace/srv/net/tl/tcp/tcp.c

    r5f7d96e re080332  
    20852085        if (!fibril) {
    20862086                free(operation_timeout);
    2087                 return ENOMEM;
    2088         }
    2089 
     2087                return EPARTY;  /* FIXME: use another EC */
     2088        }
    20902089//      fibril_mutex_lock(&socket_data->operation.mutex);
    20912090        /* Start the timeout fibril */
  • uspace/srv/vfs/vfs_lookup.c

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