2024-07-12 06:58:25 +00:00
|
|
|
;; File: cpu.inc
|
|
|
|
|
|
|
|
|
|
|
|
;; Structure: tss
|
|
|
|
;;
|
|
|
|
;; > 31 23 15 7 0
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x64 | I/O map base | 00000000 0000000T |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x60 | 00000000 00000000 | LDT |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x5c | 00000000 00000000 | GS |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x58 | 00000000 00000000 | FS |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x54 | 00000000 00000000 | DS |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x50 | 00000000 00000000 | SS |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x4C | 00000000 00000000 | CS |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x48 | 00000000 00000000 | ES |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x44 | EDI |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x40 | ESI |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x3C | EBP |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x38 | ESP |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x34 | EBX |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x30 | EDX |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x2C | ECX |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x28 | EAX |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x24 | EFLAGS |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x20 | EIP |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x1C | CR3 |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x18 | 00000000 00000000 | SS2 |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x14 | ESP2 |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x10 | 00000000 00000000 | SS1 |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x0C | ESP1 |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x08 | 00000000 00000000 | SS0 |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x04 | ESP0 |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
;; > 0x00 | 00000000 00000000 | old TSS selector |
|
|
|
|
;; > +----------|----------+----------|----------+
|
|
|
|
|
|
|
|
struc TSS {
|
|
|
|
.prev_tss dd ?
|
|
|
|
.esp0 dd ?
|
|
|
|
.ss0 dd ?
|
|
|
|
.esp1 dd ?
|
|
|
|
.ss1 dd ?
|
|
|
|
.esp2 dd ?
|
|
|
|
.ss2 dd ?
|
|
|
|
.cr3 dd ?
|
|
|
|
.eip dd ?
|
|
|
|
.eflags dd ?
|
|
|
|
.eax dd ?
|
|
|
|
.ecx dd ?
|
|
|
|
.edx dd ?
|
|
|
|
.ebx dd ?
|
|
|
|
.esp dd ?
|
|
|
|
.ebp dd ?
|
|
|
|
.esi dd ?
|
|
|
|
.edi dd ?
|
|
|
|
.es dd ?
|
|
|
|
.cs dd ?
|
|
|
|
.ss dd ?
|
|
|
|
.ds dd ?
|
|
|
|
.fs dd ?
|
|
|
|
.gs dd ?
|
|
|
|
.ldt dd ?
|
|
|
|
.trap dw ?
|
|
|
|
.iomap dw ?
|
|
|
|
}
|
|
|
|
|
2024-07-13 17:02:35 +00:00
|
|
|
struc GDTGate {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
;; Structure: IDTGate
|
2024-07-12 06:58:25 +00:00
|
|
|
;; .offset_low - TODO
|
|
|
|
;; .selector - TODO
|
|
|
|
;; .zero - TODO
|
|
|
|
;; .attributes - TODO
|
|
|
|
;; .offset_high - TODO
|
|
|
|
;;
|
2024-07-13 17:02:35 +00:00
|
|
|
struc IDTGate {
|
|
|
|
.offset_low dw ?
|
|
|
|
.selector dw ?
|
|
|
|
.zero db 0
|
|
|
|
.attributes db ?
|
|
|
|
.offset_high dw ?
|
|
|
|
}
|
2024-07-12 06:58:25 +00:00
|
|
|
|
|
|
|
;; About: Gates
|
|
|
|
;; - Task Gate
|
|
|
|
;; > 31 23 15 7 0
|
|
|
|
;; > +----------------|----------------+-----------------|-----------------+
|
|
|
|
;; > | (NOT USED) | P DPL 0 0 1 0 1 (NOT USED) |
|
|
|
|
;; > +----------------|----------------+-----------------|-----------------+
|
|
|
|
;; > | SELECTOR | (NOT USED) |
|
|
|
|
;; > +----------------|----------------+-----------------|-----------------+
|
|
|
|
;;
|
|
|
|
;; - Interrupt Gate
|
|
|
|
;; > 31 23 15 7 0
|
|
|
|
;; > +----------------|----------------+-----------------|-----------------+
|
|
|
|
;; > | OFFSET 31..16 | P DPL 0 1 1 1 0 0 0 0 0 0 0 0 0 |
|
|
|
|
;; > +----------------|----------------+-----------------|-----------------+
|
|
|
|
;; > | SELECTOR | OFFSET 15..0 |
|
|
|
|
;; > +--------------- |----------------+-----------------|-----------------+
|
|
|
|
;;
|
|
|
|
;; - Trap Gate
|
|
|
|
;; > 31 23 15 7 0
|
|
|
|
;; > +----------------|----------------+-----------------|-----------------+
|
|
|
|
;; > | OFFSET 31..16 | P DPL 0 1 1 1 1 0 0 0 0 0 0 0 0 |
|
|
|
|
;; > +----------------|----------------+-----------------|-----------------+
|
|
|
|
;; > | SELECTOR | OFFSET 15..0 |
|
|
|
|
;; > +--------------- |----------------+-----------------|-----------------+
|
|
|
|
|
|
|
|
|
2024-07-14 09:22:43 +00:00
|
|
|
struc IntFrame {
|
2024-07-12 06:58:25 +00:00
|
|
|
;; registers
|
2024-07-13 17:02:35 +00:00
|
|
|
.edi dd ?
|
|
|
|
.esi dd ?
|
|
|
|
.ebp dd ?
|
|
|
|
.esp dd ?
|
|
|
|
.ebx dd ?
|
|
|
|
.edx dd ?
|
|
|
|
.ecx dd ?
|
|
|
|
.eax dd ?
|
2024-07-12 06:58:25 +00:00
|
|
|
|
|
|
|
;;
|
2024-07-13 17:02:35 +00:00
|
|
|
.gs dd ?
|
|
|
|
.fs dd ?
|
|
|
|
.es dd ?
|
|
|
|
.ds dd ?
|
|
|
|
.intno dd ?
|
2024-07-12 06:58:25 +00:00
|
|
|
|
|
|
|
;; by x86 hardware
|
2024-07-13 17:02:35 +00:00
|
|
|
.err dd ?
|
|
|
|
.eip dd ?
|
|
|
|
.cs dd ?
|
|
|
|
.eflags dd ?
|
2024-07-12 06:58:25 +00:00
|
|
|
|
|
|
|
;; crossring
|
2024-07-13 17:02:35 +00:00
|
|
|
.useresp dd ?
|
|
|
|
.ss dd ?
|
|
|
|
}
|
2024-07-14 09:22:43 +00:00
|
|
|
virtual at 0
|
|
|
|
IntFrame IntFrame
|
|
|
|
sizeof.IntFrame:
|
|
|
|
end virtual
|