process.cc (2715:4032e02b525e) process.cc (2976:371224501196)
1/*
2 * Copyright (c) 2003-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

27 *
28 * Authors: Gabe Black
29 * Ali Saidi
30 */
31
32#include "arch/sparc/isa_traits.hh"
33#include "arch/sparc/process.hh"
34#include "base/loader/object_file.hh"
1/*
2 * Copyright (c) 2003-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

27 *
28 * Authors: Gabe Black
29 * Ali Saidi
30 */
31
32#include "arch/sparc/isa_traits.hh"
33#include "arch/sparc/process.hh"
34#include "base/loader/object_file.hh"
35#include "base/loader/elf_object.hh"
35#include "base/misc.hh"
36#include "cpu/thread_context.hh"
37#include "mem/page_table.hh"
38#include "mem/translating_port.hh"
39#include "sim/system.hh"
40
41using namespace std;
42using namespace SparcISA;

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

124 SPARC_AT_PHENT = 4,
125 SPARC_AT_PHNUM = 5,
126 SPARC_AT_BASE = 7,
127 SPARC_AT_FLAGS = 8,
128 SPARC_AT_ENTRY = 9,
129 SPARC_AT_UID = 11,
130 SPARC_AT_EUID = 12,
131 SPARC_AT_GID = 13,
36#include "base/misc.hh"
37#include "cpu/thread_context.hh"
38#include "mem/page_table.hh"
39#include "mem/translating_port.hh"
40#include "sim/system.hh"
41
42using namespace std;
43using namespace SparcISA;

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

