source: mainline/kernel/arch/amd64/include/arch/pm.h@ 6ecf5b8

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6ecf5b8 was 6ecf5b8, checked in by Vojtech Horky <vojtechhorky@…>, 13 years ago

Prevent compile-time symlinks in kernel

So far, architecture specific headers for kernel were in
kernel/arch/$ARCH/include directory.
From kernel sources, they were referenced as arch/header.h.

For example, file kernel/arch/$ARCH/include/whatever.h
was included with <arch/whatever.h>.

To allow that, a symbolic link with name `arch' pointing
to the correct `include/' was created during compilation.

This change adds one arch/ directory and instead of
creating a symbolic link for each compilation, -I flag
was added to the compiler (the header mentioned above would
now reside in kernel/arch/$ARCH/include/arch/whatever.h).

The same goes for genarch/ includes.

This change would be followed by similar changes in userspace
and ABI. To overall goal is to simplify job of documenation
generators or IDEs that might have problems with the dynamically
created symbolic links.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * Copyright (c) 2001-2004 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup amd64
30 * @{
31 */
32/** @file
33 */
34
35#ifndef KERN_amd64_PM_H_
36#define KERN_amd64_PM_H_
37
38#ifndef __ASM__
39 #include <typedefs.h>
40 #include <arch/context.h>
41#endif
42
43#define IDT_ITEMS 64
44#define GDT_ITEMS 8
45
46
47#define NULL_DES 0
48/* Warning: Do not reorder the following items, unless you look into syscall.c! */
49#define KTEXT_DES 1
50#define KDATA_DES 2
51#define UDATA_DES 3
52#define UTEXT_DES 4
53#define KTEXT32_DES 5
54/* End of warning */
55#define TSS_DES 6
56
57#ifdef CONFIG_FB
58
59#define VESA_INIT_DES 8
60#define VESA_INIT_SEGMENT 0x8000
61
62#undef GDT_ITEMS
63#define GDT_ITEMS 9
64
65#endif /* CONFIG_FB */
66
67#define GDT_SELECTOR(des) ((des) << 3)
68
69#define PL_KERNEL 0
70#define PL_USER 3
71
72#define AR_PRESENT (1 << 7)
73#define AR_DATA (2 << 3)
74#define AR_CODE (3 << 3)
75#define AR_WRITABLE (1 << 1)
76#define AR_READABLE (1 << 1)
77#define AR_TSS (0x09U)
78#define AR_INTERRUPT (0x0eU)
79#define AR_TRAP (0x0fU)
80
81#define DPL_KERNEL (PL_KERNEL << 5)
82#define DPL_USER (PL_USER << 5)
83
84#define TSS_BASIC_SIZE 104
85#define TSS_IOMAP_SIZE (8 * 1024 + 1) /* 8K for bitmap + 1 terminating byte for convenience */
86
87#define IO_PORTS (64 * 1024)
88
89#ifndef __ASM__
90
91typedef struct {
92 unsigned limit_0_15: 16;
93 unsigned base_0_15: 16;
94 unsigned base_16_23: 8;
95 unsigned access: 8;
96 unsigned limit_16_19: 4;
97 unsigned available: 1;
98 unsigned longmode: 1;
99 unsigned special: 1;
100 unsigned granularity : 1;
101 unsigned base_24_31: 8;
102} __attribute__ ((packed)) descriptor_t;
103
104typedef struct {
105 unsigned limit_0_15: 16;
106 unsigned base_0_15: 16;
107 unsigned base_16_23: 8;
108 unsigned type: 4;
109 unsigned : 1;
110 unsigned dpl : 2;
111 unsigned present : 1;
112 unsigned limit_16_19: 4;
113 unsigned available: 1;
114 unsigned : 2;
115 unsigned granularity : 1;
116 unsigned base_24_31: 8;
117 unsigned base_32_63 : 32;
118 unsigned : 32;
119} __attribute__ ((packed)) tss_descriptor_t;
120
121typedef struct {
122 unsigned offset_0_15: 16;
123 unsigned selector: 16;
124 unsigned ist:3;
125 unsigned unused: 5;
126 unsigned type: 5;
127 unsigned dpl: 2;
128 unsigned present : 1;
129 unsigned offset_16_31: 16;
130 unsigned offset_32_63: 32;
131 unsigned : 32;
132} __attribute__ ((packed)) idescriptor_t;
133
134typedef struct {
135 uint16_t limit;
136 uint64_t base;
137} __attribute__ ((packed)) ptr_16_64_t;
138
139typedef struct {
140 uint16_t limit;
141 uint32_t base;
142} __attribute__ ((packed)) ptr_16_32_t;
143
144typedef struct {
145 uint32_t reserve1;
146 uint64_t rsp0;
147 uint64_t rsp1;
148 uint64_t rsp2;
149 uint64_t reserve2;
150 uint64_t ist1;
151 uint64_t ist2;
152 uint64_t ist3;
153 uint64_t ist4;
154 uint64_t ist5;
155 uint64_t ist6;
156 uint64_t ist7;
157 uint64_t reserve3;
158 uint16_t reserve4;
159 uint16_t iomap_base;
160 uint8_t iomap[TSS_IOMAP_SIZE];
161} __attribute__ ((packed)) tss_t;
162
163extern tss_t *tss_p;
164
165extern descriptor_t gdt[];
166extern idescriptor_t idt[];
167
168extern ptr_16_64_t gdtr;
169extern ptr_16_32_t protected_ap_gdtr;
170
171extern void pm_init(void);
172
173extern void gdt_tss_setbase(descriptor_t *d, uintptr_t base);
174extern void gdt_tss_setlimit(descriptor_t *d, uint32_t limit);
175
176extern void idt_init(void);
177extern void idt_setoffset(idescriptor_t *d, uintptr_t offset);
178
179extern void tss_initialize(tss_t *t);
180
181#endif /* __ASM__ */
182
183#endif
184
185/** @}
186 */
Note: See TracBrowser for help on using the repository browser.