11.1Sjmcneill/* $NetBSD: gxreg.h,v 1.1 2026/01/09 22:54:30 jmcneill Exp $ */ 21.1Sjmcneill 31.1Sjmcneill/*- 41.1Sjmcneill * Copyright (c) 2025 Jared McNeill <jmcneill@invisible.ca> 51.1Sjmcneill * All rights reserved. 61.1Sjmcneill * 71.1Sjmcneill * Redistribution and use in source and binary forms, with or without 81.1Sjmcneill * modification, are permitted provided that the following conditions 91.1Sjmcneill * are met: 101.1Sjmcneill * 1. Redistributions of source code must retain the above copyright 111.1Sjmcneill * notice, this list of conditions and the following disclaimer. 121.1Sjmcneill * 2. Redistributions in binary form must reproduce the above copyright 131.1Sjmcneill * notice, this list of conditions and the following disclaimer in the 141.1Sjmcneill * documentation and/or other materials provided with the distribution. 151.1Sjmcneill * 161.1Sjmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 171.1Sjmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 181.1Sjmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 191.1Sjmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 201.1Sjmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 211.1Sjmcneill * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 221.1Sjmcneill * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 231.1Sjmcneill * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 241.1Sjmcneill * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 251.1Sjmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 261.1Sjmcneill * SUCH DAMAGE. 271.1Sjmcneill */ 281.1Sjmcneill 291.1Sjmcneill#ifndef _WII_DEV_GXREG_H 301.1Sjmcneill#define _WII_DEV_GXREG_H 311.1Sjmcneill 321.1Sjmcneill#define LOWER_16_BITS(x) ((x) & 0xffff) 331.1Sjmcneill#define UPPER_16_BITS(x) (((x) >> 16) & 0xffff) 341.1Sjmcneill 351.1Sjmcneill#define _REG16(x) ((x) / 2) 361.1Sjmcneill#define _REG32(x) ((x) / 4) 371.1Sjmcneill 381.1Sjmcneill#define CP_SR _REG16(0x00) 391.1Sjmcneill#define CP_SR_IDLE_CMDS 0x0008 401.1Sjmcneill#define CP_SR_IDLE_READ 0x0004 411.1Sjmcneill#define CP_CR _REG16(0x02) 421.1Sjmcneill#define CP_CR_READ_ENABLE 0x0001 431.1Sjmcneill#define CP_CR_GP_LINK_ENABLE 0x0010 441.1Sjmcneill#define CP_CLEAR _REG16(0x04) 451.1Sjmcneill#define CP_CLEAR_OVERFLOW 0x0001 461.1Sjmcneill#define CP_CLEAR_UNDERFLOW 0x0002 471.1Sjmcneill#define CP_FIFO_BASE_LO _REG16(0x20) 481.1Sjmcneill#define CP_FIFO_BASE_HI _REG16(0x22) 491.1Sjmcneill#define CP_FIFO_END_LO _REG16(0x24) 501.1Sjmcneill#define CP_FIFO_END_HI _REG16(0x26) 511.1Sjmcneill#define CP_FIFO_HIWAT_LO _REG16(0x28) 521.1Sjmcneill#define CP_FIFO_HIWAT_HI _REG16(0x2a) 531.1Sjmcneill#define CP_FIFO_LOWAT_LO _REG16(0x2c) 541.1Sjmcneill#define CP_FIFO_LOWAT_HI _REG16(0x2e) 551.1Sjmcneill#define CP_FIFO_RW_DIST_LO _REG16(0x30) 561.1Sjmcneill#define CP_FIFO_RW_DIST_HI _REG16(0x32) 571.1Sjmcneill#define CP_FIFO_WRITE_PTR_LO _REG16(0x34) 581.1Sjmcneill#define CP_FIFO_WRITE_PTR_HI _REG16(0x36) 591.1Sjmcneill#define CP_FIFO_READ_PTR_LO _REG16(0x38) 601.1Sjmcneill#define CP_FIFO_READ_PTR_HI _REG16(0x3a) 611.1Sjmcneill 621.1Sjmcneill#define PE_ZCONF _REG16(0x00) 631.1Sjmcneill#define PE_ZCONF_UPD_ENABLE 0x0010 641.1Sjmcneill#define PE_ZCONF_FUNC_ALWAYS 0x000e 651.1Sjmcneill#define PE_ZCONF_COMP_ENABLE 0x0001 661.1Sjmcneill#define PE_ALPHA_CONF _REG16(0x02) 671.1Sjmcneill#define PE_ALPHA_CONF_OP_SET 0xf000 681.1Sjmcneill#define PE_ALPHA_CONF_SRC_1 0x0100 691.1Sjmcneill#define PE_ALPHA_CONF_DST_0 0x0000 701.1Sjmcneill#define PE_ALPHA_CONF_UPD_A 0x0010 711.1Sjmcneill#define PE_ALPHA_CONF_UPD_C 0x0008 721.1Sjmcneill#define PE_ALPHA_DEST _REG16(0x04) 731.1Sjmcneill#define PE_ALPHA_DEST_ENABLE 0x0100 741.1Sjmcneill#define PE_ALPHA_MODE _REG16(0x06) 751.1Sjmcneill#define PE_ALPHA_MODE_ALWAYS 0x0700 761.1Sjmcneill#define PE_ALPHA_READ _REG16(0x08) 771.1Sjmcneill#define PE_ALPHA_READ_UNK 0x0004 781.1Sjmcneill#define PE_ALPHA_READ_FF 0x0001 791.1Sjmcneill#define PE_ISR _REG16(0x0a) 801.1Sjmcneill#define PE_ISR_FINISH 0x0008 811.1Sjmcneill#define PE_ISR_TOKEN 0x0004 821.1Sjmcneill#define PE_ISR_FINISH_ENABLE 0x0002 831.1Sjmcneill#define PE_IST_TOKEN_ENABLE 0x0001 841.1Sjmcneill#define PE_TOKEN _REG16(0x0e) 851.1Sjmcneill 861.1Sjmcneill#define PI_FIFO_BASE_START _REG32(0x0c) 871.1Sjmcneill#define PI_FIFO_BASE_END _REG32(0x10) 881.1Sjmcneill#define PI_FIFO_WRITE_PTR _REG32(0x14) 891.1Sjmcneill 901.1Sjmcneill#define GX_XF_VIEWPORT_X0 0x101a 911.1Sjmcneill#define GX_XF_VIEWPORT_Y0 0x101b 921.1Sjmcneill#define GX_XF_VIEWPORT_Z 0x101c 931.1Sjmcneill#define GX_XF_VIEWPORT_X1 0x101d 941.1Sjmcneill#define GX_XF_VIEWPORT_Y1 0x101e 951.1Sjmcneill#define GX_XF_VIEWPORT_FP 0x101f 961.1Sjmcneill#define GX_XF_PROJ_0 0x1020 971.1Sjmcneill#define GX_XF_PROJ_1 0x1021 981.1Sjmcneill#define GX_XF_PROJ_2 0x1022 991.1Sjmcneill#define GX_XF_PROJ_3 0x1023 1001.1Sjmcneill#define GX_XF_PROJ_4 0x1024 1011.1Sjmcneill#define GX_XF_PROJ_5 0x1025 1021.1Sjmcneill#define GX_XF_PROJ_MODE 0x1026 1031.1Sjmcneill 1041.1Sjmcneill#define GX_FIFO_ALIGN 32 1051.1Sjmcneill#define GX_FIFO_HIWAT(_size) ((_size) - (16 * 1024)) 1061.1Sjmcneill#define GX_FIFO_LOWAT(_size) (((_size) >> 1) & ~0x1f) 1071.1Sjmcneill#define GX_XY(x, y) (((uint32_t)(y) << 10) | (x)) 1081.1Sjmcneill 1091.1Sjmcneill#define GX_STRICT_ORDER(x) \ 1101.1Sjmcneill do { \ 1111.1Sjmcneill x; \ 1121.1Sjmcneill asm volatile("" ::: "memory"); \ 1131.1Sjmcneill } while (0) 1141.1Sjmcneill 1151.1Sjmcneilltypedef union gx_wgpipe { 1161.1Sjmcneill volatile int8_t s8; 1171.1Sjmcneill volatile uint8_t u8; 1181.1Sjmcneill volatile int16_t s16; 1191.1Sjmcneill volatile uint16_t u16; 1201.1Sjmcneill volatile int16_t s32; 1211.1Sjmcneill volatile uint32_t u32; 1221.1Sjmcneill} gx_wgpipe_t; 1231.1Sjmcneill 1241.1Sjmcneill#endif /* _WII_DEV_GXREG_H */ 125