Contiki 3.x
tss.h
1 /*
2  * Copyright (C) 2015, Intel Corporation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * 3. Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef CPU_X86_MM_TSS_H_
32 #define CPU_X86_MM_TSS_H_
33 
34 #include <stdint.h>
35 
36 /**
37  * Task State Segment. Used by the CPU to manage switching between
38  * different protection domains (tasks). The current task is referenced
39  * by the Task Register. When the CPU switches away from a task due to
40  * a far call, etc., it updates the associated in-memory TSS with the
41  * current state of the task. It then loads CPU state from the TSS for
42  * the new task. See Intel Combined Manual, Vol. 3, Chapter 7 for more
43  * details.
44  */
45 typedef struct tss {
46  uint32_t prev_tsk; /**< The selector of the task that called this one, if applicable */
47  uint32_t esp0; /**< Stack pointer for ring 0 code in this task */
48  uint32_t ss0; /**< Stack segment selector for ring 0 code in this task */
49  uint32_t esp1; /**< Stack pointer for ring 1 code in this task */
50  uint32_t ss1; /**< Stack segment selector for ring 1 code in this task */
51  uint32_t esp2; /**< Stack pointer for ring 2 code in this task */
52  uint32_t ss2; /**< Stack segment selector for ring 2 code in this task */
53  uint32_t cr3; /**< CR3 for this task when paging is enabled */
54  uint32_t eip; /**< Stored instruction pointer value */
55  uint32_t eflags; /**< Settings for EFLAGS register */
56  /** General purpose register values */
57  uint32_t eax, ecx, edx, ebx, esp, ebp, esi, edi;
58  /** Segment register selector values */
59  uint32_t es, cs, ss, ds, fs, gs;
60  /** Selector for Local Descriptor Table */
61  uint32_t ldt;
62  /** Debug-related flag */
63  uint16_t t;
64  /** Offset from base of TSS to base of IO permission bitmap, if one is installed */
65  uint16_t iomap_base;
66 } tss_t;
67 
68 void tss_init(void);
69 
70 #endif /* CPU_X86_TSS_H_ */
uint32_t es
Segment register selector values.
Definition: tss.h:59
uint32_t ldt
Selector for Local Descriptor Table.
Definition: tss.h:61
uint32_t ss1
Stack segment selector for ring 1 code in this task.
Definition: tss.h:50
uint32_t ss0
Stack segment selector for ring 0 code in this task.
Definition: tss.h:48
uint32_t esp1
Stack pointer for ring 1 code in this task.
Definition: tss.h:49
uint32_t eax
General purpose register values.
Definition: tss.h:57
uint32_t prev_tsk
The selector of the task that called this one, if applicable.
Definition: tss.h:46
uint32_t esp2
Stack pointer for ring 2 code in this task.
Definition: tss.h:51
uint32_t esp0
Stack pointer for ring 0 code in this task.
Definition: tss.h:47
Task State Segment.
Definition: tss.h:45
uint32_t ss2
Stack segment selector for ring 2 code in this task.
Definition: tss.h:52
uint32_t cr3
CR3 for this task when paging is enabled.
Definition: tss.h:53
uint32_t eip
Stored instruction pointer value.
Definition: tss.h:54
uint16_t iomap_base
Offset from base of TSS to base of IO permission bitmap, if one is installed.
Definition: tss.h:65
uint16_t t
Debug-related flag.
Definition: tss.h:63
uint32_t eflags
Settings for EFLAGS register.
Definition: tss.h:55