// 用来定义段描述符的宏 //// assembler macros to create x86 segments//// 定义了一个空段描述符 #define SEG_NULLASM \ .word 0, 0; \ .byte 0, 0, 0, 0// 以type,base,lim为参数定义一个段描述符, 其中的0xC0=(1100)2, 其// 中的第一个1对应于段描述符中的G位,置1表示段界限以4KB为单位// 第二个1对应于段描述符的D位,置1表示这是一个保护模式下的段描述符// 具体的关于段描述符的格式定义在mmu.h中 // The 0xC0 means the limit is in 4096-byte units// and (for executable segments) 32-bit mode.#define SEG_ASM(type,base,lim) \ .word (((lim) >> 12) & 0xffff), ((base) & 0xffff); \ .byte (((base) >> 16) & 0xff), (0x90 | (type)), \ (0xC0 | (((lim) >> 28) & 0xf)), (((base) >> 24) & 0xff)// 可执行段 #define STA_X 0x8 // Executable segment// 非可执行段 #define STA_E 0x4 // Expand down (non-executable segments)// 只能执行的段 #define STA_C 0x4 // Conforming code segment (executable only)// 可写段但是不能执行的段 #define STA_W 0x2 // Writeable (non-executable segments)// 可读可执行的段 #define STA_R 0x2 // Readable (executable segments)// 表明描述符是否已被访问;把选择字装入段寄存器时,该位被标记为1 #define STA_A 0x1 // Accessed