source: mainline/arch/amd64/src/pm.c@ a9387ea

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a9387ea was 6f878b7, checked in by Ondrej Palkovsky <ondrap@…>, 20 years ago

AMD64 now can switch into long mode.
Basic page tables working.

  • Property mode set to 100644
File size: 3.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#include <arch/pm.h>
30#include <arch/mm/page.h>
31#include <arch/types.h>
32
33
34/*
35 * There is no segmentation in long mode so we set up flat mode. In this
36 * mode, we use, for each privilege level, two segments spanning the
37 * whole memory. One is for code and one is for data.
38 */
39
40struct descriptor gdt[GDT_ITEMS] = {
41 /* NULL descriptor */
42 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
43 /* KTEXT descriptor */
44 { .limit_0_15 = 0xffff,
45 .base_0_15 = 0,
46 .base_16_23 = 0,
47 .access = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE ,
48 .limit_16_19 = 0xf,
49 .available = 0,
50 .longmode = 1,
51 .special = 0,
52 .granularity = 1,
53 .base_24_31 = 0 },
54 /* KDATA descriptor */
55 { .limit_0_15 = 0xffff,
56 .base_0_15 = 0,
57 .base_16_23 = 0,
58 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL,
59 .limit_16_19 = 0xf,
60 .available = 0,
61 .longmode = 0,
62 .special = 0,
63 .granularity = 1,
64 .base_24_31 = 0 },
65 /* UTEXT descriptor */
66 { .limit_0_15 = 0xffff,
67 .base_0_15 = 0,
68 .base_16_23 = 0,
69 .access = AR_PRESENT | AR_CODE | DPL_USER,
70 .limit_16_19 = 0xf,
71 .available = 0,
72 .longmode = 1,
73 .special = 0,
74 .granularity = 0,
75 .base_24_31 = 0 },
76 /* UDATA descriptor */
77 { .limit_0_15 = 0xffff,
78 .base_0_15 = 0,
79 .base_16_23 = 0,
80 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER,
81 .limit_16_19 = 0xf,
82 .available = 0,
83 .longmode = 0,
84 .special = 1,
85 .granularity = 1,
86 .base_24_31 = 0 },
87 /* KTEXT 16-bit protected */
88 { .limit_0_15 = 0xffff,
89 .base_0_15 = 0,
90 .base_16_23 = 0,
91 .access = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE,
92 .limit_16_19 = 0xf,
93 .available = 0,
94 .longmode = 0,
95 .special = 0,
96 .granularity = 1,
97 .base_24_31 = 0 },
98 /* TSS descriptor - set up will be completed later */
99 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
100};
101
102struct idescriptor idt[IDT_ITEMS];
103
104static struct tss tss;
105
106/* Does not compile correctly if it does not exist */
107int __attribute__ ((section ("K_DATA_START"))) __fake;
Note: See TracBrowser for help on using the repository browser.