Strange error while switching task from main task and INT
Posted: Tue Dec 31, 2013 3:24 pm
Hey,
My scheduler is based on IRQ0 interrupt.
While it's done in this way (nasm):
I know that I should make inside irq0_handler:
- a queue with tasks to switch,
- set 0x60 value to port 0x20,
- iretd instruction execution,
but it's only here to present my problem. In my code all of it is included Main idea of code presented above is that it will be executed in main task (0x30 selector) and hardware switch will be done properly. A goal here was to move from main task (sel 0x30) to new task (0x38 sel).
Second code presents like:
Above interrupts are disabled. A goal here is same as in first example, to change task from main (0x30 selector) to second (0x38 selector). This code causes Bochs returning errors, here is log:
I haven't set ESP0/SS0 values for TSS of new task I am jumping to. Main task and new task privilege levels are both "0". May it be a reason ? I didn't understand what SS0/ESP0 is for. OSdev wiki says about it only for software task switching. If some one could explain it to me then I would be grateful
My scheduler is based on IRQ0 interrupt.
While it's done in this way (nasm):
Code: Select all
main_program:
;some code here
sti
just_a_loop_in_main_program:
jmp just_a_loop_in_main_program
irq0_handler:
jmp dword 38h:0h
- a queue with tasks to switch,
- set 0x60 value to port 0x20,
- iretd instruction execution,
but it's only here to present my problem. In my code all of it is included Main idea of code presented above is that it will be executed in main task (0x30 selector) and hardware switch will be done properly. A goal here was to move from main task (sel 0x30) to new task (0x38 sel).
Second code presents like:
Code: Select all
main_program:
;some code here
jmp dword 38h:0h
just_a_loop_in_main_program:
jmp just_a_loop_in_main_program
Why jumping from task (not interrupt executed in main task context) causes problem here ?00147099153i[BIOS ] Booting from 0000:7c00
00153600004i[XGUI ] charmap update. Font Height is 16
00168295795e[CPU0 ] jump_protected: gate type 11 unsupported
00168295801e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295807e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295813e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295819e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295825e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295831e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295837e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295843e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295849e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295855e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295861e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295867e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295873e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295879e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295885e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295891e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295897e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295903e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295909e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295915e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295921e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295927e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295933e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295939e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295945e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295951e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295957e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295963e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295969e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295975e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295981e[CPU0 ] fetch_raw_descriptor: LDTR.valid=0
00168295981e[CPU0 ] stackPrefetch(4): access [0xfffffffc] > SS.limit [0x00007000]
00168295981e[CPU0 ] stackPrefetch(4): access [0xfffffffc] > SS.limit [0x00007000]
00168295981i[CPU0 ] CPU is in protected mode (active)
00168295981i[CPU0 ] CS.mode = 32 bit
00168295981i[CPU0 ] SS.mode = 32 bit
00168295981i[CPU0 ] EFER = 0x00000000
00168295981i[CPU0 ] | EAX=0000ea46 EBX=00000004 ECX=00000002 EDX=00000000
00168295981i[CPU0 ] | ESP=00000004 EBP=00000000 ESI=00000090 EDI=00000000
I haven't set ESP0/SS0 values for TSS of new task I am jumping to. Main task and new task privilege levels are both "0". May it be a reason ? I didn't understand what SS0/ESP0 is for. OSdev wiki says about it only for software task switching. If some one could explain it to me then I would be grateful