Subversion Repositories HelenOS-historic

Rev

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

Rev 999 Rev 1028
Line 26... Line 26...
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>
-
 
32
#include <stdio.h>
31
#include <stdio.h>
33
#include <unistd.h>
32
#include <unistd.h>
34
#include <stdlib.h>
33
#include <stdlib.h>
-
 
34
#include <ns.h>
35
 
35
 
36
/*
36
/*
37
static void test_printf(void)
37
static void test_printf(void)
38
{
38
{
39
    printf("Simple text.\n");
39
    printf("Simple text.\n");
Line 44... Line 44...
44
    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 );
45
    printf("Thats all, folks!\n");
45
    printf("Thats all, folks!\n");
46
}
46
}
47
*/
47
*/
48
 
48
 
49
/*
49
extern char _heap;
50
static void test_mremap(void)
50
static void test_mremap(void)
51
{
51
{
52
    printf("Writing to good memory\n");
52
    printf("Writing to good memory\n");
53
    mremap(&_heap, 120000, 0);
53
    mremap(&_heap, 120000, 0);
54
    printf("%P\n", ((char *)&_heap));
54
    printf("%P\n", ((char *)&_heap));
Line 59... Line 59...
59
    printf("Failing..\n");
59
    printf("Failing..\n");
60
    *((&_heap) + 80000) = 10;
60
    *((&_heap) + 80000) = 10;
61
 
61
 
62
    printf("memory done\n");
62
    printf("memory done\n");
63
}
63
}
64
*/
-
 
65
/*
64
/*
66
static void test_sbrk(void)
65
static void test_sbrk(void)
67
{
66
{
68
    printf("Writing to good memory\n");
67
    printf("Writing to good memory\n");
69
    printf("Got: %P\n", sbrk(120000));
68
    printf("Got: %P\n", sbrk(120000));
Line 89... Line 88...
89
    data[0] = 'a';
88
    data[0] = 'a';
90
    free(data);
89
    free(data);
91
}
90
}
92
*/
91
*/
93
 
92
 
-
 
93
 
-
 
94
static void test_ping(void)
94
/*
95
{
-
 
96
    ipcarg_t result;
-
 
97
    int retval;
-
 
98
 
-
 
99
    retval = ipc_call_sync(PHONE_NS, NS_PING, 0xbeef,&result);
-
 
100
    printf("Retval: %d - received: %P\n", retval, result);
-
 
101
}
-
 
102
 
95
static void got_answer(void *private, int retval, ipc_data_t *data)
103
static void got_answer(void *private, int retval, ipc_data_t *data)
96
{
104
{
97
    printf("Retval: %d...%s...%X, %X\n", retval, private,
105
    printf("Retval: %d...%s...%X, %X\n", retval, private,
98
           IPC_GET_ARG1(*data), IPC_GET_ARG2(*data));
106
           IPC_GET_ARG1(*data), IPC_GET_ARG2(*data));
99
}
107
}
100
static void test_async_ipc(void)
108
static void test_async_ipc(void)
101
{
109
{
102
    ipc_data_t data;
110
    ipc_call_t data;
103
    int i;
111
    int i;
104
 
112
 
105
    printf("Sending ping\n");
113
    printf("Sending ping\n");
106
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
114
    ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
107
             "Pong1", got_answer);
115
             "Pong1", got_answer);
Line 120... Line 128...
120
        printf(".");
128
        printf(".");
121
    printf("\n");
129
    printf("\n");
122
    ipc_wait_for_call(&data, NULL);
130
    ipc_wait_for_call(&data, NULL);
123
    printf("Received call???\n");
131
    printf("Received call???\n");
124
}
132
}
125
*/
-
 
126
 
133
 
-
 
134
 
127
int main(int argc, char *argv[])
135
static void got_answer_2(void *private, int retval, ipc_data_t *data)
128
{
136
{
-
 
137
    printf("Pong\n");
-
 
138
}
-
 
139
static void test_advanced_ipc(void)
-
 
140
{
-
 
141
    int res;
-
 
142
    unsigned long long taskid;
-
 
143
    ipc_callid_t callid;
129
    ipcarg_t arg1, arg2;
144
    ipc_call_t data;
-
 
145
 
-
 
146
    printf("Asking 0 to connect to me...\n");
-
 
147
    res = ipc_connect_to_me(0, 1, 2, &taskid);
-
 
148
    printf("Result: %d - taskid: %Q\n", res, taskid);
-
 
149
//  while (1) {
-
 
150
        printf("----------------\n");
-
 
151
        ipc_call_async(PHONE_NS, NS_PING_SVC, 0, "prov",
-
 
152
                   got_answer_2);
-
 
153
        callid = ipc_wait_for_call(&data, NULL);
-
 
154
        printf("Received ping\n");
-
 
155
        ipc_answer(callid, 0, 0, 0);
-
 
156
//  }
-
 
157
        callid = ipc_wait_for_call(&data, NULL);
-
 
158
}
130
 
159
 
-
 
160
int main(int argc, char *argv[])
-
 
161
{
131
    version_print();
162
    version_print();
132
 
163
 
-
 
164
//  test_ping();
133
    ipc_call_sync_2(PHONE_NS, NS_PING, 0xaaaa, 0xbbbb, &arg1, &arg2);
165
//  test_async_ipc();
134
    printf("Pong: %P %P\n", arg1, arg2);
166
    test_advanced_ipc();
135
   
-
 
136
    return 0;
167
    return 0;
137
}
168
}