Subversion Repositories HelenOS

Rev

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

Rev 2637 Rev 2660
Line 47... Line 47...
47
{
47
{
48
    ipc_callid_t callid;
48
    ipc_callid_t callid;
49
    ipc_call_t call;
49
    ipc_call_t call;
50
    int retval;
50
    int retval;
51
   
51
   
52
    printf("connected: method=%u arg1=%u, arg2=%u arg3=%u.\n", IPC_GET_METHOD(*icall),
52
    printf("connected: method=%u arg1=%u, arg2=%u arg3=%u.\n",
53
        IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall), IPC_GET_ARG3(*icall));
53
        IPC_GET_METHOD(*icall), IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall),
-
 
54
        IPC_GET_ARG3(*icall));
54
 
55
 
55
    printf("driver_client_connection.\n");
56
    printf("driver_client_connection.\n");
56
    ipc_answer_0(iid, EOK);
57
    ipc_answer_0(iid, EOK);
57
 
58
 
58
    /* Ignore parameters, the connection is already opened */
59
    /* Ignore parameters, the connection is already opened */
59
    while (1) {
60
    while (1) {
60
        callid = async_get_call(&call);
61
        callid = async_get_call(&call);
61
        retval = EOK;
62
        retval = EOK;
62
        printf("method=%u arg1=%u, arg2=%u arg3=%u.\n", IPC_GET_METHOD(call),
63
        printf("method=%u arg1=%u, arg2=%u arg3=%u.\n",
-
 
64
            IPC_GET_METHOD(call), IPC_GET_ARG1(call),
63
            IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call));
65
            IPC_GET_ARG2(call), IPC_GET_ARG3(call));
64
        switch (IPC_GET_METHOD(call)) {
66
        switch (IPC_GET_METHOD(call)) {
65
        case IPC_M_PHONE_HUNGUP:
67
        case IPC_M_PHONE_HUNGUP:
66
            /* TODO: Handle hangup */
68
            /* TODO: Handle hangup */
67
            return;
69
            return;
68
        default:
70
        default:
69
            printf("Unknown device method %u.\n", IPC_GET_METHOD(call));
71
            printf("Unknown device method %u.\n",
-
 
72
                IPC_GET_METHOD(call));
70
            retval = ENOENT;
73
            retval = ENOENT;
71
        }
74
        }
72
        ipc_answer_0(callid, retval);
75
        ipc_answer_0(callid, retval);
73
    }
76
    }
74
    return;
77
    return;
Line 79... Line 82...
79
    int handle;
82
    int handle;
80
    int device_phone;
83
    int device_phone;
81
 
84
 
82
    handle = (int)arg;
85
    handle = (int)arg;
83
 
86
 
84
    device_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, \
87
    device_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
85
        DEVMAP_CONNECT_TO_DEVICE, handle);
88
        DEVMAP_CONNECT_TO_DEVICE, handle);
86
 
89
 
87
    if (device_phone < 0) {
90
    if (device_phone < 0) {
88
        printf("Failed to connect to devmap as client (handle = %u).\n",
91
        printf("Failed to connect to devmap as client (handle = %u).\n",
89
            handle);
92
            handle);
90
        return -1;
93
        return -1;
91
    }
94
    }
92
/* 
95
/* 
93
 *  device_phone = (int) IPC_GET_ARG5(answer);
96
 *  device_phone = (int) IPC_GET_ARG5(answer);
94
 */
97
 */
Line 127... Line 130...
127
    aid_t req;
130
    aid_t req;
128
    ipc_call_t answer;
131
    ipc_call_t answer;
129
    int phone;
132
    int phone;
130
    ipcarg_t callback_phonehash;
133
    ipcarg_t callback_phonehash;
131
 
134
 
132
    phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
135
    phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
133
        DEVMAP_DRIVER, 0);
-
 
134
 
136
 
