Changeset 84876aa4 in mainline for uspace/srv


Ignore:
Timestamp:
2019-11-15T13:46:34Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ecb7828
Parents:
b093a62 (diff), d548fc0 (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 master into gfx

Mainly to get XCW fixes

Location:
uspace/srv
Files:
7 added
13 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/input.c

    rb093a62 r84876aa4  
    6666#include "serial.h"
    6767
    68 #define NUM_LAYOUTS  4
     68#define NUM_LAYOUTS 5
    6969
    7070static layout_ops_t *layout[NUM_LAYOUTS] = {
     
    7272        &us_dvorak_ops,
    7373        &cz_ops,
    74         &ar_ops
     74        &ar_ops,
     75        &fr_azerty_ops
    7576};
    7677
     
    208209        // TODO: More elegant layout switching
    209210
    210         if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    211             (key == KC_F1)) {
    212                 layout_destroy(kdev->active_layout);
    213                 kdev->active_layout = layout_create(layout[0]);
    214                 return;
    215         }
    216 
    217         if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    218             (key == KC_F2)) {
    219                 layout_destroy(kdev->active_layout);
    220                 kdev->active_layout = layout_create(layout[1]);
    221                 return;
    222         }
    223 
    224         if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    225             (key == KC_F3)) {
    226                 layout_destroy(kdev->active_layout);
    227                 kdev->active_layout = layout_create(layout[2]);
    228                 return;
    229         }
    230 
    231         if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    232             (key == KC_F4)) {
    233                 layout_destroy(kdev->active_layout);
    234                 kdev->active_layout = layout_create(layout[3]);
    235                 return;
     211        if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL)) {
     212                switch (key) {
     213                case KC_F1:
     214                        layout_destroy(kdev->active_layout);
     215                        kdev->active_layout = layout_create(layout[0]);
     216                        break;
     217                case KC_F2:
     218                        layout_destroy(kdev->active_layout);
     219                        kdev->active_layout = layout_create(layout[1]);
     220                        break;
     221                case KC_F3:
     222                        layout_destroy(kdev->active_layout);
     223                        kdev->active_layout = layout_create(layout[2]);
     224                        break;
     225                case KC_F4:
     226                        layout_destroy(kdev->active_layout);
     227                        kdev->active_layout = layout_create(layout[3]);
     228                        break;
     229                case KC_F5:
     230                        layout_destroy(kdev->active_layout);
     231                        kdev->active_layout = layout_create(layout[4]);
     232                        break;
     233                default: // default: is here to avoid compiler warning about unhandled cases
     234                        break;
     235                }
    236236        }
    237237
  • uspace/srv/hid/input/layout.h

    rb093a62 r84876aa4  
    6060extern layout_ops_t cz_ops;
    6161extern layout_ops_t ar_ops;
     62extern layout_ops_t fr_azerty_ops;
    6263
    6364extern layout_t *layout_create(layout_ops_t *);
  • uspace/srv/hid/input/meson.build

    rb093a62 r84876aa4  
    3131src = files(
    3232        'layout/cz.c',
     33        'layout/fr_azerty.c',
    3334        'layout/us_qwerty.c',
    3435        'layout/us_dvorak.c',
  • uspace/srv/net/tcp/test/tqueue.c

    rb093a62 r84876aa4  
    3232
    3333#include "../conn.h"
     34#include "../segment.h"
    3435#include "../tqueue.h"
    3536
     
    117118        PCUT_ASSERT_EQUALS(CTL_SYN, trans_seg[0]->ctrl);
    118119        PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq);
     120        tcp_segment_delete(trans_seg[0]);
    119121}
    120122
     
    156158        PCUT_ASSERT_EQUALS(CTL_FIN | CTL_ACK, trans_seg[0]->ctrl);
    157159        PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq);
     160        tcp_segment_delete(trans_seg[0]);
    158161}
    159162
     
    198201        PCUT_ASSERT_EQUALS(CTL_ACK, trans_seg[0]->ctrl);
    199202        PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq);
     203        tcp_segment_delete(trans_seg[0]);
    200204}
    201205
     
    256260static void tqueue_test_transmit_seg(inet_ep2_t *epp, tcp_segment_t *seg)
    257261{
    258         trans_seg[seg_cnt++] = seg;
     262        trans_seg[seg_cnt++] = tcp_segment_dup(seg);
    259263}
    260264
  • uspace/srv/net/udp/assoc.c

    rb093a62 r84876aa4  
    4040#include <fibril_synch.h>
    4141#include <inet/endpoint.h>
    42 #include <inet/inet.h>
    4342#include <io/log.h>
    4443#include <nettl/amap.h>
     
    4847#include "msg.h"
    4948#include "pdu.h"
    50 #include "udp_inet.h"
    5149#include "udp_type.h"
    5250
     
    5755static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *);
    5856static errno_t udp_assoc_queue_msg(udp_assoc_t *, inet_ep2_t *, udp_msg_t *);
     57static udp_assocs_dep_t *assocs_dep;
    5958
    6059/** Initialize associations. */
    61 errno_t udp_assocs_init(void)
     60errno_t udp_assocs_init(udp_assocs_dep_t *dep)
    6261{
    6362        errno_t rc;
     
    6968        }
    7069
     70        assocs_dep = dep;
    7171        return EOK;
     72}
     73
     74/** Finalize associations. */
     75void udp_assocs_fini(void)
     76{
     77        assert(list_empty(&assoc_list));
     78
     79        amap_destroy(amap);
     80        amap = NULL;
    7281}
    7382
     
    174183
    175184        assert(assoc->deleted == false);
     185        assoc->deleted = true;
    176186        udp_assoc_delref(assoc);
    177         assoc->deleted = true;
    178187}
    179188
     
    244253errno_t udp_assoc_send(udp_assoc_t *assoc, inet_ep_t *remote, udp_msg_t *msg)
    245254{
    246         udp_pdu_t *pdu;
    247255        inet_ep2_t epp;
    248256        errno_t rc;
     
    266274        if (inet_addr_is_any(&epp.local.addr) && !assoc->nolocal) {
    267275                log_msg(LOG_DEFAULT, LVL_DEBUG, "Determine local address.");
    268                 rc = inet_get_srcaddr(&epp.remote.addr, 0, &epp.local.addr);
     276                rc = (*assocs_dep->get_srcaddr)(&epp.remote.addr, 0,
     277                    &epp.local.addr);
    269278                if (rc != EOK) {
    270279                        log_msg(LOG_DEFAULT, LVL_DEBUG, "Cannot determine "
     
    280289                return EINVAL;
    281290
    282         log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - encode pdu");
    283 
    284         rc = udp_pdu_encode(&epp, msg, &pdu);
    285         if (rc != EOK)
    286                 return ENOMEM;
    287 
    288291        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - transmit");
    289 
    290         rc = udp_transmit_pdu(pdu);
    291         udp_pdu_delete(pdu);
     292        rc = (*assocs_dep->transmit_msg)(&epp, msg);
    292293
    293294        if (rc != EOK)
  • uspace/srv/net/udp/assoc.h

    rb093a62 r84876aa4  
    4040#include "udp_type.h"
    4141
    42 extern errno_t udp_assocs_init(void);
     42extern errno_t udp_assocs_init(udp_assocs_dep_t *);
     43extern void udp_assocs_fini(void);
    4344extern udp_assoc_t *udp_assoc_new(inet_ep2_t *, udp_assoc_cb_t *, void *);
    4445extern void udp_assoc_delete(udp_assoc_t *);
  • uspace/srv/net/udp/meson.build

    rb093a62 r84876aa4  
    2828
    2929deps = [ 'nettl' ]
    30 src = files(
     30
     31_common_src = files(
    3132        'assoc.c',
     33        'cassoc.c',
    3234        'msg.c',
    3335        'pdu.c',
     36)
     37
     38src = files(
    3439        'service.c',
    3540        'udp.c',
    3641        'udp_inet.c',
    3742)
     43
     44test_src = files(
     45        'test/assoc.c',
     46        'test/msg.c',
     47        'test/main.c',
     48        'test/pdu.c',
     49)
     50
     51src = [ _common_src, src ]
     52test_src = [ _common_src, test_src ]
  • uspace/srv/net/udp/service.c

    rb093a62 r84876aa4  
    4646
    4747#include "assoc.h"
     48#include "cassoc.h"
    4849#include "msg.h"
    4950#include "service.h"
     
    5556#define MAX_MSG_SIZE DATA_XFER_LIMIT
    5657
    57 static void udp_cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);
     58static void udp_recv_msg_cassoc(void *, inet_ep2_t *, udp_msg_t *);
    5859
    5960/** Callbacks to tie us to association layer */
    6061static udp_assoc_cb_t udp_cassoc_cb = {
    61         .recv_msg = udp_cassoc_recv_msg
     62        .recv_msg = udp_recv_msg_cassoc
    6263};
    63 
    64 /** Add message to client receive queue.
    65  *
    66  * @param cassoc Client association
    67  * @param epp    Endpoint pair on which message was received
    68  * @param msg    Message
    69  *
    70  * @return EOK on success, ENOMEM if out of memory
    71  */
    72 static errno_t udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,
    73     udp_msg_t *msg)
    74 {
    75         udp_crcv_queue_entry_t *rqe;
    76 
    77         log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_cassoc_queue_msg(%p, %p, %p)",
    78             cassoc, epp, msg);
    79 
    80         rqe = calloc(1, sizeof(udp_crcv_queue_entry_t));
    81         if (rqe == NULL)
    82                 return ENOMEM;
    83 
    84         link_initialize(&rqe->link);
    85         rqe->epp = *epp;
    86         rqe->msg = msg;
    87         rqe->cassoc = cassoc;
    88 
    89         list_append(&rqe->link, &cassoc->client->crcv_queue);
    90         return EOK;
    91 }
    9264
    9365/** Send 'data' event to client.
     
    10880}
    10981
    110 /** Create client association.
    111  *
    112  * This effectively adds an association into a client's namespace.
    113  *
    114  * @param client  Client
    115  * @param assoc   Association
    116  * @param rcassoc Place to store pointer to new client association
    117  *
    118  * @return EOK on soccess, ENOMEM if out of memory
    119  */
    120 static errno_t udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,
    121     udp_cassoc_t **rcassoc)
    122 {
    123         udp_cassoc_t *cassoc;
    124         sysarg_t id;
    125 
    126         cassoc = calloc(1, sizeof(udp_cassoc_t));
    127         if (cassoc == NULL)
    128                 return ENOMEM;
    129 
    130         /* Allocate new ID */
    131         id = 0;
    132         list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {
    133                 if (cassoc->id >= id)
    134                         id = cassoc->id + 1;
    135         }
    136 
    137         cassoc->id = id;
    138         cassoc->client = client;
    139         cassoc->assoc = assoc;
    140 
    141         list_append(&cassoc->lclient, &client->cassoc);
    142         *rcassoc = cassoc;
    143         return EOK;
    144 }
    145 
    146 /** Destroy client association.
    147  *
    148  * @param cassoc Client association
    149  */
    150 static void udp_cassoc_destroy(udp_cassoc_t *cassoc)
    151 {
    152         list_remove(&cassoc->lclient);
    153         free(cassoc);
    154 }
    155 
    156 /** Get client association by ID.
    157  *
    158  * @param client  Client
    159  * @param id      Client association ID
    160  * @param rcassoc Place to store pointer to client association
    161  *
    162  * @return EOK on success, ENOENT if no client association with the given ID
    163  *         is found.
    164  */
    165 static errno_t udp_cassoc_get(udp_client_t *client, sysarg_t id,
    166     udp_cassoc_t **rcassoc)
    167 {
    168         list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {
    169                 if (cassoc->id == id) {
    170                         *rcassoc = cassoc;
    171                         return EOK;
    172                 }
    173         }
    174 
    175         return ENOENT;
    176 }
    177 
    17882/** Message received on client association.
    17983 *
     
    18488 * @param msg Message
    18589 */
    186 static void udp_cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
     90static void udp_recv_msg_cassoc(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
    18791{
    18892        udp_cassoc_t *cassoc = (udp_cassoc_t *) arg;
  • uspace/srv/net/udp/udp.c

    rb093a62 r84876aa4  
    4747#define NAME       "udp"
    4848
     49static udp_assocs_dep_t udp_assocs_dep = {
     50        .get_srcaddr = udp_get_srcaddr,
     51        .transmit_msg = udp_transmit_msg
     52};
     53
    4954static errno_t udp_init(void)
    5055{
     
    5358        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_init()");
    5459
    55         rc = udp_assocs_init();
     60        rc = udp_assocs_init(&udp_assocs_dep);
    5661        if (rc != EOK) {
    5762                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing associations.");
  • uspace/srv/net/udp/udp_inet.c

    rb093a62 r84876aa4  
    134134}
    135135
     136/** Get source address.
     137 *
     138 * @param remote Remote address
     139 * @param tos Type of service
     140 * @param local Place to store local address
     141 * @return EOK on success or an error code
     142 */
     143errno_t udp_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local)
     144{
     145        return inet_get_srcaddr(remote, tos, local);
     146}
     147
     148/** Transmit message over network layer. */
     149errno_t udp_transmit_msg(inet_ep2_t *epp, udp_msg_t *msg)
     150{
     151        udp_pdu_t *pdu;
     152        errno_t rc;
     153
     154        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_transmit_msg()");
     155
     156        rc = udp_pdu_encode(epp, msg, &pdu);
     157        if (rc != EOK) {
     158                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed encoding PDU");
     159                return rc;
     160        }
     161
     162        rc = udp_transmit_pdu(pdu);
     163        udp_pdu_delete(pdu);
     164
     165        return rc;
     166}
     167
    136168/**
    137169 * @}
  • uspace/srv/net/udp/udp_inet.h

    rb093a62 r84876aa4  
    3636#define UDP_INET_H
    3737
     38#include <inet/addr.h>
     39#include <stdint.h>
    3840#include "udp_type.h"
    3941
    4042extern errno_t udp_inet_init(void);
    4143extern errno_t udp_transmit_pdu(udp_pdu_t *);
     44extern errno_t udp_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
     45extern errno_t udp_transmit_msg(inet_ep2_t *, udp_msg_t *);
    4246
    4347#endif
  • uspace/srv/net/udp/udp_type.h

    rb093a62 r84876aa4  
    3737
    3838#include <async.h>
     39#include <errno.h>
    3940#include <fibril.h>
    4041#include <fibril_synch.h>
     
    4445#include <stdbool.h>
    4546#include <stddef.h>
     47#include <stdint.h>
    4648#include <inet/addr.h>
    4749
     
    8789} udp_pdu_t;
    8890
    89 /** Association callbacks */
     91/** Functions needed by associations module.
     92 *
     93 * Functions that need to be provided by the caller so that the associations
     94 * module can function.
     95 */
     96typedef struct {
     97        errno_t (*get_srcaddr)(inet_addr_t *, uint8_t, inet_addr_t *);
     98        errno_t (*transmit_msg)(inet_ep2_t *, udp_msg_t *);
     99} udp_assocs_dep_t;
     100
     101/** Association callbacks.
     102 *
     103 * Callbacks for a particular association, to notify caller of events
     104 * on the association.
     105 */
    90106typedef struct {
    91107        /** Message received */
  • uspace/srv/volsrv/volume.c

    rb093a62 r84876aa4  
    367367        if (refcount_down(&volume->refcnt)) {
    368368                /* No more references. Check if volume is persistent. */
    369                 if (!vol_volume_is_persist(volume)) {
    370                         list_remove(&volume->lvolumes);
    371                         vol_volume_delete(volume);
    372                 }
     369                list_remove(&volume->lvolumes);
     370                vol_volume_delete(volume);
    373371        }
    374372}
     
    399397                /* Volume is now persistent */
    400398                if (volume->nvolume == NULL) {
     399                        /* Prevent volume from being freed */
     400                        refcount_up(&volume->refcnt);
     401
    401402                        /* Create volume node */
    402403                        rc = sif_trans_begin(volume->volumes->repo, &trans);
     
    426427                        volume->nvolume = nvolume;
    427428                } else {
     429                        /* Allow volume to be freed */
     430                        vol_volume_del_ref(volume);
     431
    428432                        /* Update volume node */
    429433                        rc = sif_trans_begin(volume->volumes->repo, &trans);
Note: See TracChangeset for help on using the changeset viewer.