1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * Mupen64plus - pi_controller.h * 3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * 4 * Copyright (C) 2014 Bobby Smiles * 5 * * 6 * This program is free software; you can redistribute it and/or modify * 7 * it under the terms of the GNU General Public License as published by * 8 * the Free Software Foundation; either version 2 of the License, or * 9 * (at your option) any later version. * 10 * * 11 * This program is distributed in the hope that it will be useful, * 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 * GNU General Public License for more details. * 15 * * 16 * You should have received a copy of the GNU General Public License * 17 * along with this program; if not, write to the * 18 * Free Software Foundation, Inc., * 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 20 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 21 22 #ifndef M64P_PI_PI_CONTROLLER_H 23 #define M64P_PI_PI_CONTROLLER_H 24 25 #include <stddef.h> 26 #include <stdint.h> 27 28 #include "cart_rom.h" 29 #include "flashram.h" 30 #include "sram.h" 31 #include "../dd/dd_rom.h" 32 33 #ifndef PI_REG 34 #define PI_REG(a) ((a & 0xffff) >> 2) 35 #endif 36 37 struct r4300_core; 38 struct ri_controller; 39 40 enum pi_registers 41 { 42 PI_DRAM_ADDR_REG, 43 PI_CART_ADDR_REG, 44 PI_RD_LEN_REG, 45 PI_WR_LEN_REG, 46 PI_STATUS_REG, 47 PI_BSD_DOM1_LAT_REG, 48 PI_BSD_DOM1_PWD_REG, 49 PI_BSD_DOM1_PGS_REG, 50 PI_BSD_DOM1_RLS_REG, 51 PI_BSD_DOM2_LAT_REG, 52 PI_BSD_DOM2_PWD_REG, 53 PI_BSD_DOM2_PGS_REG, 54 PI_BSD_DOM2_RLS_REG, 55 PI_REGS_COUNT 56 }; 57 58 struct pi_controller 59 { 60 uint32_t regs[PI_REGS_COUNT]; 61 62 struct cart_rom cart_rom; 63 struct flashram flashram; 64 struct sram sram; 65 struct dd_rom dd_rom; 66 67 int use_flashram; 68 69 struct r4300_core* r4300; 70 struct ri_controller *ri; 71 }; 72 73 void init_pi(struct pi_controller* pi, 74 uint8_t* rom, size_t rom_size, 75 uint8_t* ddrom, size_t ddrom_size, 76 void* flashram_user_data, void (*flashram_save)(void*), uint8_t* flashram_data, 77 void* sram_user_data, void (*sram_save)(void*), uint8_t* sram_data, 78 struct r4300_core* r4300, 79 struct ri_controller *ri); 80 81 void poweron_pi(struct pi_controller* pi); 82 83 int read_pi_regs(void* opaque, uint32_t address, uint32_t* value); 84 int write_pi_regs(void* opaque, uint32_t address, uint32_t value, uint32_t mask); 85 86 void pi_end_of_dma_event(struct pi_controller* pi); 87 88 #endif 89