42a43
> #include "sim/system.hh"
413a415,427
> /// Target set_tls() handler.
> static SyscallReturn
> setTLSFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
> ThreadContext *tc)
> {
> uint32_t tlsPtr = process->getSyscallArg(tc, 0);
> TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
>
> tc->getMemPort()->writeBlob(ArmLinuxProcess::commPage + 0x0ff0,
> (uint8_t *)&tlsPtr, sizeof(tlsPtr));
> return 0;
> }
>
419c433
< /* 5 */ SyscallDesc("set_tls", unimplementedFunc)
---
> /* 5 */ SyscallDesc("set_tls", setTLSFunc)
428a443,444
> const Addr ArmLinuxProcess::commPage = 0xffff0000;
>
450a467,491
>
> void
> ArmLinuxProcess::startup()
> {
> ArmLiveProcess::startup();
> pTable->allocate(commPage, PageBytes);
> ThreadContext *tc = system->getThreadContext(contextIds[0]);
>
> uint8_t swiNeg1[] = {
> 0xff, 0xff, 0xff, 0xef //swi -1
> };
>
> // Fill this page with swi -1 so we'll no if we land in it somewhere.
> for (Addr addr = 0; addr < PageBytes; addr += sizeof(swiNeg1)) {
> tc->getMemPort()->writeBlob(commPage + addr,
> swiNeg1, sizeof(swiNeg1));
> }
>
> uint8_t get_tls[] =
> {
> 0x08, 0x00, 0x9f, 0xe5, //ldr r0, [pc, #(16 - 8)]
> 0x0e, 0xf0, 0xa0, 0xe1 //usr_ret lr
> };
> tc->getMemPort()->writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls));
> }