diff options
Diffstat (limited to 'nvbiosemu.c')
-rw-r--r-- | nvbiosemu.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/nvbiosemu.c b/nvbiosemu.c index 79c92f0..2278730 100644 --- a/nvbiosemu.c +++ b/nvbiosemu.c @@ -170,7 +170,7 @@ int reload_nv_bios(uintptr_t pcimemaddr) if ((fd = open("/dev/mem", O_RDWR)) == -1) { printf("Can't open /dev/mem\n"); - return 0; + return 1; } printf("Using card memory region at %p\n", (void *)pcimemaddr); @@ -195,3 +195,28 @@ int reload_nv_bios(uintptr_t pcimemaddr) return ret; } + +int reload_bios_from_file(char *romfile) +{ + uint8_t bios[NV_PROM_SIZE]; + FILE *romf; + + if (!(romf = fopen(romfile, "r"))) { + printf("File open failed\n"); + return 1; + } + + fread(bios, NV_PROM_SIZE, 1, romf); + fclose(romf); + + if (!NVValidVBIOS(NULL, bios)) + return 1; + + printf("Loading contents of %s as bios image to be used, unless ^C is hit in next 5s\n", romfile); + sleep(5); + + if (mmap_in_bios(bios)) + return 1; + + return 0; +} |