debuggers.hg

view extras/mini-os/include/ia64/page.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 /*
2 * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
3 * Common stuff for memory and page handling.
4 * Parts are taken from FreeBSD.
5 *
6 ****************************************************************************
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
27 #if !defined(_PAGE_H_)
28 #define _PAGE_H_
30 #include "os.h"
31 #include "ia64_cpu.h"
33 #define PTE_KERNEL_ATTR ((PTE_P<<PTE_P_SHIFT) |\
34 (PTE_MA_WB<<PTE_MA_SHIFT) |\
35 (PTE_D<<PTE_D_SHIFT) |\
36 (PTE_A<<PTE_A_SHIFT) |\
37 (PTE_PL_KERN<<PTE_PL_SHIFT) |\
38 (PTE_AR_RWX<<PTE_AR_SHIFT))
41 /* The kernel tr page size for text and data. */
42 #define KERNEL_TR_PAGE_SIZE PTE_PS_1M
43 /* The efi-pal page size for text and data. */
44 #define PAL_TR_PAGE_SIZE PTE_PS_1M
46 #include "arch_limits.h"
47 #define PAGE_SHIFT __PAGE_SHIFT
48 #define PAGE_SIZE __PAGE_SIZE
49 #define PAGE_MASK (~(PAGE_SIZE-1))
51 #define KSTACK_PAGES 4 /* 4 pages for the kernel stack + bsp */
53 #define IA64_TR_KERNEL 0 /* itr0, dtr0: maps kernel image (code) */
54 #define IA64_TR_PAL 1 /* itr1: maps pal code */
56 /*
57 * Manipulating region bits of an address.
58 */
59 #define IA64_RR_BASE(n) ((UL_TYPE(n)) << 61)
60 #define IA64_RR_MASK(x) ((UL_TYPE(x)) & ((1L << 61) - 1))
61 #define IA64_RR_EXTR(x) ((x) >> 61)
63 #define IA64_PHYS_TO_RR5(x) ((x) | IA64_RR_BASE(5))
64 #define IA64_PHYS_TO_RR7(x) ((x) | IA64_RR_BASE(7))
66 #define __pa(x) IA64_RR_MASK(x)
67 #define __va(x) IA64_PHYS_TO_RR7(x)
69 #define roundup_page(x) ((((unsigned long)(x)) + PAGE_SIZE -1) & PAGE_MASK)
70 #define trunc_page(x) ((unsigned long)(x) & PAGE_MASK)
73 #if !defined(__ASSEMBLY__)
75 /* Contains the parts of the physically memory. */
76 extern paddr_t phys_avail[];
78 #define page_to_pfn(page) ((uint64_t)(page) >> PAGE_SHIFT)
79 #define pfn_to_page(pfn) ((uint64_t)pfn << PAGE_SHIFT)
80 /* Get phyiscal address of page of virtual address. */
81 #define virt_to_page(addr) ((uint64_t)__pa(addr) & PAGE_MASK)
82 #define virt_to_pfn(addr) (page_to_pfn(virt_to_page(addr)))
85 #endif /* __ASSEMBLY__ */
88 /* For both see minios-ia64.lds. */
89 /* This is where the kernel virtually starts. */
90 #define KERNEL_START IA64_PHYS_TO_RR5(0x100000000)
91 /* !!!!!
92 * For physical start of kernel
93 * Currently used in arch/ia64/fw.S.
94 * !!!!!
95 */
96 #define KERNEL_PHYS_START_SHIFT 20
98 /* A region 5 address to physical address */
99 #define KERN_VIRT_2_PHYS(x) (((x) - KERNEL_START) + \
100 (1 << KERNEL_PHYS_START_SHIFT))
102 /* Some protection keys for region 5 and 7 addresses. */
103 #define IA64_KEY_REG7 0x234 /* Region 7 - identity mapped addresses */
104 #define IA64_KEY_REG5 0x89a /* Region 5 - kernel addresses */
106 // This is xen specific !
107 #define PAGE_SHIFT_XEN_16K 14 // For 16KB page size
108 #define mfn_to_virt(mfn) ((void*)__va((mfn) << PAGE_SHIFT_XEN_16K))
110 #endif /* !defined(_PAGE_H_) */