System segment type field
##########################
0 undefined
1. 286TSS available
2 LDT
3 busy 286TSS
4. 286 call Portals
5 tasks
6 286 broken doors
286 trap door
8 undefined
9. Available ipvtss
A undefined
B busy javastss
C 386
D undefined
E 386 interrupt door
F 386 trap door
#########################
CS Transfer
CPL = DPL, RPL <= DPL; CPL> = DPL
Transfer by calling the door
1. CPL <= DPL of the calling door
2. The sub-RPL must meet the requirements of RPL <= DPL of the call gate
Load and load data segments read and executable code segments DS, ES, FS, or GS
1. CPL <= DPL, RPL <= DPL
Use the inter-segment transfer command JMP of the call door
RPL = 0. Therefore, the RPL <= DPL condition can always be met.
1. When CPL = DPL for a common non-consistent code segment, there is a transfer without a privilege level change.
2. For consistent code segments that meet CPL> = DPL, there is also a transfer without a privilege level change.
3. Exceptions may occur in other cases.
The selection of the return address used by the RET command can only use the code segment descriptor, but cannot use any
The system segment descriptor or gate descriptor, of course, cannot use the data segment descriptor, otherwise it will cause an exception
Switch tasks directly through TSS, and switch tasks through the job Gate
CPL <= dpl rpl <= tss dpl, CPL <= task gate dpl rpl <= task gate dpl tss dpl is not detected
Task Switching Process
|
|
|
V
TSS call gate CPL <= DPL, RPL <= DPL
|
|
|
V
TSS_DESC DPL not detected
|
|
|
V
TSS
|
|
|
V
Cs_selector [RPL-> CPL, RPL = DPL]
Cs_selector to be put into the TSS must be equal to the DPL of the corresponding segment descriptor
Task Switching and privilege level transformation Sample:
(Use only privileged)
# Initialization task 0. the TSS segment of tss0_sel already has a valid value of level 0 Stack
Init_task0:
Movw tss0_sel, % ax
Ltr % ax
Movw $ tss_0, % ax
# Switch from privileged level 0 to privileged level 3. At this time, level 0 stacks must be available
Switch_to_usermode:
# Cs and eip
Pushw <Select Sub>
Pushl <eip start address>
Lret
Switch_to_sysmode:
Call <call door>
0x0 null
0x8 kernel cs at DPL = 0 desc
0x10 kernel ds at DPL = 0 desc
0x18 kernel cs at DPL = 3 desc
0x20 kernel ds at DPL = 3 desc
0x28 reserved
0x30 reserved
0x38 reserved
0x40 reserved
0x48 reserved
0x50 reserved
0x58 reserved
0x60 reserved
0x68 reserved
0x70
Vector number, Exception name, exception type, error code, interrupt, service program, related commands
0 Division Error fault NO _ divide_error DIV, IDIV
1. debug abnormal faults/traps without any instructions
2 NMI unshielded and interrupted
3 single-byte INT3 trap no INT 3
4. No INTO overflow traps
5. bounds_check_error BOUNT
6. Invalid operation code fault NO _ illegal_opt_code illegal instruction code or operand
7 device unavailable fault NO _ device_not_available floating point instruction or WAIT
8. Dual-fault suspension with any instructions
9. The coprocessor segment is out of the range to abort floating point commands without access to memory.
0AH invalid TSS exception faults include _ invalid_tss JMP, CALL, IRET, or interruption
The 0BH segment does not have a fault. The _ segment_not_exist loading segment register instruction exists.
0CH stack segment exception fault: _ stack_segment_error: any commands for loading SS registers and accessing SS addressing segments
0DH general protection exception faults include _ general_protect_error any privileged commands and any access to memory commands
0EH page exception faults include _ page_error commands for access to memory
10 H coprocessor_error: coprocessor_error floating point instruction or WAIT
11H-0FFH Soft Interrupt trap no INT n
----------------------------------------------------------
Offset size name description
0x90000 0x10 hda hard disk parameters
0x90010 0x10 hdb hard disk parameters
0x90020 word dma_mem size between 1-16 M in KB max = 3C00h = 15 M
0x90022 word normal_mem mem above 16 M, in 64KB blocks
0x90024 word cur_video_page current video page
0x90026 byte video_mode
0x90027 byte reserved
0x90028 byte video_mem 0x00-64kb, 0x01-128kb, 0x02-192kb, 0x03-256kb
0x90029 byte reserved
0x90030 word reserved
0x90032 byte video_stat 0x00-color, I/O = 0x3dX; 0x11-monochrome, I/O = 0x3bX
0x90033 byte reserved
0x90034 word charac_par graphics card feature parameters
0x90040 word kernel_size kernel size, in 4kb