|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
最近在做操作系统,已经实现了r0到r3的跳转,但是在中断的时候cpu又触发了无效TSS的异常,然后系统直接挂掉重启,有那个大佬帮忙看看是哪里出了问题
TASK_STATE_SEGMENT tss;
void init_tss()
{
/* Initialize TSS and TR */
memset_w((word*)&tss, 0, sizeof(TASK_STATE_SEGMENT) >> 1);
tss.ss0 = KERNEL_DS;
tss.io_bitmap_base = sizeof(tss); /* No IO bitmap */
load_tr(add_tss_descriptor((dword)&tss, sizeof(TASK_STATE_SEGMENT)));
}
word add_tss_descriptor(dword seg_base, dword seg_limit)
{
return add_global_descriptor(seg_base, seg_limit,
SEG_PRESENT | DPL_RING0 | SYSTEM_DESCPRITOR | AVAILABLE_386TSS, USE_32BITS_OPERAND);
}
word add_global_descriptor(dword seg_base, dword seg_limit, byte authority, byte attr)
{
if (avl_gdt_index > NUM_OF_GDT_DESC)
return 0;
seg_limit--;
gdt[avl_gdt_index].seg_limit_low = LOWORD(seg_limit);
gdt[avl_gdt_index].seg_limit_high = HIWORD(seg_limit) & 0xf;
gdt[avl_gdt_index].seg_base_low = LOWORD(seg_base);
gdt[avl_gdt_index].seg_base_mid = LOBYTE(HIWORD(seg_base));
gdt[avl_gdt_index].seg_base_high = HIBYTE(HIWORD(seg_base));
gdt[avl_gdt_index].access_authority = authority;
gdt[avl_gdt_index].attribute = attr;
/* Next available index */
avl_gdt_index++;
return (avl_gdt_index - 1) << 3;
}
_load_tr:
push ebp
mov ebp, esp
ltr [ebp + 8]
leave
ret |
|