Changes in kernel/generic/src/udebug/udebug_ipc.c [96b02eb9:31696b4f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/udebug/udebug_ipc.c
r96b02eb9 r31696b4f 41 41 #include <proc/task.h> 42 42 #include <proc/thread.h> 43 #include <mm/as.h>44 43 #include <arch.h> 45 44 #include <errno.h> … … 166 165 static void udebug_receive_thread_read(call_t *call) 167 166 { 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; 170 171 void *buffer; 171 size_t copied, needed;172 size_t n; 172 173 int rc; 173 174 … … 179 180 * of threads times thread-id size. 180 181 */ 181 rc = udebug_thread_read(&buffer, buf_size, & copied, &needed);182 rc = udebug_thread_read(&buffer, buf_size, &n); 182 183 if (rc < 0) { 183 184 IPC_SET_RETVAL(call->data, rc); … … 186 187 } 187 188 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 a NAME_READ call. 205 * 206 * Returns a string containing the name of the task. 207 * 208 * @param call The call structure. 209 */ 210 static void udebug_receive_name_read(call_t *call) 211 { 212 sysarg_t uspace_addr; 213 sysarg_t to_copy; 214 size_t data_size; 215 size_t buf_size; 216 void *data; 217 218 uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */ 219 buf_size = IPC_GET_ARG3(call->data); /* Dest. buffer size */ 220 221 /* 222 * Read task name. 223 */ 224 udebug_name_read((char **) &data, &data_size); 225 226 /* Copy MAX(buf_size, data_size) bytes */ 227 228 if (buf_size > data_size) 229 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; 230 195 else 231 196 to_copy = buf_size; … … 242 207 IPC_SET_ARG2(call->data, to_copy); 243 208 244 IPC_SET_ARG3(call->data, data_size); 245 call->buffer = data; 246 247 ipc_answer(&TASK->kb.box, call); 248 } 249 250 /** Process an AREAS_READ call. 251 * 252 * Returns a list of address space areas in the current task, as an array 253 * of as_area_info_t structures. 254 * 255 * @param call The call structure. 256 */ 257 static void udebug_receive_areas_read(call_t *call) 258 { 259 sysarg_t uspace_addr; 260 sysarg_t to_copy; 261 size_t data_size; 262 size_t buf_size; 263 void *data; 264 265 uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */ 266 buf_size = IPC_GET_ARG3(call->data); /* Dest. buffer size */ 267 268 /* 269 * Read area list. 270 */ 271 as_get_area_info(AS, (as_area_info_t **) &data, &data_size); 272 273 /* Copy MAX(buf_size, data_size) bytes */ 274 275 if (buf_size > data_size) 276 to_copy = data_size; 277 else 278 to_copy = buf_size; 209 IPC_SET_ARG3(call->data, total_bytes); 210 call->buffer = buffer; 211 212 ipc_answer(&TASK->kb.box, call); 213 } 214 215 /** Process an ARGS_READ call. 216 * 217 * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E). 218 * @param call The call structure. 219 */ 220 static void udebug_receive_args_read(call_t *call) 221 { 222 thread_t *t; 223 unative_t uspace_addr; 224 int rc; 225 void *buffer; 226 227 t = (thread_t *)IPC_GET_ARG2(call->data); 228 229 rc = udebug_args_read(t, &buffer); 230 if (rc != EOK) { 231 IPC_SET_RETVAL(call->data, rc); 232 ipc_answer(&TASK->kb.box, call); 233 return; 234 } 279 235 280 236 /* 281 237 * Make use of call->buffer to transfer data to caller's userspace 282 238 */ 239 240 uspace_addr = IPC_GET_ARG3(call->data); 283 241 284 242 IPC_SET_RETVAL(call->data, 0); … … 287 245 (no way to distinguish method in answer) */ 288 246 IPC_SET_ARG1(call->data, uspace_addr); 289 IPC_SET_ARG2(call->data, to_copy); 290 291 IPC_SET_ARG3(call->data, data_size); 292 call->buffer = data; 293 294 ipc_answer(&TASK->kb.box, call); 295 } 296 297 298 /** Process an ARGS_READ call. 299 * 300 * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E). 301 * @param call The call structure. 302 */ 303 static void udebug_receive_args_read(call_t *call) 304 { 305 thread_t *t; 306 sysarg_t uspace_addr; 307 int rc; 308 void *buffer; 309 310 t = (thread_t *)IPC_GET_ARG2(call->data); 311 312 rc = udebug_args_read(t, &buffer); 313 if (rc != EOK) { 314 IPC_SET_RETVAL(call->data, rc); 315 ipc_answer(&TASK->kb.box, call); 316 return; 317 } 318 319 /* 320 * Make use of call->buffer to transfer data to caller's userspace 321 */ 322 323 uspace_addr = IPC_GET_ARG3(call->data); 324 325 IPC_SET_RETVAL(call->data, 0); 326 /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that 327 same code in process_answer() can be used 328 (no way to distinguish method in answer) */ 329 IPC_SET_ARG1(call->data, uspace_addr); 330 IPC_SET_ARG2(call->data, 6 * sizeof(sysarg_t)); 247 IPC_SET_ARG2(call->data, 6 * sizeof(unative_t)); 331 248 call->buffer = buffer; 332 249 … … 334 251 } 335 252 336 /** Receive a REGS_READ call.337 *338 * Reads the thread's register state (istate structure).339 */340 static void udebug_receive_regs_read(call_t *call)341 {342 thread_t *t;343 sysarg_t uspace_addr;344 sysarg_t to_copy;345 void *buffer;346 int rc;347 348 t = (thread_t *) IPC_GET_ARG2(call->data);349 350 rc = udebug_regs_read(t, &buffer);351 if (rc < 0) {352 IPC_SET_RETVAL(call->data, rc);353 ipc_answer(&TASK->kb.box, call);354 return;355 }356 357 /*358 * Make use of call->buffer to transfer data to caller's userspace359 */360 361 uspace_addr = IPC_GET_ARG3(call->data);362 to_copy = sizeof(istate_t);363 364 IPC_SET_RETVAL(call->data, 0);365 /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that366 same code in process_answer() can be used367 (no way to distinguish method in answer) */368 IPC_SET_ARG1(call->data, uspace_addr);369 IPC_SET_ARG2(call->data, to_copy);370 371 call->buffer = buffer;372 373 ipc_answer(&TASK->kb.box, call);374 }375 376 377 253 /** Process an MEM_READ call. 378 254 * … … 382 258 static void udebug_receive_mem_read(call_t *call) 383 259 { 384 sysarg_t uspace_dst;385 sysarg_t uspace_src;260 unative_t uspace_dst; 261 unative_t uspace_src; 386 262 unsigned size; 387 263 void *buffer; … … 455 331 udebug_receive_thread_read(call); 456 332 break; 457 case UDEBUG_M_NAME_READ:458 udebug_receive_name_read(call);459 break;460 case UDEBUG_M_AREAS_READ:461 udebug_receive_areas_read(call);462 break;463 333 case UDEBUG_M_ARGS_READ: 464 334 udebug_receive_args_read(call); 465 335 break; 466 case UDEBUG_M_REGS_READ:467 udebug_receive_regs_read(call);468 break;469 336 case UDEBUG_M_MEM_READ: 470 337 udebug_receive_mem_read(call);
Note:
See TracChangeset
for help on using the changeset viewer.