1 | // |
2 | // assembler macros to create x86 segments |
3 | // |
4 | |
5 | #define SEG_NULLASM \ |
6 | .word 0, 0; \ |
7 | .byte 0, 0, 0, 0 |
8 | |
9 | // The 0xC0 means the limit is in 4096-byte units |
10 | // and (for executable segments) 32-bit mode. |
11 | #define SEG_ASM(type,base,lim) \ |
12 | .word (((lim) >> 12) & 0xffff), ((base) & 0xffff); \ |
13 | .byte (((base) >> 16) & 0xff), (0x90 | (type)), \ |
14 | (0xC0 | (((lim) >> 28) & 0xf)), (((base) >> 24) & 0xff) |
15 | |
16 | #define STA_X 0x8 // Executable segment |
17 | #define STA_W 0x2 // Writeable (non-executable segments) |
18 | #define STA_R 0x2 // Readable (executable segments) |
19 | |