Cleanups, add some Tungsten C timer stuff

This commit is contained in:
meepingsnesroms
2019-05-03 14:33:54 -07:00
parent 3c645bd0bd
commit 8482c98010
9 changed files with 30 additions and 60 deletions

View File

@@ -87,6 +87,7 @@ CONFIG(debug, debug|release){
support_palm_os5{
DEFINES += EMU_SUPPORT_PALM_OS5 # the Qt build will not be supporting anything too slow to run OS 5
DEFINES += SUPPORT_LINUX # forces the dynarec to use accurate mode and disable Nspire OS hacks
!no_dynarec{
# Windows is only supported in 32 bit mode right now(this is a limitation of the dynarec)

View File

@@ -32,7 +32,6 @@ static inline uint16_t BSWAP16(uint16_t x) { return x << 8 | x >> 8; }
#define BSWAP32(x) __builtin_bswap32(x)
extern int cycle_count_delta __asm__("cycle_count_delta");
extern int throttle_delay;
extern uint32_t cpu_events __asm__("cpu_events");
#define EVENT_IRQ 1
#define EVENT_FIQ 2
@@ -41,66 +40,25 @@ extern uint32_t cpu_events __asm__("cpu_events");
#define EVENT_WAITING 16
// Settings
extern bool exiting, debug_on_start, debug_on_warn, print_on_warn;
extern bool exiting;
extern bool do_translate;
enum { LOG_CPU, LOG_IO, LOG_FLASH, LOG_INTS, LOG_ICOUNT, LOG_USB, LOG_GDB, MAX_LOG };
#define LOG_TYPE_TBL "CIFQ#UG"
extern int log_enabled[MAX_LOG];
void logprintf(int type, const char *str, ...);
void emuprintf(const char *format, ...);
//void warn(const char *fmt, ...);
#define warn(...) debugLog(__VA_ARGS__)
//__attribute__((noreturn)) void error(const char *fmt, ...);
//static inline __attribute__((noreturn)) void error(const char *fmt, ...){while(true){};}
#define error(...) abort()
void throttle_timer_on();
void throttle_timer_off();
void throttle_timer_wait();
int exec_hack();
void add_reset_proc(void (*proc)(void));
// Is actually a jmp_buf, but __builtin_*jmp is used instead
// as the MinGW variant is buggy
extern void *restart_after_exception[32];
// GUI callbacks
/*
void gui_do_stuff(bool wait); // Called every once in a while...
int gui_getchar(); // Serial input
void gui_putchar(char c); // Serial output
*/
#define gui_debug_printf(...) debugLog(__VA_ARGS__)
/*
void gui_debug_vprintf(const char *fmt, va_list ap); // Debug output #2
void gui_perror(const char *msg); // Error output
void gui_set_busy(bool busy); // To change the cursor, for instance
void gui_status_printf(const char *fmt, ...); // Status output
void gui_show_speed(double speed); // Speed display output
void gui_usblink_changed(bool state); // Notification for usblink state changes
void gui_debugger_entered_or_left(bool entered); // Notification for debug events
*/
/* callback == 0: Stop requesting input
* callback != 0: Call callback with input, then stop requesting */
/*
typedef void (*debug_input_cb)(const char *input);
void gui_debugger_request_input(debug_input_cb callback);
#define SNAPSHOT_SIG 0xCAFEBEE0
#define SNAPSHOT_VER 1
typedef struct emu_snapshot {
uint32_t sig; // SNAPSHOT_SIG
uint32_t version; // SNAPSHOT_VER
int product, asic_user_flags;
sched_state sched;
arm_state cpu_state;
mem_snapshot mem;
flash_snapshot flash;
} emu_snapshot;
*/
#ifdef __cplusplus
}

View File

@@ -9,15 +9,11 @@
/* cycle_count_delta is a (usually negative) number telling what the time is relative
* to the next scheduled event. See sched.c */
int cycle_count_delta = 0;
int cycle_count_delta;
int throttle_delay = 10; /* in milliseconds */
bool exiting, debug_on_start, debug_on_warn, print_on_warn;
bool exiting;
bool do_translate;
int log_enabled[MAX_LOG];
void *restart_after_exception[32];
uint32_t cpu_events;

View File

@@ -60,6 +60,10 @@ static void debugLog(char* str, ...){};
//system constants
#if defined(EMU_SUPPORT_PALM_OS5)
#define TUNGSTEN_C_CPU_CRYSTAL_FREQUENCY 3686400
#define TUNGSTEN_C_RTC_CRYSTAL_FREQUENCY 32768
#endif
#define M515_CRYSTAL_FREQUENCY 32768
#define AUDIO_SAMPLES_PER_FRAME (AUDIO_SAMPLE_RATE / EMU_FPS)
#define AUDIO_END_OF_FRAME (AUDIO_CLOCK_RATE / EMU_FPS)

View File

@@ -22,6 +22,7 @@ EMU_SOURCES_ASM :=
ifeq ($(EMU_SUPPORT_PALM_OS5), 1)
EMU_DEFINES += -DEMU_SUPPORT_PALM_OS5
EMU_DEFINES += -DSUPPORT_LINUX # forces the dynarec to use accurate mode and disable Nspire OS hacks
EMU_SOURCES_C += $(EMU_PATH)/src/pxa255/pxa255_mem.c \
$(EMU_PATH)/src/pxa255/pxa255_DMA.c \
$(EMU_PATH)/src/pxa255/pxa255_DSP.c \

View File

@@ -22,10 +22,13 @@
#define PXA255_IO_BASE 0x40000000
#define PXA255_MEMCTRL_BASE 0x48000000
#define PXA255_TIMER_TICKS_PER_FRAME (TUNGSTEN_C_CPU_CRYSTAL_FREQUENCY / EMU_FPS)
uint16_t* pxa255Framebuffer;
static Pxa255ic tungstenCIc;
static Pxa255lcd tungstenCLcd;
uint16_t* pxa255Framebuffer;
static Pxa255ic pxa255Ic;
static Pxa255lcd pxa255Lcd;
static Pxa255timr pxa255Timer;
#include "pxa255Accessors.c.h"
@@ -34,6 +37,9 @@ bool pxa255Init(uint8_t** returnRom, uint8_t** returnRam){
uint32_t mem_offset = 0;
uint8_t i;
//enable dynarec if available
do_translate = true;
mem_and_flags = os_reserve(MEM_MAXSIZE * 2);
if(!mem_and_flags)
return false;
@@ -121,8 +127,9 @@ bool pxa255Init(uint8_t** returnRom, uint8_t** returnRam){
write_word_map[PXA255_START_BANK(PXA255_MEMCTRL_BASE)] = pxa255_memctrl_write_word;
//set up CPU hardware
pxa255icInit(&tungstenCIc);
pxa255lcdInit(&tungstenCLcd, &tungstenCIc);
pxa255icInit(&pxa255Ic);
pxa255lcdInit(&pxa255Lcd, &pxa255Ic);
pxa255timrInit(&pxa255Timer, &pxa255Ic);
*returnRom = mem_areas[0].ptr;
*returnRam = mem_areas[1].ptr;
@@ -164,6 +171,7 @@ void pxa255Reset(void){
memset(&arm, 0, sizeof arm);
arm.control = 0x00050078;
arm.cpsr_low28 = MODE_SVC | 0xC0;
cycle_count_delta = 0;
cpu_events = 0;
//cpu_events &= EVENT_DEBUG_STEP;
@@ -234,7 +242,10 @@ void pxa255Execute(void){
#endif
//render
pxa255lcdFrame(&tungstenCLcd);
pxa255lcdFrame(&pxa255Lcd);
//TODO: this needs to run at 3.6864 MHz
//pxa255timrTick(&pxa255Timer);
}
uint32_t pxa255GetRegister(uint8_t reg){

View File

@@ -54,13 +54,13 @@ static void pxa255_io_write_word(uint32_t addr, uint32_t value){
static uint32_t pxa255_lcd_read_word(uint32_t addr){
uint32_t out;
pxa255lcdPrvMemAccessF(&tungstenCLcd, addr, 4, false, &out);
pxa255lcdPrvMemAccessF(&pxa255Lcd, addr, 4, false, &out);
debugLog("32 bit PXA255 LCD register read:0x%08X\n", addr);
return out;
}
static void pxa255_lcd_write_word(uint32_t addr, uint32_t value){
pxa255lcdPrvMemAccessF(&tungstenCLcd, addr, 4, true, &value);
pxa255lcdPrvMemAccessF(&pxa255Lcd, addr, 4, true, &value);
debugLog("32 bit PXA255 LCD register write:0x%08X, value:0x%08X\n", addr, value);
}

View File

@@ -108,11 +108,10 @@ static Boolean pxa255timrPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Bo
}
Boolean pxa255timrInit(Pxa255timr* timr, ArmMem* physMem, Pxa255ic* ic){
void pxa255timrInit(Pxa255timr* timr, Pxa255ic* ic){
__mem_zero(timr, sizeof(Pxa255timr));
timr->ic = ic;
return memRegionAdd(physMem, PXA255_TIMR_BASE, PXA255_TIMR_SIZE, pxa255timrPrvMemAccessF, timr);
}
void pxa255timrTick(Pxa255timr* timr){

View File

@@ -29,7 +29,7 @@ typedef struct{
}Pxa255timr;
Boolean pxa255timrInit(Pxa255timr* timr, ArmMem* physMem, Pxa255ic* ic);
void pxa255timrInit(Pxa255timr* timr, Pxa255ic* ic);
void pxa255timrTick(Pxa255timr* timr);