|
|
1.1 root 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: * Header files for the hardware virtual memory mapping stuff
24: */
25: #ifndef _PPC_MAPPINGS_H_
26: #define _PPC_MAPPINGS_H_
27:
28: typedef struct PCA { /* PTEG Control Area */
29: unsigned int PCAlock; /* PCA lock */
30: union flgs {
31: unsigned int PCAallo; /* Allocation controls */
32: struct PCAalflgs { /* Keep these in order!!! */
33: unsigned char PCAfree; /* Indicates the slot is free */
34: unsigned char PCAauto; /* Indicates that the PTE was autogenned */
35: unsigned char PCAslck; /* Indicates that the slot is locked */
36: unsigned char PCAsteal; /* Steal scan start position */
37: } PCAalflgs;
38: } flgs;
39: unsigned int PCAgas[6]; /* Filler to 32 byte boundary */
40: unsigned int PCAhash[8]; /* PTEG hash chains */
41: } PCA;
42:
43: typedef struct mapping {
44: struct mapping *next; /* MUST BE FIRST - chain off physent */
45: struct mapping *hashnext; /* Next mapping in same hash group */
46: unsigned int *PTEhash; /* Pointer to the head of the mapping hash list */
47: unsigned int *PTEent; /* Pointer to PTE if exists */
48: struct phys_entry *physent; /* Quick pointer back to the physical entry */
49: unsigned int PTEv; /* Virtual half of HW PTE */
50: unsigned int PTEr; /* Real half of HW PTE. This is used ONLY if
51: there is no physical entry associated
52: with this mapping, ie.e, physent==0 */
53: struct pmap *pmap; /* Quick pointer back to the containing pmap */
54: } mapping;
55:
56: #define MAPPING_NULL ((struct mapping *) 0)
57:
58: typedef struct mappingctl {
59: unsigned int mapclock; /* Mapping allocation lock */
60: unsigned int mapcrecurse; /* Mapping allocation recursion control */
61: struct mappingblok *mapcnext; /* First mapping block with free entries */
62: struct mappingblok *mapclast; /* Last mapping block with free entries */
63: struct mappingblok *mapcrel; /* List of deferred block releases */
64: unsigned int mapcfree; /* Total free entries on list */
65: unsigned int mapcinuse; /* Total entries in use */
66: unsigned int mapcreln; /* Total blocks on pending release list */
67: int mapcholdoff; /* Hold off clearing release list */
68: unsigned int mapcfreec; /* Total calls to mapping free */
69: unsigned int mapcallocc; /* Total calls to mapping alloc */
70: unsigned int mapcmin; /* Minimum free mappings to keep */
71: unsigned int mapcgas[4]; /* Pad to 64 bytes */
72: } mappingctl;
73:
74: #define MAPPERBLOK 127
75: #define MAPALTHRSH (4*MAPPERBLOK)
76: #define MAPFRTHRSH (2 * ((MAPALTHRSH + MAPPERBLOK - 1) / MAPPERBLOK))
77: typedef struct mappingblok {
78: unsigned int mapblokfree[4]; /* Bit map of free mapping entrys */
79: unsigned int mapblokvrswap; /* Virtual address XORed with physical address */
80: unsigned int mapblokflags; /* Various flags */
81: #define mbPerm 0x80000000 /* Block is permanent */
82: struct mappingblok *nextblok; /* Pointer to the next mapping block */
83: } mappingblok;
84:
85: typedef struct autogenblok {
86: unsigned int AGNstart; /* Start of range */
87: unsigned int AGNsize; /* Length of range */
88: struct autogenblok *AGNnext; /* Next autogen block */
89: unsigned int AGNpteX; /* Real part of translation */
90: } autogenblok;
91:
92: extern mappingctl mapCtl; /* Mapping allocation control */
93:
94: extern void mapping_phys_init(struct phys_entry *pp, unsigned int pa, unsigned int wimg); /* Initializes hw specific storage attributes */
95: extern boolean_t mapping_remove(space_t space, vm_offset_t va); /* Remove a single mapping for this VADDR */
96: extern void mapping_free_init(vm_offset_t mbl, int perm, boolean_t locked); /* Sets start and end of a block of mappings */
97: extern void mapping_adjust(void); /* Adjust free mapping count */
98: extern void mapping_free_prime(void); /* Primes the mapping block release list */
99: extern void mapping_prealloc(unsigned int); /* Preallocate mappings for large use */
100: extern void mapping_relpre(void); /* Releases preallocate request */
101: extern void mapping_init(void); /* Do initial stuff */
102: extern mapping *mapping_alloc(void); /* Obtain a mapping */
103: extern void mapping_free(struct mapping *mp); /* Release a mapping */
104: extern boolean_t mapping_tst_ref(struct phys_entry *pp); /* Tests the reference bit of a physical page */
105: extern boolean_t mapping_tst_mod(struct phys_entry *pp); /* Tests the change bit of a physical page */
106: extern void mapping_set_ref(struct phys_entry *pp); /* Sets the reference bit of a physical page */
107: extern void mapping_clr_ref(struct phys_entry *pp); /* Clears the reference bit of a physical page */
108: extern void mapping_set_mod(struct phys_entry *pp); /* Sets the change bit of a physical page */
109: extern void mapping_clr_mod(struct phys_entry *pp); /* Clears the change bit of a physical page */
110: extern void mapping_invall(struct phys_entry *pp); /* Clear all PTEs pointing to a physical page */
111: extern void mapping_protect(struct phys_entry *pp, vm_prot_t prot, boolean_t locked); /* Change protection of all mappings to page */
112: extern mapping *mapping_make(struct pmap *pmap, space_t space, struct phys_entry *pp, vm_offset_t va, vm_offset_t pa, vm_prot_t prot, int attr); /* Make an address mapping */
113: extern int mapping_remap(space_t space, vm_offset_t from, vm_offset_t to); /* Remap an address mapping */
114: extern void mapping_purge(struct phys_entry *pp); /* Remove all mappings for this physent */
115: extern boolean_t mapping_remove(space_t space, vm_offset_t va); /* Remove a single mapping for this VADDR */
116: extern space_t mapping_space(void); /* Generate a unique space ID */
117: extern vm_offset_t mapping_p2v(space_t space, struct phys_entry *pp); /* Finds first virtual mapping of a physical page in a space */
118: extern void mapping_phys_attr(struct phys_entry *pp, vm_prot_t prot, unsigned int wimg); /* Sets the default physical page attributes */
119: extern int mapalc(struct mappingblok *mb); /* Finds and allcates a mapping entry */
120: extern void ignore_zero_fault(boolean_t type); /* Sets up to ignore or honor any fault on page 0 access for the current thread */
121:
122:
123: extern boolean_t autogen_map(space_t space, vm_offset_t va, vm_offset_t spa, vm_offset_t epa, vm_prot_t prot, int attr); /* Build an autogen area */
124:
125: extern mapping *hw_lock_phys_vir(space_t space, vm_offset_t va); /* Finds and locks a physical entry by vaddr */
126: extern mapping *hw_cpv(struct mapping *mapping); /* Converts a physical mapping control block address to virtual */
127: extern mapping *hw_cvp(struct mapping *mapping); /* Converts a virtual mapping control block address to physical */
128: extern void hw_rem_map(struct mapping *mapping); /* Remove a mapping from the system */
129: extern void hw_add_map(struct mapping *mp, space_t space, vm_offset_t va); /* Add a mapping to the PTEG hash list */
130: extern void hw_prot(struct phys_entry *pp, vm_prot_t prot); /* Change the protection of a physical page */
131: extern void hw_phys_attr(struct phys_entry *pp, vm_prot_t prot, unsigned int wimg); /* Sets the default physical page attributes */
132:
133: extern boolean_t hw_tst_mod(struct phys_entry *pp); /* Tests change bit */
134: extern void hw_set_mod(struct phys_entry *pp); /* Set change bit */
135: extern void hw_clr_mod(struct phys_entry *pp); /* Clear change bit */
136:
137: extern boolean_t hw_tst_ref(struct phys_entry *pp); /* Tests reference bit */
138: extern void hw_set_ref(struct phys_entry *pp); /* Set reference bit */
139: extern void hw_clr_ref(struct phys_entry *pp); /* Clear reference bit */
140:
141: extern void hw_inv_all(struct phys_entry *pp); /* Invalidate all PTEs associated with page */
142: extern void hw_set_user_space(space_t space); /* Indicate we need a space switch */
143: extern void *LRA(space_t space, void *vaddr); /* Translate virtual to real using only HW tables */
144: extern void dumpaddr(space_t space, vm_offset_t va);
145: extern void dumpmapping(struct mapping *mp); /* Print contents of a mapping */
146: extern void dumppca(struct mapping *mp); /* Print contents of a PCA */
147: extern void dumpphys(struct phys_entry *pp); /* Prints stuff starting at phys */
148: extern unsigned int mappingdeb0; /* (TEST/DEBUG) */
149:
150: #endif /* _PPC_MAPPINGS_H_ */
151:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.