xref: /freebsd/sys/powerpc/include/sr.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
160727d8bSWarner Losh /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
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 
285244eac9SBenno Rice #ifndef _MACHINE_SR_H_
295244eac9SBenno Rice #define	_MACHINE_SR_H_
305244eac9SBenno Rice 
315244eac9SBenno Rice /*
325244eac9SBenno Rice  * Bit definitions for segment registers.
335244eac9SBenno Rice  *
345244eac9SBenno Rice  * PowerPC Microprocessor Family: The Programming Environments for 32-bit
355244eac9SBenno Rice  * Microprocessors, section 2.3.5
365244eac9SBenno Rice  */
375244eac9SBenno Rice 
385244eac9SBenno Rice #define	SR_TYPE		0x80000000	/* Type selector */
395244eac9SBenno Rice #define	SR_KS		0x40000000	/* Supervisor-state protection key */
405244eac9SBenno Rice #define	SR_KP		0x20000000	/* User-state protection key */
415244eac9SBenno Rice #define	SR_N		0x10000000	/* No-execute protection */
425244eac9SBenno Rice #define	SR_VSID_MASK	0x00ffffff	/* Virtual Segment ID mask */
435244eac9SBenno Rice 
447c277971SPeter Grehan /* Kernel segment register usage */
454daf20b2SPeter Grehan #define	USER_SR		12
464daf20b2SPeter Grehan #define	KERNEL_SR	13
474daf20b2SPeter Grehan #define	KERNEL2_SR	14
48ab739706SNathan Whitehorn #define	KERNEL3_SR	15
49c3e289e1SNathan Whitehorn #define	KERNEL_VSIDBITS	0xfffffUL
507c277971SPeter Grehan #define	KERNEL_SEGMENT	(0xfffff0 + KERNEL_SR)
514daf20b2SPeter Grehan #define	KERNEL2_SEGMENT	(0xfffff0 + KERNEL2_SR)
527c277971SPeter Grehan #define	EMPTY_SEGMENT	0xfffff0
53c3e289e1SNathan Whitehorn #ifdef __powerpc64__
5465bbba25SJustin Hibbits #define	USER_ADDR	0xc00ffffff0000000UL
55c3e289e1SNathan Whitehorn #else
56c3e289e1SNathan Whitehorn #define	USER_ADDR	((uintptr_t)USER_SR << ADDR_SR_SHFT)
57c3e289e1SNathan Whitehorn #endif
58c3e289e1SNathan Whitehorn #define	SEGMENT_LENGTH	0x10000000UL
59c3e289e1SNathan Whitehorn #define	SEGMENT_INVMASK	0x0fffffffUL
60c3e289e1SNathan Whitehorn #define	SEGMENT_MASK	~SEGMENT_INVMASK
617c277971SPeter Grehan 
625244eac9SBenno Rice #endif /* !_MACHINE_SR_H_ */
63