xref: /netbsd-src/sys/arch/mips/include/wired_map.h (revision d9d62d0f590566eb79055afcd8100425bafaa4a7)
1*d9d62d0fSandvar /*	$NetBSD: wired_map.h,v 1.5 2024/06/02 12:11:36 andvar Exp $	*/
274f4d162Stsutsui 
374f4d162Stsutsui /*-
474f4d162Stsutsui  * Copyright (c) 2005 Tadpole Computer Inc.
574f4d162Stsutsui  * All rights reserved.
674f4d162Stsutsui  *
774f4d162Stsutsui  * Written by Garrett D'Amore for Tadpole Computer Inc.
874f4d162Stsutsui  *
974f4d162Stsutsui  * Redistribution and use in source and binary forms, with or without
1074f4d162Stsutsui  * modification, are permitted provided that the following conditions
1174f4d162Stsutsui  * are met:
1274f4d162Stsutsui  * 1. Redistributions of source code must retain the above copyright
1374f4d162Stsutsui  *    notice, this list of conditions and the following disclaimer.
1474f4d162Stsutsui  * 2. Redistributions in binary form must reproduce the above copyright
1574f4d162Stsutsui  *    notice, this list of conditions and the following disclaimer in the
1674f4d162Stsutsui  *    documentation and/or other materials provided with the distribution.
1774f4d162Stsutsui  * 3. The name of Tadpole Computer Inc. may not be used to endorse
1874f4d162Stsutsui  *    or promote products derived from this software without specific
1974f4d162Stsutsui  *    prior written permission.
2074f4d162Stsutsui  *
2174f4d162Stsutsui  * THIS SOFTWARE IS PROVIDED BY TADPOLE COMPUTER INC. ``AS IS'' AND
2274f4d162Stsutsui  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2374f4d162Stsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2474f4d162Stsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL TADPOLE COMPUTER INC.
2574f4d162Stsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2674f4d162Stsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2774f4d162Stsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2874f4d162Stsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2974f4d162Stsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3074f4d162Stsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3174f4d162Stsutsui  * POSSIBILITY OF SUCH DAMAGE.
3274f4d162Stsutsui  */
3374f4d162Stsutsui 
3474f4d162Stsutsui #ifndef _MIPS_WIRED_MAP_H
3574f4d162Stsutsui #define	_MIPS_WIRED_MAP_H
3674f4d162Stsutsui 
3774f4d162Stsutsui /*
3874f4d162Stsutsui  * Certain machines have peripheral busses which are only accessible
3974f4d162Stsutsui  * using the TLB.
4074f4d162Stsutsui  *
4174f4d162Stsutsui  * For example, certain Alchemy parts place PCI and PCMCIA busses at
4274f4d162Stsutsui  * physical address spaces which are beyond the normal 32-bit range.
4374f4d162Stsutsui  * In order to access these spaces TLB entries mapping 36-bit physical
4474f4d162Stsutsui  * addresses to 32-bit logical addresses must be used.
4574f4d162Stsutsui  *
4674f4d162Stsutsui  * Note that all wired mappings are must be 32 MB aligned.  This is
4774f4d162Stsutsui  * because we use 32 MB mappings in the TLB.  Changing this might get
48*d9d62d0fSandvar  * us more efficient use of the address space, but it would greatly
4974f4d162Stsutsui  * complicate the code, and would also probably consume additional TLB
5074f4d162Stsutsui  * entries.
5174f4d162Stsutsui  *
5274f4d162Stsutsui  * Note that within a single 32 MB region, you can have multiple
5374f4d162Stsutsui  * decoders, but they must decode uniquely within the same 32MB of
5474f4d162Stsutsui  * physical address space.
5574f4d162Stsutsui  *
5674f4d162Stsutsui  * BEWARE: The start of KSEG2 (0xC0000000) is used by the NetBSD kernel
5774f4d162Stsutsui  * for context switching and is associated with wired entry 0.  So you
5874f4d162Stsutsui  * cannot use that, as I discovered the hard way.
5974f4d162Stsutsui  *
6074f4d162Stsutsui  * Note also that at the moment this is not supported on the MIPS-I
6174f4d162Stsutsui  * ISA (but it shouldn't need it anyway.)
6274f4d162Stsutsui  */
6374f4d162Stsutsui 
6474f4d162Stsutsui #ifndef MIPS3_WIRED_SIZE
6574f4d162Stsutsui #define	MIPS3_WIRED_SIZE	MIPS3_PG_SIZE_MASK_TO_SIZE(MIPS3_PG_SIZE_16M)
6674f4d162Stsutsui #endif
6774f4d162Stsutsui #define	MIPS3_WIRED_OFFMASK	(MIPS3_WIRED_SIZE - 1)
6874f4d162Stsutsui 
6974f4d162Stsutsui #define	MIPS3_WIRED_ENTRY_SIZE(pgsize)	((pgsize) * 2)
7074f4d162Stsutsui #define	MIPS3_WIRED_ENTRY_OFFMASK(pgsize) (MIPS3_WIRED_ENTRY_SIZE(pgsize) - 1)
7174f4d162Stsutsui 
7274f4d162Stsutsui /*
7374f4d162Stsutsui  * This defines the maximum number of wired TLB entries that the wired
7474f4d162Stsutsui  * map will be allowed to consume.  It can (and probably will!)
7574f4d162Stsutsui  * consume fewer, but it will not consume more.  Note that NetBSD also
7674f4d162Stsutsui  * uses one wired entry for context switching (see TLB_WIRED_UPAGES),
7774f4d162Stsutsui  * and that is not included in this number.
7874f4d162Stsutsui  */
7974f4d162Stsutsui #ifndef MIPS3_NWIRED_ENTRY
8074f4d162Stsutsui #define	MIPS3_NWIRED_ENTRY	8	/* upper limit */
8174f4d162Stsutsui #endif
8274f4d162Stsutsui 
8374f4d162Stsutsui struct wired_map_entry {
8474f4d162Stsutsui 	paddr_t	pa0;
8574f4d162Stsutsui 	paddr_t	pa1;
8674f4d162Stsutsui 	vaddr_t	va;
8774f4d162Stsutsui 	vsize_t	pgmask;
8874f4d162Stsutsui };
8974f4d162Stsutsui 
9074f4d162Stsutsui extern struct wired_map_entry mips3_wired_map[];
9174f4d162Stsutsui extern int mips3_nwired_page;
9274f4d162Stsutsui 
9374f4d162Stsutsui /*
9474f4d162Stsutsui  * Wire down a region of the specified size.
9574f4d162Stsutsui  */
96712239e3Sthorpej bool	mips3_wired_enter_region(vaddr_t, paddr_t, vsize_t);
9774f4d162Stsutsui 
9874f4d162Stsutsui /*
9974f4d162Stsutsui  * Wire down a single page using specified page size.
10074f4d162Stsutsui  */
101712239e3Sthorpej bool	mips3_wired_enter_page(vaddr_t, paddr_t, vsize_t);
10274f4d162Stsutsui 
10374f4d162Stsutsui #endif	/* _MIPS_WIRED_MAP_H */
104