Changeset 84876aa4 in mainline for uspace/srv
- Timestamp:
- 2019-11-15T13:46:34Z (6 years ago)
- 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. - Location:
- uspace/srv
- Files:
-
- 7 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/input.c
rb093a62 r84876aa4 66 66 #include "serial.h" 67 67 68 #define NUM_LAYOUTS 468 #define NUM_LAYOUTS 5 69 69 70 70 static layout_ops_t *layout[NUM_LAYOUTS] = { … … 72 72 &us_dvorak_ops, 73 73 &cz_ops, 74 &ar_ops 74 &ar_ops, 75 &fr_azerty_ops 75 76 }; 76 77 … … 208 209 // TODO: More elegant layout switching 209 210 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 } 236 236 } 237 237 -
uspace/srv/hid/input/layout.h
rb093a62 r84876aa4 60 60 extern layout_ops_t cz_ops; 61 61 extern layout_ops_t ar_ops; 62 extern layout_ops_t fr_azerty_ops; 62 63 63 64 extern layout_t *layout_create(layout_ops_t *); -
uspace/srv/hid/input/meson.build
rb093a62 r84876aa4 31 31 src = files( 32 32 'layout/cz.c', 33 'layout/fr_azerty.c', 33 34 'layout/us_qwerty.c', 34 35 'layout/us_dvorak.c', -
uspace/srv/net/tcp/test/tqueue.c
rb093a62 r84876aa4 32 32 33 33 #include "../conn.h" 34 #include "../segment.h" 34 35 #include "../tqueue.h" 35 36 … … 117 118 PCUT_ASSERT_EQUALS(CTL_SYN, trans_seg[0]->ctrl); 118 119 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 120 tcp_segment_delete(trans_seg[0]); 119 121 } 120 122 … … 156 158 PCUT_ASSERT_EQUALS(CTL_FIN | CTL_ACK, trans_seg[0]->ctrl); 157 159 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 160 tcp_segment_delete(trans_seg[0]); 158 161 } 159 162 … … 198 201 PCUT_ASSERT_EQUALS(CTL_ACK, trans_seg[0]->ctrl); 199 202 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 203 tcp_segment_delete(trans_seg[0]); 200 204 } 201 205 … … 256 260 static void tqueue_test_transmit_seg(inet_ep2_t *epp, tcp_segment_t *seg) 257 261 { 258 trans_seg[seg_cnt++] = seg;262 trans_seg[seg_cnt++] = tcp_segment_dup(seg); 259 263 } 260 264 -
uspace/srv/net/udp/assoc.c
rb093a62 r84876aa4 40 40 #include <fibril_synch.h> 41 41 #include <inet/endpoint.h> 42 #include <inet/inet.h>43 42 #include <io/log.h> 44 43 #include <nettl/amap.h> … … 48 47 #include "msg.h" 49 48 #include "pdu.h" 50 #include "udp_inet.h"51 49 #include "udp_type.h" 52 50 … … 57 55 static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *); 58 56 static errno_t udp_assoc_queue_msg(udp_assoc_t *, inet_ep2_t *, udp_msg_t *); 57 static udp_assocs_dep_t *assocs_dep; 59 58 60 59 /** Initialize associations. */ 61 errno_t udp_assocs_init( void)60 errno_t udp_assocs_init(udp_assocs_dep_t *dep) 62 61 { 63 62 errno_t rc; … … 69 68 } 70 69 70 assocs_dep = dep; 71 71 return EOK; 72 } 73 74 /** Finalize associations. */ 75 void udp_assocs_fini(void) 76 { 77 assert(list_empty(&assoc_list)); 78 79 amap_destroy(amap); 80 amap = NULL; 72 81 } 73 82 … … 174 183 175 184 assert(assoc->deleted == false); 185 assoc->deleted = true; 176 186 udp_assoc_delref(assoc); 177 assoc->deleted = true;178 187 } 179 188 … … 244 253 errno_t udp_assoc_send(udp_assoc_t *assoc, inet_ep_t *remote, udp_msg_t *msg) 245 254 { 246 udp_pdu_t *pdu;247 255 inet_ep2_t epp; 248 256 errno_t rc; … … 266 274 if (inet_addr_is_any(&epp.local.addr) && !assoc->nolocal) { 267 275 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); 269 278 if (rc != EOK) { 270 279 log_msg(LOG_DEFAULT, LVL_DEBUG, "Cannot determine " … … 280 289 return EINVAL; 281 290 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 288 291 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); 292 293 293 294 if (rc != EOK) -
uspace/srv/net/udp/assoc.h
rb093a62 r84876aa4 40 40 #include "udp_type.h" 41 41 42 extern errno_t udp_assocs_init(void); 42 extern errno_t udp_assocs_init(udp_assocs_dep_t *); 43 extern void udp_assocs_fini(void); 43 44 extern udp_assoc_t *udp_assoc_new(inet_ep2_t *, udp_assoc_cb_t *, void *); 44 45 extern void udp_assoc_delete(udp_assoc_t *); -
uspace/srv/net/udp/meson.build
rb093a62 r84876aa4 28 28 29 29 deps = [ 'nettl' ] 30 src = files( 30 31 _common_src = files( 31 32 'assoc.c', 33 'cassoc.c', 32 34 'msg.c', 33 35 'pdu.c', 36 ) 37 38 src = files( 34 39 'service.c', 35 40 'udp.c', 36 41 'udp_inet.c', 37 42 ) 43 44 test_src = files( 45 'test/assoc.c', 46 'test/msg.c', 47 'test/main.c', 48 'test/pdu.c', 49 ) 50 51 src = [ _common_src, src ] 52 test_src = [ _common_src, test_src ] -
uspace/srv/net/udp/service.c
rb093a62 r84876aa4 46 46 47 47 #include "assoc.h" 48 #include "cassoc.h" 48 49 #include "msg.h" 49 50 #include "service.h" … … 55 56 #define MAX_MSG_SIZE DATA_XFER_LIMIT 56 57 57 static void udp_ cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);58 static void udp_recv_msg_cassoc(void *, inet_ep2_t *, udp_msg_t *); 58 59 59 60 /** Callbacks to tie us to association layer */ 60 61 static udp_assoc_cb_t udp_cassoc_cb = { 61 .recv_msg = udp_ cassoc_recv_msg62 .recv_msg = udp_recv_msg_cassoc 62 63 }; 63 64 /** Add message to client receive queue.65 *66 * @param cassoc Client association67 * @param epp Endpoint pair on which message was received68 * @param msg Message69 *70 * @return EOK on success, ENOMEM if out of memory71 */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 }92 64 93 65 /** Send 'data' event to client. … … 108 80 } 109 81 110 /** Create client association.111 *112 * This effectively adds an association into a client's namespace.113 *114 * @param client Client115 * @param assoc Association116 * @param rcassoc Place to store pointer to new client association117 *118 * @return EOK on soccess, ENOMEM if out of memory119 */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 association149 */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 Client159 * @param id Client association ID160 * @param rcassoc Place to store pointer to client association161 *162 * @return EOK on success, ENOENT if no client association with the given ID163 * 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 178 82 /** Message received on client association. 179 83 * … … 184 88 * @param msg Message 185 89 */ 186 static void udp_ cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)90 static void udp_recv_msg_cassoc(void *arg, inet_ep2_t *epp, udp_msg_t *msg) 187 91 { 188 92 udp_cassoc_t *cassoc = (udp_cassoc_t *) arg; -
uspace/srv/net/udp/udp.c
rb093a62 r84876aa4 47 47 #define NAME "udp" 48 48 49 static udp_assocs_dep_t udp_assocs_dep = { 50 .get_srcaddr = udp_get_srcaddr, 51 .transmit_msg = udp_transmit_msg 52 }; 53 49 54 static errno_t udp_init(void) 50 55 { … … 53 58 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_init()"); 54 59 55 rc = udp_assocs_init( );60 rc = udp_assocs_init(&udp_assocs_dep); 56 61 if (rc != EOK) { 57 62 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing associations."); -
uspace/srv/net/udp/udp_inet.c
rb093a62 r84876aa4 134 134 } 135 135 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 */ 143 errno_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. */ 149 errno_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 136 168 /** 137 169 * @} -
uspace/srv/net/udp/udp_inet.h
rb093a62 r84876aa4 36 36 #define UDP_INET_H 37 37 38 #include <inet/addr.h> 39 #include <stdint.h> 38 40 #include "udp_type.h" 39 41 40 42 extern errno_t udp_inet_init(void); 41 43 extern errno_t udp_transmit_pdu(udp_pdu_t *); 44 extern errno_t udp_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *); 45 extern errno_t udp_transmit_msg(inet_ep2_t *, udp_msg_t *); 42 46 43 47 #endif -
uspace/srv/net/udp/udp_type.h
rb093a62 r84876aa4 37 37 38 38 #include <async.h> 39 #include <errno.h> 39 40 #include <fibril.h> 40 41 #include <fibril_synch.h> … … 44 45 #include <stdbool.h> 45 46 #include <stddef.h> 47 #include <stdint.h> 46 48 #include <inet/addr.h> 47 49 … … 87 89 } udp_pdu_t; 88 90 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 */ 96 typedef 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 */ 90 106 typedef struct { 91 107 /** Message received */ -
uspace/srv/volsrv/volume.c
rb093a62 r84876aa4 367 367 if (refcount_down(&volume->refcnt)) { 368 368 /* 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); 373 371 } 374 372 } … … 399 397 /* Volume is now persistent */ 400 398 if (volume->nvolume == NULL) { 399 /* Prevent volume from being freed */ 400 refcount_up(&volume->refcnt); 401 401 402 /* Create volume node */ 402 403 rc = sif_trans_begin(volume->volumes->repo, &trans); … … 426 427 volume->nvolume = nvolume; 427 428 } else { 429 /* Allow volume to be freed */ 430 vol_volume_del_ref(volume); 431 428 432 /* Update volume node */ 429 433 rc = sif_trans_begin(volume->volumes->repo, &trans);
Note:
See TracChangeset
for help on using the changeset viewer.