2020-04-14 01:04:37 +02:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2021-10-23 21:00:31 +02:00
|
|
|
Copyright (C) 2018-21 divingkatae and maximum
|
2020-04-14 01:04:37 +02:00
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-03-31 18:25:58 +02:00
|
|
|
#ifndef ATI_RAGE_H
|
|
|
|
#define ATI_RAGE_H
|
|
|
|
|
2021-10-23 20:17:47 +02:00
|
|
|
#include <devices/common/pci/pcidevice.h>
|
2022-04-13 23:06:42 +02:00
|
|
|
#include <devices/video/atimach64defs.h>
|
2021-10-23 20:17:47 +02:00
|
|
|
#include <devices/video/displayid.h>
|
2021-11-09 13:40:13 +01:00
|
|
|
#include <devices/video/videoctrl.h>
|
2021-10-23 20:17:47 +02:00
|
|
|
|
2020-05-12 23:55:45 +05:00
|
|
|
#include <cinttypes>
|
2021-11-17 23:30:43 +01:00
|
|
|
#include <memory>
|
2020-03-27 10:54:25 -07:00
|
|
|
|
2021-02-08 02:20:32 +01:00
|
|
|
/* Mach64 PLL register indices. */
|
|
|
|
enum {
|
|
|
|
PLL_REF_DIV = 2, // reference divider, same for all Mach64 clocks
|
|
|
|
PLL_VCLK_CNTL = 5,
|
|
|
|
VCLK_POST_DIV = 6,
|
|
|
|
VCLK0_FB_DIV = 7, // feedback divider for VCLK0
|
|
|
|
VCLK1_FB_DIV = 8, // feedback divider for VCLK1
|
|
|
|
VCLK2_FB_DIV = 9, // feedback divider for VCLK2
|
|
|
|
VCLK3_FB_DIV = 10, // feedback divider for VCLK3
|
|
|
|
PLL_EXT_CNTL = 11,
|
|
|
|
};
|
|
|
|
|
2021-11-09 13:40:13 +01:00
|
|
|
class ATIRage : public PCIDevice, public VideoCtrlBase {
|
2020-03-27 10:54:25 -07:00
|
|
|
public:
|
2021-11-09 13:40:13 +01:00
|
|
|
ATIRage(uint16_t dev_id, uint32_t vmem_size_mb);
|
2021-11-17 23:30:43 +01:00
|
|
|
~ATIRage() = default;
|
2020-03-27 10:54:25 -07:00
|
|
|
|
2020-03-31 21:19:10 +02:00
|
|
|
/* MMIODevice methods */
|
2020-03-31 18:25:58 +02:00
|
|
|
uint32_t read(uint32_t reg_start, uint32_t offset, int size);
|
|
|
|
void write(uint32_t reg_start, uint32_t offset, uint32_t value, int size);
|
|
|
|
|
|
|
|
/* PCI device methods */
|
2020-05-12 23:55:45 +05:00
|
|
|
bool supports_io_space(void) {
|
|
|
|
return true;
|
|
|
|
};
|
2020-03-31 21:19:10 +02:00
|
|
|
|
2020-03-31 18:25:58 +02:00
|
|
|
uint32_t pci_cfg_read(uint32_t reg_offs, uint32_t size);
|
2020-05-12 23:55:45 +05:00
|
|
|
void pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size);
|
2020-03-27 10:54:25 -07:00
|
|
|
|
2020-03-31 21:19:10 +02:00
|
|
|
/* I/O space access methods */
|
2020-05-12 23:55:45 +05:00
|
|
|
bool pci_io_read(uint32_t offset, uint32_t size, uint32_t* res);
|
|
|
|
bool pci_io_write(uint32_t offset, uint32_t value, uint32_t size);
|
2020-03-31 21:19:10 +02:00
|
|
|
|
|
|
|
protected:
|
2022-03-13 20:58:31 +01:00
|
|
|
void notify_bar_change(int bar_num);
|
2020-04-14 01:04:37 +02:00
|
|
|
const char* get_reg_name(uint32_t reg_offset);
|
2022-03-13 20:58:31 +01:00
|
|
|
bool io_access_allowed(uint32_t offset);
|
2020-04-14 01:04:37 +02:00
|
|
|
uint32_t read_reg(uint32_t offset, uint32_t size);
|
2020-03-31 21:19:10 +02:00
|
|
|
void write_reg(uint32_t offset, uint32_t value, uint32_t size);
|
2021-02-08 02:20:32 +01:00
|
|
|
float calc_pll_freq(int scale, int fb_div);
|
|
|
|
void verbose_pixel_format(int crtc_index);
|
|
|
|
void crtc_enable();
|
2021-09-11 21:02:46 +02:00
|
|
|
void draw_hw_cursor(uint8_t *dst_buf, int dst_pitch);
|
2020-03-31 21:19:10 +02:00
|
|
|
|
2020-03-27 10:54:25 -07:00
|
|
|
private:
|
2021-11-17 23:30:43 +01:00
|
|
|
uint8_t mm_regs[2048] = {0}; // internal registers
|
2020-03-27 10:54:25 -07:00
|
|
|
|
2021-02-05 02:01:31 +01:00
|
|
|
uint8_t plls[64] = {0}; // internal PLL registers
|
2021-02-05 01:10:56 +01:00
|
|
|
|
2020-05-28 23:47:20 +02:00
|
|
|
/* Video RAM variables */
|
2021-11-17 23:30:43 +01:00
|
|
|
std::unique_ptr<uint8_t[]> vram_ptr;
|
2020-05-28 23:47:20 +02:00
|
|
|
uint32_t vram_size;
|
2020-05-28 22:36:55 +02:00
|
|
|
|
2022-03-13 20:58:31 +01:00
|
|
|
uint32_t aperture_base = 0;
|
|
|
|
uint32_t io_base = 0;
|
|
|
|
uint8_t user_cfg = 8;
|
2020-05-28 23:47:20 +02:00
|
|
|
|
2021-11-17 23:30:43 +01:00
|
|
|
std::unique_ptr<DisplayID> disp_id;
|
2020-06-11 01:30:10 +02:00
|
|
|
|
|
|
|
int comp_index; /* color component index for DAC palette access */
|
2020-03-27 10:54:25 -07:00
|
|
|
};
|
2020-03-31 18:25:58 +02:00
|
|
|
#endif /* ATI_RAGE_H */
|