⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tss.c

📁 一个操作系统的源代码
💻 C
字号:
/** tss.c ** ** Original Author: Kasper Verdich Lund ** Date: 10/11/99 ** ** Description: ** TSS routines ** ** This program is free software, you can redistribute it and/or ** modify it under the terms of the GNU General Public License ** as published by the Free Software Foundation; either version ** 2 of the License, or (at your option) any later version. ** ** This program is distributed in the hope that it will be ** useful, but WITHOUT ANY WARRANTY; without even the implied ** warranty or MERCHANTABILITY or FITNESS FOR A PARTICULAR ** PURPOSE.  See the GNU General Public License for more ** details. ** ** You should have received a copy of the GNU General Public ** License along with this program; if not, write to the ** Free Software Foundation, Inc., 59 Temple Place, Suite 330, ** Boston, MA 02111-1307 USA ** *********************************************************Apostle OS**/#include <tss.h>#include <gdt.h>#include <paging.h>#include <exception.h>#include <address_space.h>#include <mem.h>#include <string.h>TSS *systemTSS;TSS *doublefaultTSS;TSS *nmiTSS;static TSS *newTSS(dword i_eip, dword i_esp, dword i_cr3, dword i_eflags,		   dword i_cs, dword i_ds, dword i_ss){  TSS *tss = (TSS *)pmalloc();  memset(tss, 0, PAGE_SIZE);  tss->eip = i_eip;  tss->esp = i_esp;  tss->cr3 = i_cr3;  tss->eflags = i_eflags;  tss->cs = i_cs;  tss->ds = i_ds;  tss->ss = i_ss;  return tss;}void setKernelStack(TSS *tss, dword sp){  tss->esp0 = sp;  tss->ss0 = 0x10;}/* must be called AFTER setupGDT */void setupTSS(void){  systemTSS = newTSS(0, 0, 0, 0, 0, 0, 0);  setKernelStack(systemTSS, 0);  doublefaultTSS = newTSS((dword)&__DoubleFault, 			  (dword)malloc(PAGE_SIZE)+PAGE_SIZE,			  (dword)systemSpace, 0x02, 0x08, 0x23, 0x10);  nmiTSS = newTSS((dword)&__NonMaskableInterrupt, 		  (dword)malloc(PAGE_SIZE)+PAGE_SIZE,		  (dword)systemSpace, 0x02, 0x08, 0x23, 0x10);  setupDescriptor(&GDT[5], (dword)systemTSS, sizeof(TSS)-1, 9, 0, 0, 0); /* 0x28 */  setupDescriptor(&GDT[6], (dword)doublefaultTSS, sizeof(TSS)-1, 9, 0, 0, 0);  setupDescriptor(&GDT[7], (dword)nmiTSS, sizeof(TSS)-1, 9, 0, 0, 0);  __asm__("movl $0x28, %eax\n"	  "ltr %ax");}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -