Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/include MTRR include file, based on the one by...
details: https://anonhg.NetBSD.org/src/rev/c2ea3d35d15a
branches: trunk
changeset: 514761:c2ea3d35d15a
user: fvdl <fvdl%NetBSD.org@localhost>
date: Mon Sep 10 10:10:33 2001 +0000
description:
MTRR include file, based on the one by Bill Sommerfeld from the i386 mp
branch.
diffstat:
sys/arch/i386/include/mtrr.h | 143 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 143 insertions(+), 0 deletions(-)
diffs (147 lines):
diff -r acb9796831b7 -r c2ea3d35d15a sys/arch/i386/include/mtrr.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/include/mtrr.h Mon Sep 10 10:10:33 2001 +0000
@@ -0,0 +1,143 @@
+/* $NetBSD: mtrr.h,v 1.2 2001/09/10 10:10:33 fvdl Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Bill Sommerfeld
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _I386_MTRR_H_
+#define _I386_MTRR_H_
+
+#define MTRR_I686_FIXED_IDX64K 0
+#define MTRR_I686_FIXED_IDX16K 1
+#define MTRR_I686_FIXED_IDX4K 3
+
+#define MTRR_I686_NVAR 8
+
+#define MTRR_I686_64K_START 0x00000
+#define MTRR_I686_16K_START 0x80000
+#define MTRR_I686_4K_START 0xc0000
+
+#define MTRR_I686_NFIXED_64K 1
+#define MTRR_I686_NFIXED_16K 2
+#define MTRR_I686_NFIXED_4K 8
+#define MTRR_I686_NFIXED 11
+#define MTRR_I686_NFIXED_SOFT_64K (MTRR_I686_NFIXED_64K * 8)
+#define MTRR_I686_NFIXED_SOFT_16K (MTRR_I686_NFIXED_16K * 8)
+#define MTRR_I686_NFIXED_SOFT_4K (MTRR_I686_NFIXED_4K * 8)
+#define MTRR_I686_NFIXED_SOFT (MTRR_I686_NFIXED * 8)
+
+#define MTRR_I686_ENABLE_MASK 0x0800
+#define MTRR_I686_FIXED_ENABLE_MASK 0x0400
+
+#define MTRR_I686_CAP_VCNT_MASK 0x00ff
+#define MTRR_I686_CAP_FIX_MASK 0x0100
+#define MTRR_I686_CAP_WC_MASK 0x0400
+
+#define MTRR_TYPE_UC 0
+#define MTRR_TYPE_WC 1
+#define MTRR_TYPE_UNDEF1 2
+#define MTRR_TYPE_UNDEF2 3
+#define MTRR_TYPE_WT 4
+#define MTRR_TYPE_WP 5
+#define MTRR_TYPE_WB 6
+
+struct mtrr_state {
+ uint32_t msraddr;
+ uint64_t msrval;
+};
+
+#define MTRR_PRIVATE 0x0001 /* 'own' range, reset at exit */
+#define MTRR_FIXED 0x0002 /* use fixed range mtrr */
+#define MTRR_VALID 0x0004 /* entry is valid */
+
+#define MTRR_CANTSET MTRR_FIXED
+
+#define MTRR_I686_MASK_VALID (1 << 11)
+
+
+#ifdef _KERNEL
+
+#define mtrr_base_value(mtrrp) \
+ (((uint64_t)(mtrrp)->base) | ((uint64_t)(mtrrp)->type))
+#define mtrr_mask_value(mtrrp) \
+ ((~((mtrrp)->len - 1) & 0x0000000ffffff000))
+
+
+#define mtrr_len(val) \
+ ((~((val) & 0x0000000ffffff000)+1) & 0x0000000ffffff000)
+#define mtrr_base(val) ((val) & 0x0000000ffffff000)
+#define mtrr_type(val) ((uint8_t)((val) & 0x00000000000000ff))
+#define mtrr_valid(val) (((val) & MTRR_I686_MASK_VALID) != 0)
+
+struct proc;
+struct mtrr;
+
+void i686_mtrr_init_first(void);
+
+struct mtrr_funcs {
+ void (*init_cpu)(struct cpu_info *ci);
+ void (*reload_cpu)(struct cpu_info *ci);
+ void (*clean)(struct proc *p);
+ int (*set)(struct mtrr *, int *n, struct proc *p, int flags);
+ int (*get)(struct mtrr *, int *n, struct proc *p, int flags);
+ void (*commit)(void);
+ void (*dump)(const char *tag);
+};
+
+extern struct mtrr_funcs i686_mtrr_funcs;
+extern struct mtrr_funcs *mtrr_funcs;
+
+#define mtrr_init_cpu(ci) mtrr_funcs->init_cpu(ci)
+#define mtrr_reload_cpu(ci) mtrr_funcs->reload_cpu(ci)
+#define mtrr_clean(p) mtrr_funcs->clean(p)
+#define mtrr_set(mp,n,p,f) mtrr_funcs->set(mp,n,p,f)
+#define mtrr_get(mp,n,p,f) mtrr_funcs->get(mp,n,p,f)
+#define mtrr_dump(s) mtrr_funcs->dump(s)
+#define mtrr_commit() mtrr_funcs->commit()
+
+#define MTRR_GETSET_USER 0x0001
+#define MTRR_GETSET_KERNEL 0x0002
+
+#endif /* _KERNEL */
+
+struct mtrr {
+ uint64_t base; /* physical base address */
+ uint64_t len;
+ uint8_t type;
+ int flags;
+ pid_t owner; /* valid if MTRR_PRIVATE set in flags */
+};
+
+#endif /* _I386_MTRR_H_ */
Home |
Main Index |
Thread Index |
Old Index