int floppyboot(int dev, char *file, Boot *b) { Fs *fs; if(strncmp(file, "dos!", 4) == 0) file += 4; else if(strchr(file, '!') || strcmp(file, "")==0) { print("syntax is fd0!file\n"); return -1; } fs = floppygetfspart(dev, "dos", 1); if(fs == nil) return -1; return fsboot(fs, file, b); }
int sdboot(int dev, char *pname, Boot *b) { char *file; Fs *fs; if((file = strchr(pname, '!')) == nil) { print("syntax is sdC0!partition!file\n"); return -1; } *file++ = '\0'; fs = sdgetfspart(dev, pname, 1); if(fs == nil) return -1; return fsboot(fs, file, b); }
int floppyboot(int dev, char *file, Boot *b) { Fs *fs; /* there are no partitions on floppies */ if(strncmp(file, "dos!", 4) == 0) file += 4; if(strchr(file, '!') != nil || strcmp(file, "") == 0) { print("syntax is fd0!file\n"); return -1; } fs = floppygetfspart(dev, "dos", 1); if(fs == nil) return -1; return fsboot(fs, file, b); }
int cmd_fsboot(int argc, CmdArg* argv) { int i = 0; void* address = NULL; void(*hooker)(int flags, void* addr, void* phymem) = &hooked; if(argc != 1) { puts("usage: fsboot\n"); return 0; } // search for jump_to function if(strstr((char*) (IBOOT_BASEADDR + 0x200), "n72ap")) { jump_to = patch_find(IBOOT_BASEADDR, 0x30000, "\xf0\xb5\x03\xaf\x04\x1c\x15\x1c", 8); } else { // 80 B5 00 AF 04 46 15 46 jump_to = patch_find(IBOOT_BASEADDR, 0x30000, "\x80\xb5\x00\xaf\x04\x46\x15\x46", 8); } printf("Found jump_to function at %p\n", jump_to); memcpy(jump_to, "\x00\x4b\x98\x47", 4); memcpy(jump_to+4, &hooker, 4); printf("Hooked jump_to function to call 0x%08x\n", hooker); if(fsboot == NULL) { if(strstr((char*) (IBOOT_BASEADDR + 0x200), "n72ap")) { fsboot = patch_find(IBOOT_BASEADDR, 0x30000, "\xf0\xb5\x03\xaf\x11\x48", 6); } else if(strstr((char*) (IBOOT_BASEADDR + 0x200), "k66ap")) { fsboot = patch_find(IBOOT_BASEADDR, 0x30000, "\xf0\xb5\x03\xaf\x81\xb0", 6); } else { fsboot = patch_find(IBOOT_BASEADDR, 0x30000, "\xb0\xb5\x02\xaf\x11\x48", 6); } printf("Found fsboot function at %p\n", fsboot); } //call address //fsboot++; printf("Calling %p\n", fsboot); fsboot(); return 0; }
static void do_command(char *c) { char *token; token = get_token(&c); if(strcmp(token, "cons") == 0) vga_set_console(!vga_get_console()); else if(strcmp(token, "flush") == 0) flush_bridge_cache(); else if(strcmp(token, "mr") == 0) mr(get_token(&c), get_token(&c)); else if(strcmp(token, "mw") == 0) mw(get_token(&c), get_token(&c), get_token(&c)); else if(strcmp(token, "mc") == 0) mc(get_token(&c), get_token(&c), get_token(&c)); else if(strcmp(token, "crc") == 0) crc(get_token(&c), get_token(&c)); else if(strcmp(token, "ls") == 0) ls(get_token(&c)); else if(strcmp(token, "load") == 0) load(get_token(&c), get_token(&c), get_token(&c)); else if(strcmp(token, "netboot") == 0) netboot(); else if(strcmp(token, "serialboot") == 0) serialboot(); else if(strcmp(token, "fsboot") == 0) fsboot(BLOCKDEV_MEMORY_CARD); else if(strcmp(token, "flashboot") == 0) flashboot(); else if(strcmp(token, "mdior") == 0) mdior(get_token(&c)); else if(strcmp(token, "mdiow") == 0) mdiow(get_token(&c), get_token(&c)); else if(strcmp(token, "version") == 0) puts(VERSION); else if(strcmp(token, "reboot") == 0) reboot(); else if(strcmp(token, "reconf") == 0) reconf(); else if(strcmp(token, "help") == 0) help(); else if(strcmp(token, "rcsr") == 0) rcsr(get_token(&c)); else if(strcmp(token, "wcsr") == 0) wcsr(get_token(&c), get_token(&c)); else if(strcmp(token, "") != 0) printf("Command not found\n"); }