void file_load_postload( const gchar *filename, int pc ) { gchar *bootstrap_file = lxdream_get_global_config_path_value(CONFIG_BOOTSTRAP); if( bootstrap_file != NULL && bootstrap_file[0] != '\0' ) { /* Load in a bootstrap before the binary, to initialize everything * correctly */ if( mem_load_block( bootstrap_file, BOOTSTRAP_LOAD_ADDR, BOOTSTRAP_SIZE ) == 0 ) { dreamcast_program_loaded( filename, BOOTSTRAP_ENTRY_ADDR ); g_free(bootstrap_file); return; } } dreamcast_program_loaded( filename, pc ); g_free(bootstrap_file); }
gboolean bios_boot_gdrom_disc( void ) { cdrom_disc_t disc = gdrom_get_current_disc(); int status = gdrom_get_drive_status(); if( status == CDROM_DISC_NONE ) { ERROR( "No disc in drive" ); return FALSE; } /* Find the bootable data track (if present) */ cdrom_track_t track = gdrom_disc_get_boot_track(disc); if( track == NULL ) { ERROR( "Disc is not bootable" ); return FALSE; } uint32_t lba = track->lba; uint32_t sectors = cdrom_disc_get_track_size(disc,track); if( sectors < MIN_ISO_SECTORS ) { ERROR( "Disc is not bootable" ); return FALSE; } /* Load the initial bootstrap into DC ram at 8c008000 */ size_t length = BOOTSTRAP_SIZE; unsigned char *bootstrap = mem_get_region(BOOTSTRAP_LOAD_ADDR); if( cdrom_disc_read_sectors( disc, track->lba, BOOTSTRAP_SIZE/2048, CDROM_READ_DATA|CDROM_READ_MODE2_FORM1, bootstrap, &length ) != CDROM_ERROR_OK ) { ERROR( "Disc is not bootable" ); return FALSE; } /* Check the magic just to be sure */ dc_bootstrap_head_t metadata = (dc_bootstrap_head_t)bootstrap; if( memcmp( metadata->magic, BOOTSTRAP_MAGIC, BOOTSTRAP_MAGIC_SIZE ) != 0 ) { ERROR( "Disc is not bootable (missing dreamcast bootstrap)" ); return FALSE; } /* Get the initial program from the bootstrap (usually 1ST_READ.BIN) */ char program_name[18] = "/"; memcpy(program_name+1, metadata->boot_file, 16); program_name[17] = '\0'; for( int i=16; i >= 0 && program_name[i] == ' '; i-- ) { program_name[i] = '\0'; } /* Bootstrap is good. Now find the program in the actual filesystem... */ unsigned char *program = mem_get_region(BINARY_LOAD_ADDR); gboolean isGDROM = (disc->disc_type == CDROM_DISC_GDROM ); if( !bios_load_ipl( disc, track, program_name, program, !isGDROM ) ) return FALSE; asic_enable_ide_interface(isGDROM); dreamcast_program_loaded( "", BOOTSTRAP_ENTRY_ADDR ); return TRUE; }