diff --git a/charrom.cpp b/charrom.cpp index e25c38f..b045d7d 100644 --- a/charrom.cpp +++ b/charrom.cpp @@ -17,7 +17,7 @@ unsigned char charfont[256][8] = { 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55 }, // 1 [0x1] { 0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A }, // 2 [0x2] { 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14 }, // 3 [0x3] - { 0x00,0x7f,0x6b,0x77,0x41,0x55,0x6b,0x7f }, // 4 [0x4] bluetooth + { 0x7f,0x6b,0x77,0x41,0x55,0x6b,0x7f,0x00 }, // 4 [0x4] bluetooth { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 5 [0x5] { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 6 [0x6] { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 7 [0x7] @@ -164,6 +164,11 @@ unsigned char charfont[256][8] = { 0x7F,0x71,0x71,0x71,0x71,0x71,0x7F,0x00 }, // 143 [0x8F] fill 2 { 0x7F,0x79,0x79,0x79,0x79,0x79,0x7F,0x00 }, // 144 [0x90] fill 3 { 0x7F,0x7D,0x7D,0x7D,0x7D,0x7D,0x7F,0x00 }, // 145 [0x91] fill 4 + + { 0x2A,0x7F,0x41,0x41,0x41,0x7F,0x2A,0x00 }, // 146 [0x92] mem-none + { 0x2A,0x7F,0x41,0x71,0x79,0x7F,0x2A,0x00 }, // 147 [0x93] mem32 + { 0x2A,0x7F,0x79,0x79,0x79,0x7F,0x2A,0x00 }, // 148 [0x94] mem64 + { 0x2A,0x7F,0x7F,0x7F,0x7F,0x7F,0x2A,0x00 }, // 149 [0x95] mem128 }; static unsigned char tempfont[2048]; diff --git a/fpga_io.cpp b/fpga_io.cpp index d0ca54d..01cc2f3 100644 --- a/fpga_io.cpp +++ b/fpga_io.cpp @@ -423,7 +423,7 @@ static int make_env(const char *name, const char *cfg) } volatile char* str = (volatile char*)buf; - memset((void*)str, 0, 0x1000); + memset((void*)str, 0, 0xF00); *str++ = 0x21; *str++ = 0x43; diff --git a/menu.cpp b/menu.cpp index 2d76305..04da49b 100644 --- a/menu.cpp +++ b/menu.cpp @@ -4335,7 +4335,7 @@ void HandleUI(void) } else { - sprintf(str, " MiSTer "); + sprintf(str, " MiSTer "); time_t t = time(NULL); struct tm tm = *localtime(&t); @@ -4345,9 +4345,28 @@ void HandleUI(void) } int netType = (int)getNet(0); - if (netType) str[9] = 0x1b + netType; - if (has_bt()) str[10] = 4; - str[21] = ' '; + if (netType) str[8] = 0x1b + netType; + if (has_bt()) str[9] = 4; + if (user_io_get_sdram_cfg() & 0x8000) + { + switch (user_io_get_sdram_cfg() & 7) + { + case 7: + str[10] = 0x95; + break; + case 3: + str[10] = 0x94; + break; + case 1: + str[10] = 0x93; + break; + default: + str[10] = 0x92; + break; + } + } + + str[22] = ' '; } OsdWrite(16, "", 1, 0); diff --git a/user_io.cpp b/user_io.cpp index 9a55e8c..482a885 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "lib/lodepng/lodepng.h" #include "hardware.h" @@ -69,6 +70,8 @@ static bool caps_status = 0; static bool num_status = 0; static bool scrl_status = 0; +static uint16_t sdram_cfg = 0; + typedef struct { bool track_active; @@ -514,6 +517,11 @@ const char* get_rbf_name() return p+1; } +const char* get_rbf_path() +{ + return core_path; +} + void MakeFile(const char * filename, const char * data) { FILE * file; @@ -557,6 +565,49 @@ void SetMidiLinkMode(int mode) } } +static uint16_t sdram_sz(int sz) +{ + int res = 0; + + int fd; + if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) return 0; + + void* buf = mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x1FFFF000); + if (buf == (void *)-1) + { + printf("Unable to mmap(/dev/mem)\n"); + close(fd); + return 0; + } + + volatile uint8_t* par = (volatile uint8_t*)buf; + par += 0xF00; + if (sz >= 0) + { + *par++ = 0x12; + *par++ = 0x57; + *par++ = (uint8_t)(sz>>8); + *par++ = (uint8_t)sz; + } + else + { + if ((par[0] == 0x12) && (par[1] == 0x57)) + { + res = 0x8000 | (par[2]<<8) | par[3]; + if(res & 0x4000) printf("*** Debug phase: %d\n", (res & 0x100) ? (res & 0xFF) : -(res & 0xFF)); + else printf("*** Found SDRAM config: %d\n", res & 7); + } + else if(!is_menu_core()) + { + printf("*** SDRAM config not found\n"); + } + } + + munmap(buf, 0x1000); + close(fd); + return res; +} + void user_io_init(const char *path) { char *name; @@ -565,8 +616,6 @@ void user_io_init(const char *path) disable_osd = 0; memset(sd_image, 0, sizeof(sd_image)); - ikbd_init(); - tos_config_init(); strcpy(core_path, path); core_type = (fpga_core_id() & 0xFF); @@ -595,6 +644,8 @@ void user_io_init(const char *path) // set core name. This currently only sets a name for the 8 bit cores user_io_read_core_name(); + spi_uio_cmd16(UIO_SET_MEMSZ, sdram_sz(-1)); + // send a reset user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET); } @@ -625,16 +676,20 @@ void user_io_init(const char *path) case CORE_TYPE_MINIMIG2: puts("Identified Minimig V2 core"); + spi_uio_cmd16(UIO_SET_MEMSZ, sdram_sz(-1)); BootInit(); break; case CORE_TYPE_MIST: puts("Identified MiST core"); + ikbd_init(); + tos_config_init(); tos_upload(NULL); break; case CORE_TYPE_ARCHIE: puts("Identified Archimedes core"); + spi_uio_cmd16(UIO_SET_MEMSZ, sdram_sz(-1)); send_rtc(1); archie_init(); user_io_read_core_name(); @@ -1637,9 +1692,18 @@ void user_io_send_buttons(char force) if ((map != key_map) || force) { + const char *name = get_rbf_path(); + if (name[0] && (get_key_mod() & (LGUI | LSHIFT)) == (LGUI | LSHIFT) && (key_map & BUTTON2) && !(map & BUTTON2)) + { + uint16_t sz = sdram_sz(-1); + if (sz & 0x4000) sz++; + else sz = 0x4000; + sdram_sz(sz); + fpga_load_rbf(name); + } + if (is_archie() && (key_map & BUTTON2) && !(map & BUTTON2)) { - const char *name = get_rbf_name(); fpga_load_rbf(name[0] ? name : "Archie.rbf"); } @@ -2591,6 +2655,37 @@ void user_io_poll() } else if(CheckTimer(res_timer)) { + if (is_menu_core()) + { + static int got_cfg = 0; + if (!got_cfg) + { + spi_uio_cmd_cont(UIO_GET_OSDMASK); + sdram_cfg = spi_w(0); + DisableIO(); + + if (sdram_cfg & 0x8000) + { + got_cfg = 1; + printf("*** Got SDRAM module type: %d\n", sdram_cfg & 7); + switch (user_io_get_sdram_cfg() & 7) + { + case 7: + sdram_sz(3); + break; + case 3: + sdram_sz(2); + break; + case 1: + sdram_sz(1); + break; + default: + sdram_sz(0); + } + } + } + } + res_timer = GetTimer(500); if (!minimig_get_adjust()) { @@ -3135,3 +3230,8 @@ unsigned char user_io_ext_idx(char *name, char* ext) printf("not found! use 0\n"); return 0; } + +uint16_t user_io_get_sdram_cfg() +{ + return sdram_cfg; +} diff --git a/user_io.h b/user_io.h index 3bb45ef..ba93b8b 100644 --- a/user_io.h +++ b/user_io.h @@ -69,6 +69,7 @@ #define UIO_GET_OSDMASK 0x2E // Get mask #define UIO_SET_FBUF 0x2F // Set frame buffer for HPS output #define UIO_WAIT_VSYNC 0x30 // Wait for VSync +#define UIO_SET_MEMSZ 0x31 // Send memory size to the core // codes as used by 8bit for file loading from OSD #define UIO_FILE_TX 0x53 @@ -221,6 +222,7 @@ void user_io_set_joyswap(int swap); int user_io_get_joyswap(); char user_io_osd_is_visible(); void user_io_send_buttons(char); +uint16_t user_io_get_sdram_cfg(); void user_io_set_index(unsigned char index); unsigned char user_io_ext_idx(char *, char*); @@ -231,6 +233,7 @@ void user_io_rtc_reset(); const char* get_rbf_dir(); const char* get_rbf_name(); +const char* get_rbf_path(); int GetUARTMode(); int GetMidiLinkMode();