/[qemu]/qemu/vl.c
ViewVC logotype

Diff of /qemu/vl.c

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

revision 1.11 by bellard, Fri Jul 4 14:38:25 2003 UTC revision 1.12 by bellard, Sun Jul 6 17:15:21 2003 UTC
# Line 63  Line 63 
63  #define INITRD_LOAD_ADDR   0x00400000  #define INITRD_LOAD_ADDR   0x00400000
64  #define KERNEL_PARAMS_ADDR 0x00090000  #define KERNEL_PARAMS_ADDR 0x00090000
65    
66    #define MAX_DISKS 2
67    
68  /* from plex86 (BSD license) */  /* from plex86 (BSD license) */
69  struct  __attribute__ ((packed)) linux_params {  struct  __attribute__ ((packed)) linux_params {
70    // For 0x00..0x3f, see 'struct screen_info' in linux/include/linux/tty.h.    // For 0x00..0x3f, see 'struct screen_info' in linux/include/linux/tty.h.
# Line 190  FILE *logfile = NULL; Line 192  FILE *logfile = NULL;
192  int loglevel;  int loglevel;
193  IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];  IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
194  IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];  IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
195    BlockDriverState *bs_table[MAX_DISKS];
196    
197  /***********************************************************/  /***********************************************************/
198  /* x86 io ports */  /* x86 io ports */
# Line 1265  void term_print_help(void) Line 1268  void term_print_help(void)
1268      printf("\n"      printf("\n"
1269             "C-a h    print this help\n"             "C-a h    print this help\n"
1270             "C-a x    exit emulatior\n"             "C-a x    exit emulatior\n"
1271               "C-a s    save disk data back to file (if -snapshot)\n"
1272             "C-a b    send break (magic sysrq)\n"             "C-a b    send break (magic sysrq)\n"
1273             "C-a C-a  send C-a\n"             "C-a C-a  send C-a\n"
1274             );             );
# Line 1282  void serial_received_byte(SerialState *s Line 1286  void serial_received_byte(SerialState *s
1286          case 'x':          case 'x':
1287              exit(0);              exit(0);
1288              break;              break;
1289            case 's':
1290                {
1291                    int i;
1292                    for (i = 0; i < MAX_DISKS; i++) {
1293                        if (bs_table[i])
1294                            bdrv_commit(bs_table[i]);
1295                    }
1296                }
1297                break;
1298          case 'b':          case 'b':
1299              /* send break */              /* send break */
1300              s->rbr = 0;              s->rbr = 0;
# Line 1976  void ne2000_init(void) Line 1989  void ne2000_init(void)
1989  /* set to 1 set disable mult support */  /* set to 1 set disable mult support */
1990  #define MAX_MULT_SECTORS 8  #define MAX_MULT_SECTORS 8
1991    
 #define MAX_DISKS 2  
   
1992  struct IDEState;  struct IDEState;
1993    
1994  typedef void EndTransferFunc(struct IDEState *);  typedef void EndTransferFunc(struct IDEState *);
# Line 2009  typedef struct IDEState { Line 2020  typedef struct IDEState {
2020      uint8_t io_buffer[MAX_MULT_SECTORS*512 + 4];      uint8_t io_buffer[MAX_MULT_SECTORS*512 + 4];
2021  } IDEState;  } IDEState;
2022    
 BlockDriverState *bs_table[MAX_DISKS];  
