Home | History | Annotate | Line # | Download | only in dev
      1  1.1  jmcneill /* $NetBSD: gxreg.h,v 1.1 2025/10/25 15:02:56 jmcneill Exp $ */
      2  1.1  jmcneill 
      3  1.1  jmcneill /*-
      4  1.1  jmcneill  * Copyright (c) 2025 Jared McNeill <jmcneill (at) invisible.ca>
      5  1.1  jmcneill  * All rights reserved.
      6  1.1  jmcneill  *
      7  1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8  1.1  jmcneill  * modification, are permitted provided that the following conditions
      9  1.1  jmcneill  * are met:
     10  1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12  1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15  1.1  jmcneill  *
     16  1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1  jmcneill  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1  jmcneill  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1  jmcneill  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1  jmcneill  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  1.1  jmcneill  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  1.1  jmcneill  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  1.1  jmcneill  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  1.1  jmcneill  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1  jmcneill  * SUCH DAMAGE.
     27  1.1  jmcneill  */
     28  1.1  jmcneill 
     29  1.1  jmcneill #ifndef _WII_DEV_GXREG_H
     30  1.1  jmcneill #define _WII_DEV_GXREG_H
     31  1.1  jmcneill 
     32  1.1  jmcneill #define LOWER_16_BITS(x)	((x) & 0xffff)
     33  1.1  jmcneill #define UPPER_16_BITS(x)	(((x) >> 16) & 0xffff)
     34  1.1  jmcneill 
     35  1.1  jmcneill #define _REG16(x)	((x) / 2)
     36  1.1  jmcneill #define _REG32(x)	((x) / 4)
     37  1.1  jmcneill 
     38  1.1  jmcneill #define CP_SR			_REG16(0x00)
     39  1.1  jmcneill #define  CP_SR_IDLE_CMDS	0x0008
     40  1.1  jmcneill #define  CP_SR_IDLE_READ	0x0004
     41  1.1  jmcneill #define CP_CR			_REG16(0x02)
     42  1.1  jmcneill #define  CP_CR_READ_ENABLE	0x0001
     43  1.1  jmcneill #define  CP_CR_GP_LINK_ENABLE	0x0010
     44  1.1  jmcneill #define CP_CLEAR		_REG16(0x04)
     45  1.1  jmcneill #define  CP_CLEAR_OVERFLOW	0x0001
     46  1.1  jmcneill #define  CP_CLEAR_UNDERFLOW	0x0002
     47  1.1  jmcneill #define CP_FIFO_BASE_LO		_REG16(0x20)
     48  1.1  jmcneill #define CP_FIFO_BASE_HI		_REG16(0x22)
     49  1.1  jmcneill #define CP_FIFO_END_LO		_REG16(0x24)
     50  1.1  jmcneill #define CP_FIFO_END_HI		_REG16(0x26)
     51  1.1  jmcneill #define CP_FIFO_HIWAT_LO	_REG16(0x28)
     52  1.1  jmcneill #define CP_FIFO_HIWAT_HI	_REG16(0x2a)
     53  1.1  jmcneill #define CP_FIFO_LOWAT_LO	_REG16(0x2c)
     54  1.1  jmcneill #define CP_FIFO_LOWAT_HI	_REG16(0x2e)
     55  1.1  jmcneill #define CP_FIFO_RW_DIST_LO	_REG16(0x30)
     56  1.1  jmcneill #define CP_FIFO_RW_DIST_HI	_REG16(0x32)
     57  1.1  jmcneill #define CP_FIFO_WRITE_PTR_LO	_REG16(0x34)
     58  1.1  jmcneill #define CP_FIFO_WRITE_PTR_HI	_REG16(0x36)
     59  1.1  jmcneill #define CP_FIFO_READ_PTR_LO	_REG16(0x38)
     60  1.1  jmcneill #define CP_FIFO_READ_PTR_HI	_REG16(0x3a)
     61  1.1  jmcneill 
     62  1.1  jmcneill #define PE_ZCONF		_REG16(0x00)
     63  1.1  jmcneill #define  PE_ZCONF_UPD_ENABLE	0x0010
     64  1.1  jmcneill #define  PE_ZCONF_FUNC_ALWAYS	0x000e
     65  1.1  jmcneill #define  PE_ZCONF_COMP_ENABLE	0x0001
     66  1.1  jmcneill #define PE_ALPHA_CONF		_REG16(0x02)
     67  1.1  jmcneill #define  PE_ALPHA_CONF_OP_SET	0xf000
     68  1.1  jmcneill #define  PE_ALPHA_CONF_SRC_1	0x0100
     69  1.1  jmcneill #define  PE_ALPHA_CONF_DST_0	0x0000
     70  1.1  jmcneill #define  PE_ALPHA_CONF_UPD_A	0x0010
     71  1.1  jmcneill #define  PE_ALPHA_CONF_UPD_C	0x0008
     72  1.1  jmcneill #define PE_ALPHA_DEST		_REG16(0x04)
     73  1.1  jmcneill #define  PE_ALPHA_DEST_ENABLE	0x0100
     74  1.1  jmcneill #define PE_ALPHA_MODE		_REG16(0x06)
     75  1.1  jmcneill #define  PE_ALPHA_MODE_ALWAYS	0x0700
     76  1.1  jmcneill #define PE_ALPHA_READ		_REG16(0x08)
     77  1.1  jmcneill #define  PE_ALPHA_READ_UNK	0x0004
     78  1.1  jmcneill #define  PE_ALPHA_READ_FF	0x0001
     79  1.1  jmcneill #define PE_ISR			_REG16(0x0a)
     80  1.1  jmcneill #define  PE_ISR_FINISH		0x0008
     81  1.1  jmcneill #define  PE_ISR_TOKEN		0x0004
     82  1.1  jmcneill #define  PE_ISR_FINISH_ENABLE	0x0002
     83  1.1  jmcneill #define  PE_IST_TOKEN_ENABLE	0x0001
     84  1.1  jmcneill #define PE_TOKEN		_REG16(0x0e)
     85  1.1  jmcneill 
     86  1.1  jmcneill #define PI_FIFO_BASE_START	_REG32(0x0c)
     87  1.1  jmcneill #define PI_FIFO_BASE_END	_REG32(0x10)
     88  1.1  jmcneill #define PI_FIFO_WRITE_PTR	_REG32(0x14)
     89  1.1  jmcneill 
     90  1.1  jmcneill #define GX_XF_VIEWPORT_X0	0x101a
     91  1.1  jmcneill #define GX_XF_VIEWPORT_Y0	0x101b
     92  1.1  jmcneill #define GX_XF_VIEWPORT_Z	0x101c
     93  1.1  jmcneill #define GX_XF_VIEWPORT_X1	0x101d
     94  1.1  jmcneill #define GX_XF_VIEWPORT_Y1	0x101e
     95  1.1  jmcneill #define GX_XF_VIEWPORT_FP	0x101f
     96  1.1  jmcneill #define GX_XF_PROJ_0		0x1020
     97  1.1  jmcneill #define GX_XF_PROJ_1		0x1021
     98  1.1  jmcneill #define GX_XF_PROJ_2		0x1022
     99  1.1  jmcneill #define GX_XF_PROJ_3		0x1023
    100  1.1  jmcneill #define GX_XF_PROJ_4		0x1024
    101  1.1  jmcneill #define GX_XF_PROJ_5		0x1025
    102  1.1  jmcneill #define GX_XF_PROJ_MODE		0x1026
    103  1.1  jmcneill 
    104  1.1  jmcneill #define GX_FIFO_ALIGN		32
    105  1.1  jmcneill #define GX_FIFO_HIWAT(_size)	((_size) - (16 * 1024))
    106  1.1  jmcneill #define GX_FIFO_LOWAT(_size)	(((_size) >> 1) & ~0x1f)
    107  1.1  jmcneill #define GX_XY(x, y)		(((uint32_t)(y) << 10) | (x))
    108  1.1  jmcneill 
    109  1.1  jmcneill #define GX_STRICT_ORDER(x)			\
    110  1.1  jmcneill 	do {					\
    111  1.1  jmcneill 		x;				\
    112  1.1  jmcneill 		asm volatile("" ::: "memory");	\
    113  1.1  jmcneill 	} while (0)
    114  1.1  jmcneill 
    115  1.1  jmcneill typedef union gx_wgpipe {
    116  1.1  jmcneill 	volatile int8_t		s8;
    117  1.1  jmcneill 	volatile uint8_t	u8;
    118  1.1  jmcneill 	volatile int16_t	s16;
    119  1.1  jmcneill 	volatile uint16_t	u16;
    120  1.1  jmcneill 	volatile int16_t	s32;
    121  1.1  jmcneill 	volatile uint32_t	u32;
    122  1.1  jmcneill } gx_wgpipe_t;
    123  1.1  jmcneill 
    124  1.1  jmcneill #endif /* _WII_DEV_GXREG_H */
    125