| 181 | } |
| 182 | |
| 183 | void 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 | |
| 205 | int ProgramManager::executeProcess(const char *filename, int priority) |
| 206 | { |