1 /* $NetBSD: cpu.h,v 1.25 2021/03/30 02:04:44 rin Exp $ */ 2 3 /* 4 * Copyright 2002 Wasabi Systems, Inc. 5 * All rights reserved. 6 * 7 * Written by Eduardo Horvath for Wasabi Systems, Inc. 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 for the NetBSD Project by 20 * Wasabi Systems, Inc. 21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22 * or promote products derived from this software without specific prior 23 * written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38 #ifndef _IBM4XX_CPU_H_ 39 #define _IBM4XX_CPU_H_ 40 41 #include <powerpc/psl.h> 42 #include <powerpc/spr.h> 43 #include <powerpc/ibm4xx/spr.h> 44 #include <powerpc/ibm4xx/dcr4xx.h> 45 46 #if defined(_KERNEL) 47 struct exc_info { 48 vaddr_t exc_vector; 49 const uint32_t *exc_addr; 50 uintptr_t exc_size; 51 }; 52 53 #include <sys/param.h> 54 #include <sys/device.h> 55 #include <prop/proplib.h> 56 57 /* export from ibm4xx/autoconf.c */ 58 extern void (*md_device_register)(device_t dev, void *aux); 59 60 /* export from ibm4xx/machdep.c */ 61 extern void (*md_consinit)(void); 62 extern void (*md_cpu_startup)(void); 63 64 /* export from ibm4xx/ibm40x_machdep.c */ 65 extern void ibm40x_memsize_init(u_int, u_int); 66 67 /* export from ibm4xx/ibm4xx_machdep.c */ 68 extern void ibm4xx_init(vaddr_t, vaddr_t, void (*)(void)); 69 extern void ibm4xx_cpu_startup(const char *); 70 extern void ibm4xx_dumpsys(void); 71 extern void ibm4xx_install_extint(void (*)(void)); 72 73 /* export from ibm4xx/ibm4xx_autoconf.c */ 74 extern void ibm4xx_device_register(device_t, void *, int); 75 76 /* export from ibm4xx/clock.c */ 77 extern void calc_delayconst(void); 78 79 /* export from ibm4xx/4xx_locore.S */ 80 extern void ppc4xx_reset(void) __dead; 81 82 extern void intr_init(void); 83 84 /* 85 * DCR (Device Control Register) access. These have to be 86 * macros because register address is encoded as immediate 87 * operand. 88 */ 89 static __inline void 90 mtdcr(int reg, uint32_t val) 91 { 92 __asm volatile("mtdcr %0,%1" : : "K"(reg), "r"(val)); 93 } 94 95 static __inline uint32_t 96 mfdcr(int reg) 97 { 98 uint32_t val; 99 100 __asm volatile("mfdcr %0,%1" : "=r"(val) : "K"(reg)); 101 return val; 102 } 103 104 static __inline void 105 mtcpr(int reg, uint32_t val) 106 { 107 mtdcr(DCR_CPR0_CFGADDR, reg); 108 mtdcr(DCR_CPR0_CFGDATA, val); 109 } 110 111 static __inline uint32_t 112 mfcpr(int reg) 113 { 114 mtdcr(DCR_CPR0_CFGADDR, reg); 115 return mfdcr(DCR_CPR0_CFGDATA); 116 } 117 118 static void inline 119 mtsdr(int reg, uint32_t val) 120 { 121 mtdcr(DCR_SDR0_CFGADDR, reg); 122 mtdcr(DCR_SDR0_CFGDATA, val); 123 } 124 125 static __inline uint32_t 126 mfsdr(int reg) 127 { 128 mtdcr(DCR_SDR0_CFGADDR, reg); 129 return mfdcr(DCR_SDR0_CFGDATA); 130 } 131 132 #include <powerpc/pic/picvar.h> 133 134 extern struct pic_ops pic_uic403; 135 extern struct pic_ops pic_uic0; 136 extern struct pic_ops pic_uic1; 137 extern struct pic_ops pic_uic2; 138 139 extern paddr_t msgbuf_paddr; 140 extern vaddr_t msgbuf_vaddr; 141 extern char msgbuf[MSGBUFSIZE]; 142 #endif /* _KERNEL */ 143 144 /* Board info dictionary */ 145 extern prop_dictionary_t board_properties; 146 extern void board_info_init(void); 147 148 #endif /* _IBM4XX_CPU_H_ */ 149