2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
2015-08-29 14:41:17 -04:00
|
|
|
/**
|
2015-07-15 17:10:25 -04:00
|
|
|
* @file
|
2016-12-23 07:32:56 -05:00
|
|
|
* @brief IA-32 specific kernel interface header
|
|
|
|
* This header contains the IA-32 specific kernel interface. It is included
|
|
|
|
* by the generic kernel interface header (include/arch/cpu.h)
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2019-06-27 15:01:01 -07:00
|
|
|
#ifndef ZEPHYR_INCLUDE_ARCH_X86_IA32_ARCH_H_
|
|
|
|
#define ZEPHYR_INCLUDE_ARCH_X86_IA32_ARCH_H_
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2019-06-27 16:49:10 -07:00
|
|
|
#include "sys_io.h"
|
2019-06-28 13:06:37 -07:00
|
|
|
#include <drivers/interrupt_controller/sysapic.h>
|
2017-04-04 13:19:13 -07:00
|
|
|
#include <kernel_arch_thread.h>
|
2019-06-29 11:00:39 -07:00
|
|
|
#include <ia32/mmustructs.h>
|
2018-09-18 12:32:27 -07:00
|
|
|
#include <stdbool.h>
|
2019-06-27 15:59:43 -07:00
|
|
|
#include <arch/common/ffs.h>
|
2019-07-24 17:25:56 -07:00
|
|
|
#include <misc/util.h>
|
2016-02-25 13:21:02 -08:00
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifndef _ASMLANGUAGE
|
2019-08-12 15:54:24 -05:00
|
|
|
#include <stddef.h> /* for size_t */
|
|
|
|
|
2019-06-02 21:44:42 -04:00
|
|
|
#include <arch/common/addr_types.h>
|
2019-06-27 15:32:20 -07:00
|
|
|
#include <arch/x86/ia32/segmentation.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2019-08-12 15:54:24 -05:00
|
|
|
#endif /* _ASMLANGUAGE */
|
2016-01-22 12:38:49 -05:00
|
|
|
|
2017-08-30 14:06:30 -07:00
|
|
|
/* GDT layout */
|
|
|
|
#define CODE_SEG 0x08
|
|
|
|
#define DATA_SEG 0x10
|
|
|
|
#define MAIN_TSS 0x18
|
|
|
|
#define DF_TSS 0x20
|
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
2015-04-10 16:44:37 -07:00
|
|
|
* Macro used internally by NANO_CPU_INT_REGISTER and NANO_CPU_INT_REGISTER_ASM.
|
2015-07-27 09:47:56 -04:00
|
|
|
* Not meant to be used explicitly by platform, driver or application code.
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
#define MK_ISR_NAME(x) __isr__##x
|
|
|
|
|
2018-10-30 16:55:38 -07:00
|
|
|
#define Z_DYN_STUB_SIZE 4
|
|
|
|
#define Z_DYN_STUB_OFFSET 0
|
|
|
|
#define Z_DYN_STUB_LONG_JMP_EXTRA_SIZE 3
|
|
|
|
#define Z_DYN_STUB_PER_BLOCK 32
|
|
|
|
|
|
|
|
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
|
2019-08-12 15:54:24 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2019-08-12 15:54:24 -05:00
|
|
|
/* interrupt/exception/error related definitions */
|
2018-10-30 16:55:38 -07:00
|
|
|
|
2015-05-26 10:21:42 -04:00
|
|
|
/*
|
2015-08-20 11:04:01 -04:00
|
|
|
* The TCS must be aligned to the same boundary as that used by the floating
|
|
|
|
* point register set. This applies even for threads that don't initially
|
2015-05-26 10:21:42 -04:00
|
|
|
* use floating point, since it is possible to enable floating point support
|
|
|
|
* later on.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define STACK_ALIGN FP_REG_SET_ALIGN
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-11 10:10:41 -05:00
|
|
|
typedef struct s_isrList {
|
2015-07-15 17:10:25 -04:00
|
|
|
/** Address of ISR/stub */
|
|
|
|
void *fnc;
|
2016-08-02 12:05:08 -07:00
|
|
|
/** IRQ associated with the ISR/stub, or -1 if this is not
|
|
|
|
* associated with a real interrupt; in this case vec must
|
|
|
|
* not be -1
|
|
|
|
*/
|
2015-10-01 15:31:31 -04:00
|
|
|
unsigned int irq;
|
2016-08-02 12:05:08 -07:00
|
|
|
/** Priority associated with the IRQ. Ignored if vec is not -1 */
|
2015-10-01 15:31:31 -04:00
|
|
|
unsigned int priority;
|
2016-08-02 12:05:08 -07:00
|
|
|
/** Vector number associated with ISR/stub, or -1 to assign based
|
|
|
|
* on priority
|
|
|
|
*/
|
2015-07-15 17:10:25 -04:00
|
|
|
unsigned int vec;
|
|
|
|
/** Privilege level associated with ISR/stub */
|
|
|
|
unsigned int dpl;
|
2017-07-14 13:29:19 -07:00
|
|
|
|
|
|
|
/** If nonzero, specifies a TSS segment selector. Will configure
|
|
|
|
* a task gate instead of an interrupt gate. fnc parameter will be
|
|
|
|
* ignored
|
|
|
|
*/
|
|
|
|
unsigned int tss;
|
2015-04-10 16:44:37 -07:00
|
|
|
} ISR_LIST;
|
|
|
|
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Connect a routine to an interrupt vector
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-09-17 12:59:37 -04:00
|
|
|
* This macro "connects" the specified routine, @a r, to the specified interrupt
|
|
|
|
* vector, @a v using the descriptor privilege level @a d. On the IA-32
|
2015-07-01 17:22:39 -04:00
|
|
|
* architecture, an interrupt vector is a value from 0 to 255. This macro
|
|
|
|
* populates the special intList section with the address of the routine, the
|
|
|
|
* vector number and the descriptor privilege level. The genIdt tool then picks
|
|
|
|
* up this information and generates an actual IDT entry with this information
|
2016-08-01 15:59:10 -07:00
|
|
|
* properly encoded.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-09-17 12:59:37 -04:00
|
|
|
* The @a d argument specifies the privilege level for the interrupt-gate
|
2015-07-01 17:22:39 -04:00
|
|
|
* descriptor; (hardware) interrupts and exceptions should specify a level of 0,
|
|
|
|
* whereas handlers for user-mode software generated interrupts should specify 3.
|
2015-07-15 17:10:25 -04:00
|
|
|
* @param r Routine to be connected
|
2015-10-01 15:31:31 -04:00
|
|
|
* @param n IRQ number
|
|
|
|
* @param p IRQ priority
|
2015-07-15 17:10:25 -04:00
|
|
|
* @param v Interrupt Vector
|
|
|
|
* @param d Descriptor Privilege Level
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-07-01 17:29:04 -04:00
|
|
|
* @return N/A
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-10-01 15:31:31 -04:00
|
|
|
#define NANO_CPU_INT_REGISTER(r, n, p, v, d) \
|
2017-01-18 13:20:37 -08:00
|
|
|
static ISR_LIST __attribute__((section(".intList"))) \
|
|
|
|
__attribute__((used)) MK_ISR_NAME(r) = \
|
2017-07-14 13:29:19 -07:00
|
|
|
{ \
|
|
|
|
.fnc = &(r), \
|
|
|
|
.irq = (n), \
|
|
|
|
.priority = (p), \
|
|
|
|
.vec = (v), \
|
|
|
|
.dpl = (d), \
|
|
|
|
.tss = 0 \
|
|
|
|
}
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2017-07-14 13:29:19 -07:00
|
|
|
/**
|
|
|
|
* @brief Connect an IA hardware task to an interrupt vector
|
|
|
|
*
|
|
|
|
* This is very similar to NANO_CPU_INT_REGISTER but instead of connecting
|
|
|
|
* a handler function, the interrupt will induce an IA hardware task
|
|
|
|
* switch to another hardware task instead.
|
|
|
|
*
|
|
|
|
* @param tss_p GDT/LDT segment selector for the TSS representing the task
|
|
|
|
* @param irq_p IRQ number
|
|
|
|
* @param priority_p IRQ priority
|
|
|
|
* @param vec_p Interrupt vector
|
|
|
|
* @param dpl_p Descriptor privilege level
|
|
|
|
*/
|
|
|
|
#define _X86_IDT_TSS_REGISTER(tss_p, irq_p, priority_p, vec_p, dpl_p) \
|
|
|
|
static ISR_LIST __attribute__((section(".intList"))) \
|
|
|
|
__attribute__((used)) MK_ISR_NAME(r) = \
|
|
|
|
{ \
|
|
|
|
.fnc = NULL, \
|
|
|
|
.irq = (irq_p), \
|
|
|
|
.priority = (priority_p), \
|
|
|
|
.vec = (vec_p), \
|
|
|
|
.dpl = (dpl_p), \
|
|
|
|
.tss = (tss_p) \
|
|
|
|
}
|
2016-01-08 00:46:14 -08:00
|
|
|
|
2015-10-09 16:23:25 -04:00
|
|
|
/**
|
2016-01-08 00:46:14 -08:00
|
|
|
* Code snippets for populating the vector ID and priority into the intList
|
2015-10-09 16:23:25 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* The 'magic' of static interrupts is accomplished by building up an array
|
|
|
|
* 'intList' at compile time, and the gen_idt tool uses this to create the
|
|
|
|
* actual IDT data structure.
|
|
|
|
*
|
|
|
|
* For controllers like APIC, the vectors in the IDT are not normally assigned
|
|
|
|
* at build time; instead the sentinel value -1 is saved, and gen_idt figures
|
|
|
|
* out the right vector to use based on our priority scheme. Groups of 16
|
|
|
|
* vectors starting at 32 correspond to each priority level.
|
|
|
|
*
|
2016-01-27 10:07:31 -08:00
|
|
|
* These macros are only intended to be used by IRQ_CONNECT() macro.
|
2015-10-09 16:23:25 -04:00
|
|
|
*/
|
2016-08-02 12:05:08 -07:00
|
|
|
#define _VECTOR_ARG(irq_p) (-1)
|
2015-10-09 16:23:25 -04:00
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2016-01-08 00:46:14 -08:00
|
|
|
* Configure a static interrupt.
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-09-22 11:20:26 -07:00
|
|
|
* All arguments must be computable by the compiler at build time.
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* Internally this function does a few things:
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-07-27 09:44:31 -07:00
|
|
|
* 1. There is a declaration of the interrupt parameters in the .intList
|
2016-01-08 00:46:14 -08:00
|
|
|
* section, used by gen_idt to create the IDT. This does the same thing
|
|
|
|
* as the NANO_CPU_INT_REGISTER() macro, but is done in assembly as we
|
|
|
|
* need to populate the .fnc member with the address of the assembly
|
|
|
|
* IRQ stub that we generate immediately afterwards.
|
|
|
|
*
|
2016-07-27 09:44:31 -07:00
|
|
|
* 2. The IRQ stub itself is declared. The code will go in its own named
|
|
|
|
* section .text.irqstubs section (which eventually gets linked into 'text')
|
|
|
|
* and the stub shall be named (isr_name)_irq(irq_line)_stub
|
2016-01-08 00:46:14 -08:00
|
|
|
*
|
2016-09-23 14:01:39 -07:00
|
|
|
* 3. The IRQ stub pushes the ISR routine and its argument onto the stack
|
|
|
|
* and then jumps to the common interrupt handling code in _interrupt_enter().
|
2016-07-08 13:53:50 -07:00
|
|
|
*
|
2019-03-08 14:19:05 -07:00
|
|
|
* 4. z_irq_controller_irq_config() is called at runtime to set the mapping
|
2016-08-02 12:05:08 -07:00
|
|
|
* between the vector and the IRQ line as well as triggering flags
|
2016-01-08 00:46:14 -08:00
|
|
|
*
|
|
|
|
* @param irq_p IRQ line number
|
|
|
|
* @param priority_p Interrupt priority
|
|
|
|
* @param isr_p Interrupt service routine
|
|
|
|
* @param isr_param_p ISR parameter
|
2019-06-28 13:06:37 -07:00
|
|
|
* @param flags_p IRQ triggering options, as defined in sysapic.h
|
2016-01-08 00:46:14 -08:00
|
|
|
*
|
|
|
|
* @return The vector assigned to this interrupt
|
|
|
|
*/
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
|
2016-01-08 00:46:14 -08:00
|
|
|
({ \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
".pushsection .intList\n\t" \
|
2017-02-21 09:47:14 -08:00
|
|
|
".long %c[isr]_irq%c[irq]_stub\n\t" /* ISR_LIST.fnc */ \
|
|
|
|
".long %c[irq]\n\t" /* ISR_LIST.irq */ \
|
|
|
|
".long %c[priority]\n\t" /* ISR_LIST.priority */ \
|
|
|
|
".long %c[vector]\n\t" /* ISR_LIST.vec */ \
|
2016-01-08 00:46:14 -08:00
|
|
|
".long 0\n\t" /* ISR_LIST.dpl */ \
|
2017-07-14 13:29:19 -07:00
|
|
|
".long 0\n\t" /* ISR_LIST.tss */ \
|
2016-01-08 00:46:14 -08:00
|
|
|
".popsection\n\t" \
|
2016-07-27 09:44:31 -07:00
|
|
|
".pushsection .text.irqstubs\n\t" \
|
2017-02-21 09:47:14 -08:00
|
|
|
".global %c[isr]_irq%c[irq]_stub\n\t" \
|
|
|
|
"%c[isr]_irq%c[irq]_stub:\n\t" \
|
2016-09-23 14:01:39 -07:00
|
|
|
"pushl %[isr_param]\n\t" \
|
|
|
|
"pushl %[isr]\n\t" \
|
|
|
|
"jmp _interrupt_enter\n\t" \
|
2016-07-27 09:44:31 -07:00
|
|
|
".popsection\n\t" \
|
2016-01-08 00:46:14 -08:00
|
|
|
: \
|
|
|
|
: [isr] "i" (isr_p), \
|
|
|
|
[isr_param] "i" (isr_param_p), \
|
2016-08-02 12:05:08 -07:00
|
|
|
[priority] "i" (priority_p), \
|
2016-01-08 00:46:14 -08:00
|
|
|
[vector] "i" _VECTOR_ARG(irq_p), \
|
|
|
|
[irq] "i" (irq_p)); \
|
2019-03-08 14:19:05 -07:00
|
|
|
z_irq_controller_irq_config(Z_IRQ_TO_INTERRUPT_VECTOR(irq_p), (irq_p), \
|
2016-08-02 12:05:08 -07:00
|
|
|
(flags_p)); \
|
2019-03-08 14:19:05 -07:00
|
|
|
Z_IRQ_TO_INTERRUPT_VECTOR(irq_p); \
|
2016-01-08 00:46:14 -08:00
|
|
|
})
|
|
|
|
|
2017-01-18 13:20:37 -08:00
|
|
|
/** Configure a 'direct' static interrupt
|
|
|
|
*
|
|
|
|
* All arguments must be computable by the compiler at build time
|
|
|
|
*
|
|
|
|
*/
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_IRQ_DIRECT_CONNECT(irq_p, priority_p, isr_p, flags_p) \
|
2017-01-18 13:20:37 -08:00
|
|
|
({ \
|
|
|
|
NANO_CPU_INT_REGISTER(isr_p, irq_p, priority_p, -1, 0); \
|
2019-03-08 14:19:05 -07:00
|
|
|
z_irq_controller_irq_config(Z_IRQ_TO_INTERRUPT_VECTOR(irq_p), (irq_p), \
|
2017-01-18 13:20:37 -08:00
|
|
|
(flags_p)); \
|
2019-03-08 14:19:05 -07:00
|
|
|
Z_IRQ_TO_INTERRUPT_VECTOR(irq_p); \
|
2017-01-18 13:20:37 -08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
2019-03-08 14:19:05 -07:00
|
|
|
extern void z_arch_irq_direct_pm(void);
|
|
|
|
#define Z_ARCH_ISR_DIRECT_PM() z_arch_irq_direct_pm()
|
2017-01-18 13:20:37 -08:00
|
|
|
#else
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_ISR_DIRECT_PM() do { } while (false)
|
2017-01-18 13:20:37 -08:00
|
|
|
#endif
|
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_ISR_DIRECT_HEADER() z_arch_isr_direct_header()
|
|
|
|
#define Z_ARCH_ISR_DIRECT_FOOTER(swap) z_arch_isr_direct_footer(swap)
|
2017-01-18 13:20:37 -08:00
|
|
|
|
2018-03-26 10:11:00 -05:00
|
|
|
/* FIXME prefer these inline, but see GH-3056 */
|
2019-03-08 14:19:05 -07:00
|
|
|
extern void z_arch_isr_direct_header(void);
|
|
|
|
extern void z_arch_isr_direct_footer(int maybe_swap);
|
2017-01-18 13:20:37 -08:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_ISR_DIRECT_DECLARE(name) \
|
2017-01-18 13:20:37 -08:00
|
|
|
static inline int name##_body(void); \
|
|
|
|
__attribute__ ((interrupt)) void name(void *stack_frame) \
|
|
|
|
{ \
|
|
|
|
ARG_UNUSED(stack_frame); \
|
|
|
|
int check_reschedule; \
|
|
|
|
ISR_DIRECT_HEADER(); \
|
|
|
|
check_reschedule = name##_body(); \
|
|
|
|
ISR_DIRECT_FOOTER(check_reschedule); \
|
|
|
|
} \
|
|
|
|
static inline int name##_body(void)
|
2015-06-01 14:14:31 -04:00
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
2017-04-09 11:57:54 -04:00
|
|
|
* @brief Exception Stack Frame
|
2015-10-04 09:32:31 -04:00
|
|
|
*
|
2015-04-10 16:44:37 -07:00
|
|
|
* A pointer to an "exception stack frame" (ESF) is passed as an argument
|
2015-10-05 10:48:46 -04:00
|
|
|
* to exception handlers registered via nanoCpuExcConnect(). As the system
|
|
|
|
* always operates at ring 0, only the EIP, CS and EFLAGS registers are pushed
|
|
|
|
* onto the stack when an exception occurs.
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
2015-10-05 10:48:46 -04:00
|
|
|
* The exception stack frame includes the volatile registers (EAX, ECX, and
|
|
|
|
* EDX) as well as the 5 non-volatile registers (EDI, ESI, EBX, EBP and ESP).
|
|
|
|
* Those registers are pushed onto the stack by _ExcEnt().
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct nanoEsf {
|
2015-10-05 10:48:46 -04:00
|
|
|
unsigned int esp;
|
2015-04-10 16:44:37 -07:00
|
|
|
unsigned int ebp;
|
|
|
|
unsigned int ebx;
|
|
|
|
unsigned int esi;
|
|
|
|
unsigned int edi;
|
|
|
|
unsigned int edx;
|
|
|
|
unsigned int eax;
|
2016-01-14 16:22:28 -08:00
|
|
|
unsigned int ecx;
|
2015-04-10 16:44:37 -07:00
|
|
|
unsigned int errorCode;
|
|
|
|
unsigned int eip;
|
|
|
|
unsigned int cs;
|
|
|
|
unsigned int eflags;
|
2019-07-16 15:21:19 -07:00
|
|
|
} z_arch_esf_t;
|
2015-04-10 16:44:37 -07:00
|
|
|
|
userspace: flesh out internal syscall interface
* Instead of a common system call entry function, we instead create a
table mapping system call ids to handler skeleton functions which are
invoked directly by the architecture code which receives the system
call.
* system call handler prototype specified. All but the most trivial
system calls will implement one of these. They validate all the
arguments, including verifying kernel/device object pointers, ensuring
that the calling thread has appropriate access to any memory buffers
passed in, and performing other parameter checks that the base system
call implementation does not check, or only checks with __ASSERT().
It's only possible to install a system call implementation directly
inside this table if the implementation has a return value and requires
no validation of any of its arguments.
A sample handler implementation for k_mutex_unlock() might look like:
u32_t _syscall_k_mutex_unlock(u32_t mutex_arg, u32_t arg2, u32_t arg3,
u32_t arg4, u32_t arg5, void *ssf)
{
struct k_mutex *mutex = (struct k_mutex *)mutex_arg;
_SYSCALL_ARG1;
_SYSCALL_IS_OBJ(mutex, K_OBJ_MUTEX, 0, ssf);
_SYSCALL_VERIFY(mutex->lock_count > 0, ssf);
_SYSCALL_VERIFY(mutex->owner == _current, ssf);
k_mutex_unlock(mutex);
return 0;
}
* the x86 port modified to work with the system call table instead of
calling a common handler function. fixed an issue where registers being
changed could confuse the compiler has been fixed; all registers, even
ones used for parameters, must be preserved across the system call.
* a new arch API for producing a kernel oops when validating system call
arguments added. The debug information reported will be from the system
call site and not inside the handler function.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-13 18:04:21 -07:00
|
|
|
|
|
|
|
struct _x86_syscall_stack_frame {
|
|
|
|
u32_t eip;
|
|
|
|
u32_t cs;
|
|
|
|
u32_t eflags;
|
|
|
|
|
|
|
|
/* These are only present if cs = USER_CODE_SEG */
|
|
|
|
u32_t esp;
|
|
|
|
u32_t ss;
|
|
|
|
};
|
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Disable all interrupts on the CPU (inline)
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2017-10-29 07:10:22 -04:00
|
|
|
* This routine disables interrupts. It can be called from either interrupt
|
|
|
|
* or thread level. This routine returns an architecture-dependent
|
2015-07-01 17:22:39 -04:00
|
|
|
* lock-out key representing the "interrupt disable state" prior to the call;
|
2015-08-12 18:31:41 -04:00
|
|
|
* this key can be passed to irq_unlock() to re-enable interrupts.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-08-12 18:31:41 -04:00
|
|
|
* The lock-out key should only be used as the argument to the irq_unlock()
|
|
|
|
* API. It should never be used to manually re-enable interrupts or to inspect
|
|
|
|
* or manipulate the contents of the source register.
|
|
|
|
*
|
|
|
|
* This function can be called recursively: it will return a key to return the
|
|
|
|
* state of interrupt locking to the previous level.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
|
|
|
* WARNINGS
|
|
|
|
* Invoking a kernel routine with interrupts locked may result in
|
|
|
|
* interrupts being re-enabled for an unspecified period of time. If the
|
|
|
|
* called routine blocks, interrupts will be re-enabled while another
|
2015-08-20 11:04:01 -04:00
|
|
|
* thread executes, or while the system is idle.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-08-20 11:04:01 -04:00
|
|
|
* The "interrupt disable state" is an attribute of a thread. Thus, if a
|
2017-10-29 07:10:22 -04:00
|
|
|
* thread disables interrupts and subsequently invokes a kernel
|
2015-08-20 11:04:01 -04:00
|
|
|
* routine that causes the calling thread to block, the interrupt
|
|
|
|
* disable state will be restored when the thread is later rescheduled
|
2015-07-01 17:22:39 -04:00
|
|
|
* for execution.
|
|
|
|
*
|
2015-07-01 17:29:04 -04:00
|
|
|
* @return An architecture-dependent lock-out key representing the
|
2015-07-01 17:22:39 -04:00
|
|
|
* "interrupt disable state" prior to the call.
|
|
|
|
*
|
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
static ALWAYS_INLINE unsigned int z_arch_irq_lock(void)
|
2015-05-14 16:30:48 -05:00
|
|
|
{
|
2019-07-05 12:02:49 -07:00
|
|
|
unsigned int key;
|
|
|
|
|
2019-07-26 09:53:17 -07:00
|
|
|
__asm__ volatile ("pushfl; cli; popl %0" : "=g" (key) :: "memory");
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
return key;
|
2015-05-14 16:30:48 -05:00
|
|
|
}
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
2015-09-17 12:59:37 -04:00
|
|
|
* The NANO_SOFT_IRQ macro must be used as the value for the @a irq parameter
|
2016-11-11 15:45:03 -05:00
|
|
|
* to NANO_CPU_INT_REGISTER when connecting to an interrupt that does not
|
2016-01-08 13:40:09 -08:00
|
|
|
* correspond to any IRQ line (such as spurious vector or SW IRQ)
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
#define NANO_SOFT_IRQ ((unsigned int) (-1))
|
|
|
|
|
2016-11-11 15:45:03 -05:00
|
|
|
/**
|
|
|
|
* @defgroup float_apis Floating Point APIs
|
|
|
|
* @ingroup kernel_apis
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2017-11-01 11:43:14 -07:00
|
|
|
struct k_thread;
|
|
|
|
|
2016-11-11 15:45:03 -05:00
|
|
|
/**
|
|
|
|
* @brief Enable preservation of floating point context information.
|
|
|
|
*
|
|
|
|
* This routine informs the kernel that the specified thread (which may be
|
|
|
|
* the current thread) will be using the floating point registers.
|
|
|
|
* The @a options parameter indicates which floating point register sets
|
|
|
|
* will be used by the specified thread:
|
|
|
|
*
|
|
|
|
* a) K_FP_REGS indicates x87 FPU and MMX registers only
|
|
|
|
* b) K_SSE_REGS indicates SSE registers (and also x87 FPU and MMX registers)
|
|
|
|
*
|
|
|
|
* Invoking this routine initializes the thread's floating point context info
|
|
|
|
* to that of an FPU that has been reset. The next time the thread is scheduled
|
2019-03-08 14:19:05 -07:00
|
|
|
* by z_swap() it will either inherit an FPU that is guaranteed to be in a "sane"
|
2016-11-11 15:45:03 -05:00
|
|
|
* state (if the most recent user of the FPU was cooperatively swapped out)
|
|
|
|
* or the thread's own floating point context will be loaded (if the most
|
2017-05-02 17:21:56 -07:00
|
|
|
* recent user of the FPU was preempted, or if this thread is the first user
|
2016-11-11 15:45:03 -05:00
|
|
|
* of the FPU). Thereafter, the kernel will protect the thread's FP context
|
|
|
|
* so that it is not altered during a preemptive context switch.
|
|
|
|
*
|
|
|
|
* @warning
|
|
|
|
* This routine should only be used to enable floating point support for a
|
|
|
|
* thread that does not currently have such support enabled already.
|
|
|
|
*
|
|
|
|
* @param thread ID of thread.
|
|
|
|
* @param options Registers to be preserved (K_FP_REGS or K_SSE_REGS).
|
|
|
|
*
|
|
|
|
* @return N/A
|
|
|
|
*/
|
2018-09-25 14:17:28 -07:00
|
|
|
extern void k_float_enable(struct k_thread *thread, unsigned int options);
|
2016-11-11 15:45:03 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2017-11-06 11:42:54 -08:00
|
|
|
#ifdef CONFIG_X86_ENABLE_TSS
|
2017-08-30 14:06:30 -07:00
|
|
|
extern struct task_state_segment _main_tss;
|
2017-11-06 11:42:54 -08:00
|
|
|
#endif
|
2017-08-30 14:06:30 -07:00
|
|
|
|
2019-07-24 17:25:56 -07:00
|
|
|
#ifdef CONFIG_USERSPACE
|
|
|
|
/* We need a set of page tables for each thread in the system which runs in
|
|
|
|
* user mode. For each thread, we have:
|
|
|
|
*
|
|
|
|
* - a toplevel PDPT
|
|
|
|
* - a set of page directories for the memory range covered by system RAM
|
|
|
|
* - a set of page tbales for the memory range covered by system RAM
|
|
|
|
*
|
|
|
|
* Directories and tables for memory ranges outside of system RAM will be
|
|
|
|
* shared and not thread-specific.
|
|
|
|
*
|
|
|
|
* NOTE: We are operating under the assumption that memory domain partitions
|
|
|
|
* will not be configured which grant permission to address ranges outside
|
|
|
|
* of system RAM.
|
|
|
|
*
|
|
|
|
* Each of these page tables will be programmed to reflect the memory
|
|
|
|
* permission policy for that thread, which will be the union of:
|
|
|
|
*
|
|
|
|
* - The boot time memory regions (text, rodata, and so forth)
|
|
|
|
* - The thread's stack buffer
|
|
|
|
* - Partitions in the memory domain configuration (if a member of a
|
|
|
|
* memory domain)
|
|
|
|
*
|
|
|
|
* The PDPT is fairly small singleton on x86 PAE (32 bytes) and also must
|
|
|
|
* be aligned to 32 bytes, so we place it at the highest addresses of the
|
|
|
|
* page reserved for the privilege elevation stack.
|
|
|
|
*
|
|
|
|
* The page directories and tables require page alignment so we put them as
|
|
|
|
* additional fields in the stack object, using the below macros to compute how
|
|
|
|
* many pages we need.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Define a range [Z_X86_PT_START, Z_X86_PT_END) which is the memory range
|
|
|
|
* covered by all the page tables needed for system RAM
|
|
|
|
*/
|
|
|
|
#define Z_X86_PT_START ((u32_t)ROUND_DOWN(DT_PHYS_RAM_ADDR, Z_X86_PT_AREA))
|
|
|
|
#define Z_X86_PT_END ((u32_t)ROUND_UP(DT_PHYS_RAM_ADDR + \
|
|
|
|
(DT_RAM_SIZE * 1024U), \
|
|
|
|
Z_X86_PT_AREA))
|
|
|
|
|
|
|
|
/* Number of page tables needed to cover system RAM. Depends on the specific
|
|
|
|
* bounds of system RAM, but roughly 1 page table per 2MB of RAM */
|
|
|
|
#define Z_X86_NUM_PT ((Z_X86_PT_END - Z_X86_PT_START) / Z_X86_PT_AREA)
|
|
|
|
|
|
|
|
/* Same semantics as above, but for the page directories needed to cover
|
|
|
|
* system RAM.
|
|
|
|
*/
|
|
|
|
#define Z_X86_PD_START ((u32_t)ROUND_DOWN(DT_PHYS_RAM_ADDR, Z_X86_PD_AREA))
|
|
|
|
#define Z_X86_PD_END ((u32_t)ROUND_UP(DT_PHYS_RAM_ADDR + \
|
|
|
|
(DT_RAM_SIZE * 1024U), \
|
|
|
|
Z_X86_PD_AREA))
|
|
|
|
/* Number of page directories needed to cover system RAM. Depends on the
|
|
|
|
* specific bounds of system RAM, but roughly 1 page directory per 1GB of RAM */
|
|
|
|
#define Z_X86_NUM_PD ((Z_X86_PD_END - Z_X86_PD_START) / Z_X86_PD_AREA)
|
|
|
|
|
|
|
|
/* Number of pages we need to reserve in the stack for per-thread page tables */
|
|
|
|
#define Z_X86_NUM_TABLE_PAGES (Z_X86_NUM_PT + Z_X86_NUM_PD)
|
|
|
|
#else
|
|
|
|
/* If we're not implementing user mode, then the MMU tables don't get changed
|
|
|
|
* on context switch and we don't need any per-thread page tables
|
|
|
|
*/
|
|
|
|
#define Z_X86_NUM_TABLE_PAGES 0U
|
|
|
|
#endif /* CONFIG_USERSPACE */
|
|
|
|
|
|
|
|
#define Z_X86_THREAD_PT_AREA (Z_X86_NUM_TABLE_PAGES * MMU_PAGE_SIZE)
|
|
|
|
|
2019-08-01 15:06:40 -07:00
|
|
|
#if defined(CONFIG_HW_STACK_PROTECTION) || defined(CONFIG_USERSPACE)
|
|
|
|
#define Z_X86_STACK_BASE_ALIGN MMU_PAGE_SIZE
|
|
|
|
#else
|
|
|
|
#define Z_X86_STACK_BASE_ALIGN STACK_ALIGN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_USERSPACE
|
|
|
|
/* If user mode enabled, expand any stack size to fill a page since that is
|
|
|
|
* the access control granularity and we don't want other kernel data to
|
|
|
|
* unintentionally fall in the latter part of the page
|
|
|
|
*/
|
|
|
|
#define Z_X86_STACK_SIZE_ALIGN MMU_PAGE_SIZE
|
|
|
|
#else
|
|
|
|
#define Z_X86_STACK_SIZE_ALIGN 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct z_x86_kernel_stack_data {
|
|
|
|
struct x86_mmu_pdpt pdpt;
|
|
|
|
} __aligned(0x20);
|
|
|
|
|
2017-11-06 11:42:54 -08:00
|
|
|
/* With both hardware stack protection and userspace enabled, stacks are
|
|
|
|
* arranged as follows:
|
2017-08-30 14:06:30 -07:00
|
|
|
*
|
|
|
|
* High memory addresses
|
2019-07-24 17:25:56 -07:00
|
|
|
* +-----------------------------------------+
|
|
|
|
* | Thread stack (varies) |
|
|
|
|
* +-----------------------------------------+
|
|
|
|
* | PDPT (32 bytes) |
|
|
|
|
* | Privilege elevation stack (4064 bytes) |
|
|
|
|
* +-----------------------------------------+
|
|
|
|
* | Guard page (4096 bytes) |
|
|
|
|
* +-----------------------------------------+
|
|
|
|
* | User page tables (Z_X86_THREAD_PT_AREA) |
|
|
|
|
* +-----------------------------------------+
|
2017-08-30 14:06:30 -07:00
|
|
|
* Low Memory addresses
|
|
|
|
*
|
2019-07-24 17:25:56 -07:00
|
|
|
* Privilege elevation stacks are fixed-size. All the pages containing the
|
|
|
|
* thread stack are marked as user-accessible. The guard page is marked
|
|
|
|
* read-only to catch stack overflows in supervisor mode.
|
|
|
|
*
|
|
|
|
* If a thread starts in supervisor mode, the page containing the PDPT and
|
|
|
|
* privilege elevation stack is also marked read-only.
|
|
|
|
*
|
|
|
|
* If a thread starts in, or drops down to user mode, the privilege stack page
|
|
|
|
* will be marked as present, supervior-only. The PDPT will be initialized and
|
|
|
|
* used as the active page tables when that thread is active.
|
|
|
|
*
|
|
|
|
* If KPTI is not enabled, the _main_tss.esp0 field will always be updated
|
|
|
|
* updated to point to the top of the privilege elevation stack. Otherwise
|
|
|
|
* _main_tss.esp0 always points to the trampoline stack, which handles the
|
|
|
|
* page table switch to the kernel PDPT and transplants context to the
|
|
|
|
* privileged mode stack.
|
2017-11-06 11:42:54 -08:00
|
|
|
*/
|
2019-08-01 15:06:40 -07:00
|
|
|
struct z_x86_thread_stack_header {
|
|
|
|
#ifdef CONFIG_USERSPACE
|
|
|
|
char page_tables[Z_X86_THREAD_PT_AREA];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_HW_STACK_PROTECTION
|
|
|
|
char guard_page[MMU_PAGE_SIZE];
|
2017-11-06 11:42:54 -08:00
|
|
|
#endif
|
2017-07-14 09:38:59 -07:00
|
|
|
|
2018-05-30 09:47:14 -07:00
|
|
|
#ifdef CONFIG_USERSPACE
|
2019-08-01 15:06:40 -07:00
|
|
|
char privilege_stack[MMU_PAGE_SIZE -
|
|
|
|
sizeof(struct z_x86_kernel_stack_data)];
|
|
|
|
|
|
|
|
struct z_x86_kernel_stack_data kernel_data;
|
2018-05-30 09:47:14 -07:00
|
|
|
#endif
|
2019-08-01 15:06:40 -07:00
|
|
|
} __packed __aligned(Z_X86_STACK_SIZE_ALIGN);
|
|
|
|
|
|
|
|
#define Z_ARCH_THREAD_STACK_RESERVED \
|
|
|
|
((u32_t)sizeof(struct z_x86_thread_stack_header))
|
2018-05-30 09:47:14 -07:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_THREAD_STACK_DEFINE(sym, size) \
|
2019-01-31 15:53:24 -08:00
|
|
|
struct _k_thread_stack_element __noinit \
|
2019-08-01 15:06:40 -07:00
|
|
|
__aligned(Z_X86_STACK_BASE_ALIGN) \
|
|
|
|
sym[ROUND_UP((size), Z_X86_STACK_SIZE_ALIGN) + \
|
|
|
|
Z_ARCH_THREAD_STACK_RESERVED]
|
2017-06-14 16:10:20 -07:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_THREAD_STACK_LEN(size) \
|
2018-06-27 13:26:20 +05:30
|
|
|
(ROUND_UP((size), \
|
2019-08-01 15:06:40 -07:00
|
|
|
MAX(Z_X86_STACK_BASE_ALIGN, \
|
|
|
|
Z_X86_STACK_SIZE_ALIGN)) + \
|
2019-03-19 10:42:24 -07:00
|
|
|
Z_ARCH_THREAD_STACK_RESERVED)
|
2018-06-27 13:26:20 +05:30
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size) \
|
2019-01-31 15:53:24 -08:00
|
|
|
struct _k_thread_stack_element __noinit \
|
2019-08-01 15:06:40 -07:00
|
|
|
__aligned(Z_X86_STACK_BASE_ALIGN) \
|
2019-03-08 14:19:05 -07:00
|
|
|
sym[nmemb][Z_ARCH_THREAD_STACK_LEN(size)]
|
2017-06-14 16:10:20 -07:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_THREAD_STACK_MEMBER(sym, size) \
|
2019-08-01 15:06:40 -07:00
|
|
|
struct _k_thread_stack_element __aligned(Z_X86_STACK_BASE_ALIGN) \
|
|
|
|
sym[ROUND_UP((size), Z_X86_STACK_SIZE_ALIGN) + \
|
|
|
|
Z_ARCH_THREAD_STACK_RESERVED]
|
2017-06-14 16:10:20 -07:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_THREAD_STACK_SIZEOF(sym) \
|
2019-03-19 10:42:24 -07:00
|
|
|
(sizeof(sym) - Z_ARCH_THREAD_STACK_RESERVED)
|
2017-06-14 16:10:20 -07:00
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_THREAD_STACK_BUFFER(sym) \
|
2019-03-19 10:42:24 -07:00
|
|
|
((char *)((sym) + Z_ARCH_THREAD_STACK_RESERVED))
|
2017-06-14 16:10:20 -07:00
|
|
|
|
2017-04-18 15:22:54 -07:00
|
|
|
#if CONFIG_X86_KERNEL_OOPS
|
2019-03-08 14:19:05 -07:00
|
|
|
#define Z_ARCH_EXCEPT(reason_p) do { \
|
2017-04-18 15:22:54 -07:00
|
|
|
__asm__ volatile( \
|
|
|
|
"push %[reason]\n\t" \
|
|
|
|
"int %[vector]\n\t" \
|
|
|
|
: \
|
|
|
|
: [vector] "i" (CONFIG_X86_KERNEL_OOPS_VECTOR), \
|
|
|
|
[reason] "i" (reason_p)); \
|
|
|
|
CODE_UNREACHABLE; \
|
2018-09-18 12:32:27 -07:00
|
|
|
} while (false)
|
2017-07-14 16:35:17 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_MMU
|
2019-07-29 18:22:30 -07:00
|
|
|
/* Kernel's page table. Always active when threads are running in supervisor
|
|
|
|
* mode, or handling an interrupt.
|
|
|
|
*
|
|
|
|
* If KPTI is not enabled, this is used as a template to create per-thread
|
|
|
|
* page tables for when threads run in user mode.
|
|
|
|
*/
|
2019-02-06 16:51:38 -08:00
|
|
|
extern struct x86_mmu_pdpt z_x86_kernel_pdpt;
|
2019-02-06 15:35:24 -08:00
|
|
|
#ifdef CONFIG_X86_KPTI
|
2019-07-29 18:22:30 -07:00
|
|
|
/* Separate page tables for user mode threads. The top-level PDPT is never
|
|
|
|
* installed into the CPU; instead used as a template for creating per-thread
|
|
|
|
* page tables.
|
|
|
|
*/
|
2019-02-06 15:35:24 -08:00
|
|
|
extern struct x86_mmu_pdpt z_x86_user_pdpt;
|
|
|
|
#define USER_PDPT z_x86_user_pdpt
|
|
|
|
#else
|
|
|
|
#define USER_PDPT z_x86_kernel_pdpt
|
|
|
|
#endif
|
2017-08-01 13:04:43 -07:00
|
|
|
/**
|
|
|
|
* @brief Fetch page table flags for a particular page
|
|
|
|
*
|
|
|
|
* Given a memory address, return the flags for the containing page's
|
|
|
|
* PDE and PTE entries. Intended for debugging.
|
|
|
|
*
|
2019-02-06 16:51:38 -08:00
|
|
|
* @param pdpt Which page table to use
|
2017-08-01 13:04:43 -07:00
|
|
|
* @param addr Memory address to example
|
|
|
|
* @param pde_flags Output parameter for page directory entry flags
|
|
|
|
* @param pte_flags Output parameter for page table entry flags
|
|
|
|
*/
|
2019-03-08 14:19:05 -07:00
|
|
|
void z_x86_mmu_get_flags(struct x86_mmu_pdpt *pdpt, void *addr,
|
2017-09-18 17:07:16 +05:30
|
|
|
x86_page_entry_data_t *pde_flags,
|
|
|
|
x86_page_entry_data_t *pte_flags);
|
2017-08-01 13:04:43 -07:00
|
|
|
|
|
|
|
|
2017-07-14 17:39:47 -07:00
|
|
|
/**
|
|
|
|
* @brief set flags in the MMU page tables
|
|
|
|
*
|
|
|
|
* Modify bits in the existing page tables for a particular memory
|
|
|
|
* range, which must be page-aligned
|
|
|
|
*
|
2019-02-06 16:51:38 -08:00
|
|
|
* @param pdpt Which page table to use
|
2017-07-14 17:39:47 -07:00
|
|
|
* @param ptr Starting memory address which must be page-aligned
|
|
|
|
* @param size Size of the region, must be page size multiple
|
2017-12-04 11:40:36 -08:00
|
|
|
* @param flags Value of bits to set in the page table entries
|
|
|
|
* @param mask Mask indicating which particular bits in the page table entries to
|
2017-07-14 17:39:47 -07:00
|
|
|
* modify
|
2019-07-29 18:22:30 -07:00
|
|
|
* @param flush Whether to flush the TLB for the modified pages, only needed
|
|
|
|
* when modifying the active page tables
|
2017-07-14 17:39:47 -07:00
|
|
|
*/
|
2019-03-08 14:19:05 -07:00
|
|
|
void z_x86_mmu_set_flags(struct x86_mmu_pdpt *pdpt, void *ptr,
|
2019-07-29 18:22:30 -07:00
|
|
|
size_t size,
|
|
|
|
x86_page_entry_data_t flags,
|
|
|
|
x86_page_entry_data_t mask, bool flush);
|
2019-02-06 15:35:24 -08:00
|
|
|
|
2019-07-29 18:22:30 -07:00
|
|
|
int z_x86_mmu_validate(struct x86_mmu_pdpt *pdpt, void *addr, size_t size,
|
|
|
|
int write);
|
2017-07-14 16:35:17 -07:00
|
|
|
#endif /* CONFIG_X86_MMU */
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-08-12 15:54:24 -05:00
|
|
|
#endif /* !_ASMLANGUAGE */
|
|
|
|
|
2019-06-27 15:01:01 -07:00
|
|
|
#endif /* ZEPHYR_INCLUDE_ARCH_X86_IA32_ARCH_H_ */
|