Ignore:
Timestamp:
2010-01-23T20:20:54Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e095644
Parents:
9d3133d (diff), bc310a05 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge task dump infrastructure.

File:
1 edited

Legend:

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

    r9d3133d rfea0ce6  
    4141#include <proc/task.h>
    4242#include <proc/thread.h>
     43#include <mm/as.h>
    4344#include <arch.h>
    4445#include <errno.h>
     
    165166static void udebug_receive_thread_read(call_t *call)
    166167{
     168        uintptr_t uspace_addr;
     169        size_t buf_size;
     170        void *buffer;
     171        size_t copied, needed;
     172        int rc;
     173
     174        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     175        buf_size = IPC_GET_ARG3(call->data);    /* Dest. buffer size */
     176
     177        /*
     178         * Read thread list. Variable n will be filled with actual number
     179         * of threads times thread-id size.
     180         */
     181        rc = udebug_thread_read(&buffer, buf_size, &copied, &needed);
     182        if (rc < 0) {
     183                IPC_SET_RETVAL(call->data, rc);
     184                ipc_answer(&TASK->kb.box, call);
     185                return;
     186        }
     187
     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 */
     211static void udebug_receive_areas_read(call_t *call)
     212{
    167213        unative_t uspace_addr;
    168214        unative_t to_copy;
    169         unsigned total_bytes;
    170         unsigned buf_size;
    171         void *buffer;
    172         size_t n;
    173         int rc;
     215        size_t data_size;
     216        size_t buf_size;
     217        void *data;
    174218
    175219        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     
    177221
    178222        /*
    179          * Read thread list. Variable n will be filled with actual number
    180          * of threads times thread-id size.
    181          */
    182         rc = udebug_thread_read(&buffer, buf_size, &n);
    183         if (rc < 0) {
    184                 IPC_SET_RETVAL(call->data, rc);
    185                 ipc_answer(&TASK->kb.box, call);
    186                 return;
    187         }
    188 
    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;
     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;
    195231        else
    196232                to_copy = buf_size;
     
    207243        IPC_SET_ARG2(call->data, to_copy);
    208244
    209         IPC_SET_ARG3(call->data, total_bytes);
    210         call->buffer = buffer;
    211 
    212         ipc_answer(&TASK->kb.box, call);
    213 }
     245        IPC_SET_ARG3(call->data, data_size);
     246        call->buffer = data;
     247
     248        ipc_answer(&TASK->kb.box, call);
     249}
     250
    214251
    215252/** Process an ARGS_READ call.
     
    331368                udebug_receive_thread_read(call);
    332369                break;
     370        case UDEBUG_M_AREAS_READ:
     371                udebug_receive_areas_read(call);
     372                break;
    333373        case UDEBUG_M_ARGS_READ:
    334374                udebug_receive_args_read(call);
Note: See TracChangeset for help on using the changeset viewer.