system.cc (9762:4574c5123153) system.cc (10554:fe2e2f06a7c8)
1/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
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

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

58X86System::X86System(Params *p) :
59 System(p), smbiosTable(p->smbios_table),
60 mpFloatingPointer(p->intel_mp_pointer),
61 mpConfigTable(p->intel_mp_table),
62 rsdp(p->acpi_description_table_pointer)
63{
64}
65
1/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
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

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

58X86System::X86System(Params *p) :
59 System(p), smbiosTable(p->smbios_table),
60 mpFloatingPointer(p->intel_mp_pointer),
61 mpConfigTable(p->intel_mp_table),
62 rsdp(p->acpi_description_table_pointer)
63{
64}
65
66static void
67installSegDesc(ThreadContext *tc, SegmentRegIndex seg,
66void
67X86ISA::installSegDesc(ThreadContext *tc, SegmentRegIndex seg,
68 SegDescriptor desc, bool longmode)
69{
70 uint64_t base = desc.baseLow + (desc.baseHigh << 24);
71 bool honorBase = !longmode || seg == SEGMENT_REG_FS ||
72 seg == SEGMENT_REG_GS ||
73 seg == SEGMENT_REG_TSL ||
74 seg == SYS_SEGMENT_REG_TR;
75 uint64_t limit = desc.limitLow | (desc.limitHigh << 16);

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

146 */
147 uint8_t numGDTEntries = 0;
148 // Place holder at selector 0
149 uint64_t nullDescriptor = 0;
150 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
151 (uint8_t *)(&nullDescriptor), 8);
152 numGDTEntries++;
153
68 SegDescriptor desc, bool longmode)
69{
70 uint64_t base = desc.baseLow + (desc.baseHigh << 24);
71 bool honorBase = !longmode || seg == SEGMENT_REG_FS ||
72 seg == SEGMENT_REG_GS ||
73 seg == SEGMENT_REG_TSL ||
74 seg == SYS_SEGMENT_REG_TR;
75 uint64_t limit = desc.limitLow | (desc.limitHigh << 16);

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

146 */
147 uint8_t numGDTEntries = 0;
148 // Place holder at selector 0
149 uint64_t nullDescriptor = 0;
150 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
151 (uint8_t *)(&nullDescriptor), 8);
152 numGDTEntries++;
153
154 SegDescriptor initDesc = 0;
155 initDesc.type.codeOrData = 0; // code or data type
156 initDesc.type.c = 0; // conforming
157 initDesc.type.r = 1; // readable
158 initDesc.dpl = 0; // privilege
159 initDesc.p = 1; // present
160 initDesc.l = 1; // longmode - 64 bit
161 initDesc.d = 0; // operand size
162 initDesc.g = 1; // granularity
163 initDesc.s = 1; // system segment
164 initDesc.limitHigh = 0xFFFF;
165 initDesc.limitLow = 0xF;
166 initDesc.baseHigh = 0x0;
167 initDesc.baseLow = 0x0;
168
154 //64 bit code segment
169 //64 bit code segment
155 SegDescriptor csDesc = 0;
170 SegDescriptor csDesc = initDesc;
156 csDesc.type.codeOrData = 1;
171 csDesc.type.codeOrData = 1;
157 csDesc.type.c = 0; // Not conforming
158 csDesc.type.r = 1; // Readable
159 csDesc.dpl = 0; // Privelege level 0
160 csDesc.p = 1; // Present
161 csDesc.l = 1; // 64 bit
162 csDesc.d = 0; // default operand size
163 csDesc.g = 1; // Page granularity
164 csDesc.s = 1; // Not a system segment
165 csDesc.limitHigh = 0xF;
166 csDesc.limitLow = 0xFFFF;
172 csDesc.dpl = 0;
167 //Because we're dealing with a pointer and I don't think it's
168 //guaranteed that there isn't anything in a nonvirtual class between
169 //it's beginning in memory and it's actual data, we'll use an
170 //intermediary.
171 uint64_t csDescVal = csDesc;
172 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
173 (uint8_t *)(&csDescVal), 8);
174
175 numGDTEntries++;
176
177 SegSelector cs = 0;
178 cs.si = numGDTEntries - 1;
179
180 tc->setMiscReg(MISCREG_CS, (MiscReg)cs);
181
182 //32 bit data segment
173 //Because we're dealing with a pointer and I don't think it's
174 //guaranteed that there isn't anything in a nonvirtual class between
175 //it's beginning in memory and it's actual data, we'll use an
176 //intermediary.
177 uint64_t csDescVal = csDesc;
178 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
179 (uint8_t *)(&csDescVal), 8);
180
181 numGDTEntries++;
182
183 SegSelector cs = 0;
184 cs.si = numGDTEntries - 1;
185
186 tc->setMiscReg(MISCREG_CS, (MiscReg)cs);
187
188 //32 bit data segment
183 SegDescriptor dsDesc = 0;
184 dsDesc.type.codeOrData = 0;
185 dsDesc.type.e = 0; // Not expand down
186 dsDesc.type.w = 1; // Writable
187 dsDesc.dpl = 0; // Privelege level 0
188 dsDesc.p = 1; // Present
189 dsDesc.d = 1; // default operand size
190 dsDesc.g = 1; // Page granularity
191 dsDesc.s = 1; // Not a system segment
192 dsDesc.limitHigh = 0xF;
193 dsDesc.limitLow = 0xFFFF;
189 SegDescriptor dsDesc = initDesc;
194 uint64_t dsDescVal = dsDesc;
195 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
196 (uint8_t *)(&dsDescVal), 8);
197
198 numGDTEntries++;
199
200 SegSelector ds = 0;
201 ds.si = numGDTEntries - 1;
202
203 tc->setMiscReg(MISCREG_DS, (MiscReg)ds);
204 tc->setMiscReg(MISCREG_ES, (MiscReg)ds);
205 tc->setMiscReg(MISCREG_FS, (MiscReg)ds);
206 tc->setMiscReg(MISCREG_GS, (MiscReg)ds);
207 tc->setMiscReg(MISCREG_SS, (MiscReg)ds);
208
209 tc->setMiscReg(MISCREG_TSL, 0);
210 tc->setMiscReg(MISCREG_TSG_BASE, GDTBase);
211 tc->setMiscReg(MISCREG_TSG_LIMIT, 8 * numGDTEntries - 1);
212
190 uint64_t dsDescVal = dsDesc;
191 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
192 (uint8_t *)(&dsDescVal), 8);
193
194 numGDTEntries++;
195
196 SegSelector ds = 0;
197 ds.si = numGDTEntries - 1;
198
199 tc->setMiscReg(MISCREG_DS, (MiscReg)ds);
200 tc->setMiscReg(MISCREG_ES, (MiscReg)ds);
201 tc->setMiscReg(MISCREG_FS, (MiscReg)ds);
202 tc->setMiscReg(MISCREG_GS, (MiscReg)ds);
203 tc->setMiscReg(MISCREG_SS, (MiscReg)ds);
204
205 tc->setMiscReg(MISCREG_TSL, 0);
206 tc->setMiscReg(MISCREG_TSG_BASE, GDTBase);
207 tc->setMiscReg(MISCREG_TSG_LIMIT, 8 * numGDTEntries - 1);
208
213 SegDescriptor tssDesc = 0;
214 tssDesc.type = 0xB;
215 tssDesc.dpl = 0; // Privelege level 0
216 tssDesc.p = 1; // Present
217 tssDesc.d = 1; // default operand size
218 tssDesc.g = 1; // Page granularity
219 tssDesc.s = 0;
220 tssDesc.limitHigh = 0xF;
221 tssDesc.limitLow = 0xFFFF;
209 SegDescriptor tssDesc = initDesc;
222 uint64_t tssDescVal = tssDesc;
223 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
224 (uint8_t *)(&tssDescVal), 8);
225
226 numGDTEntries++;
227
228 SegSelector tss = 0;
229 tss.si = numGDTEntries - 1;

--- 166 unchanged lines hidden ---
210 uint64_t tssDescVal = tssDesc;
211 physProxy.writeBlob(GDTBase + numGDTEntries * 8,
212 (uint8_t *)(&tssDescVal), 8);
213
214 numGDTEntries++;
215
216 SegSelector tss = 0;
217 tss.si = numGDTEntries - 1;

--- 166 unchanged lines hidden ---