source: trunk/hal/x86_64/hal_boot.h @ 25

Last change on this file since 25 was 25, checked in by max@…, 5 years ago

First shot of the x86_64 port. It uses Multiboot V1. Most of the HAL functions
are empty, and several TSAR-specific files and comments remain; they will be
cleaned up later. The Makefile and LD script will come in another commit.

File size: 3.7 KB
Line 
1/*
2 * hal_boot.h - General values used by the boot procedure
3 *
4 * Author        Maxime Villard (2017)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-kernel.
9 *
10 * ALMOS-kernel is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-kernel is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#define PAGE_SIZE       4096
25#define PGOFSET         (PAGE_SIZE-1)
26#define PGSHIFT         12
27
28#define KERNBASE        0xffffffff80000000
29#define KERNBASE_HI     0xffffffff
30#define KERNBASE_LO     0x80000000
31
32#define KERNTEXTOFF     0xffffffff80200000
33#define KERNTEXTOFF_HI  0xffffffff
34#define KERNTEXTOFF_LO  0x80200000
35
36/* -------------------------------------------------------------------------- */
37
38#define PSL_MBO         0x00000002
39
40#define STKPAGES        4
41
42#define NKL4_KIMG_ENTRIES       1
43#define NKL3_KIMG_ENTRIES       1
44#define NKL2_KIMG_ENTRIES       32
45
46/* -------------------------------------------------------------------------- */
47
48#define L1_SHIFT        12
49#define L2_SHIFT        21
50#define L3_SHIFT        30
51#define L4_SHIFT        39
52#define NBPD_L1         (1UL << L1_SHIFT) /* # bytes mapped by L1 ent (4K) */
53#define NBPD_L2         (1UL << L2_SHIFT) /* # bytes mapped by L2 ent (2MB) */
54#define NBPD_L3         (1UL << L3_SHIFT) /* # bytes mapped by L3 ent (1G) */
55#define NBPD_L4         (1UL << L4_SHIFT) /* # bytes mapped by L4 ent (512G) */
56
57#define L4_MASK         0x0000ff8000000000
58#define L3_MASK         0x0000007fc0000000
59#define L2_MASK         0x000000003fe00000
60#define L1_MASK         0x00000000001ff000
61
62#define L4_FRAME        L4_MASK
63#define L3_FRAME        (L4_FRAME|L3_MASK)
64#define L2_FRAME        (L3_FRAME|L2_MASK)
65#define L1_FRAME        (L2_FRAME|L1_MASK)
66
67#define PDE_SIZE        8
68
69/* PDE/PTE bits. */
70#define PG_V            0x0000000000000001      /* valid */
71#define PG_RO           0x0000000000000000      /* read-only */
72#define PG_RW           0x0000000000000002      /* read-write */
73#define PG_u            0x0000000000000004      /* user accessible */
74#define PG_PROT         0x0000000000000006
75#define PG_WT           0x0000000000000008      /* write-through */
76#define PG_N            0x0000000000000010      /* non-cacheable */
77#define PG_U            0x0000000000000020      /* used */
78#define PG_M            0x0000000000000040      /* modified */
79#define PG_PAT          0x0000000000000080      /* PAT (on pte) */
80#define PG_PS           0x0000000000000080      /* 2MB page size (on pde) */
81#define PG_G            0x0000000000000100      /* not flushed */
82#define PG_AVAIL1       0x0000000000000200
83#define PG_AVAIL2       0x0000000000000400
84#define PG_AVAIL3       0x0000000000000800
85#define PG_LGPAT        0x0000000000001000      /* PAT on large pages */
86#define PG_FRAME        0x000ffffffffff000
87#define PG_NX           0x8000000000000000
88
89#define PG_2MFRAME      0x000fffffffe00000      /* large (2M) page frame mask */
90#define PG_1GFRAME      0x000fffffc0000000      /* large (1G) page frame mask */
91#define PG_LGFRAME      PG_2MFRAME
92
93/* Short forms of protection codes. */
94#define PG_KR           0x0000000000000000      /* kernel read-only */
95#define PG_KW           0x0000000000000002      /* kernel read-write */
96
97/* -------------------------------------------------------------------------- */
98
99#define IOM_BEGIN       0x0a0000                /* Start of I/O Memory "hole" */
100#define IOM_END         0x100000                /* End of I/O Memory "hole" */
101#define IOM_SIZE        (IOM_END - IOM_BEGIN)
102
103/* -------------------------------------------------------------------------- */
104
105#define L4_SLOT_PTE             255
106#define L4_SLOT_KERN            256
107#define L4_SLOT_KERNBASE        511
108
109#define PDIR_SLOT_KERN  L4_SLOT_KERN
110#define PDIR_SLOT_PTE   L4_SLOT_PTE
111
Note: See TracBrowser for help on using the repository browser.