Changeset 180255f in mainline


Ignore:
Timestamp:
2011-05-06T12:45:29Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
03cfda08
Parents:
561112f
Message:

Implement access to memory mapped register in irq pseudocode.

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ddi/irq.h

    r561112f r180255f  
    224224        /** Notification configuration structure. */
    225225        ipc_notif_cfg_t notif_cfg;
     226
     227        as_t *driver_as;
    226228} irq_t;
    227229
  • kernel/generic/src/ipc/irq.c

    r561112f r180255f  
    174174        irq->notif_cfg.code = code;
    175175        irq->notif_cfg.counter = 0;
     176        irq->driver_as = AS;
    176177       
    177178        /*
     
    364365                return IRQ_DECLINE;
    365366       
     367#define CMD_MEM_READ(target) \
     368do { \
     369        void *va = code->cmds[i].addr; \
     370        if (AS != irq->driver_as) \
     371                as_switch(AS, irq->driver_as); \
     372        printf("Copying data from address: %p.\n", va); \
     373        memcpy_from_uspace(&target, va, (sizeof(target))); \
     374        if (dstarg) \
     375                scratch[dstarg] = target; \
     376} while(0)
     377
     378#define CMD_MEM_WRITE(val) \
     379do { \
     380        void *va = code->cmds[i].addr; \
     381        if (AS != irq->driver_as) \
     382                as_switch(AS, irq->driver_as); \
     383        printf("Writing data to address: %p.\n", va); \
     384        memcpy_to_uspace(va, &val, sizeof(val)); \
     385} while (0)
     386
     387        as_t *current_as = AS;
    366388        size_t i;
    367389        for (i = 0; i < code->cmdcount; i++) {
     
    422444                        }
    423445                        break;
     446                case CMD_MEM_READ_8: {
     447                        uint8_t val;
     448                        CMD_MEM_READ(val);
     449                        break;
     450                        }
     451                case CMD_MEM_READ_16: {
     452                        uint16_t val;
     453                        CMD_MEM_READ(val);
     454                        break;
     455                        }
     456                case CMD_MEM_READ_32: {
     457                        uint32_t val;
     458                        CMD_MEM_READ(val);
     459                        printf("mem READ value: %x.\n", val);
     460                        break;
     461                        }
     462                case CMD_MEM_WRITE_8: {
     463                        uint8_t val = code->cmds[i].value;
     464                        CMD_MEM_WRITE(val);
     465                        break;
     466                        }
     467                case CMD_MEM_WRITE_16: {
     468                        uint16_t val = code->cmds[i].value;
     469                        CMD_MEM_WRITE(val);
     470                        break;
     471                        }
     472                case CMD_MEM_WRITE_32: {
     473                        uint32_t val = code->cmds[i].value;
     474                        CMD_MEM_WRITE(val);
     475                        break;
     476                        }
     477                case CMD_MEM_WRITE_A_8:
     478                        if (srcarg) {
     479                                uint8_t val = scratch[srcarg];
     480                                CMD_MEM_WRITE(val);
     481                        }
     482                        break;
     483                case CMD_MEM_WRITE_A_16:
     484                        if (srcarg) {
     485                                uint16_t val = scratch[srcarg];
     486                                CMD_MEM_WRITE(val);
     487                        }
     488                        break;
     489                case CMD_MEM_WRITE_A_32:
     490                        if (srcarg) {
     491                                uint32_t val = scratch[srcarg];
     492                                CMD_MEM_WRITE(val);
     493                        }
     494                        break;
    424495                case CMD_BTEST:
    425496                        if ((srcarg) && (dstarg)) {
     
    435506                        break;
    436507                case CMD_ACCEPT:
     508                        if (AS != current_as)
     509                                as_switch(AS, current_as);
    437510                        return IRQ_ACCEPT;
    438511                case CMD_DECLINE:
    439512                default:
     513                        if (AS != current_as)
     514                                as_switch(AS, current_as);
    440515                        return IRQ_DECLINE;
    441516                }
    442517        }
     518        if (AS != current_as)
     519                as_switch(AS, current_as);
    443520       
    444521        return IRQ_DECLINE;
Note: See TracChangeset for help on using the changeset viewer.