process.cc (6232:e0ea733d2105) | process.cc (6233:014ae6da6c2a) |
---|---|
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * Copyright (c) 2007-2008 The Florida State University 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35#include "arch/arm/isa_traits.hh" 36 37#include "base/trace.hh" 38#include "cpu/thread_context.hh" 39#include "kern/linux/linux.hh" 40 41#include "sim/process.hh" 42#include "sim/syscall_emul.hh" | 1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * Copyright (c) 2007-2008 The Florida State University 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35#include "arch/arm/isa_traits.hh" 36 37#include "base/trace.hh" 38#include "cpu/thread_context.hh" 39#include "kern/linux/linux.hh" 40 41#include "sim/process.hh" 42#include "sim/syscall_emul.hh" |
43#include "sim/system.hh" |
|
43 44using namespace std; 45using namespace ArmISA; 46 47/// Target uname() handler. 48static SyscallReturn 49unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 50 ThreadContext *tc) --- 355 unchanged lines hidden (view full) --- 406 /* 341 */ SyscallDesc("arm_sync_file_range", unimplementedFunc), 407 /* 342 */ SyscallDesc("tee", unimplementedFunc), 408 /* 343 */ SyscallDesc("vmsplice", unimplementedFunc), 409 /* 344 */ SyscallDesc("move_pages", unimplementedFunc), 410 /* 345 */ SyscallDesc("getcpu", unimplementedFunc), 411 /* 346 */ SyscallDesc("epoll_pwait", unimplementedFunc), 412}; 413 | 44 45using namespace std; 46using namespace ArmISA; 47 48/// Target uname() handler. 49static SyscallReturn 50unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 51 ThreadContext *tc) --- 355 unchanged lines hidden (view full) --- 407 /* 341 */ SyscallDesc("arm_sync_file_range", unimplementedFunc), 408 /* 342 */ SyscallDesc("tee", unimplementedFunc), 409 /* 343 */ SyscallDesc("vmsplice", unimplementedFunc), 410 /* 344 */ SyscallDesc("move_pages", unimplementedFunc), 411 /* 345 */ SyscallDesc("getcpu", unimplementedFunc), 412 /* 346 */ SyscallDesc("epoll_pwait", unimplementedFunc), 413}; 414 |
415/// Target set_tls() handler. 416static SyscallReturn 417setTLSFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 418 ThreadContext *tc) 419{ 420 uint32_t tlsPtr = process->getSyscallArg(tc, 0); 421 TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0)); 422 423 tc->getMemPort()->writeBlob(ArmLinuxProcess::commPage + 0x0ff0, 424 (uint8_t *)&tlsPtr, sizeof(tlsPtr)); 425 return 0; 426} 427 |
|
414SyscallDesc ArmLinuxProcess::privSyscallDescs[] = { 415 /* 1 */ SyscallDesc("breakpoint", unimplementedFunc), 416 /* 2 */ SyscallDesc("cacheflush", unimplementedFunc), 417 /* 3 */ SyscallDesc("usr26", unimplementedFunc), 418 /* 4 */ SyscallDesc("usr32", unimplementedFunc), | 428SyscallDesc ArmLinuxProcess::privSyscallDescs[] = { 429 /* 1 */ SyscallDesc("breakpoint", unimplementedFunc), 430 /* 2 */ SyscallDesc("cacheflush", unimplementedFunc), 431 /* 3 */ SyscallDesc("usr26", unimplementedFunc), 432 /* 4 */ SyscallDesc("usr32", unimplementedFunc), |
419 /* 5 */ SyscallDesc("set_tls", unimplementedFunc) | 433 /* 5 */ SyscallDesc("set_tls", setTLSFunc) |
420}; 421 422ArmLinuxProcess::ArmLinuxProcess(LiveProcessParams * params, 423 ObjectFile *objFile) 424 : ArmLiveProcess(params, objFile), 425 Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc)), 426 Num_Priv_Syscall_Descs(sizeof(privSyscallDescs) / sizeof(SyscallDesc)) 427{ } 428 | 434}; 435 436ArmLinuxProcess::ArmLinuxProcess(LiveProcessParams * params, 437 ObjectFile *objFile) 438 : ArmLiveProcess(params, objFile), 439 Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc)), 440 Num_Priv_Syscall_Descs(sizeof(privSyscallDescs) / sizeof(SyscallDesc)) 441{ } 442 |
443const Addr ArmLinuxProcess::commPage = 0xffff0000; 444 |
|
429SyscallDesc* 430ArmLinuxProcess::getDesc(int callnum) 431{ 432 // Angel SWI syscalls are unsupported in this release 433 if (callnum == 0x123456) { 434 panic("Attempt to execute an ANGEL_SWI system call (newlib-related)"); 435 } else if ((callnum & 0x00f00000) == 0x00900000) { 436 callnum &= 0x000fffff; --- 6 unchanged lines hidden (view full) --- 443 } 444 // Linux syscalls have to strip off the 0x00900000 445 446 if (callnum < 0 || callnum > Num_Syscall_Descs) 447 return NULL; 448 449 return &syscallDescs[callnum]; 450} | 445SyscallDesc* 446ArmLinuxProcess::getDesc(int callnum) 447{ 448 // Angel SWI syscalls are unsupported in this release 449 if (callnum == 0x123456) { 450 panic("Attempt to execute an ANGEL_SWI system call (newlib-related)"); 451 } else if ((callnum & 0x00f00000) == 0x00900000) { 452 callnum &= 0x000fffff; --- 6 unchanged lines hidden (view full) --- 459 } 460 // Linux syscalls have to strip off the 0x00900000 461 462 if (callnum < 0 || callnum > Num_Syscall_Descs) 463 return NULL; 464 465 return &syscallDescs[callnum]; 466} |
467 468void 469ArmLinuxProcess::startup() 470{ 471 ArmLiveProcess::startup(); 472 pTable->allocate(commPage, PageBytes); 473 ThreadContext *tc = system->getThreadContext(contextIds[0]); 474 475 uint8_t swiNeg1[] = { 476 0xff, 0xff, 0xff, 0xef //swi -1 477 }; 478 479 // Fill this page with swi -1 so we'll no if we land in it somewhere. 480 for (Addr addr = 0; addr < PageBytes; addr += sizeof(swiNeg1)) { 481 tc->getMemPort()->writeBlob(commPage + addr, 482 swiNeg1, sizeof(swiNeg1)); 483 } 484 485 uint8_t get_tls[] = 486 { 487 0x08, 0x00, 0x9f, 0xe5, //ldr r0, [pc, #(16 - 8)] 488 0x0e, 0xf0, 0xa0, 0xe1 //usr_ret lr 489 }; 490 tc->getMemPort()->writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls)); 491} |
|