2023  IDEState ide_state[MAX_DISKS];  IDEState ide_state[MAX_DISKS];
2024    
2025  static void padstr(char *str, const char *src, int len)  static void padstr(char *str, const char *src, int len)
# Line 2513  static void host_alarm_handler(int host_ Line 2523  static void host_alarm_handler(int host_
2523      }      }
2524  }  }
2525    
2526    unsigned long mmap_addr = PHYS_RAM_BASE;
2527    
2528    void *get_mmap_addr(unsigned long size)
2529    {
2530        unsigned long addr;
2531        addr = mmap_addr;
2532        mmap_addr += ((size + 4095) & ~4095) + 4096;
2533        return (void *)addr;
2534    }
2535    
2536  /* main execution loop */  /* main execution loop */
2537    
2538  CPUState *cpu_gdbstub_get_env(void *opaque)  CPUState *cpu_gdbstub_get_env(void *opaque)
# Line 2612  void help(void) Line 2632  void help(void)
2632             "-initrd file   use 'file' as initial ram disk\n"             "-initrd file   use 'file' as initial ram disk\n"
2633             "-hda file      use 'file' as hard disk 0 image\n"             "-hda file      use 'file' as hard disk 0 image\n"
2634             "-hdb file      use 'file' as hard disk 1 image\n"             "-hdb file      use 'file' as hard disk 1 image\n"
2635               "-snapshot      write to temporary files instead of disk image files\n"
2636             "-m megs        set virtual RAM size to megs MB\n"             "-m megs        set virtual RAM size to megs MB\n"
2637             "-n script      set network init script [default=%s]\n"             "-n script      set network init script [default=%s]\n"
2638             "\n"             "\n"
# Line 2630  struct option long_options[] = { Line 2651  struct option long_options[] = {
2651      { "initrd", 1, NULL, 0, },      { "initrd", 1, NULL, 0, },
2652      { "hda", 1, NULL, 0, },      { "hda", 1, NULL, 0, },
2653      { "hdb", 1, NULL, 0, },      { "hdb", 1, NULL, 0, },
2654        { "snapshot", 0, NULL, 0, },
2655      { NULL, 0, NULL, 0 },      { NULL, 0, NULL, 0 },
2656  };  };
2657    
2658  int main(int argc, char **argv)  int main(int argc, char **argv)
2659  {  {
2660      int c, ret, initrd_size, i, use_gdbstub, gdbstub_port, long_index;      int c, ret, initrd_size, i, use_gdbstub, gdbstub_port, long_index;
2661        int snapshot;
2662      struct linux_params *params;      struct linux_params *params;
2663      struct sigaction act;      struct sigaction act;
2664      struct itimerval itv;      struct itimerval itv;
# Line 2652  int main(int argc, char **argv) Line 2675  int main(int argc, char **argv)
2675      pstrcpy(network_script, sizeof(network_script), DEFAULT_NETWORK_SCRIPT);      pstrcpy(network_script, sizeof(network_script), DEFAULT_NETWORK_SCRIPT);
2676      use_gdbstub = 0;      use_gdbstub = 0;
2677      gdbstub_port = DEFAULT_GDBSTUB_PORT;      gdbstub_port = DEFAULT_GDBSTUB_PORT;
2678        snapshot = 0;
2679      for(;;) {      for(;;) {
2680          c = getopt_long_only(argc, argv, "hm:dn:sp:", long_options, &long_index);          c = getopt_long_only(argc, argv, "hm:dn:sp:", long_options, &long_index);
2681          if (c == -1)          if (c == -1)
# Line 2668  int main(int argc, char **argv) Line 2692  int main(int argc, char **argv)
2692              case 2:              case 2:
2693                  hd_filename[1] = optarg;                  hd_filename[1] = optarg;
2694                  break;                  break;
2695                case 3:
2696                    snapshot = 1;
2697                    break;
2698              }              }
2699              break;              break;
2700          case 'h':          case 'h':
# Line 2711  int main(int argc, char **argv) Line 2738  int main(int argc, char **argv)
2738          setvbuf(logfile, NULL, _IOLBF, 0);          setvbuf(logfile, NULL, _IOLBF, 0);
2739      }      }
2740    
     /* open the virtual block devices */  
     for(i = 0; i < MAX_DISKS; i++) {  
         if (hd_filename[i]) {  
             bs_table[i] = bdrv_open(hd_filename[i]);  
             if (!bs_table[i]) {  
                 fprintf(stderr, "vl: could not open hard disk image '%s\n",  
                         hd_filename[i]);  
                 exit(1);  
             }  
         }  
     }  
   
2741      /* init network tun interface */      /* init network tun interface */
2742      net_init();      net_init();
2743    
# Line 2744  int main(int argc, char **argv) Line 2759  int main(int argc, char **argv)
2759      }      }
2760      ftruncate(phys_ram_fd, phys_ram_size);      ftruncate(phys_ram_fd, phys_ram_size);
2761      unlink(phys_ram_file);      unlink(phys_ram_file);
2762      phys_ram_base = mmap((void *)PHYS_RAM_BASE, phys_ram_size,      phys_ram_base = mmap(get_mmap_addr(phys_ram_size), phys_ram_size,
2763                           PROT_WRITE | PROT_READ, MAP_SHARED | MAP_FIXED,                           PROT_WRITE | PROT_READ, MAP_SHARED | MAP_FIXED,
2764                           phys_ram_fd, 0);                           phys_ram_fd, 0);
2765      if (phys_ram_base == MAP_FAILED) {      if (phys_ram_base == MAP_FAILED) {
# Line 2752  int main(int argc, char **argv) Line 2767  int main(int argc, char **argv)
2767          exit(1);          exit(1);
2768      }      }
2769    
2770        /* open the virtual block devices */
2771        for(i = 0; i < MAX_DISKS; i++) {
2772            if (hd_filename[i]) {
2773                bs_table[i] = bdrv_open(hd_filename[i], snapshot);
2774                if (!bs_table[i]) {
2775                    fprintf(stderr, "vl: could not open hard disk image '%s\n",
2776                            hd_filename[i]);
2777                    exit(1);
2778                }
2779            }
2780        }
2781    
2782      /* now we can load the kernel */      /* now we can load the kernel */
2783      ret = load_kernel(argv[optind], phys_ram_base + KERNEL_LOAD_ADDR);      ret = load_kernel(argv[optind], phys_ram_base + KERNEL_LOAD_ADDR);
2784      if (ret < 0) {      if (ret < 0) {

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26