Rev 995 | Rev 1028 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 995 | Rev 999 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2005 Martin Decky |
2 | * Copyright (C) 2005 Martin Decky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
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 |
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. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
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 |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 |
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. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include "version.h" |
29 | #include "version.h" |
30 | #include <ipc.h> |
30 | #include <ipc.h> |
31 | #include <ns.h> |
31 | #include <ns.h> |
32 | #include <stdio.h> |
32 | #include <stdio.h> |
33 | #include <unistd.h> |
33 | #include <unistd.h> |
34 | #include <stdlib.h> |
34 | #include <stdlib.h> |
- | 35 | ||
35 | /* |
36 | /* |
36 | static void test_printf(void) |
37 | static void test_printf(void) |
37 | { |
38 | { |
38 | printf("Simple text.\n"); |
39 | printf("Simple text.\n"); |
39 | printf("Now insert '%s' string.\n","this"); |
40 | printf("Now insert '%s' string.\n","this"); |
40 | printf("We are brave enought to print numbers like %%d = '%d'\n", 0x123456); |
41 | printf("We are brave enought to print numbers like %%d = '%d'\n", 0x123456); |
41 | printf("And now... '%b' byte! '%w' word! '%W' Word! \n", 0x12, 0x1234, 0x1234); |
42 | printf("And now... '%b' byte! '%w' word! '%W' Word! \n", 0x12, 0x1234, 0x1234); |
42 | printf(" '%Q' Q! Another '%q' q! \n", 0x1234567887654321ll, 0x1234567887654321ll); |
43 | printf(" '%Q' Q! Another '%q' q! \n", 0x1234567887654321ll, 0x1234567887654321ll); |
43 | printf(" '%P' with 64bit value and '%p' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 ); |
44 | printf(" '%P' with 64bit value and '%p' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 ); |
44 | printf("Thats all, folks!\n"); |
45 | printf("Thats all, folks!\n"); |
45 | } |
46 | } |
46 | */ |
47 | */ |
- | 48 | ||
47 | /* |
49 | /* |
48 | static void test_mremap(void) |
50 | static void test_mremap(void) |
49 | { |
51 | { |
50 | printf("Writing to good memory\n"); |
52 | printf("Writing to good memory\n"); |
51 | mremap(&_heap, 120000, 0); |
53 | mremap(&_heap, 120000, 0); |
52 | printf("%P\n", ((char *)&_heap)); |
54 | printf("%P\n", ((char *)&_heap)); |
53 | printf("%P\n", ((char *)&_heap) + 80000); |
55 | printf("%P\n", ((char *)&_heap) + 80000); |
54 | *(((char *)&_heap) + 80000) = 10; |
56 | *(((char *)&_heap) + 80000) = 10; |
55 | printf("Making small\n"); |
57 | printf("Making small\n"); |
56 | mremap(&_heap, 16000, 0); |
58 | mremap(&_heap, 16000, 0); |
57 | printf("Failing..\n"); |
59 | printf("Failing..\n"); |
58 | *((&_heap) + 80000) = 10; |
60 | *((&_heap) + 80000) = 10; |
59 | 61 | ||
60 | printf("memory done\n"); |
62 | printf("memory done\n"); |
61 | } |
63 | } |
62 | */ |
64 | */ |
63 | /* |
65 | /* |
64 | static void test_sbrk(void) |
66 | static void test_sbrk(void) |
65 | { |
67 | { |
66 | printf("Writing to good memory\n"); |
68 | printf("Writing to good memory\n"); |
67 | printf("Got: %P\n", sbrk(120000)); |
69 | printf("Got: %P\n", sbrk(120000)); |
68 | printf("%P\n", ((char *)&_heap)); |
70 | printf("%P\n", ((char *)&_heap)); |
69 | printf("%P\n", ((char *)&_heap) + 80000); |
71 | printf("%P\n", ((char *)&_heap) + 80000); |
70 | *(((char *)&_heap) + 80000) = 10; |
72 | *(((char *)&_heap) + 80000) = 10; |
71 | printf("Making small, got: %P\n",sbrk(-120000)); |
73 | printf("Making small, got: %P\n",sbrk(-120000)); |
72 | printf("Testing access to heap\n"); |
74 | printf("Testing access to heap\n"); |
73 | _heap = 10; |
75 | _heap = 10; |
74 | printf("Failing..\n"); |
76 | printf("Failing..\n"); |
75 | *((&_heap) + 80000) = 10; |
77 | *((&_heap) + 80000) = 10; |
76 | 78 | ||
77 | printf("memory done\n"); |
79 | printf("memory done\n"); |
78 | } |
80 | } |
79 | */ |
81 | */ |
80 | /* |
82 | /* |
81 | static void test_malloc(void) |
83 | static void test_malloc(void) |
82 | { |
84 | { |
83 | char *data; |
85 | char *data; |
84 | 86 | ||
85 | data = malloc(10); |
87 | data = malloc(10); |
86 | printf("Heap: %P, data: %P\n", &_heap, data); |
88 | printf("Heap: %P, data: %P\n", &_heap, data); |
87 | data[0] = 'a'; |
89 | data[0] = 'a'; |
88 | free(data); |
90 | free(data); |
89 | } |
91 | } |
90 | */ |
92 | */ |
91 | 93 | ||
- | 94 | /* |
|
- | 95 | static void got_answer(void *private, int retval, ipc_data_t *data) |
|
- | 96 | { |
|
- | 97 | printf("Retval: %d...%s...%X, %X\n", retval, private, |
|
- | 98 | IPC_GET_ARG1(*data), IPC_GET_ARG2(*data)); |
|
- | 99 | } |
|
- | 100 | static void test_async_ipc(void) |
|
- | 101 | { |
|
- | 102 | ipc_data_t data; |
|
- | 103 | int i; |
|
- | 104 | ||
- | 105 | printf("Sending ping\n"); |
|
- | 106 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
|
- | 107 | "Pong1", got_answer); |
|
- | 108 | ipc_call_async_2(PHONE_NS, NS_PING, 2, 0xbeefbee4, |
|
- | 109 | "Pong2", got_answer); |
|
- | 110 | ipc_call_async_2(PHONE_NS, NS_PING, 3, 0xbeefbee4, |
|
- | 111 | "Pong3", got_answer); |
|
- | 112 | ipc_call_async_2(PHONE_NS, NS_PING, 4, 0xbeefbee4, |
|
- | 113 | "Pong4", got_answer); |
|
- | 114 | ipc_call_async_2(PHONE_NS, NS_PING, 5, 0xbeefbee4, |
|
- | 115 | "Pong5", got_answer); |
|
- | 116 | ipc_call_async_2(PHONE_NS, NS_PING, 6, 0xbeefbee4, |
|
- | 117 | "Pong6", got_answer); |
|
- | 118 | printf("Waiting forever...\n"); |
|
- | 119 | for (i=0; i<100;i++) |
|
- | 120 | printf("."); |
|
- | 121 | printf("\n"); |
|
- | 122 | ipc_wait_for_call(&data, NULL); |
|
- | 123 | printf("Received call???\n"); |
|
- | 124 | } |
|
- | 125 | */ |
|
- | 126 | ||
92 | int main(int argc, char *argv[]) |
127 | int main(int argc, char *argv[]) |
93 | { |
128 | { |
- | 129 | ipcarg_t arg1, arg2; |
|
- | 130 | ||
94 | version_print(); |
131 | version_print(); |
95 | 132 | ||
96 | ipc_call_sync_2(PHONE_NS, NS_PING, 2, 0, 0, 0); |
133 | ipc_call_sync_2(PHONE_NS, NS_PING, 0xaaaa, 0xbbbb, &arg1, &arg2); |
- | 134 | printf("Pong: %P %P\n", arg1, arg2); |
|
97 | 135 | ||
98 | return 0; |
136 | return 0; |
99 | } |
137 | } |
100 | 138 |