process.cc (14014:ce216ee5d886) process.cc (14024:abe47b13653d)
1/*
2 * Copyright (c) 2010-2013, 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 103 unchanged lines hidden (view full) ---

112 TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
113
114 strcpy(name->sysname, "Linux");
115 strcpy(name->nodename, "m5.eecs.umich.edu");
116 strcpy(name->release, process->release.c_str());
117 strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012");
118 strcpy(name->machine, "armv7l");
119
1/*
2 * Copyright (c) 2010-2013, 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 103 unchanged lines hidden (view full) ---

112 TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
113
114 strcpy(name->sysname, "Linux");
115 strcpy(name->nodename, "m5.eecs.umich.edu");
116 strcpy(name->release, process->release.c_str());
117 strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012");
118 strcpy(name->machine, "armv7l");
119
120 name.copyOut(tc->getMemProxy());
120 name.copyOut(tc->getVirtProxy());
121 return 0;
122}
123
124/// Target uname() handler.
125static SyscallReturn
126unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
127{
128 int index = 0;
129 auto process = tc->getProcessPtr();
130 TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
131
132 strcpy(name->sysname, "Linux");
133 strcpy(name->nodename, "gem5");
134 strcpy(name->release, process->release.c_str());
135 strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012");
136 strcpy(name->machine, "armv8l");
137
121 return 0;
122}
123
124/// Target uname() handler.
125static SyscallReturn
126unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
127{
128 int index = 0;
129 auto process = tc->getProcessPtr();
130 TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
131
132 strcpy(name->sysname, "Linux");
133 strcpy(name->nodename, "gem5");
134 strcpy(name->release, process->release.c_str());
135 strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012");
136 strcpy(name->machine, "armv8l");
137
138 name.copyOut(tc->getMemProxy());
138 name.copyOut(tc->getVirtProxy());
139 return 0;
140}
141
142/// Target set_tls() handler.
143static SyscallReturn
144setTLSFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc)
145{
146 int index = 0;
147 auto process = tc->getProcessPtr();
148 uint32_t tlsPtr = process->getSyscallArg(tc, index);
149
139 return 0;
140}
141
142/// Target set_tls() handler.
143static SyscallReturn
144setTLSFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc)
145{
146 int index = 0;
147 auto process = tc->getProcessPtr();
148 uint32_t tlsPtr = process->getSyscallArg(tc, index);
149
150 tc->getMemProxy().writeBlob(ArmLinuxProcess32::commPage + 0x0ff0,
150 tc->getVirtProxy().writeBlob(ArmLinuxProcess32::commPage + 0x0ff0,
151 &tlsPtr, sizeof(tlsPtr));
152 tc->setMiscReg(MISCREG_TPIDRURO,tlsPtr);
153 return 0;
154}
155
156static SyscallReturn
157setTLSFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
158{

--- 1573 unchanged lines hidden (view full) ---

1732 ThreadContext *tc = system->getThreadContext(contextIds[0]);
1733
1734 uint8_t swiNeg1[] = {
1735 0xff, 0xff, 0xff, 0xef // swi -1
1736 };
1737
1738 // Fill this page with swi -1 so we'll no if we land in it somewhere.
1739 for (Addr addr = 0; addr < PageBytes; addr += sizeof(swiNeg1)) {
151 &tlsPtr, sizeof(tlsPtr));
152 tc->setMiscReg(MISCREG_TPIDRURO,tlsPtr);
153 return 0;
154}
155
156static SyscallReturn
157setTLSFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc)
158{

--- 1573 unchanged lines hidden (view full) ---

1732 ThreadContext *tc = system->getThreadContext(contextIds[0]);
1733
1734 uint8_t swiNeg1[] = {
1735 0xff, 0xff, 0xff, 0xef // swi -1
1736 };
1737
1738 // Fill this page with swi -1 so we'll no if we land in it somewhere.
1739 for (Addr addr = 0; addr < PageBytes; addr += sizeof(swiNeg1)) {
1740 tc->getMemProxy().writeBlob(commPage + addr,
1741 swiNeg1, sizeof(swiNeg1));
1740 tc->getVirtProxy().writeBlob(commPage + addr,
1741 swiNeg1, sizeof(swiNeg1));
1742 }
1743
1744 uint8_t memory_barrier[] =
1745 {
1746 0x5f, 0xf0, 0x7f, 0xf5, // dmb
1747 0x0e, 0xf0, 0xa0, 0xe1 // return
1748 };
1742 }
1743
1744 uint8_t memory_barrier[] =
1745 {
1746 0x5f, 0xf0, 0x7f, 0xf5, // dmb
1747 0x0e, 0xf0, 0xa0, 0xe1 // return
1748 };
1749 tc->getMemProxy().writeBlob(commPage + 0x0fa0, memory_barrier,
1750 sizeof(memory_barrier));
1749 tc->getVirtProxy().writeBlob(commPage + 0x0fa0, memory_barrier,
1750 sizeof(memory_barrier));
1751
1752 uint8_t cmpxchg[] =
1753 {
1754 0x9f, 0x3f, 0x92, 0xe1, // ldrex r3, [r2]
1755 0x00, 0x30, 0x53, 0xe0, // subs r3, r3, r0
1756 0x91, 0x3f, 0x82, 0x01, // strexeq r3, r1, [r2]
1757 0x01, 0x00, 0x33, 0x03, // teqeq r3, #1
1758 0xfa, 0xff, 0xff, 0x0a, // beq 1b
1759 0x00, 0x00, 0x73, 0xe2, // rsbs r0, r3, #0
1760 0x5f, 0xf0, 0x7f, 0xf5, // dmb
1761 0x0e, 0xf0, 0xa0, 0xe1 // return
1762 };
1751
1752 uint8_t cmpxchg[] =
1753 {
1754 0x9f, 0x3f, 0x92, 0xe1, // ldrex r3, [r2]
1755 0x00, 0x30, 0x53, 0xe0, // subs r3, r3, r0
1756 0x91, 0x3f, 0x82, 0x01, // strexeq r3, r1, [r2]
1757 0x01, 0x00, 0x33, 0x03, // teqeq r3, #1
1758 0xfa, 0xff, 0xff, 0x0a, // beq 1b
1759 0x00, 0x00, 0x73, 0xe2, // rsbs r0, r3, #0
1760 0x5f, 0xf0, 0x7f, 0xf5, // dmb
1761 0x0e, 0xf0, 0xa0, 0xe1 // return
1762 };
1763 tc->getMemProxy().writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg));
1763 tc->getVirtProxy().writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg));
1764
1765 uint8_t get_tls[] =
1766 {
1767 // read user read-only thread id register
1768 0x70, 0x0f, 0x1d, 0xee, // mrc p15, 0, r0, c13, c0, 3
1769 0x0e, 0xf0, 0xa0, 0xe1 // return
1770 };
1764
1765 uint8_t get_tls[] =
1766 {
1767 // read user read-only thread id register
1768 0x70, 0x0f, 0x1d, 0xee, // mrc p15, 0, r0, c13, c0, 3
1769 0x0e, 0xf0, 0xa0, 0xe1 // return
1770 };
1771 tc->getMemProxy().writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls));
1771 tc->getVirtProxy().writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls));
1772}
1773
1774void
1775ArmLinuxProcess64::initState()
1776{
1777 ArmProcess64::initState();
1778 // The 64 bit equivalent of the comm page would be set up here.
1779}
1772}
1773
1774void
1775ArmLinuxProcess64::initState()
1776{
1777 ArmProcess64::initState();
1778 // The 64 bit equivalent of the comm page would be set up here.
1779}