首页 > 解决方案 > 调用8259A的时钟中断0x20中断时,跳转到0xf000:fff0

问题描述

我正在尝试编写一个微内核。当我想从内核跳转到第一个进程时,时钟中断有问题。当代码仍在内核中时, i stiand int 0x20and 代码确实会跳转到时钟处理程序。使用iret返回第一个进程后,我尝试int 0x20在进程中,但它没有跳转到时钟处理程序和 f000:fff0。仅供参考:eflags 在过程中间是 0x1212。我在 bochs 中刺激 x86 机器。 我想知道它无法跳转到时钟处理程序的原因。 如果需要更多细节,请告诉我。感谢您提前回复。

%include "const.inc"

extern  cstart          ;function
extern  gdtPos          ;global variable
extern  idtPos          ;global variable
extern  dispPos         ;global variable
extern  PCBready        ;global variable
extern  intReEnterFlag  ;global variable
extern  tss             ;global variable

global LABEL_TOPOFSTACK
global halt

[SECTION .bss]
LABEL_STACK_KERNEL:     resb        2*1024
LABEL_TOPOFSTACK:

[SECTION .text]
global _start

_start:
    mov esp,LABEL_TOPOFSTACK    ;LABEL_TOPSTACK=0x32800  ss=0x10
    mov dword [dispPos],0x00    ;label dispPos is 0x32800
    mov dword [intReEnterFlag],0x00
    sgdt [gdtPos];label gdtPos is 0x32c20
    call cstart
    lgdt [gdtPos]
    lidt [idtPos]                   ;label idtPos is 0x32804
    jmp MACRO_SelectorFlatC:csinit
csinit:                             ;0x08:0x3043a
;start the first process, recover the first process field
    mov ax,MACRO_SelectorTSS
    ltr ax
    mov esp,[PCBready]
    lldt [esp+MACRO_P_PCBSel]
    lea eax,[esp+MACRO_P_STACKTOP]
    mov dword [tss+MACRO_T_ESP0],eax

    dec dword [intReEnterFlag]
    pop gs
    pop fs
    pop es
    pop ds
    popad
    ;sti
    ;hlt
    add esp,4
    iretd
halt:
    int 0x20
    hlt
    ret
#include "type.h"
#include "const.h"
#include "intVector.h"
#include "important.h"
#include "process.h"
#include "prototype.h"
#include "task.h"
#include "global.h"

void halt();
PUBLIC void TestA() { //0x05:0x30d01
    halt();
    int i = 0;
    while (1) {
        dispPos = 0;
        dispStr("A");
        dispInt(i++);
        dispStr(".");
    }
}

标签: cassemblyx86-16

解决方案


推荐阅读