Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/udebug/udebug_ipc.c

    r336db295 r31696b4f  
    4141#include <proc/task.h>
    4242#include <proc/thread.h>
    43 #include <mm/as.h>
    4443#include <arch.h>
    4544#include <errno.h>
     
    166165static void udebug_receive_thread_read(call_t *call)
    167166{
    168         uintptr_t uspace_addr;
    169         size_t buf_size;
     167        unative_t uspace_addr;
     168        unative_t to_copy;
     169        unsigned total_bytes;
     170        unsigned buf_size;
    170171        void *buffer;
    171         size_t copied, needed;
     172        size_t n;
    172173        int rc;
    173174
     
    179180         * of threads times thread-id size.
    180181         */
    181         rc = udebug_thread_read(&buffer, buf_size, &copied, &needed);
     182        rc = udebug_thread_read(&buffer, buf_size, &n);
    182183        if (rc < 0) {
    183184                IPC_SET_RETVAL(call->data, rc);
     
    186187        }
    187188
    188         /*
    189          * Make use of call->buffer to transfer data to caller's userspace
    190          */
    191 
    192         IPC_SET_RETVAL(call->data, 0);
    193         /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
    194            same code in process_answer() can be used
    195            (no way to distinguish method in answer) */
    196         IPC_SET_ARG1(call->data, uspace_addr);
    197         IPC_SET_ARG2(call->data, copied);
    198         IPC_SET_ARG3(call->data, needed);
    199         call->buffer = buffer;
    200 
    201         ipc_answer(&TASK->kb.box, call);
    202 }
    203 
    204 /** Process an AREAS_READ call.
    205  *
    206  * Returns a list of address space areas in the current task, as an array
    207  * of as_area_info_t structures.
    208  *
    209  * @param call  The call structure.
    210  */
    211 static void udebug_receive_areas_read(call_t *call)
    212 {
    213         unative_t uspace_addr;
    214         unative_t to_copy;
    215         size_t data_size;
    216         size_t buf_size;
    217         void *data;
    218 
    219         uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
    220         buf_size = IPC_GET_ARG3(call->data);    /* Dest. buffer size */
    221 
    222         /*
    223          * Read area list.
    224          */
    225         as_get_area_info(AS, (as_area_info_t **) &data, &data_size);
    226 
    227         /* Copy MAX(buf_size, data_size) bytes */
    228 
    229         if (buf_size > data_size)
    230                 to_copy = data_size;
     189        total_bytes = n;
     190
     191        /* Copy MAX(buf_size, total_bytes) bytes */
     192
     193        if (buf_size > total_bytes)
     194                to_copy = total_bytes;
    231195        else
    232196                to_copy = buf_size;
     
    243207        IPC_SET_ARG2(call->data, to_copy);
    244208
    245         IPC_SET_ARG3(call->data, data_size);
    246         call->buffer = data;
    247 
    248         ipc_answer(&TASK->kb.box, call);
    249 }
    250 
     209        IPC_SET_ARG3(call->data, total_bytes);
     210        call->buffer = buffer;
     211
     212        ipc_answer(&TASK->kb.box, call);
     213}
    251214
    252215/** Process an ARGS_READ call.
     
    368331                udebug_receive_thread_read(call);
    369332                break;
    370         case UDEBUG_M_AREAS_READ:
    371                 udebug_receive_areas_read(call);
    372                 break;
    373333        case UDEBUG_M_ARGS_READ:
    374334                udebug_receive_args_read(call);
Note: See TracChangeset for help on using the changeset viewer.