slb.h revision 210704
1209975Snwhitehorn/*- 2209975Snwhitehorn * Copyright (C) 2009 Nathan Whitehorn 3209975Snwhitehorn * All rights reserved. 4209975Snwhitehorn * 5209975Snwhitehorn * Redistribution and use in source and binary forms, with or without 6209975Snwhitehorn * modification, are permitted provided that the following conditions 7209975Snwhitehorn * are met: 8209975Snwhitehorn * 1. Redistributions of source code must retain the above copyright 9209975Snwhitehorn * notice, this list of conditions and the following disclaimer. 10209975Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright 11209975Snwhitehorn * notice, this list of conditions and the following disclaimer in the 12209975Snwhitehorn * documentation and/or other materials provided with the distribution. 13209975Snwhitehorn * 14209975Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15209975Snwhitehorn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16209975Snwhitehorn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17209975Snwhitehorn * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18209975Snwhitehorn * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19209975Snwhitehorn * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20209975Snwhitehorn * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21209975Snwhitehorn * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22209975Snwhitehorn * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23209975Snwhitehorn * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24209975Snwhitehorn * 25209975Snwhitehorn * $FreeBSD: head/sys/powerpc/include/slb.h 210704 2010-07-31 21:35:15Z nwhitehorn $ 26209975Snwhitehorn */ 27209975Snwhitehorn 28209975Snwhitehorn#ifndef _MACHINE_SLB_H_ 29209975Snwhitehorn#define _MACHINE_SLB_H_ 30209975Snwhitehorn 31209975Snwhitehorn/* 32209975Snwhitehorn * Bit definitions for segment lookaside buffer entries. 33209975Snwhitehorn * 34209975Snwhitehorn * PowerPC Microprocessor Family: The Programming Environments for 64-bit 35209975Snwhitehorn * Microprocessors, section 7.4.2.1 36209975Snwhitehorn * 37209975Snwhitehorn * Note that these bitmasks are relative to the values for one of the two 38209975Snwhitehorn * values for slbmte, slbmfee, and slbmfev, not the internal SLB 39209975Snwhitehorn * representation. 40209975Snwhitehorn */ 41209975Snwhitehorn 42209975Snwhitehorn#define SLBV_KS 0x0000000000000800UL /* Supervisor-state prot key */ 43209975Snwhitehorn#define SLBV_KP 0x0000000000000400UL /* User-state prot key */ 44209975Snwhitehorn#define SLBV_N 0x0000000000000200UL /* No-execute protection */ 45209975Snwhitehorn#define SLBV_L 0x0000000000000100UL /* Large page selector */ 46209975Snwhitehorn#define SLBV_CLASS 0x0000000000000080UL /* Class selector */ 47209975Snwhitehorn#define SLBV_VSID_MASK 0xfffffffffffff000UL /* Virtual segment ID mask */ 48209975Snwhitehorn#define SLBV_VSID_SHIFT 12 49209975Snwhitehorn 50209975Snwhitehorn/* 51210704Snwhitehorn * Make a predictable 1:1 map from ESIDs to VSIDs for the kernel. Hash table 52210704Snwhitehorn * coverage is increased by swizzling the ESID and multiplying by a prime 53210704Snwhitehorn * number (0x13bb). 54209975Snwhitehorn */ 55210704Snwhitehorn#define KERNEL_VSID_BIT 0x0000001000000000UL /* Bit set in all kernel VSIDs */ 56210704Snwhitehorn#define KERNEL_VSID(esid) ((((((uint64_t)esid << 8) | ((uint64_t)esid >> 28)) \ 57210704Snwhitehorn * 0x13bbUL) & (KERNEL_VSID_BIT - 1)) | \ 58210704Snwhitehorn KERNEL_VSID_BIT) 59209975Snwhitehorn 60209975Snwhitehorn#define SLBE_VALID 0x0000000008000000UL /* SLB entry valid */ 61209975Snwhitehorn#define SLBE_INDEX_MASK 0x0000000000000fffUL /* SLB index mask*/ 62209975Snwhitehorn#define SLBE_ESID_MASK 0xfffffffff0000000UL /* Effective segment ID mask */ 63209975Snwhitehorn#define SLBE_ESID_SHIFT 28 64209975Snwhitehorn 65209975Snwhitehornstruct slb { 66209975Snwhitehorn uint64_t slbv; 67209975Snwhitehorn uint64_t slbe; 68209975Snwhitehorn}; 69209975Snwhitehorn 70209975Snwhitehorn#endif /* !_MACHINE_SLB_H_ */ 71