Changeset eb522e8 in mainline for kernel/generic/src/ipc/irq.c
- Timestamp:
- 2011-06-01T08:43:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d6c1f1
- Parents:
- 9e2e715 (diff), e51a514 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/irq.c
r9e2e715 reb522e8 42 42 * 43 43 * The structure of a notification message is as follows: 44 * - METHOD: method as registered by the SYS_IPC_REGISTER_IRQ syscall 44 * - IMETHOD: interface and method as registered by the SYS_REGISTER_IRQ 45 * syscall 45 46 * - ARG1: payload modified by a 'top-half' handler 46 47 * - ARG2: payload modified by a 'top-half' handler … … 49 50 * - ARG5: payload modified by a 'top-half' handler 50 51 * - in_phone_hash: interrupt counter (may be needed to assure correct order 51 * in multithreaded drivers)52 * in multithreaded drivers) 52 53 * 53 54 * Note on synchronization for ipc_irq_register(), ipc_irq_unregister(), … … 130 131 /** Register an answerbox as a receiving end for IRQ notifications. 131 132 * 132 * @param box 133 * @param inr 134 * @param devno 135 * @param method Method to be associated with the notification.136 * @param ucode Uspace pointer to top-half pseudocode.137 * 138 * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.133 * @param box Receiving answerbox. 134 * @param inr IRQ number. 135 * @param devno Device number. 136 * @param imethod Interface and method to be associated with the 137 * notification. 138 * @param ucode Uspace pointer to top-half pseudocode. 139 * @return EOK on success or a negative error code. 139 140 * 140 141 */ 141 142 int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, 142 unative_tmethod, irq_code_t *ucode)143 { 144 unative_t key[] = {145 ( unative_t) inr,146 ( unative_t) devno143 sysarg_t imethod, irq_code_t *ucode) 144 { 145 sysarg_t key[] = { 146 (sysarg_t) inr, 147 (sysarg_t) devno 147 148 }; 149 150 if ((inr < 0) || (inr > last_inr)) 151 return ELIMIT; 148 152 149 153 irq_code_t *code; … … 167 171 irq->notif_cfg.notify = true; 168 172 irq->notif_cfg.answerbox = box; 169 irq->notif_cfg. method =method;173 irq->notif_cfg.imethod = imethod; 170 174 irq->notif_cfg.code = code; 171 175 irq->notif_cfg.counter = 0; 176 irq->driver_as = AS; 172 177 173 178 /* … … 206 211 /** Unregister task from IRQ notification. 207 212 * 208 * @param box 209 * @param inr 210 * @param devno 211 * 213 * @param box Answerbox associated with the notification. 214 * @param inr IRQ number. 215 * @param devno Device number. 216 * @return EOK on success or a negative error code. 212 217 */ 213 218 int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno) 214 219 { 215 unative_t key[] = {216 ( unative_t) inr,217 ( unative_t) devno220 sysarg_t key[] = { 221 (sysarg_t) inr, 222 (sysarg_t) devno 218 223 }; 224 225 if ((inr < 0) || (inr > last_inr)) 226 return ELIMIT; 219 227 220 228 irq_spinlock_lock(&irq_uspace_hash_table_lock, true); … … 290 298 } 291 299 292 unative_t key[2];300 sysarg_t key[2]; 293 301 key[0] = irq->inr; 294 302 key[1] = irq->devno; … … 357 365 return IRQ_DECLINE; 358 366 367 #define CMD_MEM_READ(target) \ 368 do { \ 369 void *va = code->cmds[i].addr; \ 370 if (AS != irq->driver_as) \ 371 as_switch(AS, irq->driver_as); \ 372 memcpy_from_uspace(&target, va, (sizeof(target))); \ 373 if (dstarg) \ 374 scratch[dstarg] = target; \ 375 } while(0) 376 377 #define CMD_MEM_WRITE(val) \ 378 do { \ 379 void *va = code->cmds[i].addr; \ 380 if (AS != irq->driver_as) \ 381 as_switch(AS, irq->driver_as); \ 382 memcpy_to_uspace(va, &val, sizeof(val)); \ 383 } while (0) 384 385 as_t *current_as = AS; 359 386 size_t i; 360 387 for (i = 0; i < code->cmdcount; i++) { … … 397 424 (uint32_t) code->cmds[i].value); 398 425 break; 426 case CMD_PIO_WRITE_A_8: 427 if (srcarg) { 428 pio_write_8((ioport8_t *) code->cmds[i].addr, 429 (uint8_t) scratch[srcarg]); 430 } 431 break; 432 case CMD_PIO_WRITE_A_16: 433 if (srcarg) { 434 pio_write_16((ioport16_t *) code->cmds[i].addr, 435 (uint16_t) scratch[srcarg]); 436 } 437 break; 438 case CMD_PIO_WRITE_A_32: 439 if (srcarg) { 440 pio_write_32((ioport32_t *) code->cmds[i].addr, 441 (uint32_t) scratch[srcarg]); 442 } 443 break; 444 case CMD_MEM_READ_8: { 445 uint8_t val; 446 CMD_MEM_READ(val); 447 break; 448 } 449 case CMD_MEM_READ_16: { 450 uint16_t val; 451 CMD_MEM_READ(val); 452 break; 453 } 454 case CMD_MEM_READ_32: { 455 uint32_t val; 456 CMD_MEM_READ(val); 457 break; 458 } 459 case CMD_MEM_WRITE_8: { 460 uint8_t val = code->cmds[i].value; 461 CMD_MEM_WRITE(val); 462 break; 463 } 464 case CMD_MEM_WRITE_16: { 465 uint16_t val = code->cmds[i].value; 466 CMD_MEM_WRITE(val); 467 break; 468 } 469 case CMD_MEM_WRITE_32: { 470 uint32_t val = code->cmds[i].value; 471 CMD_MEM_WRITE(val); 472 break; 473 } 474 case CMD_MEM_WRITE_A_8: 475 if (srcarg) { 476 uint8_t val = scratch[srcarg]; 477 CMD_MEM_WRITE(val); 478 } 479 break; 480 case CMD_MEM_WRITE_A_16: 481 if (srcarg) { 482 uint16_t val = scratch[srcarg]; 483 CMD_MEM_WRITE(val); 484 } 485 break; 486 case CMD_MEM_WRITE_A_32: 487 if (srcarg) { 488 uint32_t val = scratch[srcarg]; 489 CMD_MEM_WRITE(val); 490 } 491 break; 399 492 case CMD_BTEST: 400 493 if ((srcarg) && (dstarg)) { … … 410 503 break; 411 504 case CMD_ACCEPT: 505 if (AS != current_as) 506 as_switch(AS, current_as); 412 507 return IRQ_ACCEPT; 413 508 case CMD_DECLINE: 414 509 default: 510 if (AS != current_as) 511 as_switch(AS, current_as); 415 512 return IRQ_DECLINE; 416 513 } 417 514 } 515 if (AS != current_as) 516 as_switch(AS, current_as); 418 517 419 518 return IRQ_DECLINE; … … 444 543 445 544 /* Set up args */ 446 IPC_SET_ METHOD(call->data, irq->notif_cfg.method);545 IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod); 447 546 IPC_SET_ARG1(call->data, irq->notif_cfg.scratch[1]); 448 547 IPC_SET_ARG2(call->data, irq->notif_cfg.scratch[2]); … … 465 564 * 466 565 */ 467 void ipc_irq_send_msg(irq_t *irq, unative_t a1, unative_t a2, unative_t a3,468 unative_t a4, unative_t a5)566 void ipc_irq_send_msg(irq_t *irq, sysarg_t a1, sysarg_t a2, sysarg_t a3, 567 sysarg_t a4, sysarg_t a5) 469 568 { 470 569 irq_spinlock_lock(&irq->lock, true); … … 481 580 call->priv = ++irq->notif_cfg.counter; 482 581 483 IPC_SET_ METHOD(call->data, irq->notif_cfg.method);582 IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod); 484 583 IPC_SET_ARG1(call->data, a1); 485 584 IPC_SET_ARG2(call->data, a2);
Note:
See TracChangeset
for help on using the changeset viewer.