Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
coreboot feature
[MiSTer.ini]
; 0 - Always menu core
; 1 - Last core loaded (autosaved in CONFIG/coreboot.txt)
; 2 - Always core defined in CONFIG/coreboot.txt
coreboot=0             ; Autoboot
  • Loading branch information
spark2k06 committed Mar 4, 2019
1 parent 76b12bf commit 2e9ef46
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 2 deletions.
5 changes: 5 additions & 0 deletions MiSTer.ini
Expand Up @@ -17,6 +17,11 @@ vscale_border=0 ; set vertical border for TVs cutting the upper/bottom pa
rbf_hide_datecode=0 ; 1 - hides datecodes from rbf file names. Press F2 for quick temporary toggle
menu_pal=0 ; 1 - PAL mode for menu core

; 0 - Always menu core
; 1 - Last core loaded (autosaved in CONFIG/coreboot.txt)
; 2 - Always core defined in CONFIG/coreboot.txt
coreboot=0 ; Autoboot

; USER button emulation by keybaord. Usually it's reset button.
; 0 - lctrl+lalt+ralt (lctrl+lgui+rgui on keyrah)
; 1 - lctrl+lgui+rgui
Expand Down
1 change: 1 addition & 0 deletions cfg.cpp
Expand Up @@ -46,6 +46,7 @@ const ini_var_t ini_vars[] = {
{ "VSCALE_BORDER", (void*)(&(cfg.vscale_border)), UINT8, 0, 100, 1 },
{ "RBF_HIDE_DATECODE", (void*)(&(cfg.rbf_hide_datecode)), UINT8, 0, 1, 1 },
{ "MENU_PAL", (void*)(&(cfg.menu_pal)), UINT8, 0, 1, 1 },
{ "COREBOOT", (void*)(&(cfg.coreboot)), UINT8, 0, 2, 1 },
};

// mist ini config
Expand Down
1 change: 1 addition & 0 deletions cfg.h
Expand Up @@ -35,6 +35,7 @@ typedef struct {
char video_conf[1024];
char video_conf_pal[1024];
char video_conf_ntsc[1024];
uint8_t coreboot;
} cfg_t;

//// functions ////
Expand Down
33 changes: 33 additions & 0 deletions file_io.cpp
Expand Up @@ -566,6 +566,39 @@ int FileLoadConfig(const char *name, void *pBuffer, int size)
return FileLoad(path, pBuffer, size);
}

char* FileLoadCoreBoot()
{

char path[256] = { CONFIG_DIR"/" };
strcat(path, "coreboot.txt");
sprintf(full_path, "%s/%s", getRootDir(), path);
FILE *fd = fopen(full_path, "r");
if (!fd)
{
printf("Error open coreboot.txt\n");
return NULL;
}
fseek(fd, 0L, SEEK_END);
long size = ftell(fd);

fseek(fd, 0L, SEEK_SET);
char *coreboot = (char*)malloc(size + 1);
memset(coreboot, 0, size + 1);

int ret = fread(coreboot, sizeof(char), size, fd);
fclose(fd);
if (ret == size)
{
return coreboot;
}
else
{
printf("Error reading coreboot.txt, bytes: %d <> %d, name: %s\n", ret, size, coreboot);
}

return NULL;
}

int FileCanWrite(const char *name)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
Expand Down
2 changes: 2 additions & 0 deletions file_io.h
Expand Up @@ -74,6 +74,8 @@ int FileLoad(const char *name, void *pBuffer, int size); // supply pBuffer = 0 t
int FileSaveConfig(const char *name, void *pBuffer, int size);
int FileLoadConfig(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading

char* FileLoadCoreBoot();

void AdjustDirectory(char *path);
int ScanDirectory(char* path, int mode, const char *extension, int options, const char *prefix = NULL);

Expand Down
2 changes: 1 addition & 1 deletion fpga_io.cpp
Expand Up @@ -516,7 +516,7 @@ int fpga_load_rbf(const char *name, const char *cfg)
}
}
close(rbf);
app_restart(!strcasecmp(name, "menu.rbf") ? NULL : path);
app_restart(!strcasecmp(name, "menu.rbf") ? "menu.rbf" : path);

return ret;
}
Expand Down
23 changes: 22 additions & 1 deletion main.cpp
Expand Up @@ -31,6 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "input.h"
#include "fpga_io.h"
#include "scheduler.h"
#include "cfg.h"


const char *version = "$VER:HPS" VDATE;

Expand All @@ -46,6 +48,7 @@ int main(int argc, char *argv[])

fpga_io_init();
fpga_gpo_write(0);
char *coreboot;

DISKLED_OFF;

Expand All @@ -64,9 +67,27 @@ int main(int argc, char *argv[])
exit(0);
}

MiSTer_ini_parse();
if (cfg.coreboot)
{
coreboot = FileLoadCoreBoot();
if (coreboot != NULL)
{
if (argc == 1)
{
fpga_load_rbf(coreboot);
}
}
if (cfg.coreboot == 1 && argc > 1)
{
if (coreboot == NULL || strcmp(coreboot, argv[1]))
{
FileSaveConfig("coreboot.txt", (char*)argv[1], strlen(argv[1]));
}
}
}
FindStorage();
user_io_init((argc > 1) ? argv[1] : "");

scheduler_init();
scheduler_run();

Expand Down

0 comments on commit 2e9ef46

Please sign in to comment.