Rev 2817 | Rev 2819 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2817 | Rev 2818 | ||
|---|---|---|---|
| Line 274... | Line 274... | ||
| 274 | 274 | ||
| 275 | klog_printf("debug_thread_read() done"); |
275 | klog_printf("debug_thread_read() done"); |
| 276 | return 1; /* actually need becksend with retval 0 */ |
276 | return 1; /* actually need becksend with retval 0 */ |
| 277 | } |
277 | } |
| 278 | 278 | ||
| - | 279 | static int udebug_rp_mem_write(call_t *call, phone_t *phone) |
|
| - | 280 | { |
|
| - | 281 | void *uspace_data; |
|
| - | 282 | unative_t to_copy; |
|
| - | 283 | int rc; |
|
| - | 284 | void *buffer; |
|
| - | 285 | ||
| - | 286 | klog_printf("udebug_rp_mem_write()"); |
|
| - | 287 | // FIXME: verify task/thread state |
|
| - | 288 | ||
| - | 289 | uspace_data = (void *)IPC_GET_ARG2(call->data); |
|
| - | 290 | to_copy = IPC_GET_ARG4(call->data); |
|
| - | 291 | ||
| - | 292 | buffer = malloc(to_copy, 0); // ??? |
|
| - | 293 | ||
| - | 294 | rc = copy_from_uspace(buffer, uspace_data, to_copy); |
|
| - | 295 | if (rc != 0) { |
|
| - | 296 | klog_printf(" - copy failed"); |
|
| - | 297 | return rc; |
|
| - | 298 | } |
|
| - | 299 | ||
| - | 300 | call->buffer = buffer; |
|
| - | 301 | ||
| - | 302 | klog_printf(" - done"); |
|
| - | 303 | return 1; /* actually need becksend with retval 0 */ |
|
| - | 304 | } |
|
| - | 305 | ||
| - | 306 | ||
| 279 | int udebug_request_preprocess(call_t *call, phone_t *phone) |
307 | int udebug_request_preprocess(call_t *call, phone_t *phone) |
| 280 | { |
308 | { |
| 281 | int rc; |
309 | int rc; |
| 282 | 310 | ||
| 283 | switch (IPC_GET_ARG1(call->data)) { |
311 | switch (IPC_GET_ARG1(call->data)) { |
| Line 296... | Line 324... | ||
| 296 | case UDEBUG_M_REGS_WRITE: |
324 | case UDEBUG_M_REGS_WRITE: |
| 297 | rc = udebug_rp_regs_write(call, phone); |
325 | rc = udebug_rp_regs_write(call, phone); |
| 298 | return rc; |
326 | return rc; |
| 299 | case UDEBUG_M_THREAD_READ: |
327 | case UDEBUG_M_THREAD_READ: |
| 300 | rc = udebug_rp_thread_read(call, phone); |
328 | rc = udebug_rp_thread_read(call, phone); |
| - | 329 | case UDEBUG_M_MEM_WRITE: |
|
| - | 330 | rc = udebug_rp_mem_write(call, phone); |
|
| 301 | return rc; |
331 | return rc; |
| 302 | default: |
332 | default: |
| 303 | break; |
333 | break; |
| 304 | } |
334 | } |
| 305 | 335 | ||
| Line 341... | Line 371... | ||
| 341 | call->buffer = buffer; |
371 | call->buffer = buffer; |
| 342 | 372 | ||
| 343 | ipc_answer(&TASK->kernel_box, call); |
373 | ipc_answer(&TASK->kernel_box, call); |
| 344 | } |
374 | } |
| 345 | 375 | ||
| - | 376 | static void udebug_receive_mem_write(call_t *call) |
|
| - | 377 | { |
|
| - | 378 | void *uspace_dst; |
|
| - | 379 | unsigned size; |
|
| - | 380 | void *buffer; |
|
| - | 381 | int rc; |
|
| - | 382 | ||
| - | 383 | klog_printf("udebug_receive_mem_write()"); |
|
| - | 384 | uspace_dst = (void *)IPC_GET_ARG3(call->data); |
|
| - | 385 | size = IPC_GET_ARG4(call->data); |
|
| - | 386 | ||
| - | 387 | buffer = call->buffer; |
|
| - | 388 | klog_printf("dst=%u, size=%u", uspace_dst, size); |
|
| - | 389 | ||
| - | 390 | /* NOTE: this is not strictly from a syscall... but that shouldn't |
|
| - | 391 | * be a problem */ |
|
| - | 392 | rc = copy_to_uspace(uspace_dst, buffer, size); |
|
| - | 393 | if (rc) { |
|
| - | 394 | IPC_SET_RETVAL(call->data, rc); |
|
| - | 395 | return; |
|
| - | 396 | } |
|
| - | 397 | ||
| - | 398 | IPC_SET_RETVAL(call->data, 0); |
|
| - | 399 | ||
| - | 400 | free(call->buffer); |
|
| - | 401 | call->buffer = NULL; |
|
| - | 402 | ||
| - | 403 | ipc_answer(&TASK->kernel_box, call); |
|
| - | 404 | } |
|
| - | 405 | ||
| - | 406 | ||
| 346 | /** |
407 | /** |
| 347 | * Handle a debug call received on the kernel answerbox. |
408 | * Handle a debug call received on the kernel answerbox. |
| 348 | * |
409 | * |
| 349 | * This is called by the kbox servicing thread. |
410 | * This is called by the kbox servicing thread. |
| 350 | */ |
411 | */ |
| Line 356... | Line 417... | ||
| 356 | 417 | ||
| 357 | switch (debug_method) { |
418 | switch (debug_method) { |
| 358 | case UDEBUG_M_MEM_READ: |
419 | case UDEBUG_M_MEM_READ: |
| 359 | udebug_receive_mem_read(call); |
420 | udebug_receive_mem_read(call); |
| 360 | break; |
421 | break; |
| - | 422 | case UDEBUG_M_MEM_WRITE: |
|
| - | 423 | udebug_receive_mem_write(call); |
|
| - | 424 | break; |
|
| 361 | } |
425 | } |
| 362 | } |
426 | } |
| 363 | 427 | ||
| 364 | /** @} |
428 | /** @} |
| 365 | */ |
429 | */ |