1 1.5 andvar /* $NetBSD: wired_map.h,v 1.5 2024/06/02 12:11:36 andvar Exp $ */ 2 1.1 tsutsui 3 1.1 tsutsui /*- 4 1.1 tsutsui * Copyright (c) 2005 Tadpole Computer Inc. 5 1.1 tsutsui * All rights reserved. 6 1.1 tsutsui * 7 1.1 tsutsui * Written by Garrett D'Amore for Tadpole Computer Inc. 8 1.1 tsutsui * 9 1.1 tsutsui * Redistribution and use in source and binary forms, with or without 10 1.1 tsutsui * modification, are permitted provided that the following conditions 11 1.1 tsutsui * are met: 12 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright 13 1.1 tsutsui * notice, this list of conditions and the following disclaimer. 14 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright 15 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the 16 1.1 tsutsui * documentation and/or other materials provided with the distribution. 17 1.1 tsutsui * 3. The name of Tadpole Computer Inc. may not be used to endorse 18 1.1 tsutsui * or promote products derived from this software without specific 19 1.1 tsutsui * prior written permission. 20 1.1 tsutsui * 21 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY TADPOLE COMPUTER INC. ``AS IS'' AND 22 1.1 tsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 1.1 tsutsui * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 1.1 tsutsui * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TADPOLE COMPUTER INC. 25 1.1 tsutsui * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 1.1 tsutsui * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 1.1 tsutsui * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 1.1 tsutsui * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 1.1 tsutsui * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 1.1 tsutsui * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 1.1 tsutsui * POSSIBILITY OF SUCH DAMAGE. 32 1.1 tsutsui */ 33 1.1 tsutsui 34 1.1 tsutsui #ifndef _MIPS_WIRED_MAP_H 35 1.4 simonb #define _MIPS_WIRED_MAP_H 36 1.1 tsutsui 37 1.1 tsutsui /* 38 1.1 tsutsui * Certain machines have peripheral busses which are only accessible 39 1.1 tsutsui * using the TLB. 40 1.1 tsutsui * 41 1.1 tsutsui * For example, certain Alchemy parts place PCI and PCMCIA busses at 42 1.1 tsutsui * physical address spaces which are beyond the normal 32-bit range. 43 1.1 tsutsui * In order to access these spaces TLB entries mapping 36-bit physical 44 1.1 tsutsui * addresses to 32-bit logical addresses must be used. 45 1.1 tsutsui * 46 1.1 tsutsui * Note that all wired mappings are must be 32 MB aligned. This is 47 1.1 tsutsui * because we use 32 MB mappings in the TLB. Changing this might get 48 1.5 andvar * us more efficient use of the address space, but it would greatly 49 1.1 tsutsui * complicate the code, and would also probably consume additional TLB 50 1.1 tsutsui * entries. 51 1.1 tsutsui * 52 1.1 tsutsui * Note that within a single 32 MB region, you can have multiple 53 1.1 tsutsui * decoders, but they must decode uniquely within the same 32MB of 54 1.1 tsutsui * physical address space. 55 1.1 tsutsui * 56 1.1 tsutsui * BEWARE: The start of KSEG2 (0xC0000000) is used by the NetBSD kernel 57 1.1 tsutsui * for context switching and is associated with wired entry 0. So you 58 1.1 tsutsui * cannot use that, as I discovered the hard way. 59 1.1 tsutsui * 60 1.1 tsutsui * Note also that at the moment this is not supported on the MIPS-I 61 1.1 tsutsui * ISA (but it shouldn't need it anyway.) 62 1.1 tsutsui */ 63 1.1 tsutsui 64 1.1 tsutsui #ifndef MIPS3_WIRED_SIZE 65 1.4 simonb #define MIPS3_WIRED_SIZE MIPS3_PG_SIZE_MASK_TO_SIZE(MIPS3_PG_SIZE_16M) 66 1.1 tsutsui #endif 67 1.4 simonb #define MIPS3_WIRED_OFFMASK (MIPS3_WIRED_SIZE - 1) 68 1.1 tsutsui 69 1.4 simonb #define MIPS3_WIRED_ENTRY_SIZE(pgsize) ((pgsize) * 2) 70 1.4 simonb #define MIPS3_WIRED_ENTRY_OFFMASK(pgsize) (MIPS3_WIRED_ENTRY_SIZE(pgsize) - 1) 71 1.1 tsutsui 72 1.1 tsutsui /* 73 1.1 tsutsui * This defines the maximum number of wired TLB entries that the wired 74 1.1 tsutsui * map will be allowed to consume. It can (and probably will!) 75 1.1 tsutsui * consume fewer, but it will not consume more. Note that NetBSD also 76 1.1 tsutsui * uses one wired entry for context switching (see TLB_WIRED_UPAGES), 77 1.1 tsutsui * and that is not included in this number. 78 1.1 tsutsui */ 79 1.1 tsutsui #ifndef MIPS3_NWIRED_ENTRY 80 1.4 simonb #define MIPS3_NWIRED_ENTRY 8 /* upper limit */ 81 1.1 tsutsui #endif 82 1.1 tsutsui 83 1.1 tsutsui struct wired_map_entry { 84 1.1 tsutsui paddr_t pa0; 85 1.1 tsutsui paddr_t pa1; 86 1.1 tsutsui vaddr_t va; 87 1.1 tsutsui vsize_t pgmask; 88 1.1 tsutsui }; 89 1.1 tsutsui 90 1.1 tsutsui extern struct wired_map_entry mips3_wired_map[]; 91 1.1 tsutsui extern int mips3_nwired_page; 92 1.1 tsutsui 93 1.1 tsutsui /* 94 1.1 tsutsui * Wire down a region of the specified size. 95 1.1 tsutsui */ 96 1.3 thorpej bool mips3_wired_enter_region(vaddr_t, paddr_t, vsize_t); 97 1.1 tsutsui 98 1.1 tsutsui /* 99 1.1 tsutsui * Wire down a single page using specified page size. 100 1.1 tsutsui */ 101 1.3 thorpej bool mips3_wired_enter_page(vaddr_t, paddr_t, vsize_t); 102 1.1 tsutsui 103 1.1 tsutsui #endif /* _MIPS_WIRED_MAP_H */ 104