MCPcopy Create free account
hub / github.com/YatSenOS/YatSenOS-Tutorial-Volume-1 / initializeTSS

Method initializeTSS

lab8/src/6/src/kernel/program.cpp:183–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183void ProgramManager::initializeTSS()
184{
185
186 int size = sizeof(TSS);
187 int address = (int)&tss;
188
189 memset((char *)address, 0, size);
190 tss.ss0 = STACK_SELECTOR; // 内核态堆栈段选择子
191
192 int low, high, limit;
193
194 limit = size - 1;
195 low = (address << 16) | (limit & 0xff);
196 // DPL = 0
197 high = (address & 0xff000000) | ((address & 0x00ff0000) >> 16) | ((limit & 0xff00) << 16) | 0x00008900;
198
199 int selector = asm_add_global_descriptor(low, high);
200 // RPL = 0
201 asm_ltr(selector << 3);
202 tss.ioMap = address + size;
203}
204
205int ProgramManager::executeProcess(const char *filename, int priority)
206{

Callers

nothing calls this directly

Calls 1

memsetFunction · 0.50

Tested by

no test coverage detected