125 SPARC_AT_PHENT = 4,
126 SPARC_AT_PHNUM = 5,
127 SPARC_AT_BASE = 7,
128 SPARC_AT_FLAGS = 8,
129 SPARC_AT_ENTRY = 9,
130 SPARC_AT_UID = 11,
131 SPARC_AT_EUID = 12,
132 SPARC_AT_GID = 13,
132 SPARC_AT_EGID = 14
133 SPARC_AT_EGID = 14,
134 SPARC_AT_SECURE = 23
133 };
134
135 enum hardwareCaps
136 {
137 M5_HWCAP_SPARC_FLUSH = 1,
138 M5_HWCAP_SPARC_STBAR = 2,
139 M5_HWCAP_SPARC_SWAP = 4,
140 M5_HWCAP_SPARC_MULDIV = 8,

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

148 const int64_t hwcap =
149 M5_HWCAP_SPARC_FLUSH |
150 M5_HWCAP_SPARC_STBAR |
151 M5_HWCAP_SPARC_SWAP |
152 M5_HWCAP_SPARC_MULDIV |
153 M5_HWCAP_SPARC_V9 |
154 M5_HWCAP_SPARC_ULTRA3;
155
135 };
136
137 enum hardwareCaps
138 {
139 M5_HWCAP_SPARC_FLUSH = 1,
140 M5_HWCAP_SPARC_STBAR = 2,
141 M5_HWCAP_SPARC_SWAP = 4,
142 M5_HWCAP_SPARC_MULDIV = 8,

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

150 const int64_t hwcap =
151 M5_HWCAP_SPARC_FLUSH |
152 M5_HWCAP_SPARC_STBAR |
153 M5_HWCAP_SPARC_SWAP |
154 M5_HWCAP_SPARC_MULDIV |
155 M5_HWCAP_SPARC_V9 |
156 M5_HWCAP_SPARC_ULTRA3;
157
156 //Setup the auxilliary vectors. These will already have
157 //endian conversion.
158 auxv.push_back(buildAuxVect(SPARC_AT_EGID, 100));
159 auxv.push_back(buildAuxVect(SPARC_AT_GID, 100));
160 auxv.push_back(buildAuxVect(SPARC_AT_EUID, 100));
161 auxv.push_back(buildAuxVect(SPARC_AT_UID, 100));
162 //This would work, but the entry point is a protected member
163 //auxv.push_back(buildAuxVect(SPARC_AT_ENTRY, objFile->entry));
164 auxv.push_back(buildAuxVect(SPARC_AT_FLAGS, 0));
165 //This is the address of the elf "interpreter", which I don't
166 //think we currently set up. It should be set to 0 (I think)
167 //auxv.push_back(buildAuxVect(SPARC_AT_BASE, 0));
168 //This is the number of headers which were in the original elf
169 //file. This information isn't avaibale by this point.
170 //auxv.push_back(buildAuxVect(SPARC_AT_PHNUM, 3));
171 //This is the size of a program header entry. This isn't easy
172 //to compute here.
173 //auxv.push_back(buildAuxVect(SPARC_AT_PHENT, blah));
174 //This is should be set to load_addr (whatever that is) +
175 //e_phoff. I think it's a pointer to the program headers.
176 //auxv.push_back(buildAuxVect(SPARC_AT_PHDR, blah));
177 //This should be easy to get right, but I won't set it for now
178 //auxv.push_back(buildAuxVect(SPARC_AT_CLKTCK, blah));
179 auxv.push_back(buildAuxVect(SPARC_AT_PAGESZ, SparcISA::VMPageSize));
180 auxv.push_back(buildAuxVect(SPARC_AT_HWCAP, hwcap));
181
158
159 //Setup the auxilliary vectors. These will already have endian conversion.
160 //Auxilliary vectors are loaded only for elf formatted executables.
161 ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
162 if(elfObject)
163 {
164 //Bits which describe the system hardware capabilities
165 auxv.push_back(buildAuxVect(SPARC_AT_HWCAP, hwcap));
166 //The system page size
167 auxv.push_back(buildAuxVect(SPARC_AT_PAGESZ, SparcISA::VMPageSize));
168 //Defined to be 100 in the kernel source.
169 //Frequency at which times() increments
170 auxv.push_back(buildAuxVect(SPARC_AT_CLKTCK, 100));
171 // For statically linked executables, this is the virtual address of the
172 // program header tables if they appear in the executable image
173 auxv.push_back(buildAuxVect(SPARC_AT_PHDR, elfObject->programHeaderTable()));
174 // This is the size of a program header entry from the elf file.
175 auxv.push_back(buildAuxVect(SPARC_AT_PHENT, elfObject->programHeaderSize()));
176 // This is the number of program headers from the original elf file.
177 auxv.push_back(buildAuxVect(SPARC_AT_PHNUM, elfObject->programHeaderCount()));
178 //This is the address of the elf "interpreter", It should be set
179 //to 0 for regular executables. It should be something else
180 //(not sure what) for dynamic libraries.
181 auxv.push_back(buildAuxVect(SPARC_AT_BASE, 0));
182 //This is hardwired to 0 in the elf loading code in the kernel
183 auxv.push_back(buildAuxVect(SPARC_AT_FLAGS, 0));
184 //The entry point to the program
185 auxv.push_back(buildAuxVect(SPARC_AT_ENTRY, objFile->entryPoint()));
186 //Different user and group IDs
187 auxv.push_back(buildAuxVect(SPARC_AT_UID, 100));
188 auxv.push_back(buildAuxVect(SPARC_AT_EUID, 100));
189 auxv.push_back(buildAuxVect(SPARC_AT_GID, 100));
190 auxv.push_back(buildAuxVect(SPARC_AT_EGID, 100));
191 //Whether to enable "secure mode" in the executable
192 auxv.push_back(buildAuxVect(SPARC_AT_SECURE, 0));
193 }
194
182 //Figure out how big the initial stack needs to be
183
184 //Each auxilliary vector is two 8 byte words
185 int aux_data_size = 2 * intSize * auxv.size();
186 int env_data_size = 0;
187 for (int i = 0; i < envp.size(); ++i) {
188 env_data_size += envp[i].size() + 1;
189 }

--- 95 unchanged lines hidden ---
195 //Figure out how big the initial stack needs to be
196
197 //Each auxilliary vector is two 8 byte words
198 int aux_data_size = 2 * intSize * auxv.size();
199 int env_data_size = 0;
200 for (int i = 0; i < envp.size(); ++i) {
201 env_data_size += envp[i].size() + 1;
202 }

--- 95 unchanged lines hidden ---