diff mbox

[U-Boot,v3,16/28] x86: Add an enum for some commonly-used GDT bits

Message ID 1438713246-1887-17-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Aug. 4, 2015, 6:33 p.m. UTC
Rather than add these as open-coded values, create an enum with the commonly
used flags.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---

Changes in v3: None
Changes in v2:
- Add descriptor bits for the base and limit
- Rename GDT_4GB to GDT_4KB

 arch/x86/include/asm/cpu.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Simon Glass Aug. 5, 2015, 6:03 p.m. UTC | #1
On 4 August 2015 at 12:33, Simon Glass <sjg@chromium.org> wrote:
> Rather than add these as open-coded values, create an enum with the commonly
> used flags.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Add descriptor bits for the base and limit
> - Rename GDT_4GB to GDT_4KB
>
>  arch/x86/include/asm/cpu.h | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Applied to u-boot-x86.
diff mbox

Patch

diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index 08284ee..5b89139 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -27,6 +27,24 @@  enum {
 	X86_VENDOR_UNKNOWN = 0xff
 };
 
+/* Global descriptor table (GDT) bits */
+enum {
+	GDT_4KB			= 1ULL << 55,
+	GDT_32BIT		= 1ULL << 54,
+	GDT_LONG		= 1ULL << 53,
+	GDT_PRESENT		= 1ULL << 47,
+	GDT_NOTSYS		= 1ULL << 44,
+	GDT_CODE		= 1ULL << 43,
+	GDT_LIMIT_LOW_SHIFT	= 0,
+	GDT_LIMIT_LOW_MASK	= 0xffff,
+	GDT_LIMIT_HIGH_SHIFT	= 48,
+	GDT_LIMIT_HIGH_MASK	= 0xf,
+	GDT_BASE_LOW_SHIFT	= 16,
+	GDT_BASE_LOW_MASK	= 0xffff,
+	GDT_BASE_HIGH_SHIFT	= 56,
+	GDT_BASE_HIGH_MASK	= 0xf,
+};
+
 struct cpuid_result {
 	uint32_t eax;
 	uint32_t ebx;