Subversion Repositories HelenOS-historic

Rev

Rev 1284 | Rev 1507 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1284 Rev 1288
Line 45... Line 45...
45
#include <mm/slab.h>
45
#include <mm/slab.h>
46
#include <errno.h>
46
#include <errno.h>
47
#include <ipc/ipc.h>
47
#include <ipc/ipc.h>
48
#include <ipc/irq.h>
48
#include <ipc/irq.h>
49
#include <atomic.h>
49
#include <atomic.h>
-
 
50
#include <syscall/copy.h>
50
 
51
 
51
typedef struct {
52
typedef struct {
52
    SPINLOCK_DECLARE(lock);
53
    SPINLOCK_DECLARE(lock);
53
    answerbox_t *box;
54
    answerbox_t *box;
54
    irq_code_t *code;
55
    irq_code_t *code;
Line 118... Line 119...
118
 
119
 
119
static irq_code_t * code_from_uspace(irq_code_t *ucode)
120
static irq_code_t * code_from_uspace(irq_code_t *ucode)
120
{
121
{
121
    irq_code_t *code;
122
    irq_code_t *code;
122
    irq_cmd_t *ucmds;
123
    irq_cmd_t *ucmds;
-
 
124
    int rc;
123
 
125
 
124
    code = malloc(sizeof(*code), 0);
126
    code = malloc(sizeof(*code), 0);
125
    copy_from_uspace(code, ucode, sizeof(*code));
127
    rc = copy_from_uspace(code, ucode, sizeof(*code));
-
 
128
    if (rc != 0) {
-
 
129
        free(code);
-
 
130
        return NULL;
-
 
131
    }
126
   
132
   
127
    if (code->cmdcount > IRQ_MAX_PROG_SIZE) {
133
    if (code->cmdcount > IRQ_MAX_PROG_SIZE) {
128
        free(code);
134
        free(code);
129
        return NULL;
135
        return NULL;
130
    }
136
    }
131
    ucmds = code->cmds;
137
    ucmds = code->cmds;
132
    code->cmds = malloc(sizeof(code->cmds[0]) * (code->cmdcount), 0);
138
    code->cmds = malloc(sizeof(code->cmds[0]) * (code->cmdcount), 0);
133
    copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount));
139
    rc = copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount));
-
 
140
    if (rc != 0) {
-
 
141
        free(code->cmds);
-
 
142
        free(code);
-
 
143
        return NULL;
-
 
144
    }
134
 
145
 
135
    return code;
146
    return code;
136
}
147
}
137
 
148
 
138
/** Unregister task from irq */
149
/** Unregister task from irq */