/[gxemul]/trunk/src/disk/bootblock.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/disk/bootblock.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by dpavlin, Mon Oct 8 16:21:34 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: bootblock.c,v 1.1 2007/03/16 14:45:30 debug Exp $   *  $Id: bootblock.c,v 1.4 2007/06/15 17:02:39 debug Exp $
29   *   *
30   *  Bootblock handling:   *  Bootblock handling:
31   *   *
# Line 49  Line 49 
49  #include "diskimage.h"  #include "diskimage.h"
50  #include "emul.h"  #include "emul.h"
51  #include "machine.h"  #include "machine.h"
52  #include "misc.h"  #include "memory.h"
53    
54  static char *diskimage_types[] = DISKIMAGE_TYPES;  static char *diskimage_types[] = DISKIMAGE_TYPES;
55    
# Line 90  int load_bootblock(struct machine *m, st Line 90  int load_bootblock(struct machine *m, st
90                          exit(1);                          exit(1);
91                  }                  }
92    
93                  bootblock_buf = malloc(32768);                  CHECK_ALLOCATION(bootblock_buf = malloc(32768));
                 if (bootblock_buf == NULL) {  
                         fprintf(stderr, "Out of memory.\n");  
                         exit(1);  
                 }  
94    
95                  debug("loading Dreamcast IP.BIN from %s id %i\n",                  debug("loading Dreamcast IP.BIN from %s id %i\n",
96                      diskimage_types[boot_disk_type], boot_disk_id);                      diskimage_types[boot_disk_type], boot_disk_id);
# Line 125  int load_bootblock(struct machine *m, st Line 121  int load_bootblock(struct machine *m, st
121                                          bootblock_buf[i] = 0;                                          bootblock_buf[i] = 0;
122                                  i ++;                                  i ++;
123                          }                          }
124                          cpu->machine->boot_kernel_filename = strdup(                          CHECK_ALLOCATION(cpu->machine->boot_kernel_filename =
125                              (char *)bootblock_buf + 0x60);                              strdup((char *)bootblock_buf + 0x60));
126                  }                  }
127    
128                  debug("boot filename: %s\n",                  debug("boot filename: %s\n",
# Line 183  int load_bootblock(struct machine *m, st Line 179  int load_bootblock(struct machine *m, st
179                  bootblock_pc |= 0xffffffffa0000000ULL;                  bootblock_pc |= 0xffffffffa0000000ULL;
180                  cpu->pc = bootblock_pc;                  cpu->pc = bootblock_pc;
181    
182                  debug("DEC boot: loadaddr=0x%08x, pc=0x%08x",                  debug("DEC boot: loadaddr=0x%08"PRIx32", pc=0x%08"PRIx32,
183                      (int)bootblock_loadaddr, (int)bootblock_pc);                      (uint32_t) bootblock_loadaddr, (uint32_t) bootblock_pc);
184    
185                  readofs = 0x18;                  readofs = 0x18;
186    
# Line 212  int load_bootblock(struct machine *m, st Line 208  int load_bootblock(struct machine *m, st
208                                  fatal("\nWARNING! Unusually large bootblock "                                  fatal("\nWARNING! Unusually large bootblock "
209                                      "(%i bytes)\n\n", n_blocks * 512);                                      "(%i bytes)\n\n", n_blocks * 512);
210    
211                          bootblock_buf = malloc(n_blocks * 512);                          CHECK_ALLOCATION(bootblock_buf = malloc(n_blocks*512));
                         if (bootblock_buf == NULL) {  
                                 fprintf(stderr, "out of memory in "  
                                     "load_bootblock()\n");  
                                 exit(1);  
                         }  
212    
213                          res = diskimage_access(m, boot_disk_id, boot_disk_type,                          res = diskimage_access(m, boot_disk_id, boot_disk_type,
214                              0, bootblock_offset, bootblock_buf, n_blocks * 512);                              0, bootblock_offset, bootblock_buf, n_blocks * 512);
# Line 245  int load_bootblock(struct machine *m, st Line 236  int load_bootblock(struct machine *m, st
236           *  does not rely on machine-dependent boot blocks etc.           *  does not rely on machine-dependent boot blocks etc.
237           */           */
238          /*  ISO9660: (0x800 bytes at 0x8000 + base_offset)  */          /*  ISO9660: (0x800 bytes at 0x8000 + base_offset)  */
239          bootblock_buf = malloc(0x800);          CHECK_ALLOCATION(bootblock_buf = malloc(0x800));
         if (bootblock_buf == NULL) {  
                 fprintf(stderr, "Out of memory.\n");  
                 exit(1);  
         }  
   
240          res = diskimage_access(m, boot_disk_id, boot_disk_type,          res = diskimage_access(m, boot_disk_id, boot_disk_type,
241              0, base_offset + 0x8000, bootblock_buf, 0x800);              0, base_offset + 0x8000, bootblock_buf, 0x800);
242          if (!res) {          if (!res) {

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26