| // This file contains definitions for the | |
| // x86 memory management unit (MMU). | |
| // Eflags register | |
| // Control Register flags | |
| // various segment selectors. | |
| // cpu->gdt[NSEGS] holds the above segments. | |
| // Segment Descriptor | |
| struct segdesc { | |
| uint lim_15_0 : 16; // Low bits of segment limit | |
| uint base_15_0 : 16; // Low bits of segment base address | |
| uint base_23_16 : 8; // Middle bits of segment base address | |
| uint type : 4; // Segment type (see STS_ constants) | |
| uint s : 1; // 0 = system, 1 = application | |
| uint dpl : 2; // Descriptor Privilege Level | |
| uint p : 1; // Present | |
| uint lim_19_16 : 4; // High bits of segment limit | |
| uint avl : 1; // Unused (available for software use) | |
| uint rsv1 : 1; // Reserved | |
| uint db : 1; // 0 = 16-bit segment, 1 = 32-bit segment | |
| uint g : 1; // Granularity: limit scaled by 4K when set | |
| uint base_31_24 : 8; // High bits of segment base address | |
| }; | |
| // Normal segment | |
| // Application segment type bits | |
| // System segment type bits | |
| // A virtual address 'la' has a three-part structure as follows: | |
| // | |
| // +--------10------+-------10-------+---------12----------+ | |
| // | Page Directory | Page Table | Offset within Page | | |
| // | Index | Index | | | |
| // +----------------+----------------+---------------------+ | |
| // \--- PDX(va) --/ \--- PTX(va) --/ | |
| // page directory index | |
| // page table index | |
| // construct virtual address from indexes and offset | |
| // Page directory and page table constants. | |
| // Page table/directory entry flags. | |
| // Address in page table or page directory entry | |
| typedef uint pte_t; | |
| // Task state segment format | |
| struct taskstate { | |
| uint link; // Old ts selector | |
| uint esp0; // Stack pointers and segment selectors | |
| ushort ss0; // after an increase in privilege level | |
| ushort padding1; | |
| uint *esp1; | |
| ushort ss1; | |
| ushort padding2; | |
| uint *esp2; | |
| ushort ss2; | |
| ushort padding3; | |
| void *cr3; // Page directory base | |
| uint *eip; // Saved state from last task switch | |
| uint eflags; | |
| uint eax; // More saved state (registers) | |
| uint ecx; | |
| uint edx; | |
| uint ebx; | |
| uint *esp; | |
| uint *ebp; | |
| uint esi; | |
| uint edi; | |
| ushort es; // Even more saved state (segment selectors) | |
| ushort padding4; | |
| ushort cs; | |
| ushort padding5; | |
| ushort ss; | |
| ushort padding6; | |
| ushort ds; | |
| ushort padding7; | |
| ushort fs; | |
| ushort padding8; | |
| ushort gs; | |
| ushort padding9; | |
| ushort ldt; | |
| ushort padding10; | |
| ushort t; // Trap on task switch | |
| ushort iomb; // I/O map base address | |
| }; | |
| // Gate descriptors for interrupts and traps | |
| struct gatedesc { | |
| uint off_15_0 : 16; // low 16 bits of offset in segment | |
| uint cs : 16; // code segment selector | |
| uint args : 5; // # args, 0 for interrupt/trap gates | |
| uint rsv1 : 3; // reserved(should be zero I guess) | |
| uint type : 4; // type(STS_{IG32,TG32}) | |
| uint s : 1; // must be 0 (system) | |
| uint dpl : 2; // descriptor(meaning new) privilege level | |
| uint p : 1; // Present | |
| uint off_31_16 : 16; // high bits of offset in segment | |
| }; | |
| // Set up a normal interrupt/trap gate descriptor. | |
| // - istrap: 1 for a trap (= exception) gate, 0 for an interrupt gate. | |
| // interrupt gate clears FL_IF, trap gate leaves FL_IF alone | |
| // - sel: Code segment selector for interrupt/trap handler | |
| // - off: Offset in code segment for interrupt/trap handler | |
| // - dpl: Descriptor Privilege Level - | |
| // the privilege level required for software to invoke | |
| // this interrupt/trap gate explicitly using an int instruction. | |
Xet Storage Details
- Size:
- 6.57 kB
- Xet hash:
- a8d524f0d256c1b52d86363b70b58567bf02018378d6791f2df86134d5b66482
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.