/* Copyright (C) 2008 Emmanuel Varoquaux This file is part of XOS. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _SYSTEM_DATA_STRUCTS_H #define _SYSTEM_DATA_STRUCTS_H /* descripteurs */ /* types de descripteurs systeme */ #define SDT_AVL286TSS 0x1 /* Available 286 TSS */ #define SDT_LDT 0x2 /* LDT */ #define SDT_BSY286TSS 0x3 /* Busy 286 TSS */ #define SDT_CALLGT 0x4 /* Call Gate */ #define SDT_TASKGT 0x5 /* Task Gate */ #define SDT_286INTGT 0x6 /* 286 Interrupt Gate */ #define SDT_286TRAPGT 0x7 /* 286 Trap Gate */ #define SDT_AVL386TSS 0x9 /* Available 386 TSS */ #define SDT_BSY386TSS 0xb /* Busy 386 TSS */ #define SDT_386CALLGT 0xc /* 386 Call Gate */ #define SDT_386INTGT 0xe /* 386 Interrupt Gate */ #define SDT_386TRAPGT 0xf /* 386 Trap Gate */ struct descr_data_struct { unsigned type : 1; /* 0=system, 1=segment */ union { struct { /* system */ unsigned system_type : 4; }; struct { /* segment */ unsigned accessed : 1; unsigned segment_type : 1; /* 0=data, 1=code */ union { struct { /* data */ unsigned writable : 1; unsigned expand_down : 1; }; struct { /* code */ unsigned readable : 1; unsigned conforming : 1; }; }; }; }; unsigned dpl : 2; unsigned present : 1; union { struct { /* present */ union { struct { /* segment, ldt, tss */ unsigned long base; unsigned limit : 20; unsigned granularity : 1; unsigned avl : 1; union { unsigned x : 1; /* system */ unsigned big : 1; /* data */ unsigned def : 1; /* code */ }; }; struct { /* gate */ unsigned short selector; union { struct { /* call gate, interrupt gate, trap gate */ unsigned long offset; union { unsigned dword_count : 5; /* call gate */ }; }; }; }; }; }; }; }; /* selecteurs */ struct sel_data_struct { unsigned rpl : 2; unsigned table_ind : 1; unsigned index : 13; }; /* adresses lineaires */ struct linear_address_data_struct { unsigned dir : 10; unsigned page : 10; unsigned offset : 12; }; /* entrees de table des pages */ struct page_table_entry_data_struct { unsigned present : 1; union { struct { /* present */ unsigned rw : 1; /* 0=read-only, 1=read/write */ unsigned us : 1; /* 0=supervisor, 1=user */ unsigned accessed : 1; unsigned dirty : 1; unsigned avail : 3; unsigned long page_frame_addr; }; }; }; /* segments d'etat de tache */ struct tss_data_struct { /* champs statiques */ unsigned long pdbr; unsigned short ldt; unsigned short ss0; unsigned long esp0; unsigned short ss1; unsigned long esp1; unsigned short ss2; unsigned long esp2; unsigned trap : 1; unsigned short iomap_base; /* champs dynamiques */ unsigned long eax; unsigned long ebx; unsigned long ecx; unsigned long edx; unsigned long ebp; unsigned long esp; unsigned long esi; unsigned long edi; unsigned short cs; unsigned short ds; unsigned short es; unsigned short fs; unsigned short gs; unsigned short ss; unsigned long eflags; unsigned long eip; unsigned short previous; }; /* code d'erreur */ struct error_code_data_struct { unsigned ext : 1; unsigned idt : 1; unsigned table_ind : 1; unsigned index : 13; }; /* code d'erreur des defauts de page */ struct page_fault_error_code_data_struct { unsigned cause : 1; /* 0=not-present page, 1=protection violation */ unsigned access : 1; /* 0=read, 1=write */ unsigned mode : 1; /* 0=supervisor, 1=user */ }; #endif