Home | History | Annotate | Line # | Download | only in ibm4xx
cpu.h revision 1.22
      1 /*	$NetBSD: cpu.h,v 1.22 2018/04/19 21:50:07 christos 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 extern char bootpath[];
     48 
     49 struct exc_info {
     50 	vaddr_t exc_vector;
     51 	const uint32_t *exc_addr;
     52 	uintptr_t exc_size;
     53 };
     54 
     55 #include <sys/param.h>
     56 #include <sys/device.h>
     57 #include <prop/proplib.h>
     58 
     59 /* export from ibm4xx/autoconf.c */
     60 extern void (*md_device_register)(device_t dev, void *aux);
     61 
     62 /* export from ibm4xx/machdep.c */
     63 extern void (*md_consinit)(void);
     64 extern void (*md_cpu_startup)(void);
     65 
     66 /* export from ibm4xx/ibm40x_machdep.c */
     67 extern void ibm40x_memsize_init(u_int, u_int);
     68 
     69 /* export from ibm4xx/ibm4xx_machdep.c */
     70 extern void ibm4xx_init(vaddr_t, vaddr_t, void (*)(void));
     71 extern void ibm4xx_cpu_startup(const char *);
     72 extern void ibm4xx_dumpsys(void);
     73 extern void ibm4xx_install_extint(void (*)(void));
     74 
     75 /* export from ibm4xx/ibm4xx_autoconf.c */
     76 extern void ibm4xx_device_register(device_t dev, void *aux);
     77 
     78 /* export from ibm4xx/clock.c */
     79 extern void calc_delayconst(void);
     80 
     81 /* export from ibm4xx/4xx_locore.S */
     82 extern void ppc4xx_reset(void) __dead;
     83 
     84 extern void intr_init(void);
     85 
     86 /*
     87  * DCR (Device Control Register) access. These have to be
     88  * macros because register address is encoded as immediate
     89  * operand.
     90  */
     91 static __inline void
     92 mtdcr(int reg, uint32_t val)
     93 {
     94 	__asm volatile("mtdcr %0,%1" : : "K"(reg), "r"(val));
     95 }
     96 
     97 static __inline uint32_t
     98 mfdcr(int reg)
     99 {
    100 	uint32_t val;
    101 
    102 	__asm volatile("mfdcr %0,%1" : "=r"(val) : "K"(reg));
    103 	return val;
    104 }
    105 
    106 static __inline void
    107 mtcpr(int reg, uint32_t val)
    108 {
    109 	mtdcr(DCR_CPR0_CFGADDR, reg);
    110 	mtdcr(DCR_CPR0_CFGDATA, val);
    111 }
    112 
    113 static __inline uint32_t
    114 mfcpr(int reg)
    115 {
    116 	mtdcr(DCR_CPR0_CFGADDR, reg);
    117 	return mfdcr(DCR_CPR0_CFGDATA);
    118 }
    119 
    120 static void inline
    121 mtsdr(int reg, uint32_t val)
    122 {
    123 	mtdcr(DCR_SDR0_CFGADDR, reg);
    124 	mtdcr(DCR_SDR0_CFGDATA, val);
    125 }
    126 
    127 static __inline uint32_t
    128 mfsdr(int reg)
    129 {
    130 	mtdcr(DCR_SDR0_CFGADDR, reg);
    131 	return mfdcr(DCR_SDR0_CFGDATA);
    132 }
    133 
    134 #include <powerpc/pic/picvar.h>
    135 
    136 extern struct pic_ops pic_uic403;
    137 extern struct pic_ops pic_uic0;
    138 extern struct pic_ops pic_uic1;
    139 extern struct pic_ops pic_uic2;
    140 
    141 extern paddr_t msgbuf_paddr;
    142 extern vaddr_t msgbuf_vaddr;
    143 extern char msgbuf[MSGBUFSIZE];
    144 #endif /* _KERNEL */
    145 
    146 /* Board info dictionary */
    147 extern prop_dictionary_t board_properties;
    148 extern void board_info_init(void);
    149 
    150 /*****************************************************************************/
    151 /* THIS CODE IS OBSOLETE. WILL BE REMOVED */
    152 /*
    153  * Board configuration structure from the OpenBIOS.
    154  */
    155 struct board_cfg_data {
    156 	unsigned char	usr_config_ver[4];
    157 	unsigned char	rom_sw_ver[30];
    158 	unsigned int	mem_size;
    159 	unsigned char	mac_address_local[6];
    160 	unsigned char	mac_address_pci[6];
    161 	unsigned int	processor_speed;
    162 	unsigned int	plb_speed;
    163 	unsigned int	pci_speed;
    164 };
    165 
    166 extern struct board_cfg_data board_data;
    167 /*****************************************************************************/
    168 
    169 #endif	/* _IBM4XX_CPU_H_ */
    170