135
    while (phone < 0) {
137
    while (phone < 0) {
136
        usleep(100000);
138
        usleep(100000);
137
        phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
139
        phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
138
            DEVMAP_DRIVER, 0);
140
            DEVMAP_DRIVER, 0);
139
    }
141
    }
140
   
142
   
141
    req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
143
    req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
142
 
144
 
143
    retval = ipc_data_send(phone, (char *)name, strlen(name) + 1);
145
    retval = ipc_data_write_send(phone, (char *)name, strlen(name) + 1);
144
 
146
 
145
    if (retval != EOK) {
147
    if (retval != EOK) {
146
        async_wait_for(req, NULL);
148
        async_wait_for(req, NULL);
147
        return -1;
149
        return -1;
148
    }
150
    }
Line 168... Line 170...
168
{
170
{
169
    ipcarg_t retval;
171
    ipcarg_t retval;
170
    aid_t req;
172
    aid_t req;
171
    ipc_call_t answer;
173
    ipc_call_t answer;
172
 
174
 
173
    req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0, &answer);
175
    req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0,
-
 
176
        &answer);
174
 
177
 
175
    retval = ipc_data_send(driver_phone, name, strlen(name) + 1);
178
    retval = ipc_data_write_send(driver_phone, name, strlen(name) + 1);
176
 
179
 
177
    if (retval != EOK) {
180
    if (retval != EOK) {
178
        printf("Failed to send device name '%s'.\n", name);
181
        printf("Failed to send device name '%s'.\n", name);
179
        async_wait_for(req, NULL);
182
        async_wait_for(req, NULL);
180
        return retval;
183
        return retval;
Line 189... Line 192...
189
    if (EOK == retval) {
192
    if (EOK == retval) {
190
       
193
       
191
        if (NULL != handle) {
194
        if (NULL != handle) {
192
            *handle = (int) IPC_GET_ARG1(answer);
195
            *handle = (int) IPC_GET_ARG1(answer);
193
        }
196
        }
194
        printf("Device '%s' has handle %u.\n", name, (int) IPC_GET_ARG1(answer));
197
        printf("Device '%s' has handle %u.\n", name,
-
 
198
            (int) IPC_GET_ARG1(answer));
195
    } else {
199
    } else {
196
        printf("Failed to get handle for device '%s'.\n", name);
200
        printf("Failed to get handle for device '%s'.\n", name);
197
    }
201
    }
198
 
202
 
199
    return retval;
203
    return retval;
Line 210... Line 214...
210
    aid_t req;
214
    aid_t req;
211
    ipc_call_t answer;
215
    ipc_call_t answer;
212
 
216
 
213
    req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer);
217
    req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer);
214
 
218
 
215
    retval = ipc_data_send(driver_phone, (char *)name, strlen(name) + 1);
219
    retval = ipc_data_write_send(driver_phone, (char *)name,
-
 
220
        strlen(name) + 1);
216
 
221
 
217
    if (retval != EOK) {
222
    if (retval != EOK) {
218
        printf("Failed to send device name '%s'.\n", name);
223
        printf("Failed to send device name '%s'.\n", name);
219
        async_wait_for(req, NULL);
224
        async_wait_for(req, NULL);
220
        return retval;
225
        return retval;
Line 229... Line 234...
229
    if (EOK == retval) {
234
    if (EOK == retval) {
230
       
235
       
231
        if (NULL != handle) {
236
        if (NULL != handle) {
232
            *handle = (int) IPC_GET_ARG1(answer);
237
            *handle = (int) IPC_GET_ARG1(answer);
233
        }
238
        }
234
        printf("Device registered with handle %u.\n", (int) IPC_GET_ARG1(answer));
239
        printf("Device registered with handle %u.\n",
-
 
240
            (int) IPC_GET_ARG1(answer));
235
    }
241
    }
236
 
242
 
237
    return retval;
243
    return retval;
238
}
244
}
239
 
245