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