xref: /xv6-public/asm.h (revision 210a0f0b)
1dfcc5b99Srtm //
2ab4cedb5Srtm // assembler macros to create x86 segments
3dfcc5b99Srtm //
4dfcc5b99Srtm 
57abf49d2Skaashoek #define SEG_NULLASM                                             \
68352b998Skaashoek         .word 0, 0;                                             \
78352b998Skaashoek         .byte 0, 0, 0, 0
8a650c606Srsc 
9*1afc9d3fSRobert Morris // The 0xC0 means the limit is in 4096-byte units
10*1afc9d3fSRobert Morris // and (for executable segments) 32-bit mode.
117abf49d2Skaashoek #define SEG_ASM(type,base,lim)                                  \
128352b998Skaashoek         .word (((lim) >> 12) & 0xffff), ((base) & 0xffff);      \
138352b998Skaashoek         .byte (((base) >> 16) & 0xff), (0x90 | (type)),         \
148352b998Skaashoek                 (0xC0 | (((lim) >> 28) & 0xf)), (((base) >> 24) & 0xff)
158352b998Skaashoek 
168352b998Skaashoek #define STA_X     0x8       // Executable segment
178352b998Skaashoek #define STA_W     0x2       // Writeable (non-executable segments)
188352b998Skaashoek #define STA_R     0x2       // Readable (executable segments)
19