Subversion Repositories HelenOS

Rev

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

Rev 4420 Rev 4537
Line 97... Line 97...
97
    int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
97
    int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
98
   
98
   
99
    if (phone < 0)
99
    if (phone < 0)
100
        return phone;
100
        return phone;
101
   
101
   
-
 
102
    async_serialize_start();
-
 
103
   
102
    ipc_call_t answer;
104
    ipc_call_t answer;
103
    aid_t req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
105
    aid_t req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
104
   
106
   
105
    ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1);
107
    ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1);
106
   
108
   
107
    if (retval != EOK) {
109
    if (retval != EOK) {
108
        async_wait_for(req, NULL);
110
        async_wait_for(req, NULL);
-
 
111
        async_serialize_end();
109
        return -1;
112
        return -1;
110
    }
113
    }
111
   
114
   
112
    async_set_client_connection(conn);
115
    async_set_client_connection(conn);
113
   
116
   
114
    ipcarg_t callback_phonehash;
117
    ipcarg_t callback_phonehash;
115
    ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
118
    ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
116
    async_wait_for(req, &retval);
119
    async_wait_for(req, &retval);
117
   
120
   
-
 
121
    async_serialize_end();
-
 
122
   
118
    return retval;
123
    return retval;
119
}
124
}
120
 
125
 
121
/** Register new device.
126
/** Register new device.
122
 *
127
 *
Line 129... Line 134...
129
    int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
134
    int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
130
   
135
   
131
    if (phone < 0)
136
    if (phone < 0)
132
        return phone;
137
        return phone;
133
   
138
   
-
 
139
    async_serialize_start();
-
 
140
   
134
    ipc_call_t answer;
141
    ipc_call_t answer;
135
    aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, 0, 0,
142
    aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, 0, 0,
136
        &answer);
143
        &answer);
137
   
144
   
138
    ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1);
145
    ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1);
139
   
146
   
140
    if (retval != EOK) {
147
    if (retval != EOK) {
141
        async_wait_for(req, NULL);
148
        async_wait_for(req, NULL);
-
 
149
        async_serialize_end();
142
        return retval;
150
        return retval;
143
    }
151
    }
144
   
152
   
145
    async_wait_for(req, &retval);
153
    async_wait_for(req, &retval);
146
   
154
   
-
 
155
    async_serialize_end();
-
 
156
   
147
    if (retval != EOK) {
157
    if (retval != EOK) {
148
        if (handle != NULL)
158
        if (handle != NULL)
149
            *handle = -1;
159
            *handle = -1;
150
        return retval;
160
        return retval;
151
    }
161
    }
Line 161... Line 171...
161
    int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
171
    int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
162
   
172
   
163
    if (phone < 0)
173
    if (phone < 0)
164
        return phone;
174
        return phone;
165
   
175
   
-
 
176
    async_serialize_start();
-
 
177
   
166
    ipc_call_t answer;
178
    ipc_call_t answer;
167
    aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, flags, 0,
179
    aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, flags, 0,
168
        &answer);
180
        &answer);
169
   
181
   
170
    ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1);
182
    ipcarg_t retval = ipc_data_write_start(phone, name, str_size(name) + 1);
171
   
183
   
172
    if (retval != EOK) {
184
    if (retval != EOK) {
173
        async_wait_for(req, NULL);
185
        async_wait_for(req, NULL);
-
 
186
        async_serialize_end();
174
        return retval;
187
        return retval;
175
    }
188
    }
176
   
189
   
177
    async_wait_for(req, &retval);
190
    async_wait_for(req, &retval);
178
   
191
   
-
 
192
    async_serialize_end();
-
 
193
   
179
    if (retval != EOK) {
194
    if (retval != EOK) {
180
        if (handle != NULL)
195
        if (handle != NULL)
181
            *handle = -1;
196
            *handle = -1;
182
        return retval;
197
        return retval;
183
    }
198
    }
Line 209... Line 224...
209
   
224
   
210
    if (phone < 0)
225
    if (phone < 0)
211
        return 0;
226
        return 0;
212
   
227
   
213
    ipcarg_t count;
228
    ipcarg_t count;
214
    int retval = ipc_call_sync_0_1(phone, DEVMAP_DEVICE_GET_COUNT, &count);
229
    int retval = async_req_0_1(phone, DEVMAP_DEVICE_GET_COUNT, &count);
215
    if (retval != EOK)
230
    if (retval != EOK)
216
        return 0;
231
        return 0;
217
   
232
   
218
    return count;
233
    return count;
219
}
234
}
Line 223... Line 238...
223
    int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
238
    int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
224
   
239
   
225
    if (phone < 0)
240
    if (phone < 0)
226
        return 0;
241
        return 0;
227
   
242
   
-
 
243
    async_serialize_start();
-
 
244
   
228
    ipc_call_t answer;
245
    ipc_call_t answer;
229
    aid_t req = async_send_0(phone, DEVMAP_DEVICE_GET_DEVICES, &answer);
246
    aid_t req = async_send_0(phone, DEVMAP_DEVICE_GET_DEVICES, &answer);
230
   
247
   
231
    ipcarg_t retval = ipc_data_read_start(phone, data, count * sizeof(dev_desc_t));
248
    ipcarg_t retval = ipc_data_read_start(phone, data, count * sizeof(dev_desc_t));
232
   
249
   
233
    if (retval != EOK) {
250
    if (retval != EOK) {
234
        async_wait_for(req, NULL);
251
        async_wait_for(req, NULL);
-
 
252
        async_serialize_end();
235
        return 0;
253
        return 0;
236
    }
254
    }
237
   
255
   
238
    async_wait_for(req, &retval);
256
    async_wait_for(req, &retval);
239
   
257
   
-
 
258
    async_serialize_end();
-
 
259
   
240
    if (retval != EOK)
260
    if (retval != EOK)
241
        return 0;
261
        return 0;
242
   
262
   
243
    return IPC_GET_ARG1(answer);
263
    return IPC_GET_ARG1(answer);
244
}
264
}