|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: * Copyright (c) 1992 NeXT Computer, Inc.
27: *
28: * Intel386 Family: Definitions for pmap.
29: *
30: * HISTORY
31: *
32: * 15 December 1992 ? at NeXT
33: * Removed ldt from pmap.
34: *
35: * 22 August 1992 ? at NeXT
36: * Moved 'section' definition over to pmap_private.h.
37: *
38: * 9 April 1992 ? at NeXT
39: * Created.
40: */
41:
42: #import <mach/vm_param.h>
43: #import <mach/vm_prot.h>
44: #import <mach/vm_statistics.h>
45:
46: #import <kern/lock.h>
47:
48: typedef struct pt_entry {
49: unsigned int valid :1,
50: prot :2,
51: #define PT_PROT_KR 0
52: #define PT_PROT_KRW 1
53: #define PT_PROT_UR 2
54: #define PT_PROT_URW 3
55: cachewrt:1, /* 486 specific */
56: cachedis:1, /* 486 specific */
57: refer :1,
58: dirty :1,
59: :2,
60: wired :1,
61: :1,
62: :1,
63: pfn :20;
64: } pt_entry_t;
65:
66: #define PT_ENTRY_NULL ((pt_entry_t *) 0)
67:
68: typedef struct pd_entry {
69: unsigned int valid :1,
70: prot :2,
71: :2,
72: refer :1,
73: :3,
74: :3,
75: pfn :20;
76: } pd_entry_t;
77:
78: #define PD_ENTRY_NULL ((pd_entry_t *) 0)
79:
80: /*
81: * This is the offset of kernel memory
82: * in the address translation trees.
83: */
84: #define KERNEL_LINEAR_BASE VM_MAX_ADDRESS
85:
86: typedef struct pmap {
87: pd_entry_t * root; /* virtual address used for walking tree */
88: unsigned int cr3; /* actual value for cr3 */
89: int ref_count;
90: simple_lock_data_t lock;
91: struct pmap_statistics
92: stats;
93: unsigned int cpus_using;
94: } *pmap_t;
95:
96: #define PMAP_NULL ((pmap_t) 0)
97:
98: /*
99: * With only one CPU, we just have to indicate whether the pmap is
100: * in use.
101: */
102: #define PMAP_ACTIVATE(pmap, thread, my_cpu) \
103: MACRO_BEGIN \
104: (pmap)->cpus_using = TRUE; \
105: MACRO_END
106:
107: #define PMAP_DEACTIVATE(pmap, thread, cpu) \
108: MACRO_BEGIN \
109: (pmap)->cpus_using = FALSE; \
110: MACRO_END
111:
112: /*
113: * PMAP_CONTEXT: update any thread-specific hardware context that
114: * is managed by pmap module.
115: */
116: #define PMAP_CONTEXT(pmap, thread)
117:
118: #define pmap_resident_count(pmap) ((pmap)->stats.resident_count)
119: #define pmap_phys_address(frame) ((vm_offset_t) (i386_ptob(frame)))
120: #define pmap_phys_to_frame(phys) ((unsigned int) (i386_btop(phys)))
121: #define pmap_phys_to_kern(phys) ((phys) + VM_MIN_KERNEL_ADDRESS)
122:
123: typedef enum {
124: cache_default,
125: cache_writethrough,
126: cache_disable
127: } cache_spec_t;
128:
129: extern inline
130: pt_entry_t *
131: pmap_pt_entry(
132: pmap_t pmap,
133: vm_offset_t va);
134:
135: extern inline
136: pd_entry_t *
137: pmap_pd_entry(
138: pmap_t pmap,
139: vm_offset_t va);
140:
141: extern inline
142: void
143: pmap_enter_cache_spec(
144: pmap_t pmap,
145: vm_offset_t va,
146: vm_offset_t pa,
147: vm_prot_t prot,
148: boolean_t wired,
149: cache_spec_t caching);
150:
151: extern
152: void
153: pmap_enter_shared_range(
154: pmap_t pmap,
155: vm_offset_t va,
156: vm_size_t size,
157: vm_offset_t kern);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.