Changes in kernel/generic/src/udebug/udebug_ipc.c [31696b4f:336db295] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/udebug/udebug_ipc.c
r31696b4f r336db295 41 41 #include <proc/task.h> 42 42 #include <proc/thread.h> 43 #include <mm/as.h> 43 44 #include <arch.h> 44 45 #include <errno.h> … … 165 166 static void udebug_receive_thread_read(call_t *call) 166 167 { 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 */ 211 static void udebug_receive_areas_read(call_t *call) 212 { 167 213 unative_t uspace_addr; 168 214 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; 174 218 175 219 uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */ … … 177 221 178 222 /* 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; 195 231 else 196 232 to_copy = buf_size; … … 207 243 IPC_SET_ARG2(call->data, to_copy); 208 244 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 214 251 215 252 /** Process an ARGS_READ call. … … 331 368 udebug_receive_thread_read(call); 332 369 break; 370 case UDEBUG_M_AREAS_READ: 371 udebug_receive_areas_read(call); 372 break; 333 373 case UDEBUG_M_ARGS_READ: 334 374 udebug_receive_args_read(call);
Note:
See TracChangeset
for help on using the changeset viewer.