1 /* $Id: sun.h,v 1.13 2009/08/30 13:54:40 fredette Exp $ */ 2 3 /* tme/machine/sun.h - public header file for Sun emulation: */ 4 5 /* 6 * Copyright (c) 2003 Matt Fredette 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Matt Fredette. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #ifndef _TME_MACHINE_SUN_H 37 #define _TME_MACHINE_SUN_H 38 39 #include <tme/common.h> 40 _TME_RCSID("$Id: sun.h,v 1.13 2009/08/30 13:54:40 fredette Exp $"); 41 42 /* includes: */ 43 #include <tme/element.h> 44 #include <tme/generic/bus.h> 45 46 /* macros: */ 47 48 /* the size of the classic Sun IDPROM: */ 49 #define TME_SUN_IDPROM_SIZE (32) 50 51 /* the size of a classic Sun z8530: */ 52 #define TME_SUN_Z8530_SIZE (8) 53 54 /* classic Sun z8530 socket: */ 55 #define TME_SUN_Z8530_SOCKET_INIT { \ 56 TME_Z8530_SOCKET_0, /* the socket version */ \ 57 0, /* socket flags */ \ 58 4, /* the bus address of channel A */ \ 59 0, /* the bus address of channel B */ \ 60 0, /* within each channel, the offset of the csr register */ \ 61 2, /* within each channel, the offset of the data register */ \ 62 3, /* the system bus byte lane the chip is wired to (D31-D24, may be overridden) */ \ 63 (9600 * 512) /* the clock rate provided to the chip: */ \ 64 } 65 66 /* classic two-level Sun MMU protections: */ 67 #define TME_SUN_MMU_PTE_PROT_MASK (0x3) 68 #define TME_SUN_MMU_PTE_PROT_ABORT (0x0) 69 #define TME_SUN_MMU_PTE_PROT_ERROR (0x1) 70 #define TME_SUN_MMU_PTE_PROT_RO (0x2) 71 #define TME_SUN_MMU_PTE_PROT_RW (0x3) 72 73 /* classic two-level Sun MMU page table entry bits: */ 74 #define TME_SUN_MMU_PTE_PROT_USER(x) ((x) << 0) 75 #define TME_SUN_MMU_PTE_PROT_SYSTEM(x) ((x) << 2) 76 #define TME_SUN_MMU_PTE_VALID TME_BIT(4) 77 #define TME_SUN_MMU_PTE_REF TME_BIT(5) 78 #define TME_SUN_MMU_PTE_MOD TME_BIT(6) 79 #define _TME_SUN_MMU_PTE_X(x) ((x) << 7) 80 81 /* a filled TLB entry can be valid for the system, or the user, or 82 both. because TME_BIT is a little too paranoid and uses a type 83 cast, we can't use it and then use these macros in preprocessor 84 expressions: */ 85 #define TME_SUN_MMU_TLB_SYSTEM (1 << 0) 86 #define TME_SUN_MMU_TLB_USER (1 << 1) 87 88 /* real sun IDPROM offsets: */ 89 #define TME_SUN_IDPROM_OFF_MACHTYPE (0x1) 90 91 /* real sun IDPROM machine type architecture and model identifiers: */ 92 #define TME_SUN_IDPROM_TYPE_MASK_ARCH (0xf0) 93 #define TME_SUN_IDPROM_TYPE_ARCH_SUN4 (0x20) 94 #define TME_SUN_IDPROM_TYPE_ARCH_SUN4C (0x50) 95 #define TME_SUN_IDPROM_TYPE_CODE_CALVIN (0x55) 96 97 /* structures: */ 98 99 /* one page table entry in a classic two-level Sun MMU: */ 100 struct tme_sun_mmu_pte { 101 102 /* the original raw page table entry: */ 103 tme_uint32_t tme_sun_mmu_pte_raw; 104 105 /* a collection of flags: */ 106 unsigned short tme_sun_mmu_pte_flags; 107 }; 108 109 /* the parameters for a classic two-level Sun MMU: */ 110 struct tme_sun_mmu_info { 111 112 /* the mainbus element: */ 113 struct tme_element *tme_sun_mmu_info_element; 114 115 /* the number of bits in an address: */ 116 tme_uint8_t tme_sun_mmu_info_address_bits; 117 118 /* the number of bits in a page offset: */ 119 tme_uint8_t tme_sun_mmu_info_pgoffset_bits; 120 121 /* the number of bits in a page table entry index: */ 122 tme_uint8_t tme_sun_mmu_info_pteindex_bits; 123 124 /* if greater than zero, the number of top address bits in a region 125 map entry index. if less than zero, the number of top address 126 bits that must be the same, and define the address hole: */ 127 tme_int8_t tme_sun_mmu_info_topindex_bits; 128 129 /* the number of contexts: */ 130 tme_uint8_t tme_sun_mmu_info_contexts; 131 132 /* the number of PMEGs: */ 133 unsigned short tme_sun_mmu_info_pmegs; 134 135 /* a TLB filler: */ 136 void *tme_sun_mmu_info_tlb_fill_private; 137 int (*tme_sun_mmu_info_tlb_fill) _TME_P((void *, struct tme_bus_tlb *, struct tme_sun_mmu_pte *, tme_uint32_t *, unsigned int)); 138 139 /* the protection error cycle handler: */ 140 void *tme_sun_mmu_info_proterr_private; 141 tme_bus_cycle_handler tme_sun_mmu_info_proterr; 142 143 /* the page-invalid cycle handler: */ 144 void *tme_sun_mmu_info_invalid_private; 145 tme_bus_cycle_handler tme_sun_mmu_info_invalid; 146 }; 147 148 /* prototypes: */ 149 150 /* MMU support: */ 151 void *tme_sun_mmu_new _TME_P((struct tme_sun_mmu_info *)); 152 int tme_sun_mmu_pte_set _TME_P((void *, tme_uint8_t, tme_uint32_t, struct tme_sun_mmu_pte *)); 153 int tme_sun_mmu_pte_get _TME_P((void *, tme_uint8_t, tme_uint32_t, struct tme_sun_mmu_pte *)); 154 void tme_sun_mmu_segmap_set _TME_P((void *, tme_uint8_t, tme_uint32_t, unsigned short)); 155 unsigned short tme_sun_mmu_segmap_get _TME_P((void *, tme_uint8_t, tme_uint32_t)); 156 unsigned short tme_sun_mmu_tlb_fill _TME_P((void *, struct tme_bus_tlb *, tme_uint8_t, tme_uint32_t, unsigned short)); 157 void tme_sun_mmu_tlbs_invalidate _TME_P((void *)); 158 void tme_sun_mmu_context_add _TME_P((void *, _tme_const struct tme_bus_tlb *)); 159 void tme_sun_mmu_context_switched _TME_P((void *)); 160 int tme_sun_mmu_tlb_set_add _TME_P((void *, struct tme_bus_tlb_set_info *)); 161 162 /* onboard Intel Ethernet support: */ 163 int tme_sun_obie _TME_P((struct tme_element *, _tme_const char * _tme_const *, char **)); 164 165 /* bwtwo support: */ 166 int tme_sun_bwtwo _TME_P((struct tme_element *, _tme_const char * _tme_const *, char **)); 167 168 /* si support: */ 169 int tme_sun_si _TME_P((struct tme_element *, _tme_const char * _tme_const *, char **)); 170 171 /* cgtwo support: */ 172 int tme_sun_cgtwo _TME_P((struct tme_element *, _tme_const char * _tme_const *, char **)); 173 174 /* cgthree support: */ 175 int tme_sun_cgthree _TME_P((struct tme_element *, _tme_const char * _tme_const *, char **)); 176 177 /* cgsix support: */ 178 int tme_sun_cgsix _TME_P((struct tme_element *, _tme_const char * _tme_const *, char **)); 179 180 #endif /* !_TME_MACHINE_SUN_H */ 181