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

Method initializeTSS

lab8/src/5/src/kernel/program.cpp:179–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

memsetFunction · 0.50

Tested by

no test coverage detected