1139825Simp/*-
290643Sbenno * Copyright (C) 2002 Benno Rice.
390643Sbenno * All rights reserved.
490643Sbenno *
590643Sbenno * Redistribution and use in source and binary forms, with or without
690643Sbenno * modification, are permitted provided that the following conditions
790643Sbenno * are met:
890643Sbenno * 1. Redistributions of source code must retain the above copyright
990643Sbenno *    notice, this list of conditions and the following disclaimer.
1090643Sbenno * 2. Redistributions in binary form must reproduce the above copyright
1190643Sbenno *    notice, this list of conditions and the following disclaimer in the
1290643Sbenno *    documentation and/or other materials provided with the distribution.
1390643Sbenno *
1490643Sbenno * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
1590643Sbenno * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1690643Sbenno * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1790643Sbenno * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1890643Sbenno * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1990643Sbenno * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2090643Sbenno * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2190643Sbenno * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2290643Sbenno * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2390643Sbenno * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2490643Sbenno *
2590643Sbenno * $FreeBSD: releng/10.3/sys/powerpc/include/sr.h 214574 2010-10-30 23:07:30Z nwhitehorn $
2690643Sbenno */
2790643Sbenno
2890643Sbenno#ifndef _MACHINE_SR_H_
2990833Sobrien#define	_MACHINE_SR_H_
3090643Sbenno
3190643Sbenno/*
3290643Sbenno * Bit definitions for segment registers.
3390643Sbenno *
3490643Sbenno * PowerPC Microprocessor Family: The Programming Environments for 32-bit
3590643Sbenno * Microprocessors, section 2.3.5
3690643Sbenno */
3790643Sbenno
3890643Sbenno#define	SR_TYPE		0x80000000	/* Type selector */
3990643Sbenno#define	SR_KS		0x40000000	/* Supervisor-state protection key */
4090643Sbenno#define	SR_KP		0x20000000	/* User-state protection key */
4190833Sobrien#define	SR_N		0x10000000	/* No-execute protection */
4290643Sbenno#define	SR_VSID_MASK	0x00ffffff	/* Virtual Segment ID mask */
4390643Sbenno
44125687Sgrehan/* Kernel segment register usage */
45126478Sgrehan#define	USER_SR		12
46126478Sgrehan#define	KERNEL_SR	13
47126478Sgrehan#define	KERNEL2_SR	14
48204128Snwhitehorn#define	KERNEL3_SR	15
49209975Snwhitehorn#define	KERNEL_VSIDBITS	0xfffffUL
50125687Sgrehan#define	KERNEL_SEGMENT	(0xfffff0 + KERNEL_SR)
51126478Sgrehan#define	KERNEL2_SEGMENT	(0xfffff0 + KERNEL2_SR)
52125687Sgrehan#define	EMPTY_SEGMENT	0xfffff0
53209975Snwhitehorn#ifdef __powerpc64__
54209975Snwhitehorn#define	USER_ADDR	0xcffffffff0000000UL
55209975Snwhitehorn#else
56209975Snwhitehorn#define	USER_ADDR	((uintptr_t)USER_SR << ADDR_SR_SHFT)
57209975Snwhitehorn#endif
58209975Snwhitehorn#define	SEGMENT_LENGTH	0x10000000UL
59209975Snwhitehorn#define	SEGMENT_INVMASK	0x0fffffffUL
60209975Snwhitehorn#define	SEGMENT_MASK	~SEGMENT_INVMASK
61125687Sgrehan
6290643Sbenno#endif /* !_MACHINE_SR_H_ */
63