Search
lxdream.org :: lxdream/src/loader.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/loader.c
changeset 427:00270806b4cf
prev294:a5beff9b2b85
next435:7a5d71e8560b
author nkeynes
date Sun Oct 07 06:21:14 2007 +0000 (16 years ago)
permissions -rw-r--r--
last change Fix compilation warnings
file annotate diff log raw
1.1 --- a/src/loader.c Tue Jan 16 09:18:32 2007 +0000
1.2 +++ b/src/loader.c Sun Oct 07 06:21:14 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: loader.c,v 1.15 2007-01-16 09:18:32 nkeynes Exp $
1.6 + * $Id: loader.c,v 1.16 2007-10-07 06:21:14 nkeynes Exp $
1.7 *
1.8 * File loading routines, mostly for loading demos without going through the
1.9 * whole procedure of making a CD image for them.
1.10 @@ -28,6 +28,8 @@
1.11 #include "sh4core.h"
1.12 #include "bootstrap.h"
1.13 #include "dreamcast.h"
1.14 +#include "loader.h"
1.15 +#include "syscall.h"
1.16
1.17 char bootstrap_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";
1.18 char iso_magic[6] = "\001CD001";
1.19 @@ -44,10 +46,12 @@
1.20 #define CDI_V2 0x80000004
1.21 #define CDI_V3 0x80000005
1.22
1.23 +int file_load_elf_fd( int fd );
1.24 +
1.25 +
1.26 gboolean file_load_magic( const gchar *filename )
1.27 {
1.28 char buf[32];
1.29 - uint32_t tmpa[2];
1.30 struct stat st;
1.31
1.32 int fd = open( filename, O_RDONLY );
1.33 @@ -68,7 +72,7 @@
1.34 if( memcmp( buf, bootstrap_magic, 32 ) == 0 ) {
1.35 /* we have a DC bootstrap */
1.36 if( st.st_size == BOOTSTRAP_SIZE ) {
1.37 - char *load = mem_get_region( BOOTSTRAP_LOAD_ADDR );
1.38 + unsigned char *load = (unsigned char *)mem_get_region( BOOTSTRAP_LOAD_ADDR );
1.39 lseek( fd, 0, SEEK_SET );
1.40 read( fd, load, BOOTSTRAP_SIZE );
1.41 bootstrap_dump( load, TRUE );
1.42 @@ -103,7 +107,7 @@
1.43 return TRUE;
1.44 }
1.45
1.46 -int file_load_postload( int pc )
1.47 +void file_load_postload( int pc )
1.48 {
1.49 const gchar *bootstrap_file = dreamcast_get_config_value(CONFIG_BOOTSTRAP);
1.50 if( bootstrap_file != NULL ) {
1.51 @@ -125,11 +129,15 @@
1.52 }
1.53
1.54
1.55 -int file_load_binary( const gchar *filename )
1.56 +gboolean file_load_binary( const gchar *filename )
1.57 {
1.58 /* Load the binary itself */
1.59 - mem_load_block( filename, BINARY_LOAD_ADDR, -1 );
1.60 - file_load_postload( BINARY_LOAD_ADDR );
1.61 + if( mem_load_block( filename, BINARY_LOAD_ADDR, -1 ) == 0 ) {
1.62 + file_load_postload( BINARY_LOAD_ADDR );
1.63 + return TRUE;
1.64 + } else {
1.65 + return FALSE;
1.66 + }
1.67 }
1.68
1.69 int file_load_elf_fd( int fd )
1.70 @@ -165,5 +173,6 @@
1.71 }
1.72 }
1.73
1.74 - return file_load_postload( head.e_entry );
1.75 + file_load_postload( head.e_entry );
1.76 + return 0;
1.77 }
.