2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011-2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-12-04 23:09:39 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Global Descriptor Table support
|
|
|
|
*
|
2015-10-21 00:42:33 +08:00
|
|
|
* This module contains routines for updating the global descriptor table (GDT)
|
|
|
|
* for the IA-32 architecture.
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#include <linker-defs.h>
|
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
|
|
|
|
2016-11-08 23:36:50 +08:00
|
|
|
#include <kernel_structs.h>
|
2015-05-29 01:56:47 +08:00
|
|
|
#include <arch/cpu.h>
|
2016-09-17 03:04:27 +08:00
|
|
|
#include <arch/x86/segmentation.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The RAM based global descriptor table. It is aligned on an 8 byte boundary
|
2016-09-20 01:40:25 +08:00
|
|
|
* as the Intel manuals recommend this for best performance, see
|
|
|
|
* Section 3.5.1 of IA architecture SW developer manual, Vol 3.
|
2016-09-17 03:04:27 +08:00
|
|
|
*
|
|
|
|
* TODO: CPU never looks at the 8-byte zero entry at all. Save a few bytes by
|
|
|
|
* stuffing the 6-byte pseudo descriptor there.
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
2016-09-17 03:04:27 +08:00
|
|
|
static struct segment_descriptor _gdt_entries[] __aligned(8) = {
|
|
|
|
DT_ZERO_ENTRY,
|
|
|
|
DT_CODE_SEG_ENTRY(0, 0xFFFFF, DT_GRAN_PAGE, 0, DT_READABLE,
|
|
|
|
DT_NONCONFORM),
|
|
|
|
DT_DATA_SEG_ENTRY(0, 0xFFFFF, DT_GRAN_PAGE, 0, DT_WRITABLE,
|
|
|
|
DT_EXPAND_UP)
|
2015-04-11 07:44:37 +08:00
|
|
|
};
|
|
|
|
|
2016-09-17 03:04:27 +08:00
|
|
|
struct pseudo_descriptor _gdt = DT_INIT(_gdt_entries);
|
|
|
|
|