972
edits
[unchecked revision] | [unchecked revision] |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
(One intermediate revision by the same user not shown) | |||
Line 125:
The above structure of the '''GDT''' doesn't show you how to write entries in the correct format. The actual structure of descriptors is a little messy for backwards compatibility with the 286's '''GDT'''. Base address are split across three different fields and you cannot encode any limit you want.
<
void encodeGdtEntry(uint8_t *target, struct GDT source)
{
Line 148:
target[6] |= (source.flags << 4);
}
</syntaxhighlight>
In order to fill your table, you will want to use this function once for each entry, with <tt>*target</tt> pointing to the logical address of the '''Segment Descriptor''' and <tt>source</tt> being a struct of your design containing the necessary information.
Line 258:
In '''[[Long Mode]]''' the process of changing '''CS''' is not simple as far jumps cannot be used. Using a far return is recommended instead:
<
reloadSegments:
; Reload CS register:
Line 274:
MOV SS, AX
RET
</syntaxhighlight>
== The LDT ==
Line 302:
Tool for easily creating GDT entries.
<
// Used for creating GDT segment descriptors in 64-bit integer form.
Line 384:
}
</syntaxhighlight>
== See Also ==
|