]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/pmap.h
xnu-124.1.tar.gz
[apple/xnu.git] / osfmk / ppc / pmap.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25/*
26 * Copyright (c) 1990 The University of Utah and
27 * the Center for Software Science at the University of Utah (CSS).
28 * All rights reserved.
29 *
30 * Permission to use, copy, modify and distribute this software is hereby
31 * granted provided that (1) source code retains these copyright, permission,
32 * and disclaimer notices, and (2) redistributions including binaries
33 * reproduce the notices in supporting documentation, and (3) all advertising
34 * materials mentioning features or use of this software display the following
35 * acknowledgement: ``This product includes software developed by the Center
36 * for Software Science at the University of Utah.''
37 *
38 * THE UNIVERSITY OF UTAH AND CSS ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
39 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSS DISCLAIM ANY LIABILITY OF
40 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 *
42 * CSS requests users of this software to return to css-dist@cs.utah.edu any
43 * improvements that they make and grant CSS redistribution rights.
44 *
45 * Utah $Hdr: pmap.h 1.13 91/09/25$
46 * Author: Mike Hibler, Bob Wheeler, University of Utah CSS, 9/90
47 */
48
49#ifndef _PPC_PMAP_H_
50#define _PPC_PMAP_H_
51
52#include <mach/vm_types.h>
53#include <mach/machine/vm_types.h>
54#include <mach/vm_prot.h>
55#include <mach/vm_statistics.h>
56#include <kern/queue.h>
57#include <vm/pmap.h>
58
59struct pmap {
60 queue_head_t pmap_link; /* MUST BE FIRST */
61 unsigned int pmapvr; /* Virtual to real conversion mask */
62 space_t space; /* space for this pmap */
63#define BMAPLOCK 0x00000001
64 struct blokmap *bmaps; /* Physical pointer to odd-size page maps */
65 int ref_count; /* reference count */
66 unsigned int vflags; /* Alternate map validity flags */
67#define pmapBatVal 0xFF000000
68#define pmapBatDVal 0xF0000000
69#define pmapBatIVal 0x0F000000
70#define pmapFlags 0x00FF0000
71#define pmapSubord 0x00800000
72#define pmapAltSeg 0x0000FFFF
73 unsigned int spaceNum; /* Space number */
74/* PPC line boundary here - 020 */
75 unsigned int pmapSegs[16]; /* Contents of segment register if different than base space */
76/* PPC line boundary here - 060 */
77 struct pmap *pmapPmaps[16]; /* Pointer to next lower level of pmaps */
78/* PPC line boundary here - 0A0 */
79/* Note: this must start on a word boundary */
80 unsigned short pmapUsage[128]; /* Count of pages mapped into 32mb (8192 page) slots */
81#define pmapUsageShft 25
82#define pmapUsageMask 0x0000007F
83#define pmapUsageSize (32*1024*1024)
84
85/* PPC line boundary here - 1A0 */
86 struct pmap_statistics stats; /* statistics */
87 decl_simple_lock_data(,lock) /* lock on map */
88
89/* Need to pad out to a power of 2 - right now it is 512 bytes */
90#define pmapSize 512
91};
92
93#define PMAP_NULL ((pmap_t) 0)
94
95extern pmap_t kernel_pmap; /* The kernel's map */
96extern pmap_t cursor_pmap; /* The pmap to start allocations with */
97
98#define PMAP_SWITCH_USER(th, map, my_cpu) th->map = map;
99
100#define PMAP_ACTIVATE(pmap, th, cpu)
101#define PMAP_DEACTIVATE(pmap, th, cpu)
102#define PMAP_CONTEXT(pmap,th)
103
104#define pmap_kernel_va(VA) \
105 (((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= VM_MAX_KERNEL_ADDRESS))
106
107#define PPC_SID_KERNEL 0 /* Must change KERNEL_SEG_REG0_VALUE if !0 */
108#define SID_MAX ((1<<20) - 1) /* Space ID=20 bits, segment_id=SID + 4 bits */
109
110#define pmap_kernel() (kernel_pmap)
111#define pmap_resident_count(pmap) ((pmap)->stats.resident_count)
112#define pmap_remove_attributes(pmap,start,end)
113#define pmap_copy(dpmap,spmap,da,len,sa)
114#define pmap_update()
115
116#define pmap_phys_address(x) ((x) << PPC_PGSHIFT)
117#define pmap_phys_to_frame(x) ((x) >> PPC_PGSHIFT)
118
119/*
120 * prototypes.
121 */
122extern void ppc_protection_init(void);
123extern vm_offset_t phystokv(vm_offset_t pa); /* Get kernel virtual address from physical */
124extern vm_offset_t kvtophys(vm_offset_t va); /* Get physical address from kernel virtual */
125extern vm_offset_t pmap_map(vm_offset_t va,
126 vm_offset_t spa,
127 vm_offset_t epa,
128 vm_prot_t prot);
129extern kern_return_t pmap_add_physical_memory(vm_offset_t spa,
130 vm_offset_t epa,
131 boolean_t available,
132 unsigned int attr);
133extern vm_offset_t pmap_map_bd(vm_offset_t va,
134 vm_offset_t spa,
135 vm_offset_t epa,
136 vm_prot_t prot);
137extern void pmap_bootstrap(unsigned int mem_size,
138 vm_offset_t *first_avail,
139 vm_offset_t *first_phys_avail, unsigned int kmapsize);
140extern void pmap_block_map(vm_offset_t pa,
141 vm_size_t size,
142 vm_prot_t prot,
143 int entry,
144 int dtlb);
145extern void pmap_switch(pmap_t);
146
147extern vm_offset_t pmap_extract(pmap_t pmap,
148 vm_offset_t va);
149
150extern void pmap_remove_all(vm_offset_t pa);
151
152extern boolean_t pmap_verify_free(vm_offset_t pa);
153extern void sync_cache(vm_offset_t pa, unsigned length);
154extern void flush_dcache(vm_offset_t va, unsigned length, boolean_t phys);
155extern void invalidate_dcache(vm_offset_t va, unsigned length, boolean_t phys);
156extern void invalidate_icache(vm_offset_t va, unsigned length, boolean_t phys);
157extern void invalidate_cache_for_io(vm_offset_t va, unsigned length, boolean_t phys);
158extern void pmap_map_block(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_size_t size,
159 vm_prot_t prot, int attr, unsigned int flags); /* Map a block */
160extern kern_return_t pmap_map_block_opt(vm_map_t map, vm_offset_t *va,
161 vm_offset_t pa, vm_size_t size, vm_prot_t prot, int attr); /* Map a block allocating an optimal virtual address */
162extern kern_return_t vm_map_block(vm_map_t map, vm_offset_t *va, vm_offset_t *bnd, vm_offset_t pa,
163 vm_size_t size, vm_prot_t prot);
164
165extern kern_return_t pmap_nest(pmap_t grand, pmap_t subord, vm_offset_t vaddr, vm_size_t size);
166
167extern void pmap_ver(pmap_t pmap, vm_offset_t sva, vm_offset_t eva);
168
169#endif /* _PPC_PMAP_H_ */
170