160727d8bSWarner Losh /*- 271e3c308SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 371e3c308SPedro F. Giffuni * 45244eac9SBenno Rice * Copyright (C) 2002 Benno Rice. 55244eac9SBenno Rice * All rights reserved. 65244eac9SBenno Rice * 75244eac9SBenno Rice * Redistribution and use in source and binary forms, with or without 85244eac9SBenno Rice * modification, are permitted provided that the following conditions 95244eac9SBenno Rice * are met: 105244eac9SBenno Rice * 1. Redistributions of source code must retain the above copyright 115244eac9SBenno Rice * notice, this list of conditions and the following disclaimer. 125244eac9SBenno Rice * 2. Redistributions in binary form must reproduce the above copyright 135244eac9SBenno Rice * notice, this list of conditions and the following disclaimer in the 145244eac9SBenno Rice * documentation and/or other materials provided with the distribution. 155244eac9SBenno Rice * 165244eac9SBenno Rice * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 175244eac9SBenno Rice * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 185244eac9SBenno Rice * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 195244eac9SBenno Rice * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205244eac9SBenno Rice * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 215244eac9SBenno Rice * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 225244eac9SBenno Rice * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 235244eac9SBenno Rice * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 245244eac9SBenno Rice * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 255244eac9SBenno Rice * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265244eac9SBenno Rice * 275244eac9SBenno Rice * $FreeBSD$ 285244eac9SBenno Rice */ 295244eac9SBenno Rice 305244eac9SBenno Rice #ifndef _MACHINE_SR_H_ 315244eac9SBenno Rice #define _MACHINE_SR_H_ 325244eac9SBenno Rice 335244eac9SBenno Rice /* 345244eac9SBenno Rice * Bit definitions for segment registers. 355244eac9SBenno Rice * 365244eac9SBenno Rice * PowerPC Microprocessor Family: The Programming Environments for 32-bit 375244eac9SBenno Rice * Microprocessors, section 2.3.5 385244eac9SBenno Rice */ 395244eac9SBenno Rice 405244eac9SBenno Rice #define SR_TYPE 0x80000000 /* Type selector */ 415244eac9SBenno Rice #define SR_KS 0x40000000 /* Supervisor-state protection key */ 425244eac9SBenno Rice #define SR_KP 0x20000000 /* User-state protection key */ 435244eac9SBenno Rice #define SR_N 0x10000000 /* No-execute protection */ 445244eac9SBenno Rice #define SR_VSID_MASK 0x00ffffff /* Virtual Segment ID mask */ 455244eac9SBenno Rice 467c277971SPeter Grehan /* Kernel segment register usage */ 474daf20b2SPeter Grehan #define USER_SR 12 484daf20b2SPeter Grehan #define KERNEL_SR 13 494daf20b2SPeter Grehan #define KERNEL2_SR 14 50ab739706SNathan Whitehorn #define KERNEL3_SR 15 51c3e289e1SNathan Whitehorn #define KERNEL_VSIDBITS 0xfffffUL 527c277971SPeter Grehan #define KERNEL_SEGMENT (0xfffff0 + KERNEL_SR) 534daf20b2SPeter Grehan #define KERNEL2_SEGMENT (0xfffff0 + KERNEL2_SR) 547c277971SPeter Grehan #define EMPTY_SEGMENT 0xfffff0 55c3e289e1SNathan Whitehorn #ifdef __powerpc64__ 56*65bbba25SJustin Hibbits #define USER_ADDR 0xc00ffffff0000000UL 57c3e289e1SNathan Whitehorn #else 58c3e289e1SNathan Whitehorn #define USER_ADDR ((uintptr_t)USER_SR << ADDR_SR_SHFT) 59c3e289e1SNathan Whitehorn #endif 60c3e289e1SNathan Whitehorn #define SEGMENT_LENGTH 0x10000000UL 61c3e289e1SNathan Whitehorn #define SEGMENT_INVMASK 0x0fffffffUL 62c3e289e1SNathan Whitehorn #define SEGMENT_MASK ~SEGMENT_INVMASK 637c277971SPeter Grehan 645244eac9SBenno Rice #endif /* !_MACHINE_SR_H_ */ 65