]> git.saurik.com Git - apple/xnu.git/blame_incremental - osfmk/i386/pmap_pcid.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / i386 / pmap_pcid.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#ifndef _PMAP_PCID_
30#define _PMAP_PCID_ 1
31#if defined(__x86_64__)
32void pmap_pcid_initialize(pmap_t);
33void pmap_pcid_initialize_kernel(pmap_t);
34pcid_t pmap_pcid_allocate_pcid(int);
35void pmap_pcid_deallocate_pcid(int, pmap_t);
36void pmap_destroy_pcid_sync_action(void *);
37void pmap_destroy_pcid_sync(pmap_t);
38void pmap_pcid_lazy_flush(pmap_t);
39void pmap_pcid_activate(pmap_t, int, boolean_t, boolean_t);
40pcid_t pcid_for_pmap_cpu_tuple(pmap_t, thread_t, int);
41
42#define PMAP_INVALID ((pmap_t)0xDEAD7347)
43#define PMAP_PCID_INVALID_PCID (0xDEAD)
44#define PMAP_PCID_MAX_REFCOUNT (0xF0)
45#define PMAP_PCID_MIN_PCID (1)
46
47extern uint32_t pmap_pcid_ncpus;
48
49static inline void
50pmap_pcid_invalidate_all_cpus(pmap_t tpmap)
51{
52 unsigned i;
53
54 pmap_assert((sizeof(tpmap->pmap_pcid_coherency_vector) >= real_ncpus) && (!(sizeof(tpmap->pmap_pcid_coherency_vector) & 7)));
55
56 for (i = 0; i < real_ncpus; i += 8) {
57 *(uint64_t *)(uintptr_t)&tpmap->pmap_pcid_coherency_vector[i] = (~0ULL);
58 }
59}
60
61static inline void
62pmap_pcid_validate_current(void)
63{
64 int ccpu = cpu_number();
65 volatile uint8_t *cptr = cpu_datap(ccpu)->cpu_pmap_pcid_coherentp;
66#ifdef PMAP_MODULE
67 pmap_assert(cptr == &(current_thread()->map->pmap->pmap_pcid_coherency_vector[ccpu]));
68#endif
69 if (cptr) {
70 *cptr = 0;
71 }
72}
73
74static inline void
75pmap_pcid_invalidate_cpu(pmap_t tpmap, int ccpu)
76{
77 tpmap->pmap_pcid_coherency_vector[ccpu] = 0xFF;
78}
79
80static inline void
81pmap_pcid_validate_cpu(pmap_t tpmap, int ccpu)
82{
83 tpmap->pmap_pcid_coherency_vector[ccpu] = 0;
84}
85#endif /* x86_64 */
86#endif