1 #ifndef DBVZ_H 2 #define DBVZ_H 3 4 #include <stdint.h> 5 #include <stdbool.h> 6 7 //interrupt names 8 #define DBVZ_INT_EMIQ 0x00800000//level 7 9 #define DBVZ_INT_RTI 0x00400000//level 4 10 #define DBVZ_INT_SPI1 0x00200000//level 1<->6, configurable, datasheet is contraditory on this one 11 #define DBVZ_INT_IRQ5 0x00100000//level 5 12 #define DBVZ_INT_IRQ6 0x00080000//level 6 13 #define DBVZ_INT_IRQ3 0x00040000//level 3 14 #define DBVZ_INT_IRQ2 0x00020000//level 2 15 #define DBVZ_INT_IRQ1 0x00010000//level 1 16 #define DBVZ_INT_PWM2 0x00002000//level 1<->6, configurable 17 #define DBVZ_INT_UART2 0x00001000//level 1<->6, configurable 18 #define DBVZ_INT_INT3 0x00000800//level 4 19 #define DBVZ_INT_INT2 0x00000400//level 4 20 #define DBVZ_INT_INT1 0x00000200//level 4 21 #define DBVZ_INT_INT0 0x00000100//level 4 22 #define DBVZ_INT_PWM1 0x00000080//level 6 23 #define DBVZ_INT_KB 0x00000040//level 4 24 #define DBVZ_INT_TMR2 0x00000020//level 1<->6, configurable 25 #define DBVZ_INT_RTC 0x00000010//level 4 26 #define DBVZ_INT_WDT 0x00000008//level 4 27 #define DBVZ_INT_UART1 0x00000004//level 4 28 #define DBVZ_INT_TMR1 0x00000002//level 6 29 #define DBVZ_INT_SPI2 0x00000001//level 4 30 31 //reasons a timer is triggered 32 #define DBVZ_TIMER_REASON_SYSCLK 0x00 33 #define DBVZ_TIMER_REASON_TIN 0x01 34 #define DBVZ_TIMER_REASON_CLK32 0x02 35 36 //chip names 37 enum{ 38 DBVZ_CHIP_BEGIN = 0, 39 DBVZ_CHIP_A0_ROM = 0, 40 DBVZ_CHIP_A1_USB, 41 DBVZ_CHIP_B0_SED, 42 DBVZ_CHIP_B1_NIL, 43 //DBVZ_CHIP_CX_RAM, //CSC* is owned by CSD during normal operation 44 DBVZ_CHIP_DX_RAM, 45 DBVZ_CHIP_00_EMU, 46 DBVZ_CHIP_REGISTERS, 47 DBVZ_CHIP_NONE, 48 DBVZ_CHIP_END 49 }; 50 51 //types 52 typedef struct{ 53 bool enable; 54 uint32_t start; 55 uint32_t lineSize;//the size of a single chip select line, multiply by 2 to get the range size for RAM 56 uint32_t mask;//the address lines the chip responds to, so 0x10000 on an chip with 16 address lines will return the value at 0x0000 57 58 //attributes 59 bool inBootMode; 60 bool readOnly; 61 bool readOnlyForProtectedMemory; 62 bool supervisorOnlyProtectedMemory; 63 uint32_t unprotectedSize; 64 }dbvz_chip_t; 65 66 //variables 67 extern dbvz_chip_t dbvzChipSelects[]; 68 extern uint8_t dbvzReg[];//needed for direct execution of the DBVZ regs without a RAM access function 69 extern uint16_t* dbvzFramebuffer; 70 extern uint16_t dbvzFramebufferWidth; 71 extern uint16_t dbvzFramebufferHeight; 72 73 //CPU 74 void dbvzLcdRender(void); 75 bool dbvzIsPllOn(void); 76 bool m515BacklightAmplifierState(void); 77 bool dbvzAreRegistersXXFFMapped(void); 78 bool sed1376ClockConnected(void); 79 void ads7846OverridePenState(bool value); 80 void m5XXRefreshTouchState(void);//just refreshes the touchscreen 81 void m5XXRefreshInputState(void);//refreshes touchscreen, buttons and docked status 82 //int32_t interruptAcknowledge(int32_t intLevel);//this is in m68kexternal.h 83 84 //memory errors 85 void dbvzSetBusErrorTimeOut(uint32_t address, bool isWrite); 86 void dbvzSetPrivilegeViolation(uint32_t address, bool isWrite); 87 void dbvzSetWriteProtectViolation(uint32_t address); 88 89 //memory accessors 90 uint8_t dbvzGetRegister8(uint32_t address); 91 uint16_t dbvzGetRegister16(uint32_t address); 92 uint32_t dbvzGetRegister32(uint32_t address); 93 void dbvzSetRegister8(uint32_t address, uint8_t value); 94 void dbvzSetRegister16(uint32_t address, uint16_t value); 95 void dbvzSetRegister32(uint32_t address, uint32_t value); 96 97 //config 98 void dbvzReset(void); 99 void dbvzLoadBootloader(uint8_t* data, uint32_t size); 100 void dbvzSetRtc(uint16_t days, uint8_t hours, uint8_t minutes, uint8_t seconds); 101 uint32_t dbvzStateSize(void); 102 void dbvzSaveState(uint8_t* data); 103 void dbvzLoadState(uint8_t* data); 104 void dbvzLoadStateFinished(void); 105 106 void dbvzExecute(void); 107 108 #endif 109