[3eddaff] | 1 | /*
|
---|
| 2 | * Copyright (C) 2005 Martin Decky
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[350514c] | 29 | #include "version.h"
|
---|
[38edb96] | 30 | #include <ipc/ipc.h>
|
---|
| 31 | #include <ipc/services.h>
|
---|
| 32 | #include <ipc/ns.h>
|
---|
[00c4994] | 33 | #include <stdio.h>
|
---|
| 34 | #include <unistd.h>
|
---|
| 35 | #include <stdlib.h>
|
---|
[c05290e] | 36 | #include <thread.h>
|
---|
[f30e6a0b] | 37 | #include <task.h>
|
---|
[29a9f62] | 38 | #include <psthread.h>
|
---|
[1cef26f] | 39 | #include <futex.h>
|
---|
[5a4c754] | 40 | #include <as.h>
|
---|
[fa3561f] | 41 | #include <ddi.h>
|
---|
[8a568e3] | 42 | #include <string.h>
|
---|
[250717cc] | 43 | #include <errno.h>
|
---|
[51d6f80] | 44 | #include <kbd.h>
|
---|
[afa6e74] | 45 | #include <ipc/fb.h>
|
---|
[01ff41c] | 46 | #include <async.h>
|
---|
[f25b73d6] | 47 | #include <sys/time.h>
|
---|
[936351c1] | 48 |
|
---|
[7048773] | 49 | int a;
|
---|
[1cef26f] | 50 | atomic_t ftx;
|
---|
[7048773] | 51 |
|
---|
[0319a8f6] | 52 | int __thread stage;
|
---|
[c4c5de5] | 53 |
|
---|
[c05290e] | 54 | extern void utest(void *arg);
|
---|
| 55 | void utest(void *arg)
|
---|
| 56 | {
|
---|
[81e55099] | 57 | printf("Uspace thread started.\n");
|
---|
[1cef26f] | 58 | if (futex_down(&ftx) < 0)
|
---|
| 59 | printf("Futex failed.\n");
|
---|
| 60 | if (futex_up(&ftx) < 0)
|
---|
| 61 | printf("Futex failed.\n");
|
---|
| 62 |
|
---|
| 63 | printf("%s in good condition.\n", __FUNCTION__);
|
---|
| 64 |
|
---|
[c05290e] | 65 | for (;;)
|
---|
| 66 | ;
|
---|
| 67 | }
|
---|
[48627ab] | 68 |
|
---|
[523fad8] | 69 | /* test different parameters types and modifiers */
|
---|
[56972c81] | 70 | static void test_printf(void)
|
---|
| 71 | {
|
---|
| 72 | printf("Simple text.\n");
|
---|
| 73 | printf("Now insert '%s' string.\n","this");
|
---|
[11a4fbf] | 74 | printf("Signed formats on uns. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", 321, 321, 321, 321);
|
---|
| 75 | printf("Signed formats on sig. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", -321, -321, -321, -321);
|
---|
| 76 | printf("Signed with different sized: '%hhd', '%hd', '%d', '%ld', %lld;\n", -3, -32, -321, -32101l, -3210123ll);
|
---|
| 77 | printf("And now... '%hhd' byte! '%hd' word! '%d' int! \n", 11, 11111, 1111111111);
|
---|
| 78 | printf("Different bases: %#hx, %#hu, %#ho and %#hb\n", 123, 123, 123, 123);
|
---|
| 79 | printf("Different bases signed: %#hx, %#hu, %#ho and %#hb\n", -123, -123, -123, -123);
|
---|
| 80 | printf("'%llX' llX! Another '%llx' llx! \n", 0x1234567887654321ll, 0x1234567887654321ll);
|
---|
| 81 | printf("'%llX' with 64bit value and '%x' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 );
|
---|
| 82 | printf("'%llx' 64bit, '%x' 32bit, '%hhx' 8bit, '%hx' 16bit, '%llX' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, 0x1234567887654321ull, "Lovely string" );
|
---|
[48627ab] | 83 |
|
---|
[56972c81] | 84 | printf("Thats all, folks!\n");
|
---|
| 85 | }
|
---|
[48627ab] | 86 |
|
---|
[523fad8] | 87 | /* test width and precision modifiers */
|
---|
| 88 | static void test_printf2(void)
|
---|
| 89 | {
|
---|
| 90 | printf(" text 10.8s %*.*s \n", 5, 3, "text");
|
---|
| 91 | printf(" very long text 10.8s %10.8s \n", "very long text");
|
---|
| 92 | printf(" text 8.10s %8.10s \n", "text");
|
---|
| 93 | printf(" very long text 8.10s %8.10s \n", "very long text");
|
---|
| 94 |
|
---|
| 95 | printf(" char: c '%c', 3.2c '%3.2c', -3.2c '%-3.2c', 2.3c '%2.3c', -2.3c '%-2.3c' \n",'a', 'b', 'c', 'd', 'e' );
|
---|
| 96 | printf(" int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",1, 1, 1, 1, 1 );
|
---|
| 97 | printf(" -int: d '%d', 3.2d '%3.2d', -3.2d '%-3.2d', 2.3d '%2.3d', -2.3d '%-2.3d' \n",-1, -1, -1, -1, -1 );
|
---|
| 98 | printf(" 0xint: x '%x', 5.3x '%#5.3x', -5.3x '%#-5.3x', 3.5x '%#3.5x', -3.5x '%#-3.5x' \n",17, 17, 17, 17, 17 );
|
---|
| 99 |
|
---|
| 100 | }
|
---|
[936351c1] | 101 |
|
---|
[5106e98] | 102 | extern char _heap;
|
---|
[4241683] | 103 | static void test_mremap(void)
|
---|
[00c4994] | 104 | {
|
---|
| 105 | printf("Writing to good memory\n");
|
---|
[d3b8c1f] | 106 | as_area_resize(&_heap, 120000, 0);
|
---|
[00c4994] | 107 | printf("%P\n", ((char *)&_heap));
|
---|
| 108 | printf("%P\n", ((char *)&_heap) + 80000);
|
---|
| 109 | *(((char *)&_heap) + 80000) = 10;
|
---|
| 110 | printf("Making small\n");
|
---|
[d3b8c1f] | 111 | as_area_resize(&_heap, 16000, 0);
|
---|
[00c4994] | 112 | printf("Failing..\n");
|
---|
| 113 | *((&_heap) + 80000) = 10;
|
---|
| 114 |
|
---|
| 115 | printf("memory done\n");
|
---|
| 116 | }
|
---|
| 117 | /*
|
---|
| 118 | static void test_sbrk(void)
|
---|
| 119 | {
|
---|
| 120 | printf("Writing to good memory\n");
|
---|
| 121 | printf("Got: %P\n", sbrk(120000));
|
---|
| 122 | printf("%P\n", ((char *)&_heap));
|
---|
| 123 | printf("%P\n", ((char *)&_heap) + 80000);
|
---|
| 124 | *(((char *)&_heap) + 80000) = 10;
|
---|
| 125 | printf("Making small, got: %P\n",sbrk(-120000));
|
---|
| 126 | printf("Testing access to heap\n");
|
---|
| 127 | _heap = 10;
|
---|
| 128 | printf("Failing..\n");
|
---|
| 129 | *((&_heap) + 80000) = 10;
|
---|
| 130 |
|
---|
| 131 | printf("memory done\n");
|
---|
| 132 | }
|
---|
| 133 | */
|
---|
| 134 | /*
|
---|
| 135 | static void test_malloc(void)
|
---|
| 136 | {
|
---|
| 137 | char *data;
|
---|
| 138 |
|
---|
| 139 | data = malloc(10);
|
---|
| 140 | printf("Heap: %P, data: %P\n", &_heap, data);
|
---|
| 141 | data[0] = 'a';
|
---|
| 142 | free(data);
|
---|
| 143 | }
|
---|
| 144 | */
|
---|
[3eddaff] | 145 |
|
---|
[5106e98] | 146 |
|
---|
| 147 | static void test_ping(void)
|
---|
| 148 | {
|
---|
| 149 | ipcarg_t result;
|
---|
| 150 | int retval;
|
---|
| 151 |
|
---|
[4c61e60] | 152 | printf("Pinging\n");
|
---|
[5106e98] | 153 | retval = ipc_call_sync(PHONE_NS, NS_PING, 0xbeef,&result);
|
---|
| 154 | printf("Retval: %d - received: %P\n", retval, result);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[4c61e60] | 157 | static void got_answer(void *private, int retval, ipc_call_t *data)
|
---|
[936351c1] | 158 | {
|
---|
[11a4fbf] | 159 | printf("Retval: %d...%s...%zX, %zX\n", retval, private,
|
---|
[936351c1] | 160 | IPC_GET_ARG1(*data), IPC_GET_ARG2(*data));
|
---|
| 161 | }
|
---|
| 162 | static void test_async_ipc(void)
|
---|
| 163 | {
|
---|
[5106e98] | 164 | ipc_call_t data;
|
---|
[936351c1] | 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");
|
---|
[04a73cdf] | 184 | ipc_wait_for_call(&data);
|
---|
[936351c1] | 185 | printf("Received call???\n");
|
---|
| 186 | }
|
---|
| 187 |
|
---|
[5106e98] | 188 |
|
---|
[4c61e60] | 189 | static void got_answer_2(void *private, int retval, ipc_call_t *data)
|
---|
[5106e98] | 190 | {
|
---|
| 191 | printf("Pong\n");
|
---|
| 192 | }
|
---|
| 193 | static void test_advanced_ipc(void)
|
---|
[3eddaff] | 194 | {
|
---|
[5106e98] | 195 | int res;
|
---|
[4c61e60] | 196 | ipcarg_t phonead;
|
---|
[5106e98] | 197 | ipc_callid_t callid;
|
---|
| 198 | ipc_call_t data;
|
---|
[11eae82] | 199 | int i;
|
---|
[936351c1] | 200 |
|
---|
[5106e98] | 201 | printf("Asking 0 to connect to me...\n");
|
---|
[4c61e60] | 202 | res = ipc_connect_to_me(0, 1, 2, &phonead);
|
---|
| 203 | printf("Result: %d - phonead: %llu\n", res, phonead);
|
---|
[11eae82] | 204 | for (i=0; i < 100; i++) {
|
---|
[5106e98] | 205 | printf("----------------\n");
|
---|
| 206 | ipc_call_async(PHONE_NS, NS_PING_SVC, 0, "prov",
|
---|
| 207 | got_answer_2);
|
---|
[04a73cdf] | 208 | callid = ipc_wait_for_call(&data);
|
---|
[5106e98] | 209 | printf("Received ping\n");
|
---|
[250717cc] | 210 | ipc_answer_fast(callid, 0, 0, 0);
|
---|
[11eae82] | 211 | }
|
---|
[7048773] | 212 | // callid = ipc_wait_for_call(&data, NULL);
|
---|
[11eae82] | 213 | }
|
---|
| 214 |
|
---|
| 215 | static void test_connection_ipc(void)
|
---|
| 216 | {
|
---|
| 217 | int res;
|
---|
| 218 | ipcarg_t result;
|
---|
[4c61e60] | 219 | int phoneid;
|
---|
[11eae82] | 220 |
|
---|
| 221 | printf("Starting connect...\n");
|
---|
| 222 | res = ipc_connect_me_to(PHONE_NS, 10, 20);
|
---|
| 223 | printf("Connected: %d\n", res);
|
---|
| 224 | printf("pinging.\n");
|
---|
| 225 | res = ipc_call_sync(res, NS_PING, 0xbeef,&result);
|
---|
[7048773] | 226 | printf("Retval: %d - received: %X\n", res, result);
|
---|
| 227 |
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 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++) {
|
---|
[04a73cdf] | 248 | if ((callid=ipc_trywait_for_call(&data)))
|
---|
[7048773] | 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);
|
---|
[11eae82] | 269 |
|
---|
[7048773] | 270 | for (i=0; i < 1000; i++) {
|
---|
[04a73cdf] | 271 | if ((callid=ipc_trywait_for_call(&data)))
|
---|
[7048773] | 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);
|
---|
[04a73cdf] | 280 | ipc_wait_for_call(&data);
|
---|
[5106e98] | 281 | }
|
---|
| 282 |
|
---|
[29a9f62] | 283 | static int ptest(void *arg)
|
---|
| 284 | {
|
---|
[0319a8f6] | 285 | stage = 1;
|
---|
| 286 | printf("Pseudo thread stage%d.\n", stage);
|
---|
| 287 | stage++;
|
---|
[520492a] | 288 | psthread_schedule_next();
|
---|
[0319a8f6] | 289 | printf("Pseudo thread stage%d.\n", stage);
|
---|
| 290 | stage++;
|
---|
[520492a] | 291 | psthread_schedule_next();
|
---|
[0319a8f6] | 292 | printf("Pseudo thread stage%d.\n", stage);
|
---|
[520492a] | 293 | psthread_schedule_next();
|
---|
[0319a8f6] | 294 | stage++;
|
---|
| 295 | printf("Pseudo thread stage%d.\n", stage);
|
---|
[520492a] | 296 | psthread_schedule_next();
|
---|
| 297 | printf("Pseudo thread exiting.\n");
|
---|
[29a9f62] | 298 | return 0;
|
---|
| 299 | }
|
---|
[1cef26f] | 300 |
|
---|
[51d6f80] | 301 | static void test_kbd()
|
---|
| 302 | {
|
---|
| 303 | int res;
|
---|
| 304 | ipcarg_t result;
|
---|
| 305 | int phoneid;
|
---|
| 306 |
|
---|
| 307 | printf("Test: Starting connect...\n");
|
---|
[51c1b003] | 308 | while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) {
|
---|
[51d6f80] | 309 | };
|
---|
| 310 |
|
---|
| 311 | printf("Test: Connected: %d\n", res);
|
---|
| 312 | printf("Test: pinging.\n");
|
---|
[51c1b003] | 313 | /* while (1) {
|
---|
| 314 |
|
---|
[51d6f80] | 315 | res = ipc_call_sync(phoneid, KBD_GETCHAR, 0xbeef,&result);
|
---|
| 316 | // printf("Test: Retval: %d - received: %c\n", res, result);
|
---|
| 317 | printf("%c", result);
|
---|
| 318 | }
|
---|
[51c1b003] | 319 | */
|
---|
[51d6f80] | 320 | printf("Test: Hangin up\n");
|
---|
| 321 | ipc_hangup(phoneid);
|
---|
| 322 | }
|
---|
| 323 |
|
---|
[01ff41c] | 324 | static void test_async_kbd()
|
---|
| 325 | {
|
---|
| 326 | int res;
|
---|
| 327 | ipcarg_t result;
|
---|
| 328 | ipc_call_t kbddata;
|
---|
| 329 | int phoneid;
|
---|
| 330 | aid_t aid;
|
---|
| 331 |
|
---|
| 332 | printf("Test: Starting connect...\n");
|
---|
| 333 | while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
|
---|
| 334 | };
|
---|
| 335 |
|
---|
| 336 | printf("Test: Connected: %d\n", res);
|
---|
| 337 | printf("Test: pinging.\n");
|
---|
[c042bdd] | 338 |
|
---|
[51c1b003] | 339 |
|
---|
[01ff41c] | 340 | while (1) {
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | printf("Test: Hangin up\n");
|
---|
| 344 | ipc_hangup(phoneid);
|
---|
| 345 | }
|
---|
| 346 |
|
---|
[250717cc] | 347 | static void test_pci()
|
---|
| 348 | {
|
---|
| 349 | int phone;
|
---|
| 350 | while ((phone = ipc_connect_me_to(PHONE_NS, SERVICE_PCI, 0)) < 0)
|
---|
| 351 | ;
|
---|
| 352 | printf("Connected to PCI service through phone %d.\n", phone);
|
---|
| 353 | }
|
---|
| 354 |
|
---|
[6efe0ddf] | 355 | static int test_as_area_send()
|
---|
[8a568e3] | 356 | {
|
---|
[6efe0ddf] | 357 | char *as_area;
|
---|
[8a568e3] | 358 | int retval;
|
---|
| 359 | ipcarg_t result;
|
---|
| 360 |
|
---|
[6efe0ddf] | 361 | as_area = as_area_create((void *)(1024*1024), 16384, AS_AREA_READ | AS_AREA_WRITE);
|
---|
| 362 | if (!as_area) {
|
---|
| 363 | printf("Error creating as_area.\n");
|
---|
[8a568e3] | 364 | return 0;
|
---|
| 365 | }
|
---|
| 366 |
|
---|
[6efe0ddf] | 367 | memcpy(as_area, "Hello world.\n", 14);
|
---|
[8a568e3] | 368 |
|
---|
[abda850] | 369 | retval = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_SEND, (sysarg_t) as_area, 0, AS_AREA_READ,
|
---|
| 370 | NULL, NULL, NULL);
|
---|
[8a568e3] | 371 | if (retval) {
|
---|
[6efe0ddf] | 372 | printf("AS_AREA_SEND failed.\n");
|
---|
[8a568e3] | 373 | return 0;
|
---|
| 374 | }
|
---|
| 375 | printf("Done\n");
|
---|
| 376 | }
|
---|
| 377 |
|
---|
[afa6e74] | 378 | static void test_fb()
|
---|
| 379 | {
|
---|
| 380 | int res;
|
---|
| 381 | ipcarg_t result;
|
---|
| 382 | int phoneid;
|
---|
| 383 |
|
---|
| 384 | // printf("Test: Starting connect...\n");
|
---|
| 385 |
|
---|
| 386 | phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0);
|
---|
| 387 |
|
---|
| 388 | while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
|
---|
| 389 | volatile int a;
|
---|
| 390 | for(a=0;a<1048576;a++);
|
---|
| 391 | };
|
---|
| 392 |
|
---|
| 393 | // printf("Test: Connected: %d\n", res);
|
---|
| 394 | // printf("Test: pinging.\n");
|
---|
| 395 | while (1) {
|
---|
| 396 | res = ipc_call_sync(phoneid, FB_GET_VFB, 0xbeef,&result);
|
---|
| 397 | // printf("Test: Retval: %d - received: %c\n", res, result);
|
---|
| 398 | // printf("%c", result);
|
---|
| 399 | }
|
---|
| 400 |
|
---|
| 401 | // printf("Test: Hangin up\n");
|
---|
| 402 | ipc_hangup(phoneid);
|
---|
| 403 | }
|
---|
| 404 |
|
---|
[0b99e40] | 405 | static void test_time(void)
|
---|
| 406 | {
|
---|
| 407 | int rc;
|
---|
| 408 | struct timeval tv;
|
---|
| 409 | struct timezone tz;
|
---|
| 410 |
|
---|
| 411 | while (1) {
|
---|
| 412 | rc = gettimeofday(&tv, &tz);
|
---|
| 413 | printf("Rc: %d, Secs: %d, Usecs: %d\n", rc, tv.tv_sec,
|
---|
| 414 | tv.tv_usec);
|
---|
| 415 | }
|
---|
| 416 | }
|
---|
[afa6e74] | 417 |
|
---|
[5106e98] | 418 | int main(int argc, char *argv[])
|
---|
| 419 | {
|
---|
[29a9f62] | 420 | pstid_t ptid;
|
---|
[c05290e] | 421 | int tid;
|
---|
[523fad8] | 422 |
|
---|
[afa6e74] | 423 | // version_print();
|
---|
[b419162] | 424 |
|
---|
[86d05fae] | 425 | // test_printf();
|
---|
[523fad8] | 426 | // test_printf2();
|
---|
[5106e98] | 427 | // test_ping();
|
---|
| 428 | // test_async_ipc();
|
---|
[11eae82] | 429 | // test_advanced_ipc();
|
---|
[7048773] | 430 | // test_connection_ipc();
|
---|
| 431 | // test_hangup();
|
---|
[4c61e60] | 432 | // test_slam();
|
---|
[01ff41c] | 433 | // test_as_area_send();
|
---|
[a1c7827] | 434 | // test_pci();
|
---|
[01ff41c] | 435 | // test_kbd();
|
---|
[c042bdd] | 436 | // test_time();
|
---|
| 437 | test_async_kbd();
|
---|
[afa6e74] | 438 | // test_fb();
|
---|
| 439 |
|
---|
| 440 | printf("Hello\nThis is Init\n\nBye.");
|
---|
| 441 |
|
---|
[51d6f80] | 442 |
|
---|
[8a568e3] | 443 | /*
|
---|
[d3b8c1f] | 444 | printf("Userspace task, taskid=%llX\n", task_get_id());
|
---|
[f30e6a0b] | 445 |
|
---|
[1cef26f] | 446 | futex_initialize(&ftx, 1);
|
---|
| 447 | if (futex_down(&ftx) < 0)
|
---|
| 448 | printf("Futex failed.\n");
|
---|
| 449 | if (futex_up(&ftx) < 0)
|
---|
| 450 | printf("Futex failed.\n");
|
---|
| 451 |
|
---|
| 452 | if (futex_down(&ftx) < 0)
|
---|
| 453 | printf("Futex failed.\n");
|
---|
[0319a8f6] | 454 |
|
---|
[86d05fae] | 455 | if ((tid = thread_create(utest, NULL, "utest")) != -1) {
|
---|
| 456 | printf("Created thread tid=%d\n", tid);
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 | if ((tid = thread_create(utest, NULL, "utest")) != -1) {
|
---|
[4c61e60] | 460 | printf("Created thread tid=%d\n", tid);
|
---|
| 461 | }
|
---|
[0319a8f6] | 462 |
|
---|
[1cef26f] | 463 | int i;
|
---|
[250717cc] | 464 |
|
---|
[86d05fae] | 465 | for (i = 0; i < 50000000; i++)
|
---|
[1cef26f] | 466 | ;
|
---|
| 467 |
|
---|
| 468 | if (futex_up(&ftx) < 0)
|
---|
| 469 | printf("Futex failed.\n");
|
---|
| 470 |
|
---|
[c4c5de5] | 471 |
|
---|
[0319a8f6] | 472 | printf("Creating pseudo thread.\n");
|
---|
| 473 | stage = 1;
|
---|
[29a9f62] | 474 | ptid = psthread_create(ptest, NULL);
|
---|
[0319a8f6] | 475 | printf("Main thread stage%d.\n", stage);
|
---|
| 476 | stage++;
|
---|
[520492a] | 477 | psthread_schedule_next();;
|
---|
[0319a8f6] | 478 | printf("Main thread stage%d.\n", stage);
|
---|
| 479 | stage++;
|
---|
[520492a] | 480 | psthread_schedule_next();;
|
---|
[0319a8f6] | 481 | printf("Main thread stage%d.\n", stage);
|
---|
[520492a] | 482 |
|
---|
| 483 | psthread_join(ptid);
|
---|
[29a9f62] | 484 |
|
---|
[1cef26f] | 485 | printf("Main thread exiting.\n");
|
---|
[8a568e3] | 486 | */
|
---|
[250717cc] | 487 |
|
---|
[3eddaff] | 488 | return 0;
|
---|
| 489 | }
|
---|