Changeset 8820544 in mainline for kernel/generic/src/ipc
- Timestamp:
- 2014-08-16T00:02:04Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 35b8bfe, 8cd680c
- Parents:
- 83f29e0
- Location:
- kernel/generic/src/ipc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/event.c
r83f29e0 r8820544 58 58 } 59 59 60 static event_t *evno2event(int evno, task_t *t )60 static event_t *evno2event(int evno, task_t *task) 61 61 { 62 62 ASSERT(evno < EVENT_TASK_END); 63 63 64 64 event_t *event; 65 65 66 66 if (evno < EVENT_END) 67 67 event = &events[(event_type_t) evno]; 68 68 else 69 event = &t ->events[(event_task_type_t) evno - EVENT_END];70 69 event = &task->events[(event_task_type_t) evno - EVENT_END]; 70 71 71 return event; 72 72 } … … 86 86 event_initialize(evno2event(i, task)); 87 87 } 88 89 88 90 89 /** Unsubscribe kernel events associated with an answerbox … … 260 259 { 261 260 int res; 262 261 263 262 spinlock_lock(&event->lock); 264 263 … … 277 276 } 278 277 278 /** Unsubscribe event notifications 279 * 280 * @param evno Event type. 281 * @param answerbox Answerbox used to send the notifications to. 282 * 283 * @return EOK if the subscription was successful. 284 * @return EEXISTS if the notifications of the given type are 285 * already subscribed. 286 * 287 */ 288 static int event_unsubscribe(event_t *event, answerbox_t *answerbox) 289 { 290 int res; 291 292 spinlock_lock(&event->lock); 293 294 if (event->answerbox == answerbox) { 295 event->answerbox = NULL; 296 event->counter = 0; 297 event->imethod = 0; 298 event->masked = false; 299 res = EOK; 300 } else 301 res = ENOENT; 302 303 spinlock_unlock(&event->lock); 304 305 return res; 306 } 307 279 308 /** Unmask event notifications 280 309 * … … 297 326 } 298 327 299 /** Event notification s yscall wrapper328 /** Event notification subscription syscall wrapper 300 329 * 301 330 * @param evno Event type to subscribe. … … 309 338 * 310 339 */ 311 sysarg_t sys_ event_subscribe(sysarg_t evno, sysarg_t imethod)340 sysarg_t sys_ipc_event_subscribe(sysarg_t evno, sysarg_t imethod) 312 341 { 313 342 if (evno >= EVENT_TASK_END) … … 316 345 return (sysarg_t) event_subscribe(evno2event(evno, TASK), 317 346 (sysarg_t) imethod, &TASK->answerbox); 347 } 348 349 /** Event notification unsubscription syscall wrapper 350 * 351 * @param evno Event type to unsubscribe. 352 * 353 * @return EOK on success. 354 * @return ELIMIT on unknown event type. 355 * @return ENOENT if the notification of the given type is not 356 subscribed. 357 * 358 */ 359 sysarg_t sys_ipc_event_unsubscribe(sysarg_t evno) 360 { 361 if (evno >= EVENT_TASK_END) 362 return ELIMIT; 363 364 return (sysarg_t) event_unsubscribe(evno2event(evno, TASK), 365 &TASK->answerbox); 318 366 } 319 367 … … 331 379 * 332 380 */ 333 sysarg_t sys_ event_unmask(sysarg_t evno)381 sysarg_t sys_ipc_event_unmask(sysarg_t evno) 334 382 { 335 383 if (evno >= EVENT_TASK_END) -
kernel/generic/src/ipc/irq.c
r83f29e0 r8820544 36 36 * @brief IRQ notification framework. 37 37 * 38 * This framework allows applications to registerto receive a notification38 * This framework allows applications to subscribe to receive a notification 39 39 * when interrupt is detected. The application may provide a simple 'top-half' 40 40 * handler as part of its registration, which can perform simple operations … … 42 42 * 43 43 * The structure of a notification message is as follows: 44 * - IMETHOD: interface and method as registered by 45 * the SYS_IRQ_REGISTER syscall 44 * - IMETHOD: interface and method as set by the SYS_IPC_IRQ_SUBSCRIBE syscall 46 45 * - ARG1: payload modified by a 'top-half' handler (scratch[1]) 47 46 * - ARG2: payload modified by a 'top-half' handler (scratch[2]) … … 52 51 * in multithreaded drivers) 53 52 * 54 * Note on synchronization for ipc_irq_ register(), ipc_irq_unregister(),53 * Note on synchronization for ipc_irq_subscribe(), ipc_irq_unsubscribe(), 55 54 * ipc_irq_cleanup() and IRQ handlers: 56 55 * … … 289 288 } 290 289 291 /** Registeran answerbox as a receiving end for IRQ notifications.290 /** Subscribe an answerbox as a receiving end for IRQ notifications. 292 291 * 293 292 * @param box Receiving answerbox. … … 301 300 * 302 301 */ 303 int ipc_irq_ register(answerbox_t *box, inr_t inr, devno_t devno,302 int ipc_irq_subscribe(answerbox_t *box, inr_t inr, devno_t devno, 304 303 sysarg_t imethod, irq_code_t *ucode) 305 304 { … … 369 368 } 370 369 371 /** Un registertask from IRQ notification.370 /** Unsubscribe task from IRQ notification. 372 371 * 373 372 * @param box Answerbox associated with the notification. … … 378 377 * 379 378 */ 380 int ipc_irq_un register(answerbox_t *box, inr_t inr, devno_t devno)379 int ipc_irq_unsubscribe(answerbox_t *box, inr_t inr, devno_t devno) 381 380 { 382 381 sysarg_t key[] = { … … 432 431 * 433 432 * This function is effective because the answerbox contains 434 * list of all irq_t structures that are registered to433 * list of all irq_t structures that are subscribed to 435 434 * send notifications to it. 436 435 * -
kernel/generic/src/ipc/sysipc.c
r83f29e0 r8820544 736 736 * @param ucode Uspace pointer to the top-half pseudocode. 737 737 * 738 * @return EPERM or a return code returned by ipc_irq_ register().739 * 740 */ 741 sysarg_t sys_i rq_register(inr_t inr, devno_t devno, sysarg_t imethod,738 * @return EPERM or a return code returned by ipc_irq_subscribe(). 739 * 740 */ 741 sysarg_t sys_ipc_irq_subscribe(inr_t inr, devno_t devno, sysarg_t imethod, 742 742 irq_code_t *ucode) 743 743 { … … 745 745 return EPERM; 746 746 747 return ipc_irq_ register(&TASK->answerbox, inr, devno, imethod, ucode);747 return ipc_irq_subscribe(&TASK->answerbox, inr, devno, imethod, ucode); 748 748 } 749 749 … … 756 756 * 757 757 */ 758 sysarg_t sys_i rq_unregister(inr_t inr, devno_t devno)758 sysarg_t sys_ipc_irq_unsubscribe(inr_t inr, devno_t devno) 759 759 { 760 760 if (!(cap_get(TASK) & CAP_IRQ_REG)) 761 761 return EPERM; 762 762 763 ipc_irq_un register(&TASK->answerbox, inr, devno);763 ipc_irq_unsubscribe(&TASK->answerbox, inr, devno); 764 764 765 765 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.