Changeset 70253688 in mainline for uspace


Ignore:
Timestamp:
2012-09-07T08:12:05Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e0c836e8
Parents:
131d9a4 (diff), 8cf4823 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

Location:
uspace
Files:
22 added
54 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile

    r131d9a4 r70253688  
    9797        srv/bd/part/mbr_part \
    9898        srv/fs/exfat \
     99        srv/fs/udf \
    99100        srv/fs/fat \
    100101        srv/fs/cdfs \
  • uspace/app/bdsh/errors.h

    r131d9a4 r70253688  
    3030#define ERRORS_H
    3131
     32#include <io/verify.h>
     33
    3234/* Various error levels */
    3335#define CL_EFATAL  -1
     
    4648extern volatile int cli_errno;
    4749
    48 extern void cli_error(int, const char *, ...);
     50extern void cli_error(int, const char *, ...)
     51    PRINTF_ATTRIBUTE(2, 3);
    4952
    5053#endif
  • uspace/app/bdsh/input.c

    r131d9a4 r70253688  
    6767int process_input(cliuser_t *usr)
    6868{
    69         token_t *tokens = calloc(WORD_MAX, sizeof(token_t));
    70         if (tokens == NULL)
     69        token_t *tokens_buf = calloc(WORD_MAX, sizeof(token_t));
     70        if (tokens_buf == NULL)
    7171                return ENOMEM;
     72        token_t *tokens = tokens_buf;
    7273       
    7374        char *cmd[WORD_MAX];
     
    8081
    8182        if (usr->line == NULL) {
    82                 free(tokens);
     83                free(tokens_buf);
    8384                return CL_EFAIL;
    8485        }
     
    213214        }
    214215        tok_fini(&tok);
    215         free(tokens);
     216        free(tokens_buf);
    216217
    217218        return rc;
  • uspace/app/edit/edit.c

    r131d9a4 r70253688  
    111111#define BUF_SIZE 64
    112112#define TAB_WIDTH 8
    113 #define ED_INFTY 65536
    114113
    115114/** Maximum filename length that can be entered. */
     
    507506static void key_handle_movement(unsigned int key, bool select)
    508507{
     508        spt_t pt;
    509509        switch (key) {
    510510        case KC_LEFT:
     
    521521                break;
    522522        case KC_HOME:
    523                 caret_move_relative(0, -ED_INFTY, dir_after, select);
     523                tag_get_pt(&pane.caret_pos, &pt);
     524                pt_get_sol(&pt, &pt);
     525                caret_move(pt, select, true);
    524526                break;
    525527        case KC_END:
    526                 caret_move_relative(0, +ED_INFTY, dir_before, select);
     528                tag_get_pt(&pane.caret_pos, &pt);
     529                pt_get_eol(&pt, &pt);
     530                caret_move(pt, select, true);
    527531                break;
    528532        case KC_PAGE_UP:
  • uspace/app/top/screen.h

    r131d9a4 r70253688  
    3636
    3737#include <io/console.h>
     38#include <io/verify.h>
    3839#include "top.h"
    3940
     
    4344extern void screen_done(void);
    4445extern void print_data(data_t *);
    45 extern void show_warning(const char *, ...);
     46extern void show_warning(const char *, ...)
     47    PRINTF_ATTRIBUTE(1, 2);
    4648
    4749extern int tgetchar(unsigned int);
  • uspace/dist/src/c/demos/top/screen.h

    r131d9a4 r70253688  
    3636
    3737#include <io/console.h>
     38#include <io/verify.h>
    3839#include "top.h"
    3940
     
    4344extern void screen_done(void);
    4445extern void print_data(data_t *);
    45 extern void print_warning(const char *, ...);
     46extern void print_warning(const char *, ...)
     47    PRINTF_ATTRIBUTE(1, 2);
    4648
    4749extern int tgetchar(unsigned int);
  • uspace/drv/bus/isa/i8237.c

    r131d9a4 r70253688  
    351351       
    352352        /* 16 bit transfers are a bit special */
    353         ddf_msg(LVL_DEBUG, "Unspoiled address: %p and size: %zu.", pa, size);
     353        ddf_msg(LVL_DEBUG, "Unspoiled address %#" PRIx32 " (size %" PRIu16 ")",
     354            pa, size);
    354355        if (channel > 4) {
    355356                /* Size must be aligned to 16 bits */
     
    367368        const dma_channel_t dma_channel = controller_8237.channels[channel];
    368369       
    369         ddf_msg(LVL_DEBUG, "Setting channel %u, to address %p(%zu), mode %hhx.",
    370             channel, pa, size, mode);
     370        ddf_msg(LVL_DEBUG, "Setting channel %u to address %#" PRIx32 " "
     371            "(size %" PRIu16 "), mode %hhx.", channel, pa, size, mode);
    371372       
    372373        /* Mask DMA request */
  • uspace/drv/char/ps2mouse/ps2mouse.c

    r131d9a4 r70253688  
    7575        const ssize_t size = chardev_read(sess, &data, 1); \
    7676        if (size != 1) { \
    77                 ddf_msg(LVL_ERROR, "Failed reading byte: %d)", size);\
     77                ddf_msg(LVL_ERROR, "Failed reading byte: %zd)", size);\
    7878                return size < 0 ? size : EIO; \
    7979        } \
  • uspace/drv/nic/rtl8139/driver.c

    r131d9a4 r70253688  
    620620                /* Check if the header is valid, otherwise we are lost in the buffer */
    621621                if (size == 0 || size > RTL8139_FRAME_MAX_LENGTH) {
    622                         ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4"PRIu16", "
    623                             "header 0x%4"PRIx16". Offset: %zu)", size, frame_header,
     622                        ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4" PRIu16 ", "
     623                            "header 0x%4" PRIx16 ". Offset: %d)", size, frame_header,
    624624                            rx_offset);
    625625                        goto rx_err;
     
    11621162
    11631163        /* Allocate buffer for receiver */
    1164         ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %zu bytes",
     1164        ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %d bytes",
    11651165            RxBUF_TOT_LENGTH);
    11661166
     
    12491249        /* Gain control over port's registers. */
    12501250        if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) {
    1251                 ddf_msg(LVL_ERROR, "Cannot gain the port %lx for device %s.", rtl8139->io_addr,
     1251                ddf_msg(LVL_ERROR, "Cannot gain the port %p for device %s.", rtl8139->io_addr,
    12521252                    ddf_dev_get_name(dev));
    12531253                return EADDRNOTAVAIL;
     
    12961296
    12971297        assert(dev);
    1298         ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)",
     1298        ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %zu)",
    12991299            ddf_dev_get_name(dev), ddf_dev_get_handle(dev));
    13001300
     
    13281328        rc = nic_connect_to_services(nic_data);
    13291329        if (rc != EOK) {
    1330                 ddf_msg(LVL_ERROR, "Failed to connect to services", rc);
     1330                ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);
    13311331                goto err_irq;
    13321332        }
     
    21392139                pio_write_32(rtl8139->io_port + TCTR, 0);
    21402140
    2141                 ddf_msg(LVL_DEBUG, "Periodic mode. Interrupt mask %"PRIx16", poll.full_skips %"
    2142                     PRIu32", last timer %"PRIu32".", rtl8139->int_mask,
    2143                     rtl8139->poll_timer.full_skips, rtl8139->poll_timer.last_val);
     2141                ddf_msg(LVL_DEBUG, "Periodic mode. Interrupt mask %" PRIx16 ", "
     2142                    "poll.full_skips %zu, last timer %" PRIu32,
     2143                    rtl8139->int_mask, rtl8139->poll_timer.full_skips,
     2144                    rtl8139->poll_timer.last_val);
    21442145                break;
    21452146        default:
  • uspace/lib/c/Makefile

    r131d9a4 r70253688  
    9595        generic/inetping.c \
    9696        generic/io/asprintf.c \
     97        generic/io/input.c \
    9798        generic/io/io.c \
    9899        generic/io/chargrid.c \
     
    106107        generic/io/vsnprintf.c \
    107108        generic/io/printf_core.c \
     109        generic/io/con_srv.c \
    108110        generic/io/console.c \
    109111        generic/io/visualizer.c \
  • uspace/lib/c/arch/abs32le/_link.ld.in

    r131d9a4 r70253688  
    1515#ifdef LOADER
    1616        . = 0x70001000 + SIZEOF_HEADERS;
    17        
    18         .interp : {
    19                 *(.interp);
    20         } :interp :text
    2117#else
    2218        . = 0x1000 + SIZEOF_HEADERS;
    2319#endif
    24        
    25         /* Make sure the code is aligned reasonably */
    26         . = ALIGN(., 16);
    2720       
    2821        .text : {
     
    3023                *(.rodata .rodata.*);
    3124        } :text
     25       
     26#ifdef LOADER
     27        .interp : {
     28                *(.interp);
     29        } :interp :text
     30#endif
    3231       
    3332        . = . + 0x1000;
  • uspace/lib/c/arch/abs32le/include/types.h

    r131d9a4 r70253688  
    4747
    4848typedef uint32_t sysarg_t;
     49typedef int32_t native_t;
    4950
    5051typedef int32_t ssize_t;
  • uspace/lib/c/arch/amd64/_link.ld.in

    r131d9a4 r70253688  
    1616#ifdef LOADER
    1717        . = 0x70001000 + SIZEOF_HEADERS;
    18        
    19         .interp : {
    20                 *(.interp);
    21         } :interp :text
    2218#else
    2319        . = 0x1000 + SIZEOF_HEADERS;
    2420#endif
    25        
    26         /* Make sure the code is aligned reasonably */
    27         . = ALIGN(., 16);
    2821       
    2922        .init : {
     
    3528                *(.rodata .rodata.*);
    3629        } :text
     30       
     31#ifdef LOADER
     32        .interp : {
     33                *(.interp);
     34        } :interp :text
     35#endif
    3736       
    3837        . = . + 0x1000;
  • uspace/lib/c/arch/amd64/include/types.h

    r131d9a4 r70253688  
    4747
    4848typedef uint64_t sysarg_t;
     49typedef int64_t native_t;
    4950
    5051typedef int64_t ssize_t;
  • uspace/lib/c/arch/arm32/_link.ld.in

    r131d9a4 r70253688  
    1515#ifdef LOADER
    1616        . = 0x70001000 + SIZEOF_HEADERS;
    17        
    18         .interp : {
    19                 *(.interp);
    20         } :interp :text
    2117#else
    2218        . = 0x1000 + SIZEOF_HEADERS;
    2319#endif
    24        
    25         /* Make sure the code is aligned reasonably */
    26         . = ALIGN(., 8);
    2720       
    2821        .init : {
     
    3427                *(.rodata .rodata.*);
    3528        } :text
     29       
     30#ifdef LOADER
     31        .interp : {
     32                *(.interp);
     33        } :interp :text
     34#endif
    3635       
    3736        . = . + 0x1000;
  • uspace/lib/c/arch/arm32/include/types.h

    r131d9a4 r70253688  
    4848
    4949typedef uint32_t sysarg_t;
     50typedef int32_t native_t;
    5051
    5152typedef int32_t ssize_t;
  • uspace/lib/c/arch/ia32/_link.ld.in

    r131d9a4 r70253688  
    2424        . = 0x1000 + SIZEOF_HEADERS;
    2525#endif
    26        
    27 #if defined(LOADER) || defined(DLEXE)
    28         .interp : {
    29                 *(.interp);
    30         } :interp :text
    31 #endif
    32        
    33         /* Make sure the code is aligned reasonably */
    34         . = ALIGN(., 16);
    3526       
    3627        .init : {
     
    7162        } :text
    7263#endif
     64       
     65#if defined(LOADER) || defined(DLEXE)
     66        .interp : {
     67                *(.interp);
     68        } :interp :text
     69#endif
     70       
    7371        . = . + 0x1000;
    7472       
  • uspace/lib/c/arch/ia32/include/types.h

    r131d9a4 r70253688  
    4747
    4848typedef uint32_t sysarg_t;
     49typedef int32_t native_t;
    4950
    5051typedef int32_t ssize_t;
  • uspace/lib/c/arch/ia64/_link.ld.in

    r131d9a4 r70253688  
    1515#ifdef LOADER
    1616        . = 0x800000000 + SIZEOF_HEADERS;
    17        
    18         .interp : {
    19                 *(.interp);
    20         } :interp :text
    2117#else
    2218        . = 0x4000 + SIZEOF_HEADERS;
    2319#endif
    2420       
    25         /* Make sure the code is aligned reasonably */
     21        /* Workaround proper alignment of the .init section */
    2622        . = ALIGN(., 16);
    2723       
     
    3430                *(.rodata .rodata.*);
    3531        } :text
     32       
     33#ifdef LOADER
     34        .interp : {
     35                *(.interp);
     36        } :interp :text
     37#endif
    3638       
    3739        . = . + 0x4000;
  • uspace/lib/c/arch/ia64/include/types.h

    r131d9a4 r70253688  
    5757
    5858typedef uint64_t sysarg_t;
     59typedef int64_t native_t;
    5960
    6061typedef int64_t ssize_t;
  • uspace/lib/c/arch/mips32/_link.ld.in

    r131d9a4 r70253688  
    1515#ifdef LOADER
    1616        . = 0x70004000 + SIZEOF_HEADERS;
    17        
    18         .interp : {
    19                 *(.interp);
    20         } :interp :text
    2117#else
    2218        . = 0x4000 + SIZEOF_HEADERS;
    2319#endif
    24        
    25         /* Make sure the code is aligned reasonably */
    26         . = ALIGN(., 16);
    2720       
    2821        .init : {
     
    3427                *(.rodata .rodata.*);
    3528        } :text
     29       
     30#ifdef LOADER
     31        .interp : {
     32                *(.interp);
     33        } :interp :text
     34#endif
    3635       
    3736        . = . + 0x4000;
  • uspace/lib/c/arch/mips32/include/types.h

    r131d9a4 r70253688  
    4848
    4949typedef uint32_t sysarg_t;
     50typedef int32_t native_t;
    5051
    5152typedef int32_t ssize_t;
  • uspace/lib/c/arch/mips64/_link.ld.in

    r131d9a4 r70253688  
    1616#ifdef LOADER
    1717        . = 0x70004000 + SIZEOF_HEADERS;
    18        
    19         .interp : {
    20                 *(.interp);
    21         } :interp :text
    2218#else
    2319        . = 0x4000 + SIZEOF_HEADERS;
    2420#endif
    25        
    26         /* Make sure the code is aligned reasonably */
    27         . = ALIGN(., 16);
    2821       
    2922        .init : {
     
    3528                *(.rodata .rodata.*);
    3629        } :text
     30       
     31#ifdef LOADER
     32        .interp : {
     33                *(.interp);
     34        } :interp :text
     35#endif
    3736       
    3837        . = . + 0x4000;
  • uspace/lib/c/arch/mips64/include/types.h

    r131d9a4 r70253688  
    4848
    4949typedef uint64_t sysarg_t;
     50typedef int64_t native_t;
    5051
    5152typedef int64_t ssize_t;
  • uspace/lib/c/arch/ppc32/_link.ld.in

    r131d9a4 r70253688  
    1616#ifdef LOADER
    1717        . = 0x70001000 + SIZEOF_HEADERS;
    18        
    19         .interp : {
    20                 *(.interp);
    21         } :interp :text
    2218#else
    2319        . = 0x1000 + SIZEOF_HEADERS;
    2420#endif
    25        
    26         /* Make sure the code is aligned reasonably */
    27         . = ALIGN(., 4);
    2821       
    2922        .init : {
     
    3528                *(.rodata .rodata.*);
    3629        } :text
     30       
     31#ifdef LOADER
     32        .interp : {
     33                *(.interp);
     34        } :interp :text
     35#endif
    3736       
    3837        . = . + 0x1000;
  • uspace/lib/c/arch/ppc32/include/types.h

    r131d9a4 r70253688  
    4747
    4848typedef uint32_t sysarg_t;
     49typedef int32_t native_t;
    4950
    5051typedef int32_t ssize_t;
  • uspace/lib/c/arch/sparc64/_link.ld.in

    r131d9a4 r70253688  
    1515#ifdef LOADER
    1616        . = 0x70004000 + SIZEOF_HEADERS;
    17        
    18         .interp : {
    19                 *(.interp);
    20         } :interp :text
    2117#else
    2218        . = 0x4000 + SIZEOF_HEADERS;
    2319#endif
    24        
    25         /* Make sure the code is aligned reasonably */
    26         . = ALIGN(., 16);
    2720       
    2821        .init : {
     
    3427                *(.rodata .rodata.*);
    3528        } :text
     29       
     30#ifdef LOADER
     31        .interp : {
     32                *(.interp);
     33        } :interp :text
     34#endif
    3635       
    3736        . = . + 0x4000;
  • uspace/lib/c/arch/sparc64/include/types.h

    r131d9a4 r70253688  
    4747
    4848typedef uint64_t sysarg_t;
     49typedef int64_t native_t;
    4950
    5051typedef int64_t ssize_t;
  • uspace/lib/c/generic/io/console.c

    r131d9a4 r70253688  
    3838#include <async.h>
    3939#include <errno.h>
    40 #include <stdio.h>
    4140#include <malloc.h>
    4241#include <vfs/vfs_sess.h>
     
    126125{
    127126        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    128         async_req_1_0(exch, CONSOLE_CURSOR_VISIBILITY, (show != false));
     127        async_req_1_0(exch, CONSOLE_SET_CURSOR_VISIBILITY, (show != false));
    129128        async_exchange_end(exch);
    130129}
     
    151150{
    152151        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    153         async_req_2_0(exch, CONSOLE_GOTO, col, row);
     152        async_req_2_0(exch, CONSOLE_SET_POS, col, row);
    154153        async_exchange_end(exch);
    155154}
  • uspace/lib/c/generic/io/output.c

    r131d9a4 r70253688  
    3737#include <as.h>
    3838#include <ipc/output.h>
     39#include <io/concaps.h>
    3940#include <io/output.h>
    4041
  • uspace/lib/c/generic/tls.c

    r131d9a4 r70253688  
    4242#include <str.h>
    4343#include <align.h>
     44#include <unistd.h>
    4445
    4546/** Create TLS (Thread Local Storage) data structures.
     
    5758       
    5859        tcb = __alloc_tls(&data, tls_size);
     60        if (!tcb)
     61                return NULL;
    5962       
    6063        /*
     
    8992
    9093        result = malloc(sizeof(tcb_t) + size);
     94        if (!result)
     95                return NULL;
    9196        *data = ((void *)result) + sizeof(tcb_t);
     97
    9298        return result;
    9399}
     
    118124        size = ALIGN_UP(size, &_tls_alignment);
    119125        *data = memalign((uintptr_t) &_tls_alignment, sizeof(tcb_t) + size);
    120 
     126        if (!*data)
     127                return NULL;
    121128        tcb = (tcb_t *) (*data + size);
    122129        tcb->self = tcb;
  • uspace/lib/c/include/io/console.h

    r131d9a4 r70253688  
    3737
    3838#include <sys/time.h>
     39#include <io/concaps.h>
     40#include <io/kbd_event.h>
    3941#include <io/keycode.h>
    4042#include <async.h>
    4143#include <bool.h>
    4244#include <stdio.h>
    43 
    44 typedef enum {
    45         CONSOLE_CAP_NONE = 0,
    46         CONSOLE_CAP_STYLE = 1,
    47         CONSOLE_CAP_INDEXED = 2,
    48         CONSOLE_CAP_RGB = 4
    49 } console_caps_t;
    5045
    5146/** Console control structure. */
     
    6964        aid_t input_aid;
    7065} console_ctrl_t;
    71 
    72 typedef enum {
    73         KEY_PRESS,
    74         KEY_RELEASE
    75 } kbd_event_type_t;
    76 
    77 /** Console event structure. */
    78 typedef struct {
    79         /** List handle */
    80         link_t link;
    81        
    82         /** Press or release event. */
    83         kbd_event_type_t type;
    84        
    85         /** Keycode of the key that was pressed or released. */
    86         keycode_t key;
    87        
    88         /** Bitmask of modifiers held. */
    89         keymod_t mods;
    90        
    91         /** The character that was generated or '\0' for none. */
    92         wchar_t c;
    93 } kbd_event_t;
    9466
    9567extern console_ctrl_t *console_init(FILE *, FILE *);
  • uspace/lib/c/include/io/klog.h

    r131d9a4 r70253688  
    3838#include <sys/types.h>
    3939#include <stdarg.h>
     40#include <io/verify.h>
    4041
    4142extern size_t klog_write(const void *, size_t);
    4243extern void klog_update(void);
    43 extern int klog_printf(const char *, ...);
     44extern int klog_printf(const char *, ...)
     45    PRINTF_ATTRIBUTE(1, 2);
    4446extern int klog_vprintf(const char *, va_list);
    4547
  • uspace/lib/c/include/io/log.h

    r131d9a4 r70253688  
    3737#include <stdarg.h>
    3838#include <inttypes.h>
    39 #include <bool.h>
     39#include <io/verify.h>
    4040
    4141typedef enum {
     
    4646        LVL_DEBUG,
    4747        LVL_DEBUG2,
    48 
     48       
    4949        /** For checking range of values */
    5050        LVL_LIMIT
     
    6262extern log_t log_create(const char *, log_t);
    6363
    64 extern void log_msg(log_t, log_level_t, const char *, ...);
     64extern void log_msg(log_t, log_level_t, const char *, ...)
     65    PRINTF_ATTRIBUTE(3, 4);
    6566extern void log_msgv(log_t, log_level_t, const char *, va_list);
    6667
  • uspace/lib/c/include/ipc/console.h

    r131d9a4 r70253688  
    4343        CONSOLE_GET_EVENT,
    4444        CONSOLE_GET_POS,
    45         CONSOLE_GOTO,
     45        CONSOLE_SET_POS,
    4646        CONSOLE_CLEAR,
    4747        CONSOLE_SET_STYLE,
    4848        CONSOLE_SET_COLOR,
    4949        CONSOLE_SET_RGB_COLOR,
    50         CONSOLE_CURSOR_VISIBILITY
     50        CONSOLE_SET_CURSOR_VISIBILITY
    5151} console_request_t;
    5252
  • uspace/lib/c/include/stdio.h

    r131d9a4 r70253688  
    3939#include <stdarg.h>
    4040#include <str.h>
    41 
    42 #ifndef NVERIFY_PRINTF
    43 
    44 #define PRINTF_ATTRIBUTE(start, end) \
    45         __attribute__((format(gnu_printf, start, end)))
    46 
    47 #else /* NVERIFY_PRINTF */
    48 
    49 #define PRINTF_ATTRIBUTE(start, end)
    50 
    51 #endif /* NVERIFY_PRINTF */
     41#include <io/verify.h>
    5242
    5343#define EOF  (-1)
  • uspace/lib/draw/surface.c

    r131d9a4 r70253688  
    4444        surface_flags_t flags;
    4545
    46         sysarg_t dirty_x_lo;
    47         sysarg_t dirty_x_hi;
    48         sysarg_t dirty_y_lo;
    49         sysarg_t dirty_y_hi;
     46        surface_coord_t dirty_x_lo;
     47        surface_coord_t dirty_x_hi;
     48        surface_coord_t dirty_y_lo;
     49        surface_coord_t dirty_y_hi;
    5050
    5151        pixelmap_t pixmap;
    5252};
    5353
    54 surface_t *surface_create(
    55     sysarg_t width, sysarg_t height, pixel_t *pixbuf, surface_flags_t flags)
     54surface_t *surface_create(surface_coord_t width, surface_coord_t height,
     55    pixel_t *pixbuf, surface_flags_t flags)
    5656{
    5757        surface_t *surface = (surface_t *) malloc(sizeof(surface_t));
     
    118118}
    119119
    120 void surface_get_resolution(surface_t *surface, sysarg_t *width, sysarg_t *height)
     120void surface_get_resolution(surface_t *surface, surface_coord_t *width, surface_coord_t *height)
    121121{
    122122        assert(width);
     
    127127}
    128128
    129 void surface_get_damaged_region(surface_t *surface, sysarg_t *x, sysarg_t *y,
    130     sysarg_t *width, sysarg_t *height)
     129void surface_get_damaged_region(surface_t *surface, surface_coord_t *x, surface_coord_t *y,
     130    surface_coord_t *width, surface_coord_t *height)
    131131{
    132132        assert(x);
     
    151151}
    152152
    153 void surface_put_pixel(surface_t *surface, sysarg_t x, sysarg_t y, pixel_t pixel)
     153void surface_put_pixel(surface_t *surface, surface_coord_t x, surface_coord_t y, pixel_t pixel)
    154154{
    155155        surface->dirty_x_lo = surface->dirty_x_lo > x ? x : surface->dirty_x_lo;
     
    163163}
    164164
    165 pixel_t surface_get_pixel(surface_t *surface, sysarg_t x, sysarg_t y)
     165pixel_t surface_get_pixel(surface_t *surface, surface_coord_t x, surface_coord_t y)
    166166{
    167167        if (x < surface->pixmap.width && y < surface->pixmap.height) {
  • uspace/lib/draw/surface.h

    r131d9a4 r70253688  
    4545typedef struct surface surface_t;
    4646
     47typedef sysarg_t surface_coord_t;
     48
    4749typedef enum {
    4850        SURFACE_FLAG_NONE = 0,
     
    5052} surface_flags_t;
    5153
    52 extern surface_t *surface_create(sysarg_t, sysarg_t, pixel_t *, surface_flags_t);
     54extern surface_t *surface_create(surface_coord_t, surface_coord_t, pixel_t *, surface_flags_t);
    5355extern void surface_destroy(surface_t *);
    5456
     
    5658extern pixel_t *surface_direct_access(surface_t *);
    5759extern pixelmap_t *surface_pixmap_access(surface_t *);
    58 extern void surface_get_resolution(surface_t *, sysarg_t *, sysarg_t *);
    59 extern void surface_get_damaged_region(surface_t *, sysarg_t *, sysarg_t *,
    60     sysarg_t *, sysarg_t *);
     60extern void surface_get_resolution(surface_t *, surface_coord_t *, surface_coord_t *);
     61extern void surface_get_damaged_region(surface_t *, surface_coord_t *, surface_coord_t *,
     62    surface_coord_t *, surface_coord_t *);
    6163extern void surface_reset_damaged_region(surface_t *);
    6264
    63 extern void surface_put_pixel(surface_t *, sysarg_t, sysarg_t, pixel_t);
    64 extern pixel_t surface_get_pixel(surface_t *, sysarg_t, sysarg_t);
     65extern void surface_put_pixel(surface_t *, surface_coord_t, surface_coord_t, pixel_t);
     66extern pixel_t surface_get_pixel(surface_t *, surface_coord_t, surface_coord_t);
    6567
    6668#endif
  • uspace/lib/drv/include/ddf/log.h

    r131d9a4 r70253688  
    3535
    3636#include <io/log.h>
     37#include <io/verify.h>
    3738
    3839extern int ddf_log_init(const char *);
    39 extern void ddf_msg(log_level_t, const char *, ...);
     40extern void ddf_msg(log_level_t, const char *, ...)
     41    PRINTF_ATTRIBUTE(2, 3);
    4042
    4143extern void ddf_dump_buffer(char *, size_t, const void *, size_t, size_t,
  • uspace/lib/ext4/libext4_filesystem.c

    r131d9a4 r70253688  
    12841284        block_t *block;
    12851285        while (level > 0) {
     1286               
     1287                /* Sparse check */
     1288                if (current_block == 0)
     1289                        return EOK;
     1290               
    12861291                int rc = block_get(&block, fs->device, current_block, 0);
    12871292                if (rc != EOK)
  • uspace/lib/gui/terminal.c

    r131d9a4 r70253688  
    3939#include <surface.h>
    4040#include <gfx/font-8x16.h>
     41#include <io/con_srv.h>
     42#include <io/concaps.h>
    4143#include <io/console.h>
    42 #include <ipc/console.h>
    4344#include <task.h>
    4445#include <adt/list.h>
     
    6061
    6162static LIST_INITIALIZE(terms);
     63
     64static int term_open(con_srvs_t *, con_srv_t *);
     65static int term_close(con_srv_t *);
     66static int term_read(con_srv_t *, void *, size_t);
     67static int term_write(con_srv_t *, void *, size_t);
     68static void term_sync(con_srv_t *);
     69static void term_clear(con_srv_t *);
     70static void term_set_pos(con_srv_t *, sysarg_t col, sysarg_t row);
     71static int term_get_pos(con_srv_t *, sysarg_t *, sysarg_t *);
     72static int term_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
     73static int term_get_color_cap(con_srv_t *, console_caps_t *);
     74static void term_set_style(con_srv_t *, console_style_t);
     75static void term_set_color(con_srv_t *, console_color_t, console_color_t,
     76    console_color_attr_t);
     77static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
     78static void term_set_cursor_visibility(con_srv_t *, bool);
     79static int term_get_event(con_srv_t *, kbd_event_t *);
     80
     81static con_ops_t con_ops = {
     82        .open = term_open,
     83        .close = term_close,
     84        .read = term_read,
     85        .write = term_write,
     86        .sync = term_sync,
     87        .clear = term_clear,
     88        .set_pos = term_set_pos,
     89        .get_pos = term_get_pos,
     90        .get_size = term_get_size,
     91        .get_color_cap = term_get_color_cap,
     92        .set_style = term_set_style,
     93        .set_color = term_set_color,
     94        .set_rgb_color = term_set_rgb_color,
     95        .set_cursor_visibility = term_set_cursor_visibility,
     96        .get_event = term_get_event
     97};
     98
     99static terminal_t *srv_to_terminal(con_srv_t *srv)
     100{
     101        return srv->srvs->sarg;
     102}
    62103
    63104static void getterm(const char *svc, const char *app)
     
    341382}
    342383
    343 static void term_set_cursor(terminal_t *term, sysarg_t col, sysarg_t row)
    344 {
    345         fibril_mutex_lock(&term->mtx);
    346         chargrid_set_cursor(term->frontbuf, col, row);
    347         fibril_mutex_unlock(&term->mtx);
    348        
    349         term_update(term);
    350 }
    351 
    352 static void term_set_cursor_visibility(terminal_t *term, bool visible)
    353 {
    354         fibril_mutex_lock(&term->mtx);
    355         chargrid_set_cursor_visibility(term->frontbuf, visible);
    356         fibril_mutex_unlock(&term->mtx);
    357        
    358         term_update(term);
    359 }
    360 
    361 static void term_read(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall)
    362 {
    363         ipc_callid_t callid;
    364         size_t size;
    365         if (!async_data_read_receive(&callid, &size)) {
    366                 async_answer_0(callid, EINVAL);
    367                 async_answer_0(iid, EINVAL);
    368                 return;
    369         }
    370        
    371         char *buf = (char *) malloc(size);
    372         if (buf == NULL) {
    373                 async_answer_0(callid, ENOMEM);
    374                 async_answer_0(iid, ENOMEM);
    375                 return;
    376         }
    377        
     384static int term_open(con_srvs_t *srvs, con_srv_t *srv)
     385{
     386        return EOK;
     387}
     388
     389static int term_close(con_srv_t *srv)
     390{
     391        return EOK;
     392}
     393
     394static int term_read(con_srv_t *srv, void *buf, size_t size)
     395{
     396        terminal_t *term = srv_to_terminal(srv);
     397        uint8_t *bbuf = buf;
    378398        size_t pos = 0;
    379399       
     
    386406                /* Copy to the buffer remaining characters. */
    387407                while ((pos < size) && (term->char_remains_len > 0)) {
    388                         buf[pos] = term->char_remains[0];
     408                        bbuf[pos] = term->char_remains[0];
    389409                        pos++;
    390410                       
     
    416436        }
    417437       
    418         (void) async_data_read_finalize(callid, buf, size);
    419         async_answer_1(iid, EOK, size);
    420         free(buf);
     438        return size;
    421439}
    422440
     
    449467}
    450468
    451 static void term_write(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall)
    452 {
    453         void *buf;
    454         size_t size;
    455         int rc = async_data_write_accept(&buf, false, 0, 0, 0, &size);
    456        
    457         if (rc != EOK) {
    458                 async_answer_0(iid, rc);
    459                 return;
    460         }
     469static int term_write(con_srv_t *srv, void *data, size_t size)
     470{
     471        terminal_t *term = srv_to_terminal(srv);
    461472       
    462473        size_t off = 0;
    463474        while (off < size)
    464                 term_write_char(term, str_decode(buf, &off, size));
    465        
    466         async_answer_1(iid, EOK, size);
    467         free(buf);
    468 }
    469 
    470 static void term_clear(terminal_t *term)
    471 {
     475                term_write_char(term, str_decode(data, &off, size));
     476       
     477        return size;
     478}
     479
     480static void term_sync(con_srv_t *srv)
     481{
     482        terminal_t *term = srv_to_terminal(srv);
     483       
     484        term_update(term);
     485}
     486
     487static void term_clear(con_srv_t *srv)
     488{
     489        terminal_t *term = srv_to_terminal(srv);
     490       
    472491        fibril_mutex_lock(&term->mtx);
    473492        chargrid_clear(term->frontbuf);
     
    477496}
    478497
    479 static void term_get_cursor(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall)
    480 {
    481         sysarg_t col;
    482         sysarg_t row;
    483        
    484         fibril_mutex_lock(&term->mtx);
    485         chargrid_get_cursor(term->frontbuf, &col, &row);
    486         fibril_mutex_unlock(&term->mtx);
    487        
    488         async_answer_2(iid, EOK, col, row);
    489 }
    490 
    491 static void term_set_style(terminal_t *term, console_style_t style)
    492 {
     498static void term_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row)
     499{
     500        terminal_t *term = srv_to_terminal(srv);
     501       
     502        fibril_mutex_lock(&term->mtx);
     503        chargrid_set_cursor(term->frontbuf, col, row);
     504        fibril_mutex_unlock(&term->mtx);
     505       
     506        term_update(term);
     507}
     508
     509static int term_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row)
     510{
     511        terminal_t *term = srv_to_terminal(srv);
     512       
     513        fibril_mutex_lock(&term->mtx);
     514        chargrid_get_cursor(term->frontbuf, col, row);
     515        fibril_mutex_unlock(&term->mtx);
     516       
     517        return EOK;
     518}
     519
     520static int term_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows)
     521{
     522        terminal_t *term = srv_to_terminal(srv);
     523       
     524        fibril_mutex_lock(&term->mtx);
     525        *cols = term->cols;
     526        *rows = term->rows;
     527        fibril_mutex_unlock(&term->mtx);
     528       
     529        return EOK;
     530}
     531
     532static int term_get_color_cap(con_srv_t *srv, console_caps_t *caps)
     533{
     534        (void) srv;
     535        *caps = TERM_CAPS;
     536       
     537        return EOK;
     538}
     539
     540static void term_set_style(con_srv_t *srv, console_style_t style)
     541{
     542        terminal_t *term = srv_to_terminal(srv);
     543       
    493544        fibril_mutex_lock(&term->mtx);
    494545        chargrid_set_style(term->frontbuf, style);
     
    496547}
    497548
    498 static void term_set_color(terminal_t *term, console_color_t bgcolor,
     549static void term_set_color(con_srv_t *srv, console_color_t bgcolor,
    499550    console_color_t fgcolor, console_color_attr_t attr)
    500551{
     552        terminal_t *term = srv_to_terminal(srv);
     553       
    501554        fibril_mutex_lock(&term->mtx);
    502555        chargrid_set_color(term->frontbuf, bgcolor, fgcolor, attr);
     
    504557}
    505558
    506 static void term_set_rgb_color(terminal_t *term, pixel_t bgcolor,
     559static void term_set_rgb_color(con_srv_t *srv, pixel_t bgcolor,
    507560    pixel_t fgcolor)
    508561{
     562        terminal_t *term = srv_to_terminal(srv);
     563       
    509564        fibril_mutex_lock(&term->mtx);
    510565        chargrid_set_rgb_color(term->frontbuf, bgcolor, fgcolor);
     
    512567}
    513568
    514 static void term_get_event(terminal_t *term, ipc_callid_t iid, ipc_call_t *icall)
    515 {
     569static void term_set_cursor_visibility(con_srv_t *srv, bool visible)
     570{
     571        terminal_t *term = srv_to_terminal(srv);
     572       
     573        fibril_mutex_lock(&term->mtx);
     574        chargrid_set_cursor_visibility(term->frontbuf, visible);
     575        fibril_mutex_unlock(&term->mtx);
     576       
     577        term_update(term);
     578}
     579
     580static int term_get_event(con_srv_t *srv, kbd_event_t *event)
     581{
     582        terminal_t *term = srv_to_terminal(srv);
    516583        link_t *link = prodcons_consume(&term->input_pc);
    517         kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
    518        
    519         async_answer_4(iid, EOK, event->type, event->key, event->mods, event->c);
    520         free(event);
     584        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
     585       
     586        *event = *kevent;
     587        free(kevent);
     588        return EOK;
    521589}
    522590
     
    612680       
    613681        if (atomic_postinc(&term->refcnt) == 0)
    614                 term_set_cursor_visibility(term, true);
    615        
    616         /* Accept the connection */
    617         async_answer_0(iid, EOK);
    618        
    619         while (true) {
    620                 ipc_call_t call;
    621                 ipc_callid_t callid = async_get_call(&call);
    622                
    623                 if (!IPC_GET_IMETHOD(call))
    624                         return;
    625                
    626                 switch (IPC_GET_IMETHOD(call)) {
    627                 case VFS_OUT_READ:
    628                         term_read(term, callid, &call);
    629                         break;
    630                 case VFS_OUT_WRITE:
    631                         term_write(term, callid, &call);
    632                         break;
    633                 case VFS_OUT_SYNC:
    634                         term_update(term);
    635                         async_answer_0(callid, EOK);
    636                         break;
    637                 case CONSOLE_CLEAR:
    638                         term_clear(term);
    639                         async_answer_0(callid, EOK);
    640                         break;
    641                 case CONSOLE_GOTO:
    642                         term_set_cursor(term, IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    643                         async_answer_0(callid, EOK);
    644                         break;
    645                 case CONSOLE_GET_POS:
    646                         term_get_cursor(term, callid, &call);
    647                         break;
    648                 case CONSOLE_GET_SIZE:
    649                         async_answer_2(callid, EOK, term->cols, term->rows);
    650                         break;
    651                 case CONSOLE_GET_COLOR_CAP:
    652                         async_answer_1(callid, EOK, TERM_CAPS);
    653                         break;
    654                 case CONSOLE_SET_STYLE:
    655                         term_set_style(term, IPC_GET_ARG1(call));
    656                         async_answer_0(callid, EOK);
    657                         break;
    658                 case CONSOLE_SET_COLOR:
    659                         term_set_color(term, IPC_GET_ARG1(call), IPC_GET_ARG2(call),
    660                             IPC_GET_ARG3(call));
    661                         async_answer_0(callid, EOK);
    662                         break;
    663                 case CONSOLE_SET_RGB_COLOR:
    664                         term_set_rgb_color(term, IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    665                         async_answer_0(callid, EOK);
    666                         break;
    667                 case CONSOLE_CURSOR_VISIBILITY:
    668                         term_set_cursor_visibility(term, IPC_GET_ARG1(call));
    669                         async_answer_0(callid, EOK);
    670                         break;
    671                 case CONSOLE_GET_EVENT:
    672                         term_get_event(term, callid, &call);
    673                         break;
    674                 default:
    675                         async_answer_0(callid, EINVAL);
    676                 }
    677         }
     682                chargrid_set_cursor_visibility(term->frontbuf, true);
     683       
     684        con_conn(iid, icall, &term->srvs);
    678685}
    679686
     
    727734       
    728735        async_set_client_connection(term_connection);
     736        con_srvs_init(&term->srvs);
     737        term->srvs.ops = &con_ops;
     738        term->srvs.sarg = term;
     739       
    729740        int rc = loc_server_register(NAME);
    730741        if (rc != EOK) {
  • uspace/lib/gui/terminal.h

    r131d9a4 r70253688  
    4141#include <font.h>
    4242#include <io/chargrid.h>
     43#include <io/con_srv.h>
    4344#include <adt/list.h>
    4445#include <adt/prodcons.h>
     
    6667       
    6768        service_id_t dsid;
     69        con_srvs_t srvs;
    6870} terminal_t;
    6971
  • uspace/srv/hid/compositor/compositor.c

    r131d9a4 r70253688  
    4949#include <adt/prodcons.h>
    5050#include <adt/list.h>
     51#include <io/input.h>
    5152#include <ipc/graph.h>
    52 #include <ipc/input.h>
    5353#include <ipc/window.h>
    5454
     
    9292        sysarg_t id;
    9393        uint8_t state;
    94         sysarg_t hpos;
    95         sysarg_t vpos;
     94        desktop_point_t pos;
    9695        sysarg_t btn_num;
    97         sysarg_t btn_hpos;
    98         sysarg_t btn_vpos;
    99         int accum_dx;
    100         int accum_dy;
     96        desktop_point_t btn_pos;
     97        desktop_vector_t accum;
    10198        sysarg_t grab_flags;
    10299        bool pressed;
     
    135132        vslmode_t mode;
    136133        async_sess_t *sess;
    137         sysarg_t hpos;
    138         sysarg_t vpos;
     134        desktop_point_t pos;
    139135        surface_t *surface;
    140136} viewport_t;
     
    143139static LIST_INITIALIZE(viewport_list);
    144140
    145 static async_sess_t *input_sess;
     141/** Input server proxy */
     142static input_t *input;
     143
     144static int comp_key_press(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
     145static int comp_mouse_move(input_t *, int, int);
     146static int comp_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned);
     147static int comp_mouse_button(input_t *, int, int);
     148
     149static input_ev_ops_t input_ev_ops = {
     150        .key = comp_key_press,
     151        .move = comp_mouse_move,
     152        .abs_move = comp_abs_move,
     153        .button = comp_mouse_button
     154};
     155
     156static void input_disconnect(void);
     157
     158
     159static pointer_t *input_pointer(input_t *input)
     160{
     161        return input->user;
     162}
    146163
    147164static pointer_t *pointer_create()
     
    153170
    154171        link_initialize(&p->link);
    155         p->hpos = coord_origin;
    156         p->vpos = coord_origin;
     172        p->pos.x = coord_origin;
     173        p->pos.y = coord_origin;
    157174        p->btn_num = 1;
    158         p->btn_hpos = p->hpos;
    159         p->btn_vpos = p->vpos;
    160         p->accum_dx = 0;
    161         p->accum_dy = 0;
     175        p->btn_pos = p->pos;
     176        p->accum.x = 0;
     177        p->accum.y = 0;
    162178        p->grab_flags = GF_EMPTY;
    163179        p->pressed = false;
     
    286302                bool isec_vp = rectangle_intersect(
    287303                    x_dmg_glob, y_dmg_glob, w_dmg_glob, h_dmg_glob,
    288                     vp->hpos, vp->vpos, w_dmg_vp, h_dmg_vp,
     304                    vp->pos.x, vp->pos.y, w_dmg_vp, h_dmg_vp,
    289305                    &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp);
    290306
     
    292308
    293309                        /* Paint background color. */
    294                         for (sysarg_t y = y_dmg_vp - vp->vpos; y <  y_dmg_vp - vp->vpos + h_dmg_vp; ++y) {
    295                                 for (sysarg_t x = x_dmg_vp - vp->hpos; x < x_dmg_vp - vp->hpos + w_dmg_vp; ++x) {
     310                        for (sysarg_t y = y_dmg_vp - vp->pos.y; y <  y_dmg_vp - vp->pos.y + h_dmg_vp; ++y) {
     311                                for (sysarg_t x = x_dmg_vp - vp->pos.x; x < x_dmg_vp - vp->pos.x + w_dmg_vp; ++x) {
    296312                                        surface_put_pixel(vp->surface, x, y, bg_color);
    297313                                }
     
    331347                                         * coordinates. */
    332348                                        transform = win->transform;
    333                                         double hpos = vp->hpos;
    334                                         double vpos = vp->vpos;
    335                                         transform_translate(&transform, -hpos, -vpos);
     349                                        double_point_t pos;
     350                                        pos.x = vp->pos.x;
     351                                        pos.y = vp->pos.y;
     352                                        transform_translate(&transform, -pos.x, -pos.y);
    336353
    337354                                        source_set_transform(&source, transform);                               
     
    340357
    341358                                        drawctx_transfer(&context,
    342                                             x_dmg_win - vp->hpos, y_dmg_win - vp->vpos, w_dmg_win, h_dmg_win);
     359                                            x_dmg_win - vp->pos.x, y_dmg_win - vp->pos.y, w_dmg_win, h_dmg_win);
    343360                                }
    344361                        }
     
    354371                                bool isec_ptr = rectangle_intersect(
    355372                                    x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp,
    356                                     ptr->hpos, ptr->vpos, w_dmg_ptr, h_dmg_ptr,
     373                                    ptr->pos.x, ptr->pos.y, w_dmg_ptr, h_dmg_ptr,
    357374                                    &x_dmg_ptr, &y_dmg_ptr, &w_dmg_ptr, &h_dmg_ptr);
    358375
     
    365382
    366383                                        pixel_t pix = 0;
    367                                         sysarg_t x_vp = x_dmg_ptr - vp->hpos;
    368                                         sysarg_t y_vp = y_dmg_ptr - vp->vpos;
    369                                         sysarg_t x_ptr = x_dmg_ptr - ptr->hpos;
    370                                         sysarg_t y_ptr = y_dmg_ptr - ptr->vpos;
     384                                        sysarg_t x_vp = x_dmg_ptr - vp->pos.x;
     385                                        sysarg_t y_vp = y_dmg_ptr - vp->pos.y;
     386                                        sysarg_t x_ptr = x_dmg_ptr - ptr->pos.x;
     387                                        sysarg_t y_ptr = y_dmg_ptr - ptr->pos.y;
    371388
    372389                                        for (sysarg_t y = 0; y < h_dmg_ptr; ++y) {
     
    759776                fibril_mutex_unlock(&viewport_list_mtx);
    760777                loc_service_unregister(winreg_id);
    761                 async_hangup(input_sess);
     778                input_disconnect();
    762779
    763780                /* Close all clients and their windows. */
     
    880897
    881898        link_initialize(&vp->link);
    882         vp->hpos = coord_origin;
    883         vp->vpos = coord_origin;
     899        vp->pos.x = coord_origin;
     900        vp->pos.y = coord_origin;
    884901
    885902        /* Establish output bidirectional connection. */
     
    981998        /* window_list_mtx locked by caller */
    982999
    983         int dx = pointer->accum_dx;
    984         int dy = pointer->accum_dy;
    985         pointer->accum_dx = 0;
    986         pointer->accum_dy = 0;
     1000        int dx = pointer->accum.x;
     1001        int dy = pointer->accum.y;
     1002        pointer->accum.x = 0;
     1003        pointer->accum.y = 0;
    9871004
    9881005        bool move = (pointer->grab_flags & GF_MOVE_X) || (pointer->grab_flags & GF_MOVE_Y);
     
    10551072}
    10561073
    1057 static void comp_mouse_move(pointer_t *pointer, ipc_callid_t iid, ipc_call_t *icall)
    1058 {
    1059         int dx = (int) IPC_GET_ARG1(*icall);
    1060         int dy = (int) IPC_GET_ARG2(*icall);
     1074static int comp_abs_move(input_t *input, unsigned x , unsigned y,
     1075    unsigned max_x, unsigned max_y)
     1076{
     1077        /* XXX TODO Use absolute coordinates directly */
     1078       
     1079        pointer_t *pointer = input_pointer(input);
     1080       
     1081        sysarg_t width, height;
     1082       
     1083        fibril_mutex_lock(&viewport_list_mtx);
     1084        if (list_empty(&viewport_list)) {
     1085                printf("No viewport found\n");
     1086                fibril_mutex_unlock(&viewport_list_mtx);
     1087                return EOK; /* XXX */
     1088        }
     1089        link_t *link = list_first(&viewport_list);
     1090        viewport_t *vp = list_get_instance(link, viewport_t, link);
     1091        surface_get_resolution(vp->surface, &width, &height);
     1092        desktop_point_t vp_pos = vp->pos;
     1093        fibril_mutex_unlock(&viewport_list_mtx);
     1094
     1095        desktop_point_t pos_in_viewport;
     1096        pos_in_viewport.x = x * width / max_x;
     1097        pos_in_viewport.y = y * height / max_y;
     1098       
     1099        /* Calculate offset from pointer */
     1100        fibril_mutex_lock(&pointer_list_mtx);
     1101        desktop_vector_t delta;
     1102        delta.x = (vp_pos.x + pos_in_viewport.x) - pointer->pos.x;
     1103        delta.y = (vp_pos.y + pos_in_viewport.y) - pointer->pos.y;
     1104        fibril_mutex_unlock(&pointer_list_mtx);
     1105       
     1106        return comp_mouse_move(input, delta.x, delta.y);
     1107}
     1108
     1109static int comp_mouse_move(input_t *input, int dx, int dy)
     1110{
     1111        pointer_t *pointer = input_pointer(input);
    10611112
    10621113        /* Update pointer position. */
    10631114        fibril_mutex_lock(&pointer_list_mtx);
    1064         sysarg_t old_hpos = pointer->hpos;
    1065         sysarg_t old_vpos = pointer->vpos;
     1115        desktop_point_t old_pos = pointer->pos;
    10661116        sysarg_t cursor_width;
    10671117        sysarg_t cursor_height;
    10681118        surface_get_resolution(pointer->cursor.states[pointer->state],
    10691119             &cursor_width, &cursor_height);
    1070         pointer->hpos += dx;
    1071         pointer->vpos += dy;
     1120        pointer->pos.x += dx;
     1121        pointer->pos.y += dy;
    10721122        fibril_mutex_unlock(&pointer_list_mtx);
    1073         comp_damage(old_hpos, old_vpos, cursor_width, cursor_height);
    1074         comp_damage(old_hpos + dx, old_vpos + dy, cursor_width, cursor_height);
     1123        comp_damage(old_pos.x, old_pos.y, cursor_width, cursor_height);
     1124        comp_damage(old_pos.x + dx, old_pos.y + dy, cursor_width, cursor_height);
    10751125
    10761126        fibril_mutex_lock(&window_list_mtx);
     
    10841134                        sysarg_t width, height;
    10851135                        surface_get_resolution(top->surface, &width, &height);
    1086                         within_client = comp_coord_to_client(pointer->hpos, pointer->vpos,
     1136                        within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
    10871137                            top->transform, width, height, &point_x, &point_y);
    10881138                        fibril_mutex_unlock(&window_list_mtx);
     
    11031153                } else {
    11041154                        /* Pointer is grabbed by top-level window action. */
    1105                         pointer->accum_dx += dx;
    1106                         pointer->accum_dy += dy;
     1155                        pointer->accum.x += dx;
     1156                        pointer->accum.y += dy;
    11071157#if ANIMATE_WINDOW_TRANSFORMS == 1
    11081158                        sysarg_t x, y, width, height;
     
    11181168        }
    11191169
    1120         async_answer_0(iid, EOK);
    1121 }
    1122 
    1123 static void comp_mouse_button(pointer_t *pointer, ipc_callid_t iid, ipc_call_t *icall)
    1124 {
    1125         sysarg_t btn_num = IPC_GET_ARG1(*icall);
    1126         bool pressed = (bool) IPC_GET_ARG2(*icall);
    1127 
    1128         if (pressed) {
    1129                 pointer->btn_hpos = pointer->hpos;
    1130                 pointer->btn_vpos = pointer->vpos;
    1131                 pointer->btn_num = btn_num;
     1170        return EOK;
     1171}
     1172
     1173static int comp_mouse_button(input_t *input, int bnum, int bpress)
     1174{
     1175        pointer_t *pointer = input_pointer(input);
     1176
     1177        if (bpress) {
     1178                pointer->btn_pos = pointer->pos;
     1179                pointer->btn_num = bnum;
    11321180                pointer->pressed = true;
    11331181
     
    11371185                if (!win || !win->surface) {
    11381186                        fibril_mutex_unlock(&window_list_mtx);
    1139                         async_answer_0(iid, EOK);
    1140                         return;
     1187                        return EOK;
    11411188                }
    11421189                sysarg_t x, y, width, height;
    11431190                surface_get_resolution(win->surface, &width, &height);
    1144                 bool within_client = comp_coord_to_client(pointer->hpos, pointer->vpos,
     1191                bool within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
    11451192                    win->transform, width, height, &x, &y);
    11461193                fibril_mutex_unlock(&window_list_mtx);
     
    11541201                                event->data.pos.pos_id = pointer->id;
    11551202                                event->data.pos.type = POS_PRESS;
    1156                                 event->data.pos.btn_num = btn_num;
     1203                                event->data.pos.btn_num = bnum;
    11571204                                event->data.pos.hpos = x;
    11581205                                event->data.pos.vpos = y;
    11591206                                comp_post_event(event);
    11601207                        } else {
    1161                                 async_answer_0(iid, ENOMEM);
    1162                                 return;
    1163                         }
    1164                 }
    1165         } else if (pointer->pressed && pointer->btn_num == btn_num) {
     1208                                return ENOMEM;
     1209                        }
     1210                }
     1211        } else if (pointer->pressed && pointer->btn_num == (unsigned)bnum) {
    11661212                pointer->pressed = false;
    11671213
     
    11781224                        if (win->surface) {
    11791225                                surface_get_resolution(win->surface, &width, &height);
    1180                                 within_client = comp_coord_to_client(pointer->hpos, pointer->vpos,
     1226                                within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y,
    11811227                                    win->transform, width, height, &point_x, &point_y);
    11821228                        }
     
    11911237                        pointer->grab_flags = GF_EMPTY;
    11921238                        fibril_mutex_unlock(&window_list_mtx);
    1193                         async_answer_0(iid, EOK);
    1194                         return;
     1239                        return EOK;
    11951240                }
    11961241
     
    12571302                                event->data.pos.pos_id = pointer->id;
    12581303                                event->data.pos.type = POS_RELEASE;
    1259                                 event->data.pos.btn_num = btn_num;
     1304                                event->data.pos.btn_num = bnum;
    12601305                                event->data.pos.hpos = point_x;
    12611306                                event->data.pos.vpos = point_y;
     
    12631308                        pointer->grab_flags = GF_EMPTY;
    12641309                       
    1265                 } else if (within_client && (pointer->grab_flags == GF_EMPTY) && (btn_num == 1)) {
     1310                } else if (within_client && (pointer->grab_flags == GF_EMPTY) && (bnum == 1)) {
    12661311
    12671312                        /* Bring the window to the foreground. */
     
    12861331        }
    12871332
    1288         async_answer_0(iid, EOK);
    1289 }
    1290 
    1291 static void comp_key_press(ipc_callid_t iid, ipc_call_t *icall)
    1292 {
    1293         kbd_event_type_t type = IPC_GET_ARG1(*icall);
    1294         keycode_t key = IPC_GET_ARG2(*icall);
    1295         keymod_t mods = IPC_GET_ARG3(*icall);
    1296         wchar_t c = IPC_GET_ARG4(*icall);
    1297 
     1333        return EOK;
     1334}
     1335
     1336static int comp_key_press(input_t *input, kbd_event_type_t type, keycode_t key,
     1337    keymod_t mods, wchar_t c)
     1338{
    12981339        bool win_transform = (mods & KM_ALT) && (
    12991340            key == KC_W || key == KC_S || key == KC_A || key == KC_D ||
     
    13781419                        if (event == NULL) {
    13791420                                fibril_mutex_unlock(&window_list_mtx);
    1380                                 async_answer_0(iid, ENOMEM);
    1381                                 return;
     1421                                return ENOMEM;
    13821422                        }
    13831423
     
    14481488        } else if (win_close) {
    14491489                window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
    1450                 if (event == NULL) {
    1451                         async_answer_0(iid, ENOMEM);
    1452                         return;
    1453                 }
     1490                if (event == NULL)
     1491                        return ENOMEM;
    14541492
    14551493                link_initialize(&event->link);
     
    15021540                        switch (key) {
    15031541                        case KC_I:
    1504                                 vp->hpos += 0;
    1505                                 vp->vpos += -20;
     1542                                vp->pos.x += 0;
     1543                                vp->pos.y += -20;
    15061544                                break;
    15071545                        case KC_K:
    1508                                 vp->hpos += 0;
    1509                                 vp->vpos += 20;
     1546                                vp->pos.x += 0;
     1547                                vp->pos.y += 20;
    15101548                                break;
    15111549                        case KC_J:
    1512                                 vp->hpos += -20;
    1513                                 vp->vpos += 0;
     1550                                vp->pos.x += -20;
     1551                                vp->pos.y += 0;
    15141552                                break;
    15151553                        case KC_L:
    1516                                 vp->hpos += 20;
    1517                                 vp->vpos += 0;
     1554                                vp->pos.x += 20;
     1555                                vp->pos.y += 0;
    15181556                                break;
    15191557                        default:
    1520                                 vp->hpos += 0;
    1521                                 vp->vpos += 0;
     1558                                vp->pos.x += 0;
     1559                                vp->pos.y += 0;
    15221560                                break;
    15231561                        }
    15241562                       
    1525                         sysarg_t x = vp->hpos;
    1526                         sysarg_t y = vp->vpos;
     1563                        sysarg_t x = vp->pos.x;
     1564                        sysarg_t y = vp->pos.y;
    15271565                        sysarg_t width, height;
    15281566                        surface_get_resolution(vp->surface, &width, &height);
     
    15941632        } else {
    15951633                window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
    1596                 if (event == NULL) {
    1597                         async_answer_0(iid, ENOMEM);
    1598                         return;
    1599                 }
     1634                if (event == NULL)
     1635                        return ENOMEM;
    16001636
    16011637                link_initialize(&event->link);
     
    16091645        }
    16101646
    1611         async_answer_0(iid, EOK);
    1612 }
    1613 
    1614 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    1615 {
     1647        return EOK;
     1648}
     1649
     1650static int input_connect(const char *svc)
     1651{
     1652        async_sess_t *sess;
     1653        service_id_t dsid;
     1654
     1655        int rc = loc_service_get_id(svc, &dsid, 0);
     1656        if (rc != EOK) {
     1657                printf("%s: Input service %s not found\n", NAME, svc);
     1658                return rc;
     1659        }
     1660
     1661        sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
     1662        if (sess == NULL) {
     1663                printf("%s: Unable to connect to input service %s\n", NAME,
     1664                    svc);
     1665                return EIO;
     1666        }
     1667
    16161668        fibril_mutex_lock(&pointer_list_mtx);
    16171669        pointer_t *pointer = pointer_create();
     
    16221674        fibril_mutex_unlock(&pointer_list_mtx);
    16231675
    1624         /* Ignore parameters, the connection is already opened. */
    1625         while (true) {
    1626                 ipc_call_t call;
    1627                 ipc_callid_t callid = async_get_call(&call);
    1628 
    1629                 if (!IPC_GET_IMETHOD(call)) {
    1630                         fibril_mutex_lock(&pointer_list_mtx);
    1631                         if (pointer != NULL) {
    1632                                 list_remove(&pointer->link);
    1633                                 pointer_destroy(pointer);
    1634                         }
    1635                         fibril_mutex_unlock(&pointer_list_mtx);
    1636                         async_hangup(input_sess);
    1637                         return;
    1638                 }
    1639 
    1640                 switch (IPC_GET_IMETHOD(call)) {
    1641                 case INPUT_EVENT_KEY:
    1642                         comp_key_press(callid, &call);
    1643                         break;
    1644                 case INPUT_EVENT_MOVE:
    1645                         comp_mouse_move(pointer, callid, &call);
    1646                         break;
    1647                 case INPUT_EVENT_BUTTON:
    1648                         comp_mouse_button(pointer, callid, &call);
    1649                         break;
    1650                 default:
    1651                         async_answer_0(callid, EINVAL);
    1652                 }
    1653         }
    1654 }
    1655 
    1656 static async_sess_t *input_connect(const char *svc)
    1657 {
    1658         async_sess_t *sess;
    1659         service_id_t dsid;
    1660 
    1661         int rc = loc_service_get_id(svc, &dsid, 0);
    1662         if (rc == EOK) {
    1663                 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
    1664                 if (sess == NULL) {
    1665                         printf("%s: Unable to connect to input service %s\n", NAME, svc);
    1666                         return NULL;
    1667                 }
    1668         } else
    1669                 return NULL;
    1670 
    1671         async_exch_t *exch = async_exchange_begin(sess);
    1672         rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL);
    1673         async_exchange_end(exch);
    1674 
     1676        if (pointer == NULL) {
     1677                printf("%s: Cannot create pointer.\n", NAME);
     1678                async_hangup(sess);
     1679                return ENOMEM;
     1680        }
     1681
     1682        rc = input_open(sess, &input_ev_ops, pointer, &input);
    16751683        if (rc != EOK) {
    16761684                async_hangup(sess);
    1677                 printf("%s: Unable to create callback connection to service %s (%s)\n",
     1685                printf("%s: Unable to communicate with service %s (%s)\n",
    16781686                    NAME, svc, str_error(rc));
    1679                 return NULL;
    1680         }
    1681 
    1682         return sess;
     1687                return rc;
     1688        }
     1689
     1690        return EOK;
     1691}
     1692
     1693static void input_disconnect(void)
     1694{
     1695        pointer_t *pointer = input->user;
     1696        input_close(input);
     1697        pointer_destroy(pointer);
    16831698}
    16841699
     
    17331748
    17341749        /* Establish input bidirectional connection. */
    1735         input_sess = input_connect(input_svc);
    1736         if (input_sess == NULL) {
    1737                 return -1;
    1738         }
     1750        rc = input_connect(input_svc);
     1751        if (rc != EOK)
     1752                return rc;
    17391753
    17401754        /* Create viewports and connect them to visualizers. */
     
    17421756        rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING);
    17431757        if (rc != EOK) {
    1744                 async_hangup(input_sess);
     1758                input_disconnect();
    17451759                return -1;
    17461760        }
     
    17501764        rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt);
    17511765        if (rc != EOK || svcs_cnt == 0) {
    1752                 async_hangup(input_sess);
     1766                input_disconnect();
    17531767                return -1;
    17541768        }
     
    17661780       
    17671781        if (list_empty(&viewport_list)) {
    1768                 async_hangup(input_sess);
     1782                input_disconnect();
    17691783                return -1;
    17701784        }
  • uspace/srv/hid/compositor/compositor.h

    r131d9a4 r70253688  
    3636#define COMPOSITOR_COMPOSITOR_H_
    3737
     38typedef native_t desktop_coord_t;
     39typedef struct {
     40        desktop_coord_t x;
     41        desktop_coord_t y;
     42} desktop_point_t;
     43typedef desktop_point_t desktop_vector_t;
     44
     45/* TODO remove? */
     46typedef struct {
     47        double x;
     48        double y;
     49} double_point_t;
     50typedef double_point_t double_vector_t;
     51
    3852#endif
    3953
  • uspace/srv/hid/console/console.c

    r131d9a4 r70253688  
    3636#include <stdio.h>
    3737#include <adt/prodcons.h>
    38 #include <ipc/input.h>
    39 #include <ipc/console.h>
     38#include <io/input.h>
    4039#include <ipc/vfs.h>
    4140#include <errno.h>
     
    4342#include <loc.h>
    4443#include <event.h>
     44#include <io/con_srv.h>
     45#include <io/kbd_event.h>
    4546#include <io/keycode.h>
    4647#include <io/chargrid.h>
    47 #include <io/console.h>
    4848#include <io/output.h>
    4949#include <align.h>
     
    7979        chargrid_t *frontbuf;    /**< Front buffer */
    8080        frontbuf_handle_t fbid;  /**< Front buffer handle */
     81        con_srvs_t srvs;         /**< Console service setup */
    8182} console_t;
    8283
    83 /** Session to the input server */
    84 static async_sess_t *input_sess;
     84/** Input server proxy */
     85static input_t *input;
    8586
    8687/** Session to the output server */
     
    101102static console_t *kernel_console = &consoles[KERNEL_CONSOLE];
    102103
     104static int input_ev_key(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
     105static int input_ev_move(input_t *, int, int);
     106static int input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned);
     107static int input_ev_button(input_t *, int, int);
     108
     109static input_ev_ops_t input_ev_ops = {
     110        .key = input_ev_key,
     111        .move = input_ev_move,
     112        .abs_move = input_ev_abs_move,
     113        .button = input_ev_button
     114};
     115
     116static int cons_open(con_srvs_t *, con_srv_t *);
     117static int cons_close(con_srv_t *);
     118static int cons_read(con_srv_t *, void *, size_t);
     119static int cons_write(con_srv_t *, void *, size_t);
     120static void cons_sync(con_srv_t *);
     121static void cons_clear(con_srv_t *);
     122static void cons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row);
     123static int cons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *);
     124static int cons_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
     125static int cons_get_color_cap(con_srv_t *, console_caps_t *);
     126static void cons_set_style(con_srv_t *, console_style_t);
     127static void cons_set_color(con_srv_t *, console_color_t, console_color_t,
     128    console_color_attr_t);
     129static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
     130static void cons_set_cursor_visibility(con_srv_t *, bool);
     131static int cons_get_event(con_srv_t *, kbd_event_t *);
     132
     133static con_ops_t con_ops = {
     134        .open = cons_open,
     135        .close = cons_close,
     136        .read = cons_read,
     137        .write = cons_write,
     138        .sync = cons_sync,
     139        .clear = cons_clear,
     140        .set_pos = cons_set_pos,
     141        .get_pos = cons_get_pos,
     142        .get_size = cons_get_size,
     143        .get_color_cap = cons_get_color_cap,
     144        .set_style = cons_set_style,
     145        .set_color = cons_set_color,
     146        .set_rgb_color = cons_set_rgb_color,
     147        .set_cursor_visibility = cons_set_cursor_visibility,
     148        .get_event = cons_get_event
     149};
     150
     151static console_t *srv_to_console(con_srv_t *srv)
     152{
     153        return srv->srvs->sarg;
     154}
     155
    103156static void cons_update(console_t *cons)
    104157{
     
    125178        fibril_mutex_unlock(&cons->mtx);
    126179        fibril_mutex_unlock(&switch_mtx);
    127 }
    128 
    129 static void cons_clear(console_t *cons)
    130 {
    131         fibril_mutex_lock(&cons->mtx);
    132         chargrid_clear(cons->frontbuf);
    133         fibril_mutex_unlock(&cons->mtx);
    134        
    135         cons_update(cons);
    136180}
    137181
     
    195239}
    196240
    197 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    198 {
    199         /* Ignore parameters, the connection is already opened */
    200         while (true) {
    201                 ipc_call_t call;
    202                 ipc_callid_t callid = async_get_call(&call);
    203                
    204                 if (!IPC_GET_IMETHOD(call)) {
    205                         /* TODO: Handle hangup */
    206                         async_hangup(input_sess);
    207                         return;
    208                 }
    209                
    210                 kbd_event_type_t type;
    211                 keycode_t key;
    212                 keymod_t mods;
    213                 wchar_t c;
    214                
    215                 switch (IPC_GET_IMETHOD(call)) {
    216                 case INPUT_EVENT_KEY:
    217                         type = IPC_GET_ARG1(call);
    218                         key = IPC_GET_ARG2(call);
    219                         mods = IPC_GET_ARG3(call);
    220                         c = IPC_GET_ARG4(call);
    221                        
    222                         if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) &&
    223                             ((mods & KM_CTRL) == 0))
    224                                 cons_switch(&consoles[key - KC_F1]);
    225                         else {
    226                                 /* Got key press/release event */
    227                                 kbd_event_t *event =
    228                                     (kbd_event_t *) malloc(sizeof(kbd_event_t));
    229                                 if (event == NULL) {
    230                                         async_answer_0(callid, ENOMEM);
    231                                         break;
    232                                 }
    233                                
    234                                 link_initialize(&event->link);
    235                                 event->type = type;
    236                                 event->key = key;
    237                                 event->mods = mods;
    238                                 event->c = c;
    239                                
    240                                 /*
    241                                  * Kernel console does not read events
    242                                  * from us, so we will redirect them
    243                                  * to the (last) active userspace console
    244                                  * if necessary.
    245                                  */
    246                                 console_t *target_console = cons_get_active_uspace();
    247                                
    248                                 prodcons_produce(&target_console->input_pc,
    249                                     &event->link);
    250                         }
    251                        
    252                         async_answer_0(callid, EOK);
    253                         break;
    254                 case INPUT_EVENT_MOVE:
    255                         async_answer_0(callid, EOK);
    256                         break;
    257                 case INPUT_EVENT_BUTTON:
    258                         async_answer_0(callid, EOK);
    259                         break;
    260                 default:
    261                         async_answer_0(callid, EINVAL);
    262                 }
    263         }
     241static int input_ev_key(input_t *input, kbd_event_type_t type, keycode_t key,
     242    keymod_t mods, wchar_t c)
     243{
     244        if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) &&
     245            ((mods & KM_CTRL) == 0)) {
     246                cons_switch(&consoles[key - KC_F1]);
     247        } else {
     248                /* Got key press/release event */
     249                kbd_event_t *event =
     250                    (kbd_event_t *) malloc(sizeof(kbd_event_t));
     251                if (event == NULL) {
     252                        return ENOMEM;
     253                }
     254               
     255                link_initialize(&event->link);
     256                event->type = type;
     257                event->key = key;
     258                event->mods = mods;
     259                event->c = c;
     260               
     261                /*
     262                 * Kernel console does not read events
     263                 * from us, so we will redirect them
     264                 * to the (last) active userspace console
     265                 * if necessary.
     266                 */
     267                console_t *target_console = cons_get_active_uspace();
     268               
     269                prodcons_produce(&target_console->input_pc,
     270                    &event->link);
     271        }
     272       
     273        return EOK;
     274}
     275
     276static int input_ev_move(input_t *input, int dx, int dy)
     277{
     278        return EOK;
     279}
     280
     281static int input_ev_abs_move(input_t *input, unsigned x , unsigned y,
     282    unsigned max_x, unsigned max_y)
     283{
     284        return EOK;
     285}
     286
     287static int input_ev_button(input_t *input, int bnum, int bpress)
     288{
     289        return EOK;
    264290}
    265291
     
    293319}
    294320
    295 static void cons_set_cursor(console_t *cons, sysarg_t col, sysarg_t row)
    296 {
    297         fibril_mutex_lock(&cons->mtx);
    298         chargrid_set_cursor(cons->frontbuf, col, row);
     321static void cons_set_cursor_vis(console_t *cons, bool visible)
     322{
     323        fibril_mutex_lock(&cons->mtx);
     324        chargrid_set_cursor_visibility(cons->frontbuf, visible);
    299325        fibril_mutex_unlock(&cons->mtx);
    300326       
     
    302328}
    303329
    304 static void cons_set_cursor_visibility(console_t *cons, bool visible)
    305 {
    306         fibril_mutex_lock(&cons->mtx);
    307         chargrid_set_cursor_visibility(cons->frontbuf, visible);
    308         fibril_mutex_unlock(&cons->mtx);
    309        
    310         cons_update_cursor(cons);
    311 }
    312 
    313 static void cons_get_cursor(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    314 {
    315         sysarg_t col;
    316         sysarg_t row;
    317        
    318         fibril_mutex_lock(&cons->mtx);
    319         chargrid_get_cursor(cons->frontbuf, &col, &row);
    320         fibril_mutex_unlock(&cons->mtx);
    321        
    322         async_answer_2(iid, EOK, col, row);
    323 }
    324 
    325 static void cons_write(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    326 {
    327         void *buf;
    328         size_t size;
    329         int rc = async_data_write_accept(&buf, false, 0, 0, 0, &size);
    330        
    331         if (rc != EOK) {
    332                 async_answer_0(iid, rc);
    333                 return;
    334         }
    335        
    336         size_t off = 0;
    337         while (off < size)
    338                 cons_write_char(cons, str_decode(buf, &off, size));
    339        
    340         async_answer_1(iid, EOK, size);
    341         free(buf);
    342 }
    343 
    344 static void cons_read(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    345 {
    346         ipc_callid_t callid;
    347         size_t size;
    348         if (!async_data_read_receive(&callid, &size)) {
    349                 async_answer_0(callid, EINVAL);
    350                 async_answer_0(iid, EINVAL);
    351                 return;
    352         }
    353        
    354         char *buf = (char *) malloc(size);
    355         if (buf == NULL) {
    356                 async_answer_0(callid, ENOMEM);
    357                 async_answer_0(iid, ENOMEM);
    358                 return;
    359         }
    360        
     330static int cons_open(con_srvs_t *srvs, con_srv_t *srv)
     331{
     332        return EOK;
     333}
     334
     335static int cons_close(con_srv_t *srv)
     336{
     337        return EOK;
     338}
     339
     340static int cons_read(con_srv_t *srv, void *buf, size_t size)
     341{
     342        uint8_t *bbuf = buf;
     343        console_t *cons = srv_to_console(srv);
    361344        size_t pos = 0;
    362345       
     
    369352                /* Copy to the buffer remaining characters. */
    370353                while ((pos < size) && (cons->char_remains_len > 0)) {
    371                         buf[pos] = cons->char_remains[0];
     354                        bbuf[pos] = cons->char_remains[0];
    372355                        pos++;
    373356                       
     
    394377                }
    395378        }
    396        
    397         (void) async_data_read_finalize(callid, buf, size);
    398         async_answer_1(iid, EOK, size);
    399         free(buf);
    400 }
    401 
    402 static void cons_set_style(console_t *cons, console_style_t style)
    403 {
     379
     380        return size;
     381}
     382
     383static int cons_write(con_srv_t *srv, void *data, size_t size)
     384{
     385        console_t *cons = srv_to_console(srv);
     386
     387        size_t off = 0;
     388        while (off < size)
     389                cons_write_char(cons, str_decode(data, &off, size));
     390        return size;
     391}
     392
     393static void cons_sync(con_srv_t *srv)
     394{
     395        console_t *cons = srv_to_console(srv);
     396       
     397        cons_update(cons);
     398}
     399
     400static void cons_clear(con_srv_t *srv)
     401{
     402        console_t *cons = srv_to_console(srv);
     403       
     404        fibril_mutex_lock(&cons->mtx);
     405        chargrid_clear(cons->frontbuf);
     406        fibril_mutex_unlock(&cons->mtx);
     407       
     408        cons_update(cons);
     409}
     410
     411static void cons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row)
     412{
     413        console_t *cons = srv_to_console(srv);
     414       
     415        fibril_mutex_lock(&cons->mtx);
     416        chargrid_set_cursor(cons->frontbuf, col, row);
     417        fibril_mutex_unlock(&cons->mtx);
     418       
     419        cons_update_cursor(cons);
     420}
     421
     422static int cons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row)
     423{
     424        console_t *cons = srv_to_console(srv);
     425       
     426        fibril_mutex_lock(&cons->mtx);
     427        chargrid_get_cursor(cons->frontbuf, col, row);
     428        fibril_mutex_unlock(&cons->mtx);
     429       
     430        return EOK;
     431}
     432
     433static int cons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows)
     434{
     435        console_t *cons = srv_to_console(srv);
     436       
     437        fibril_mutex_lock(&cons->mtx);
     438        *cols = cons->cols;
     439        *rows = cons->rows;
     440        fibril_mutex_unlock(&cons->mtx);
     441       
     442        return EOK;
     443}
     444
     445static int cons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps)
     446{
     447        console_t *cons = srv_to_console(srv);
     448       
     449        fibril_mutex_lock(&cons->mtx);
     450        *ccaps = cons->ccaps;
     451        fibril_mutex_unlock(&cons->mtx);
     452       
     453        return EOK;
     454}
     455
     456static void cons_set_style(con_srv_t *srv, console_style_t style)
     457{
     458        console_t *cons = srv_to_console(srv);
     459       
    404460        fibril_mutex_lock(&cons->mtx);
    405461        chargrid_set_style(cons->frontbuf, style);
     
    407463}
    408464
    409 static void cons_set_color(console_t *cons, console_color_t bgcolor,
     465static void cons_set_color(con_srv_t *srv, console_color_t bgcolor,
    410466    console_color_t fgcolor, console_color_attr_t attr)
    411467{
     468        console_t *cons = srv_to_console(srv);
     469       
    412470        fibril_mutex_lock(&cons->mtx);
    413471        chargrid_set_color(cons->frontbuf, bgcolor, fgcolor, attr);
     
    415473}
    416474
    417 static void cons_set_rgb_color(console_t *cons, pixel_t bgcolor,
     475static void cons_set_rgb_color(con_srv_t *srv, pixel_t bgcolor,
    418476    pixel_t fgcolor)
    419477{
     478        console_t *cons = srv_to_console(srv);
     479       
    420480        fibril_mutex_lock(&cons->mtx);
    421481        chargrid_set_rgb_color(cons->frontbuf, bgcolor, fgcolor);
     
    423483}
    424484
    425 static void cons_get_event(console_t *cons, ipc_callid_t iid, ipc_call_t *icall)
    426 {
     485static void cons_set_cursor_visibility(con_srv_t *srv, bool visible)
     486{
     487        console_t *cons = srv_to_console(srv);
     488       
     489        cons_set_cursor_vis(cons, visible);
     490}
     491
     492static int cons_get_event(con_srv_t *srv, kbd_event_t *event)
     493{
     494        console_t *cons = srv_to_console(srv);
    427495        link_t *link = prodcons_consume(&cons->input_pc);
    428         kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
    429        
    430         async_answer_4(iid, EOK, event->type, event->key, event->mods, event->c);
    431         free(event);
     496        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
     497       
     498        *event = *kevent;
     499        free(kevent);
     500        return EOK;
    432501}
    433502
     
    452521       
    453522        if (atomic_postinc(&cons->refcnt) == 0)
    454                 cons_set_cursor_visibility(cons, true);
    455        
    456         /* Accept the connection */
    457         async_answer_0(iid, EOK);
    458        
    459         while (true) {
    460                 ipc_call_t call;
    461                 ipc_callid_t callid = async_get_call(&call);
    462                
    463                 if (!IPC_GET_IMETHOD(call))
    464                         return;
    465                
    466                 switch (IPC_GET_IMETHOD(call)) {
    467                 case VFS_OUT_READ:
    468                         cons_read(cons, callid, &call);
    469                         break;
    470                 case VFS_OUT_WRITE:
    471                         cons_write(cons, callid, &call);
    472                         break;
    473                 case VFS_OUT_SYNC:
    474                         cons_update(cons);
    475                         async_answer_0(callid, EOK);
    476                         break;
    477                 case CONSOLE_CLEAR:
    478                         cons_clear(cons);
    479                         async_answer_0(callid, EOK);
    480                         break;
    481                 case CONSOLE_GOTO:
    482                         cons_set_cursor(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    483                         async_answer_0(callid, EOK);
    484                         break;
    485                 case CONSOLE_GET_POS:
    486                         cons_get_cursor(cons, callid, &call);
    487                         break;
    488                 case CONSOLE_GET_SIZE:
    489                         async_answer_2(callid, EOK, cons->cols, cons->rows);
    490                         break;
    491                 case CONSOLE_GET_COLOR_CAP:
    492                         async_answer_1(callid, EOK, cons->ccaps);
    493                         break;
    494                 case CONSOLE_SET_STYLE:
    495                         cons_set_style(cons, IPC_GET_ARG1(call));
    496                         async_answer_0(callid, EOK);
    497                         break;
    498                 case CONSOLE_SET_COLOR:
    499                         cons_set_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call),
    500                             IPC_GET_ARG3(call));
    501                         async_answer_0(callid, EOK);
    502                         break;
    503                 case CONSOLE_SET_RGB_COLOR:
    504                         cons_set_rgb_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    505                         async_answer_0(callid, EOK);
    506                         break;
    507                 case CONSOLE_CURSOR_VISIBILITY:
    508                         cons_set_cursor_visibility(cons, IPC_GET_ARG1(call));
    509                         async_answer_0(callid, EOK);
    510                         break;
    511                 case CONSOLE_GET_EVENT:
    512                         cons_get_event(cons, callid, &call);
    513                         break;
    514                 default:
    515                         async_answer_0(callid, EINVAL);
    516                 }
    517         }
    518 }
    519 
    520 static async_sess_t *input_connect(const char *svc)
     523                cons_set_cursor_vis(cons, true);
     524       
     525        con_conn(iid, icall, &cons->srvs);
     526}
     527
     528
     529static int input_connect(const char *svc)
    521530{
    522531        async_sess_t *sess;
     
    524533       
    525534        int rc = loc_service_get_id(svc, &dsid, 0);
    526         if (rc == EOK) {
    527                 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
    528                 if (sess == NULL) {
    529                         printf("%s: Unable to connect to input service %s\n", NAME,
    530                             svc);
    531                         return NULL;
    532                 }
    533         } else
    534                 return NULL;
    535        
    536         async_exch_t *exch = async_exchange_begin(sess);
    537         rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL);
    538         async_exchange_end(exch);
    539        
     535        if (rc != EOK) {
     536                printf("%s: Input service %s not found\n", NAME, svc);
     537                return rc;
     538        }
     539
     540        sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0);
     541        if (sess == NULL) {
     542                printf("%s: Unable to connect to input service %s\n", NAME,
     543                    svc);
     544                return EIO;
     545        }
     546       
     547        rc = input_open(sess, &input_ev_ops, NULL, &input);
    540548        if (rc != EOK) {
    541549                async_hangup(sess);
    542                 printf("%s: Unable to create callback connection to service %s (%s)\n",
     550                printf("%s: Unable to communicate with service %s (%s)\n",
    543551                    NAME, svc, str_error(rc));
    544                 return NULL;
    545         }
    546        
    547         return sess;
     552                return rc;
     553        }
     554       
     555        return EOK;
    548556}
    549557
     
    574582static bool console_srv_init(char *input_svc, char *output_svc)
    575583{
     584        int rc;
     585       
    576586        /* Connect to input service */
    577         input_sess = input_connect(input_svc);
    578         if (input_sess == NULL)
     587        rc = input_connect(input_svc);
     588        if (rc != EOK)
    579589                return false;
    580590       
     
    586596        /* Register server */
    587597        async_set_client_connection(client_connection);
    588         int rc = loc_server_register(NAME);
     598        rc = loc_server_register(NAME);
    589599        if (rc != EOK) {
    590600                printf("%s: Unable to register server (%s)\n", NAME,
     
    628638                }
    629639               
     640                con_srvs_init(&consoles[i].srvs);
     641                consoles[i].srvs.ops = &con_ops;
     642                consoles[i].srvs.sarg = &consoles[i];
     643               
    630644                char vc[LOC_NAME_MAXLEN + 1];
    631645                snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
  • uspace/srv/hid/remcons/remcons.c

    r131d9a4 r70253688  
    3434
    3535#include <async.h>
     36#include <errno.h>
     37#include <io/con_srv.h>
    3638#include <stdio.h>
    37 #include <adt/prodcons.h>
    38 #include <ipc/input.h>
    39 #include <ipc/console.h>
    40 #include <ipc/vfs.h>
    41 #include <errno.h>
     39#include <stdlib.h>
    4240#include <str_error.h>
    4341#include <loc.h>
     
    4543#include <io/keycode.h>
    4644#include <align.h>
    47 #include <malloc.h>
    48 #include <as.h>
    4945#include <fibril_synch.h>
    5046#include <task.h>
     
    7571    sizeof(telnet_force_character_mode_command) / sizeof(telnet_cmd_t);
    7672
    77 
    78 /** Handling client requests (VFS and console interface).
    79  *
    80  * @param user Telnet user the requests belong to.
    81  */
    82 static void client_connection_message_loop(telnet_user_t *user)
    83 {
    84         while (true) {
    85                 ipc_call_t call;
    86                 ipc_callid_t callid = 0;
    87 
    88                 /*
    89                  * The getterm task might terminate while we are here,
    90                  * waiting for a call. Also, the socket might be closed
    91                  * meanwhile.
    92                  * We want to detect this situation early, so we use a
    93                  * timeout variant of async_get_call().
    94                  */
    95                 while (callid == 0) {
    96                         callid = async_get_call_timeout(&call, 1000);
    97 
    98                         if (telnet_user_is_zombie(user)) {
    99                                 if (callid != 0) {
    100                                         async_answer_0(callid, EINTR);
    101                                 }
    102                                 return;
    103                         }
    104                 }
    105                
    106                 if (!IPC_GET_IMETHOD(call)) {
    107                         return;
    108                 }
    109 
    110                 switch (IPC_GET_IMETHOD(call)) {
    111                 case CONSOLE_GET_SIZE:
    112                         async_answer_2(callid, EOK, 100, 1);
    113                         break;
    114                 case CONSOLE_GET_POS:
    115                         fibril_mutex_lock(&user->guard);
    116                         async_answer_2(callid, EOK, user->cursor_x, 0);
    117                         fibril_mutex_unlock(&user->guard);
    118                         break;
    119                 case CONSOLE_GET_EVENT: {
    120                         kbd_event_t event;
    121                         int rc = telnet_user_get_next_keyboard_event(user, &event);
    122                         if (rc != EOK) {
    123                                 /* Silently ignore. */
    124                                 async_answer_0(callid, EOK);
    125                                 break;
    126                         }
    127                         async_answer_4(callid, EOK, event.type, event.key, event.mods, event.c);
    128                         break;
    129                 }
    130                 case CONSOLE_GOTO: {
    131                         int new_x = IPC_GET_ARG1(call);
    132                         telnet_user_update_cursor_x(user, new_x);
    133                         async_answer_0(callid, ENOTSUP);
    134                         break;
    135                 }
    136                 case VFS_OUT_READ:
    137                         async_answer_0(callid, ENOTSUP);
    138                         break;
    139                 case VFS_OUT_WRITE: {
    140                         uint8_t *buf;
    141                         size_t size;
    142                         int rc = async_data_write_accept((void **)&buf, false, 0, 0, 0, &size);
    143 
    144                         if (rc != EOK) {
    145                                 async_answer_0(callid, rc);
    146                                 break;
    147                         }
    148 
    149                         rc = telnet_user_send_data(user, buf, size);
    150                         free(buf);
    151 
    152                         if (rc != EOK) {
    153                                 async_answer_0(callid, rc);
    154                                 break;
    155                         }
    156 
    157                         async_answer_1(callid, EOK, size);
    158                         break;
    159                 }
    160                 case VFS_OUT_SYNC:
    161                         async_answer_0(callid, EOK);
    162                         break;
    163                 case CONSOLE_CLEAR:
    164                         async_answer_0(callid, EOK);
    165                         break;
    166 
    167                 case CONSOLE_GET_COLOR_CAP:
    168                         async_answer_1(callid, EOK, CONSOLE_CAP_NONE);
    169                         break;
    170                 case CONSOLE_SET_STYLE:
    171                         async_answer_0(callid, ENOTSUP);
    172                         break;
    173                 case CONSOLE_SET_COLOR:
    174                         async_answer_0(callid, ENOTSUP);
    175                         break;
    176                 case CONSOLE_SET_RGB_COLOR:
    177                         async_answer_0(callid, ENOTSUP);
    178                         break;
    179 
    180                 case CONSOLE_CURSOR_VISIBILITY:
    181                         async_answer_0(callid, ENOTSUP);
    182                         break;
    183 
    184                 default:
    185                         async_answer_0(callid, EINVAL);
    186                         break;
    187                 }
    188         }
     73static int remcons_open(con_srvs_t *, con_srv_t *);
     74static int remcons_close(con_srv_t *);
     75static int remcons_write(con_srv_t *, void *, size_t);
     76static void remcons_sync(con_srv_t *);
     77static void remcons_clear(con_srv_t *);
     78static void remcons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row);
     79static int remcons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *);
     80static int remcons_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
     81static int remcons_get_color_cap(con_srv_t *, console_caps_t *);
     82static int remcons_get_event(con_srv_t *, kbd_event_t *);
     83
     84static con_ops_t con_ops = {
     85        .open = remcons_open,
     86        .close = remcons_close,
     87        .read = NULL,
     88        .write = remcons_write,
     89        .sync = remcons_sync,
     90        .clear = remcons_clear,
     91        .set_pos = remcons_set_pos,
     92        .get_pos = remcons_get_pos,
     93        .get_size = remcons_get_size,
     94        .get_color_cap = remcons_get_color_cap,
     95        .set_style = NULL,
     96        .set_color = NULL,
     97        .set_rgb_color = NULL,
     98        .set_cursor_visibility = NULL,
     99        .get_event = remcons_get_event
     100};
     101
     102static telnet_user_t *srv_to_user(con_srv_t *srv)
     103{
     104        return srv->srvs->sarg;
     105}
     106
     107static int remcons_open(con_srvs_t *srvs, con_srv_t *srv)
     108{
     109        telnet_user_t *user = srv_to_user(srv);
     110
     111        telnet_user_log(user, "New client connected (%p).", srv);
     112
     113        /* Force character mode. */
     114        send(user->socket, (void *)telnet_force_character_mode_command,
     115            telnet_force_character_mode_command_count, 0);
     116
     117        return EOK;
     118}
     119
     120static int remcons_close(con_srv_t *srv)
     121{
     122        telnet_user_t *user = srv_to_user(srv);
     123
     124        telnet_user_notify_client_disconnected(user);
     125        telnet_user_log(user, "Client disconnected (%p).", srv);
     126
     127        return EOK;
     128}
     129
     130static int remcons_write(con_srv_t *srv, void *data, size_t size)
     131{
     132        telnet_user_t *user = srv_to_user(srv);
     133        int rc;
     134
     135        rc = telnet_user_send_data(user, data, size);
     136        if (rc != EOK)
     137                return rc;
     138
     139        return size;
     140}
     141
     142static void remcons_sync(con_srv_t *srv)
     143{
     144        (void) srv;
     145}
     146
     147static void remcons_clear(con_srv_t *srv)
     148{
     149        (void) srv;
     150}
     151
     152static void remcons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row)
     153{
     154        telnet_user_t *user = srv_to_user(srv);
     155
     156        telnet_user_update_cursor_x(user, col);
     157}
     158
     159static int remcons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row)
     160{
     161        telnet_user_t *user = srv_to_user(srv);
     162
     163        *col = user->cursor_x;
     164        *row = 0;
     165
     166        return EOK;
     167}
     168
     169static int remcons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows)
     170{
     171        (void) srv;
     172
     173        *cols = 100;
     174        *rows = 1;
     175
     176        return EOK;
     177}
     178
     179static int remcons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps)
     180{
     181        (void) srv;
     182        *ccaps = CONSOLE_CAP_NONE;
     183
     184        return EOK;
     185}
     186
     187static int remcons_get_event(con_srv_t *srv, kbd_event_t *event)
     188{
     189        telnet_user_t *user = srv_to_user(srv);
     190        int rc;
     191
     192        rc = telnet_user_get_next_keyboard_event(user, event);
     193        if (rc != EOK) {
     194                /* XXX What? */
     195                memset(event, 0, sizeof(*event));
     196                return EOK;
     197        }
     198
     199        return EOK;
    189200}
    190201
     
    198209                return;
    199210        }
    200         async_answer_0(iid, EOK);
    201 
    202         telnet_user_log(user, "New client connected (%" PRIxn").", iid);
    203 
    204         /* Force character mode. */
    205         send(user->socket, (void *)telnet_force_character_mode_command,
    206             telnet_force_character_mode_command_count, 0);
    207211
    208212        /* Handle messages. */
    209         client_connection_message_loop(user);
    210 
    211         telnet_user_notify_client_disconnected(user);
    212         telnet_user_log(user, "Client disconnected (%" PRIxn").", iid);
     213        con_conn(iid, icall, &user->srvs);
    213214}
    214215
     
    232233                fibril_mutex_lock(&user->guard);
    233234                user->task_finished = true;
     235                user->srvs.aborted = true;
    234236                fibril_condvar_signal(&user->refcount_cv);
    235237                fibril_mutex_unlock(&user->guard);
     
    251253        fibril_mutex_lock(&user->guard);
    252254        user->task_finished = true;
     255        user->srvs.aborted = true;
    253256        fibril_condvar_signal(&user->refcount_cv);
    254257        fibril_mutex_unlock(&user->guard);
     
    295298                        closesocket(user->socket);
    296299                        user->socket_closed = true;
     300                        user->srvs.aborted = true;
    297301                        continue;
    298302                } else if (user->socket_closed) {
     
    380384                assert(user);
    381385
     386                con_srvs_init(&user->srvs);
     387                user->srvs.ops = &con_ops;
     388                user->srvs.sarg = user;
     389                user->srvs.abort_timeout = 1000;
     390
     391                telnet_user_add(user);
     392
    382393                fid_t fid = fibril_create(network_user_fibril, user);
    383394                assert(fid);
  • uspace/srv/hid/remcons/user.c

    r131d9a4 r70253688  
    3535#include <stdio.h>
    3636#include <adt/prodcons.h>
    37 #include <ipc/input.h>
    38 #include <ipc/console.h>
    39 #include <ipc/vfs.h>
    4037#include <errno.h>
    4138#include <str_error.h>
     
    9592        user->locsrv_connection_count = 0;
    9693
    97 
     94        user->cursor_x = 0;
     95
     96        return user;
     97}
     98
     99void telnet_user_add(telnet_user_t *user)
     100{
    98101        fibril_mutex_lock(&users_guard);
    99102        list_append(&user->link, &users);
    100103        fibril_mutex_unlock(&users_guard);
    101 
    102         user->cursor_x = 0;
    103 
    104         return user;
    105104}
    106105
     
    199198                if ((recv_length == 0) || (recv_length == ENOTCONN)) {
    200199                        user->socket_closed = true;
     200                        user->srvs.aborted = true;
    201201                        return ENOENT;
    202202                }
  • uspace/srv/hid/remcons/user.h

    r131d9a4 r70253688  
    3636#define TELNET_USER_H_
    3737
     38#include <adt/prodcons.h>
    3839#include <fibril_synch.h>
    3940#include <inttypes.h>
     41#include <io/con_srv.h>
    4042#include "remcons.h"
    4143
     
    5557        /** Path name of the service. */
    5658        char *service_name;
     59        /** Console service setup */
     60        con_srvs_t srvs;
    5761
    5862        /** Producer-consumer of kbd_event_t. */
     
    7781
    7882extern telnet_user_t *telnet_user_create(int);
     83extern void telnet_user_add(telnet_user_t *);
    7984extern void telnet_user_destroy(telnet_user_t *);
    8085extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t);
  • uspace/srv/net/ethip/pdu.c

    r131d9a4 r70253688  
    6969            frame->size);
    7070
    71         log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoding Ethernet frame src=%llx dest=%llx etype=%x",
    72             frame->src, frame->dest, frame->etype_len);
     71        log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoding Ethernet frame "
     72            "src=%" PRIx64 " dest=%" PRIx64 " etype=%x",
     73            frame->src.addr, frame->dest.addr, frame->etype_len);
    7374        log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoded Ethernet frame (%zu bytes)", size);
    7475
     
    104105            frame->size);
    105106
    106         log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoding Ethernet frame src=%llx dest=%llx etype=%x",
    107             frame->src, frame->dest, frame->etype_len);
     107        log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoding Ethernet frame "
     108            "src=%" PRIx64 " dest=%" PRIx64 " etype=%x",
     109            frame->src.addr, frame->dest.addr, frame->etype_len);
    108110        log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoded Ethernet frame payload (%zu bytes)", frame->size);
    109111
  • uspace/srv/net/tcp/conn.c

    r131d9a4 r70253688  
    999999        } else {
    10001000                log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: Nothing left in segment, dropping "
    1001                     "(xfer_size=%zu, SEG.LEN=%zu, seg->ctrl=%u)",
    1002                     conn->name, xfer_size, seg->len, (unsigned)seg->ctrl);
     1001                    "(xfer_size=%zu, SEG.LEN=%" PRIu32 ", seg->ctrl=%u)",
     1002                    conn->name, xfer_size, seg->len, (unsigned int) seg->ctrl);
    10031003                /* Nothing left in segment */
    10041004                tcp_segment_delete(seg);
     
    11461146void tcp_conn_segment_arrived(tcp_conn_t *conn, tcp_segment_t *seg)
    11471147{
    1148         log_msg(LOG_DEFAULT, LVL_DEBUG, "%c: tcp_conn_segment_arrived(%p)",
     1148        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_segment_arrived(%p)",
    11491149            conn->name, seg);
    11501150
  • uspace/srv/net/tcp/segment.c

    r131d9a4 r70253688  
    250250        log_msg(LOG_DEFAULT, LVL_DEBUG2, "Segment dump:");
    251251        log_msg(LOG_DEFAULT, LVL_DEBUG2, " - ctrl = %u", (unsigned)seg->ctrl);
    252         log_msg(LOG_DEFAULT, LVL_DEBUG2, " - seq = % " PRIu32, seg->seq);
    253         log_msg(LOG_DEFAULT, LVL_DEBUG2, " - ack = % " PRIu32, seg->ack);
    254         log_msg(LOG_DEFAULT, LVL_DEBUG2, " - len = % " PRIu32, seg->len);
    255         log_msg(LOG_DEFAULT, LVL_DEBUG2, " - wnd = % " PRIu32, seg->wnd);
    256         log_msg(LOG_DEFAULT, LVL_DEBUG2, " - up = % " PRIu32, seg->up);
     252        log_msg(LOG_DEFAULT, LVL_DEBUG2, " - seq = %" PRIu32, seg->seq);
     253        log_msg(LOG_DEFAULT, LVL_DEBUG2, " - ack = %" PRIu32, seg->ack);
     254        log_msg(LOG_DEFAULT, LVL_DEBUG2, " - len = %" PRIu32, seg->len);
     255        log_msg(LOG_DEFAULT, LVL_DEBUG2, " - wnd = %" PRIu32, seg->wnd);
     256        log_msg(LOG_DEFAULT, LVL_DEBUG2, " - up = %" PRIu32, seg->up);
    257257}
    258258
  • uspace/srv/net/tcp/sock.c

    r131d9a4 r70253688  
    114114        *rsock = NULL;
    115115
    116         sock = calloc(sizeof(tcp_sockdata_t), 1);
     116        sock = calloc(1, sizeof(tcp_sockdata_t));
    117117        if (sock == NULL)
    118118                return ENOMEM;
     
    277277
    278278        socket->backlog = backlog;
    279         socket->lconn = calloc(sizeof(tcp_conn_t *), backlog);
     279        socket->lconn = calloc(backlog, sizeof(tcp_conn_t *));
    280280        if (socket->lconn == NULL) {
    281281                fibril_mutex_unlock(&socket->lock);
     
    293293        for (i = 0; i < backlog; i++) {
    294294
    295                 lconn = calloc(sizeof(tcp_sock_lconn_t), 1);
     295                lconn = calloc(1, sizeof(tcp_sock_lconn_t));
    296296                if (lconn == NULL) {
    297297                        /* XXX Clean up */
  • uspace/srv/net/tcp/tqueue.c

    r131d9a4 r70253688  
    172172
    173173        xfer_seqlen = min(snd_buf_seqlen, avail_wnd);
    174         log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: snd_buf_seqlen = %zu, SND.WND = %zu, "
     174        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: snd_buf_seqlen = %zu, SND.WND = %" PRIu32 ", "
    175175            "xfer_seqlen = %zu", conn->name, snd_buf_seqlen, conn->snd_wnd,
    176176            xfer_seqlen);
  • uspace/srv/net/udp/sock.c

    r131d9a4 r70253688  
    104104
    105105        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_socket()");
    106         sock = calloc(sizeof(udp_sockdata_t), 1);
     106        sock = calloc(1, sizeof(udp_sockdata_t));
    107107        if (sock == NULL) {
    108108                async_answer_0(callid, ENOMEM);
Note: See TracChangeset for help on using the changeset viewer.