KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
elan.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/elan.h
4 Copyright (C) 2026 Ruslan Rostovtsev
5
6*/
7
8/** \file dc/elan.h
9 \brief VideoLogic Elan T&L coprocessor (NAOMI 2).
10 \ingroup elan
11
12 Elan is the geometry processor on NAOMI 2 and has 32 MB of local RAM.
13 IFCTL bit 2 enables CLXB's register and VRAM windows; they are left
14 disabled at boot.
15
16 Call \ref pvr2_init() when CPU access to CLXB VRAM is required. Do not
17 set \ref ELAN_IFCTL_CS1_BCAST unless you intend to broadcast CS1 writes
18 to both GPUs.
19
20 \author Ruslan Rostovtsev
21*/
22
23#ifndef __DC_ELAN_H
24#define __DC_ELAN_H
25
26#include <kos/cdefs.h>
27__BEGIN_DECLS
28
29#include <stdbool.h>
30#include <stdint.h>
31#include <kos/regfield.h>
32#include <dc/memory.h>
33
34/** \defgroup elan Elan
35 \brief VideoLogic Elan T&L coprocessor (NAOMI 2)
36 \ingroup video
37
38 @{
39*/
40
41/** \brief Elan register block, P2. */
42#define ELAN_BASE 0xa8800000
43
44/** \brief Value of \ref ELAN_REG_ID on a present Elan. */
45#define ELAN_MAGIC 0xe1ad0000
46
47/** \brief Elan local RAM, P0. */
48#define ELAN_RAM_BASE_P0 0x0a000000
49/** \brief Elan local RAM, P2. */
50#define ELAN_RAM_BASE (MEM_AREA_P2_BASE | ELAN_RAM_BASE_P0)
51/** \brief Elan local RAM size in bytes. */
52#define ELAN_RAM_SIZE (32 * 1024 * 1024)
53
54/** \defgroup elan_regs Register offsets
55 \brief Offsets from \ref ELAN_BASE
56 \ingroup elan
57
58 @{
59*/
60#define ELAN_REG_ID 0x00 /**< \brief Magic (\ref ELAN_MAGIC) */
61#define ELAN_REG_REVISION 0x04 /**< \brief Chip revision */
62#define ELAN_REG_CMDQ 0x0c /**< \brief Command queue occupancy */
63#define ELAN_REG_IFCTL 0x10 /**< \brief SH-4 / PVR interface */
64#define ELAN_REG_REFRESH 0x14 /**< \brief SDRAM refresh */
65#define ELAN_REG_SDRAMCFG 0x1c /**< \brief SDRAM config */
66#define ELAN_REG_TILER 0x30 /**< \brief Macro tiler */
67#define ELAN_REG_IRQSTAT 0x74 /**< \brief IRQ status */
68#define ELAN_REG_IRQMASK 0x78 /**< \brief IRQ mask */
69/** @} */
70
71/** \defgroup elan_ifctl IFCTL bits
72 \brief Fields of \ref ELAN_REG_IFCTL
73 \ingroup elan
74
75 @{
76*/
77#define ELAN_IFCTL_CS1_BCAST BIT(0) /**< \brief Broadcast writes on CS1 (both PVRs) */
78#define ELAN_IFCTL_CH2 BIT(1) /**< \brief Elan channel 2 */
79#define ELAN_IFCTL_PVR2 BIT(2) /**< \brief Enable CLXB address windows */
80/** @} */
81
82/** \brief Read an Elan register. */
83#define ELAN_GET(reg) (*(volatile uint32_t *)(ELAN_BASE + (reg)))
84/** \brief Write an Elan register. */
85#define ELAN_SET(reg, value) (ELAN_GET(reg) = (value))
86
87/** \brief True when Elan is present (NAOMI 2). */
88bool elan_present(void);
89
90/** \brief Elan revision register, or 0 if absent. */
91uint32_t elan_revision(void);
92
93/** \brief Current IFCTL value, or 0 if Elan is absent. */
94uint32_t elan_ifctl_get(void);
95
96/** \brief Write IFCTL.
97
98 \warning
99 Bit 0 (\ref ELAN_IFCTL_CS1_BCAST) broadcasts CS1 to both GPUs. Leave it
100 clear unless you are duplicating textures on purpose.
101*/
102void elan_ifctl_set(uint32_t value);
103
104/** \brief Enable CLXB address windows (IFCTL bit 2, never bit 0). */
106
107/** \brief Disable CLXB address windows (IFCTL = 0). */
109
110/** \brief True if IFCTL bit 2 is set. */
112
113/** @} */
114
115__END_DECLS
116
117#endif /* __DC_ELAN_H */
Various common macros used throughout the codebase.
Constants for areas of the system memory map.
uint32_t elan_ifctl_get(void)
Current IFCTL value, or 0 if Elan is absent.
void elan_pvr2_enable(void)
Enable CLXB address windows (IFCTL bit 2, never bit 0).
bool elan_present(void)
True when Elan is present (NAOMI 2).
void elan_pvr2_disable(void)
Disable CLXB address windows (IFCTL = 0).
bool elan_pvr2_enabled(void)
True if IFCTL bit 2 is set.
uint32_t elan_revision(void)
Elan revision register, or 0 if absent.
void elan_ifctl_set(uint32_t value)
Write IFCTL.
Macros to help dealing with register fields.