Beispiel #1
0
int main(int argc, char* argv[])
{
	try
	{
		//Parameters
		if(argc!=3 && argc!=4)
		{
			std::cout<<"XFS <path> <disk> [<disk size>]"<<std::endl;
			return 0;
		}

		std::string windows_path=argv[1];
		std::string xfs_disk=argv[2];
		u32 xfs_disk_size=(argc==4?ToNumber(argv[3]):FLOPPY_SIZE);

		//Instanciamos el disco
		Disk* disk=Disk::GetDisk(xfs_disk, xfs_disk_size);
		
		//Variables del disco
		OFFSET xft_entry=TO_OFFSET(XFT_LBA);
		LBA writing_sector=XFT_LBA+XFT_SECTORS;

		//Escribimos el sector de arranque
		MappedFile boot_file(windows_path + "\\BOOT\\" BOOT_NAME);
		disk->Write(0, boot_file.GetBasePointer(), SECTOR_SIZE);

		//Escribimos el loader 
		//MappedFile loader_file(windows_path + "\\BOOT\\" LOADER_NAME);
		writing_sector+=XFS_FileWriter::Write(disk, windows_path + "\\BOOT", LOADER_NAME, xft_entry, writing_sector);
		xft_entry+=XFS_ENTRY_SIZE;

		//Escribimos el kernel
		writing_sector+=XFS_DirectoryWriter::Write(disk, windows_path, "KRNL", true, xft_entry, writing_sector, XFT_LBA);
		xft_entry+=XFS_ENTRY_SIZE;
		
		//Escribimos XFS
		writing_sector+=XFS_DirectoryWriter::Write(disk, windows_path, "XFS", false, xft_entry, writing_sector, XFT_LBA);
		xft_entry+=XFS_ENTRY_SIZE;

		delete disk;
	}
	catch(char* error)
	{
		std::cout<<error<<std::endl;
	}
	catch(std::string error)
	{
		std::cout<<error.c_str()<<std::endl;
	}
	catch(...)
	{
		std::cout<<"Unexpected error!"<<std::endl;
	}
	return 0;
}
Beispiel #2
0
void main_romfs(int argc, char **argv) {
    boot_file("romfs:/", "boot", argc, argv, false);
}
Beispiel #3
0
void main_netload(int argc, char **argv) {
    bool restart = true;

    while (restart) {
        int ret = run_file("romfs:/netload.py", argc, argv, true);

        if (ret == ERR_PARSE) {
            restart = fatal_error(false);
        } else if (ret == ERR_NETLOAD) {
            restart = false;
        } else {
            mp_obj_dict_t *globals = mp_globals_get();

            qstr filename_qstr = qstr_from_str("monty_filename");
            qstr filetype_qstr = qstr_from_str("monty_filetype");
            qstr cancel_qstr = qstr_from_str("monty_cancel");

            mp_obj_t monty_filename = MP_OBJ_NEW_QSTR(filename_qstr);
            mp_obj_t monty_filetype = MP_OBJ_NEW_QSTR(filetype_qstr);
            mp_obj_t monty_cancel = MP_OBJ_NEW_QSTR(cancel_qstr);

            mp_map_elem_t *filename_item = mp_map_lookup(&globals->map, monty_filename, MP_MAP_LOOKUP);
            mp_map_elem_t *filetype_item = mp_map_lookup(&globals->map, monty_filetype, MP_MAP_LOOKUP);
            mp_map_elem_t *cancel_item = mp_map_lookup(&globals->map, monty_cancel, MP_MAP_LOOKUP);

            if (cancel_item != NULL && mp_obj_is_true(cancel_item->value)) {
                restart = false;
                break;
            }

            const char *filename = "";
            if (filename_item != NULL) {
                filename = mp_obj_str_get_str(filename_item->value);
            }
            char file_path[PATH_MAX];
            sprintf(file_path, "sdmc:/monty3ds/%s", filename);

            int type = TYPE_NONE;
            if (filetype_item != NULL) {
                type = mp_obj_get_int(filetype_item->value);
            }

            switch (type) {
                case TYPE_PY: {
                    ret = run_file(file_path, argc, argv, true);
                    break;
                }
                case TYPE_ZIP: {
                    zipfs_handle_t handle = zipfs_mount(file_path, "zip");
                    zipfs_set_default(handle);

                    ret = boot_file("zip:/", "boot", argc, argv, true);

                    zipfs_unmount(handle);

                    break;
                }
                default:
                    continue;
            }

            if (ret) {
                restart = fatal_error(true);
            }
        }
    }

    mod_citrus_exit_all();
}