Changeset 8b243f2 in mainline for kernel/generic/src/ipc/irq.c


Ignore:
Timestamp:
2007-06-17T19:34:36Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bd72c3e9
Parents:
4680ef5
Message:

Greatly improve comments in the IPC layer.
Now I think I finally start to understand our IPC internals :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/irq.c

    r4680ef5 r8b243f2  
    6161/** Execute code associated with IRQ notification.
    6262 *
    63  * @param call Notification call.
    64  * @param code Top-half pseudocode.
     63 * @param call          Notification call.
     64 * @param code          Top-half pseudocode.
    6565 */
    6666static void code_execute(call_t *call, irq_code_t *code)
     
    7272                return;
    7373       
    74         for (i=0; i < code->cmdcount;i++) {
     74        for (i = 0; i < code->cmdcount; i++) {
    7575                switch (code->cmds[i].cmd) {
    7676                case CMD_MEM_READ_1:
    77                         dstval = *((uint8_t *)code->cmds[i].addr);
     77                        dstval = *((uint8_t *) code->cmds[i].addr);
    7878                        break;
    7979                case CMD_MEM_READ_2:
    80                         dstval = *((uint16_t *)code->cmds[i].addr);
     80                        dstval = *((uint16_t *) code->cmds[i].addr);
    8181                        break;
    8282                case CMD_MEM_READ_4:
    83                         dstval = *((uint32_t *)code->cmds[i].addr);
     83                        dstval = *((uint32_t *) code->cmds[i].addr);
    8484                        break;
    8585                case CMD_MEM_READ_8:
    86                         dstval = *((uint64_t *)code->cmds[i].addr);
     86                        dstval = *((uint64_t *) code->cmds[i].addr);
    8787                        break;
    8888                case CMD_MEM_WRITE_1:
    89                         *((uint8_t *)code->cmds[i].addr) = code->cmds[i].value;
     89                        *((uint8_t *) code->cmds[i].addr) = code->cmds[i].value;
    9090                        break;
    9191                case CMD_MEM_WRITE_2:
    92                         *((uint16_t *)code->cmds[i].addr) = code->cmds[i].value;
     92                        *((uint16_t *) code->cmds[i].addr) = code->cmds[i].value;
    9393                        break;
    9494                case CMD_MEM_WRITE_4:
    95                         *((uint32_t *)code->cmds[i].addr) = code->cmds[i].value;
     95                        *((uint32_t *) code->cmds[i].addr) = code->cmds[i].value;
    9696                        break;
    9797                case CMD_MEM_WRITE_8:
    98                         *((uint64_t *)code->cmds[i].addr) = code->cmds[i].value;
     98                        *((uint64_t *) code->cmds[i].addr) = code->cmds[i].value;
    9999                        break;
    100100#if defined(ia32) || defined(amd64)
    101101                case CMD_PORT_READ_1:
    102                         dstval = inb((long)code->cmds[i].addr);
     102                        dstval = inb((long) code->cmds[i].addr);
    103103                        break;
    104104                case CMD_PORT_WRITE_1:
    105                         outb((long)code->cmds[i].addr, code->cmds[i].value);
     105                        outb((long) code->cmds[i].addr, code->cmds[i].value);
    106106                        break;
    107107#endif
     
    125125}
    126126
     127/** Free top-half pseudocode.
     128 *
     129 * @param code          Pointer to the top-half pseudocode.
     130 */
    127131static void code_free(irq_code_t *code)
    128132{
     
    133137}
    134138
    135 static irq_code_t * code_from_uspace(irq_code_t *ucode)
     139/** Copy top-half pseudocode from userspace into the kernel.
     140 *
     141 * @param ucode         Userspace address of the top-half pseudocode.
     142 *
     143 * @return              Kernel address of the copied pseudocode.
     144 */
     145static irq_code_t *code_from_uspace(irq_code_t *ucode)
    136146{
    137147        irq_code_t *code;
     
    151161        }
    152162        ucmds = code->cmds;
    153         code->cmds = malloc(sizeof(code->cmds[0]) * (code->cmdcount), 0);
    154         rc = copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount));
     163        code->cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0);
     164        rc = copy_from_uspace(code->cmds, ucmds,
     165            sizeof(code->cmds[0]) * code->cmdcount);
    155166        if (rc != 0) {
    156167                free(code->cmds);
     
    164175/** Unregister task from IRQ notification.
    165176 *
    166  * @param box Answerbox associated with the notification.
    167  * @param inr IRQ numbe.
    168  * @param devno Device number.
     177 * @param box           Answerbox associated with the notification.
     178 * @param inr           IRQ number.
     179 * @param devno         Device number.
    169180 */
    170181void ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
     
    196207/** Register an answerbox as a receiving end for IRQ notifications.
    197208 *
    198  * @param box Receiving answerbox.
    199  * @param inr IRQ number.
    200  * @param devno Device number.
    201  * @param method Method to be associated with the notification.
    202  * @param ucode Uspace pointer to top-half pseudocode.
    203  *
    204  * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.
    205  */
    206 int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, unative_t method, irq_code_t *ucode)
     209 * @param box           Receiving answerbox.
     210 * @param inr           IRQ number.
     211 * @param devno         Device number.
     212 * @param method        Method to be associated with the notification.
     213 * @param ucode         Uspace pointer to top-half pseudocode.
     214 *
     215 * @return              EBADMEM, ENOENT or EEXISTS on failure or 0 on success.
     216 */
     217int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno,
     218    unative_t method, irq_code_t *ucode)
    207219{
    208220        ipl_t ipl;
     
    214226                if (!code)
    215227                        return EBADMEM;
    216         } else
     228        } else {
    217229                code = NULL;
     230        }
    218231
    219232        ipl = interrupts_disable();
     
    248261}
    249262
    250 /** Add call to proper answerbox queue.
     263/** Add a call to the proper answerbox queue.
    251264 *
    252265 * Assume irq->lock is locked.
    253266 *
     267 * @param irq           IRQ structure referencing the target answerbox.
     268 * @param call          IRQ notification call.
    254269 */
    255270static void send_call(irq_t *irq, call_t *call)
     
    262277}
    263278
    264 /** Send notification message
    265  *
     279/** Send notification message.
     280 *
     281 * @param irq           IRQ structure.
     282 * @param a1            Driver-specific payload argument.
     283 * @param a2            Driver-specific payload argument.
     284 * @param a3            Driver-specific payload argument.
    266285 */
    267286void ipc_irq_send_msg(irq_t *irq, unative_t a1, unative_t a2, unative_t a3)
     
    290309}
    291310
    292 /** Notify task that an irq had occurred.
     311/** Notify a task that an IRQ had occurred.
    293312 *
    294313 * We expect interrupts to be disabled and the irq->lock already held.
     314 *
     315 * @param irq           IRQ structure.
    295316 */
    296317void ipc_irq_send_notif(irq_t *irq)
     
    324345 * send notifications to it.
    325346 *
    326  * @param box Answerbox for which we want to carry out the cleanup.
     347 * @param box           Answerbox for which we want to carry out the cleanup.
    327348 */
    328349void ipc_irq_cleanup(answerbox_t *box)
Note: See TracChangeset for help on using the changeset viewer.