Subversion Repositories HelenOS-historic

Rev

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

Rev 1489 Rev 1518
Line 157... Line 157...
157
static void got_answer(void *private, int retval, ipc_call_t *data)
157
static void got_answer(void *private, int retval, ipc_call_t *data)
158
{
158
{
159
    printf("Retval: %d...%s...%zX, %zX\n", retval, private,
159
    printf("Retval: %d...%s...%zX, %zX\n", retval, private,
160
           IPC_GET_ARG1(*data), IPC_GET_ARG2(*data));
160
           IPC_GET_ARG1(*data), IPC_GET_ARG2(*data));
161
}
161
}
162
static void test_async_ipc(void)
-
 
163
{
-
 
164
    ipc_call_t data;
-
 
165
    int i;
-
 
166
 
-
 
167
    printf("Sending ping\n");
-
 
168
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
-
 
169
             "Pong1", got_answer);
-
 
170
    ipc_call_async_2(PHONE_NS, NS_PING, 2, 0xbeefbee4,
-
 
171
             "Pong2", got_answer);
-
 
172
    ipc_call_async_2(PHONE_NS, NS_PING, 3, 0xbeefbee4,
-
 
173
             "Pong3", got_answer);
-
 
174
    ipc_call_async_2(PHONE_NS, NS_PING, 4, 0xbeefbee4,
-
 
175
             "Pong4", got_answer);
-
 
176
    ipc_call_async_2(PHONE_NS, NS_PING, 5, 0xbeefbee4,
-
 
177
             "Pong5", got_answer);
-
 
178
    ipc_call_async_2(PHONE_NS, NS_PING, 6, 0xbeefbee4,
-
 
179
             "Pong6", got_answer);
-
 
180
    printf("Waiting forever...\n");
-
 
181
    for (i=0; i<100;i++)
-
 
182
        printf(".");
-
 
183
    printf("\n");
-
 
184
    ipc_wait_for_call(&data);
-
 
185
    printf("Received call???\n");
-
 
186
}
-
 
187
 
162
 
188
 
163
 
189
static void got_answer_2(void *private, int retval, ipc_call_t *data)
164
static void got_answer_2(void *private, int retval, ipc_call_t *data)
190
{
165
{
191
    printf("Pong\n");
166
    printf("Pong\n");
192
}
167
}
193
static void test_advanced_ipc(void)
-
 
194
{
-
 
195
    int res;
-
 
196
    ipcarg_t phonead;
-
 
197
    ipc_callid_t callid;
-
 
198
    ipc_call_t data;
-
 
199
    int i;
-
 
200
 
-
 
201
    printf("Asking 0 to connect to me...\n");
-
 
202
    res = ipc_connect_to_me(0, 1, 2, &phonead);
-
 
203
    printf("Result: %d - phonead: %llu\n", res, phonead);
-
 
204
    for (i=0; i < 100; i++) {
-
 
205
        printf("----------------\n");
-
 
206
        ipc_call_async(PHONE_NS, NS_PING_SVC, 0, "prov",
-
 
207
                   got_answer_2);
-
 
208
        callid = ipc_wait_for_call(&data);
-
 
209
        printf("Received ping\n");
-
 
210
        ipc_answer_fast(callid, 0, 0, 0);
-
 
211
    }
-
 
212
//  callid = ipc_wait_for_call(&data, NULL);
-
 
213
}
-
 
214
 
168
 
215
static void test_connection_ipc(void)
169
static void test_connection_ipc(void)
216
{
170
{
217
    int res;
171
    int res;
218
    ipcarg_t result;
172
    ipcarg_t result;
Line 225... Line 179...
225
    res = ipc_call_sync(res, NS_PING, 0xbeef,&result);
179
    res = ipc_call_sync(res, NS_PING, 0xbeef,&result);
226
    printf("Retval: %d - received: %X\n", res, result);
180
    printf("Retval: %d - received: %X\n", res, result);
227
   
181
   
228
}
182
}
229
 
183
 
230
static void test_hangup(void)
-
 
231
{
-
 
232
    int phoneid;
-
 
233
    ipc_call_t data;
-
 
234
    ipc_callid_t callid;
-
 
235
    int i;
-
 
236
 
-
 
237
    printf("Starting connect...\n");
-
 
238
    phoneid = ipc_connect_me_to(PHONE_NS, 10, 20);
-
 
239
    printf("Phoneid: %d, pinging\n", phoneid);
-
 
240
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
-
 
241
             "Pong1", got_answer);
-
 
242
    printf("Hangin up\n");
-
 
243
    ipc_hangup(phoneid);
-
 
244
    printf("Connecting\n");
-
 
245
    phoneid = ipc_connect_me_to(PHONE_NS, 10, 20);
-
 
246
    printf("Newphid: %d\n", phoneid);
-
 
247
    for (i=0; i < 1000; i++) {
-
 
248
        if ((callid=ipc_trywait_for_call(&data)))
-
 
249
            printf("callid: %d\n");
-
 
250
    }
-
 
251
    printf("New new phoneid: %d\n", ipc_connect_me_to(PHONE_NS, 10, 20));
-
 
252
}
-
 
253
 
-
 
254
static void test_slam(void)
-
 
255
{
-
 
256
    int i;
-
 
257
    ipc_call_t data;
-
 
258
    ipc_callid_t callid;
-
 
259
 
-
 
260
    printf("ping");
-
 
261
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
-
 
262
             "Pong1", got_answer);
-
 
263
    printf("slam");
-
 
264
    ipc_call_async_2(PHONE_NS, NS_HANGUP, 1, 0xbeefbee2,
-
 
265
             "Hang", got_answer);
-
 
266
    printf("ping2\n");
-
 
267
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
-
 
268
             "Ping2", got_answer);
-
 
269
   
-
 
270
    for (i=0; i < 1000; i++) {
-
 
271
        if ((callid=ipc_trywait_for_call(&data)))
-
 
272
            printf("callid: %d\n");
-
 
273
    }
-
 
274
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
-
 
275
             "Pong1", got_answer);
-
 
276
    printf("Closing file\n");
-
 
277
    ipc_hangup(PHONE_NS);
-
 
278
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
-
 
279
             "Pong1", got_answer);
-
 
280
    ipc_wait_for_call(&data);
-
 
281
}
-
 
282
 
-
 
283
static int ptest(void *arg)
184
static int ptest(void *arg)
284
{
185
{
285
    stage = 1;
186
    stage = 1;
286
    printf("Pseudo thread stage%d.\n", stage);
187
    printf("Pseudo thread stage%d.\n", stage);
287
    stage++;
188
    stage++;