Search
lxdream.org :: lxdream/src/loader.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/loader.c
changeset 543:361ec0a70cf2
prev537:d924be49e192
next561:533f6b478071
author nkeynes
date Thu Dec 20 09:56:07 2007 +0000 (16 years ago)
permissions -rw-r--r--
last change Fix immediate call to MMU_ldtlb (braino...)
file annotate diff log raw
1.1 --- a/src/loader.c Tue Nov 20 10:27:58 2007 +0000
1.2 +++ b/src/loader.c Thu Dec 20 09:56:07 2007 +0000
1.3 @@ -25,13 +25,10 @@
1.4 #include <stdint.h>
1.5 #include <elf.h>
1.6 #include "mem.h"
1.7 -#include "sh4core.h"
1.8 #include "bootstrap.h"
1.9 #include "dreamcast.h"
1.10 #include "config.h"
1.11 #include "loader.h"
1.12 -#include "syscall.h"
1.13 -#include "gui.h"
1.14
1.15 char bootstrap_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";
1.16 char iso_magic[6] = "\001CD001";
1.17 @@ -48,7 +45,7 @@
1.18 #define CDI_V2 0x80000004
1.19 #define CDI_V3 0x80000005
1.20
1.21 -gboolean file_load_elf_fd( int fd );
1.22 +gboolean file_load_elf_fd( const gchar *filename, int fd );
1.23
1.24
1.25 gboolean file_load_magic( const gchar *filename )
1.26 @@ -77,8 +74,7 @@
1.27 lseek( fd, 0, SEEK_SET );
1.28 read( fd, load, BOOTSTRAP_SIZE );
1.29 bootstrap_dump( load, TRUE );
1.30 - sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );
1.31 - gui_update_state();
1.32 + dreamcast_program_loaded( filename, BOOTSTRAP_LOAD_ADDR + 0x300 );
1.33 } else {
1.34 /* look for a valid ISO9660 header */
1.35 lseek( fd, 32768, SEEK_SET );
1.36 @@ -100,7 +96,7 @@
1.37 buf[2] == 'L' && buf[3] == 'F' ) {
1.38 /* ELF binary */
1.39 lseek( fd, 0, SEEK_SET );
1.40 - result = file_load_elf_fd( fd );
1.41 + result = file_load_elf_fd( filename, fd );
1.42 } else {
1.43 result = FALSE;
1.44 }
1.45 @@ -108,25 +104,19 @@
1.46 return result;
1.47 }
1.48
1.49 -void file_load_postload( int pc )
1.50 +void file_load_postload( const gchar *filename, int pc )
1.51 {
1.52 const gchar *bootstrap_file = lxdream_get_config_value(CONFIG_BOOTSTRAP);
1.53 if( bootstrap_file != NULL ) {
1.54 /* Load in a bootstrap before the binary, to initialize everything
1.55 * correctly
1.56 */
1.57 - if( mem_load_block( bootstrap_file, BOOTSTRAP_LOAD_ADDR, BOOTSTRAP_SIZE ) != 0 ) {
1.58 - /* Try it without the bootstrap */
1.59 - sh4_set_pc( pc );
1.60 - } else {
1.61 - sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );
1.62 + if( mem_load_block( bootstrap_file, BOOTSTRAP_LOAD_ADDR, BOOTSTRAP_SIZE ) == 0 ) {
1.63 + dreamcast_program_loaded( filename, BOOTSTRAP_LOAD_ADDR+0x300 );
1.64 + return;
1.65 }
1.66 - } else {
1.67 - sh4_set_pc( pc );
1.68 }
1.69 - bios_install();
1.70 - dcload_install();
1.71 - gui_update_state();
1.72 + dreamcast_program_loaded( filename, pc );
1.73 }
1.74
1.75
1.76 @@ -134,14 +124,14 @@
1.77 {
1.78 /* Load the binary itself */
1.79 if( mem_load_block( filename, BINARY_LOAD_ADDR, -1 ) == 0 ) {
1.80 - file_load_postload( BINARY_LOAD_ADDR );
1.81 + file_load_postload( filename, BINARY_LOAD_ADDR );
1.82 return TRUE;
1.83 } else {
1.84 return FALSE;
1.85 }
1.86 }
1.87
1.88 -gboolean file_load_elf_fd( int fd )
1.89 +gboolean file_load_elf_fd( const gchar *filename, int fd )
1.90 {
1.91 Elf32_Ehdr head;
1.92 Elf32_Phdr phdr;
1.93 @@ -174,6 +164,6 @@
1.94 }
1.95 }
1.96
1.97 - file_load_postload( head.e_entry );
1.98 + file_load_postload( filename, head.e_entry );
1.99 return TRUE;
1.100 }
.