diff --git a/CMakeLists.txt b/CMakeLists.txt index 3022dd0..3a062d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.15) -project(vxBoot VERSION 1.2.4 LANGUAGES C) +project(vxBoot VERSION 1.2.5 LANGUAGES C) include(GenerateG1A) include(GenerateG3A) diff --git a/include/vxBoot/hardware.h b/include/vxBoot/hardware.h index aa71c09..047e362 100644 --- a/include/vxBoot/hardware.h +++ b/include/vxBoot/hardware.h @@ -24,5 +24,7 @@ struct hwinfo { /* hardware_get_info() : get hardware information */ extern int hardware_get_info(struct hwinfo * const hwinfo); +/* hardware_utlb_patch() : patch the UTLB NULL page set by Casio */ +extern void hardware_utlb_patch(void); #endif /*__VXBOOT_HARDWARE_H__*/ diff --git a/src/builtin/hw.c b/src/builtin/hw.c index 742c0e3..dc0bff2 100644 --- a/src/builtin/hw.c +++ b/src/builtin/hw.c @@ -2,6 +2,7 @@ #include "vxBoot/terminal.h" #include "vxBoot/hardware.h" +#include /* hw_main() : hw builtin entry */ int hw_main(int argc, char **argv) @@ -12,6 +13,19 @@ int hw_main(int argc, char **argv) (void)argc; (void)argv; +#ifdef FXCG50 + if (argc >= 1) { + if (strcmp(argv[1], "patch") == 0) { + terminal_write("try to invalidate the NULL page..."); + hardware_utlb_patch(); + terminal_write("OK\n"); + return (0); + } + terminal_write("invalide argument\n"); + return (84); + } +#endif + hardware_get_info(&hwinfo); terminal_write( "- user RAM physical addr: %p\n" diff --git a/src/hardware/get_info.c b/src/hardware/get_info.c index a602ad9..606b213 100644 --- a/src/hardware/get_info.c +++ b/src/hardware/get_info.c @@ -37,3 +37,21 @@ int hardware_get_info(struct hwinfo * const hwinfo) hwinfo->ram.available -= hwinfo->ram.physical.kernel_addr & 0x00ffffff; return (0); } + + +/* hardware_utlb_patch() : patch the UTLB NULL page set by Casio */ +void hardware_utlb_patch(void) +{ + for (int i = 0; i < 64; ++i) { + utlb_addr_t *addr = (void*)utlb_addr(i); + utlb_data_t *data = (void*)utlb_data(i); + if(!addr->V || !data->V) continue; + + uintptr_t vaddr = addr->VPN << 10; + if (vaddr == 0x00000000) { + addr->V = 0; + data->V = 0; + return; + } + } +} diff --git a/src/loader/entry.c b/src/loader/entry.c index 658d411..f20a943 100644 --- a/src/loader/entry.c +++ b/src/loader/entry.c @@ -61,9 +61,12 @@ int loader(struct smemfs_inode const * restrict const inode, int mode) terminal_write("> relocalize symbols...\n"); loader_rela_patch(&kernel); - terminal_write("> path the GOT table...\n"); + terminal_write("> patch the GOT table...\n"); loader_got_patch(&kernel); + terminal_write("> patch the UTLB...\n"); + hardware_utlb_patch(); + terminal_write("%s successfully loaded !\n", inode->name); if (mode == LOADER_DUMP || mode == LOADER_CHECK) { terminal_write(