mirror of https://github.com/xemu-project/xemu.git
More generic boot devices specification, allowing more devices to be specified
and avoiding per-target hardcoded limitations. The machine implementations can then check if the given devices match the actual hardware implementation and firmware API. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3577 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
aba9ee8726
commit
28c5af54c6
22
hw/pc.c
22
hw/pc.c
|
@ -173,6 +173,7 @@ static int boot_device2nibble(char boot_device)
|
||||||
static void cmos_init(int ram_size, const char *boot_device, BlockDriverState **hd_table)
|
static void cmos_init(int ram_size, const char *boot_device, BlockDriverState **hd_table)
|
||||||
{
|
{
|
||||||
RTCState *s = rtc_state;
|
RTCState *s = rtc_state;
|
||||||
|
int nbds, bds[3] = { 0, };
|
||||||
int val;
|
int val;
|
||||||
int fd0, fd1, nb;
|
int fd0, fd1, nb;
|
||||||
int i;
|
int i;
|
||||||
|
@ -202,11 +203,22 @@ static void cmos_init(int ram_size, const char *boot_device, BlockDriverState **
|
||||||
rtc_set_memory(s, 0x35, val >> 8);
|
rtc_set_memory(s, 0x35, val >> 8);
|
||||||
|
|
||||||
/* set boot devices, and disable floppy signature check if requested */
|
/* set boot devices, and disable floppy signature check if requested */
|
||||||
rtc_set_memory(s, 0x3d,
|
#define PC_MAX_BOOT_DEVICES 3
|
||||||
boot_device2nibble(boot_device[1]) << 4 |
|
nbds = strlen(boot_device);
|
||||||
boot_device2nibble(boot_device[0]) );
|
if (nbds > PC_MAX_BOOT_DEVICES) {
|
||||||
rtc_set_memory(s, 0x38,
|
fprintf(stderr, "Too many boot devices for PC\n");
|
||||||
boot_device2nibble(boot_device[2]) << 4 | (fd_bootchk ? 0x0 : 0x1));
|
exit(1);
|
||||||
|
}
|
||||||
|
for (i = 0; i < nbds; i++) {
|
||||||
|
bds[i] = boot_device2nibble(boot_device[i]);
|
||||||
|
if (bds[i] == 0) {
|
||||||
|
fprintf(stderr, "Invalid boot device for PC: '%c'\n",
|
||||||
|
boot_device[i]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]);
|
||||||
|
rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1));
|
||||||
|
|
||||||
/* floppy type */
|
/* floppy type */
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ static void ppc_core99_init (int ram_size, int vga_ram_size,
|
||||||
qemu_irq *dummy_irq;
|
qemu_irq *dummy_irq;
|
||||||
int pic_mem_index, dbdma_mem_index, cuda_mem_index;
|
int pic_mem_index, dbdma_mem_index, cuda_mem_index;
|
||||||
int ide_mem_index[2];
|
int ide_mem_index[2];
|
||||||
int ppc_boot_device = boot_device[0];
|
int ppc_boot_device;
|
||||||
|
|
||||||
linux_boot = (kernel_filename != NULL);
|
linux_boot = (kernel_filename != NULL);
|
||||||
|
|
||||||
|
@ -175,6 +175,19 @@ static void ppc_core99_init (int ram_size, int vga_ram_size,
|
||||||
kernel_size = 0;
|
kernel_size = 0;
|
||||||
initrd_base = 0;
|
initrd_base = 0;
|
||||||
initrd_size = 0;
|
initrd_size = 0;
|
||||||
|
ppc_boot_device = '\0';
|
||||||
|
/* We consider that NewWorld PowerMac never have any floppy drive
|
||||||
|
* For now, OHW cannot boot from the network.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < boot_device[i] != '\0'; i++) {
|
||||||
|
ppc_boot_device = boot_device[i];
|
||||||
|
if (ppc_boot_device >= 'c' && ppc_boot_device <= 'f')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ppc_boot_device == '\0') {
|
||||||
|
fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isa_mem_base = 0x80000000;
|
isa_mem_base = 0x80000000;
|
||||||
|
|
|
@ -113,7 +113,7 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size,
|
||||||
int vga_bios_size, bios_size;
|
int vga_bios_size, bios_size;
|
||||||
qemu_irq *dummy_irq;
|
qemu_irq *dummy_irq;
|
||||||
int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
|
int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
|
||||||
int ppc_boot_device = boot_device[0];
|
int ppc_boot_device;
|
||||||
|
|
||||||
linux_boot = (kernel_filename != NULL);
|
linux_boot = (kernel_filename != NULL);
|
||||||
|
|
||||||
|
@ -212,6 +212,25 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size,
|
||||||
kernel_size = 0;
|
kernel_size = 0;
|
||||||
initrd_base = 0;
|
initrd_base = 0;
|
||||||
initrd_size = 0;
|
initrd_size = 0;
|
||||||
|
ppc_boot_device = '\0';
|
||||||
|
for (i = 0; i < boot_device[i] != '\0'; i++) {
|
||||||
|
ppc_boot_device = boot_device[i];
|
||||||
|
/* TOFIX: for now, the second IDE channel is not properly
|
||||||
|
* emulated. The Mac floppy disk are not emulated.
|
||||||
|
* For now, OHW cannot boot from the network.
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
if (ppc_boot_device >= 'a' && ppc_boot_device <= 'f')
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
if (ppc_boot_device >= 'c' && ppc_boot_device <= 'd')
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (ppc_boot_device == '\0') {
|
||||||
|
fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isa_mem_base = 0x80000000;
|
isa_mem_base = 0x80000000;
|
||||||
|
@ -272,7 +291,7 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size,
|
||||||
pmac_format_nvram_partition(nvr, 0x2000);
|
pmac_format_nvram_partition(nvr, 0x2000);
|
||||||
|
|
||||||
dbdma_init(&dbdma_mem_index);
|
dbdma_init(&dbdma_mem_index);
|
||||||
|
|
||||||
macio_init(pci_bus, 0x0017, 1, pic_mem_index, dbdma_mem_index,
|
macio_init(pci_bus, 0x0017, 1, pic_mem_index, dbdma_mem_index,
|
||||||
cuda_mem_index, nvr, 0, NULL);
|
cuda_mem_index, nvr, 0, NULL);
|
||||||
|
|
||||||
|
|
|
@ -521,7 +521,8 @@ CPUReadMemoryFunc *PPC_prep_io_read[] = {
|
||||||
#define NVRAM_SIZE 0x2000
|
#define NVRAM_SIZE 0x2000
|
||||||
|
|
||||||
/* PowerPC PREP hardware initialisation */
|
/* PowerPC PREP hardware initialisation */
|
||||||
static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_device,
|
static void ppc_prep_init (int ram_size, int vga_ram_size,
|
||||||
|
const char *boot_device,
|
||||||
DisplayState *ds, const char **fd_filename,
|
DisplayState *ds, const char **fd_filename,
|
||||||
int snapshot, const char *kernel_filename,
|
int snapshot, const char *kernel_filename,
|
||||||
const char *kernel_cmdline,
|
const char *kernel_cmdline,
|
||||||
|
@ -538,7 +539,7 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_devi
|
||||||
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
|
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
|
||||||
PCIBus *pci_bus;
|
PCIBus *pci_bus;
|
||||||
qemu_irq *i8259;
|
qemu_irq *i8259;
|
||||||
int ppc_boot_device = boot_device[0];
|
int ppc_boot_device;
|
||||||
|
|
||||||
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
|
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
|
||||||
if (sysctrl == NULL)
|
if (sysctrl == NULL)
|
||||||
|
@ -611,6 +612,17 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_devi
|
||||||
kernel_size = 0;
|
kernel_size = 0;
|
||||||
initrd_base = 0;
|
initrd_base = 0;
|
||||||
initrd_size = 0;
|
initrd_size = 0;
|
||||||
|
ppc_boot_device = '\0';
|
||||||
|
/* For now, OHW cannot boot from the network. */
|
||||||
|
for (i = 0; i < boot_device[i] != '\0'; i++) {
|
||||||
|
ppc_boot_device = boot_device[i];
|
||||||
|
if (ppc_boot_device >= 'a' && ppc_boot_device <= 'f')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ppc_boot_device == '\0') {
|
||||||
|
fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isa_mem_base = 0xc0000000;
|
isa_mem_base = 0xc0000000;
|
||||||
|
|
100
vl.c
100
vl.c
|
@ -162,12 +162,6 @@ static DisplayState display_state;
|
||||||
int nographic;
|
int nographic;
|
||||||
const char* keyboard_layout = NULL;
|
const char* keyboard_layout = NULL;
|
||||||
int64_t ticks_per_sec;
|
int64_t ticks_per_sec;
|
||||||
#if defined(TARGET_I386)
|
|
||||||
#define MAX_BOOT_DEVICES 3
|
|
||||||
#else
|
|
||||||
#define MAX_BOOT_DEVICES 1
|
|
||||||
#endif
|
|
||||||
static char boot_device[MAX_BOOT_DEVICES + 1];
|
|
||||||
int ram_size;
|
int ram_size;
|
||||||
int pit_min_timer_count = 0;
|
int pit_min_timer_count = 0;
|
||||||
int nb_nics;
|
int nb_nics;
|
||||||
|
@ -7587,14 +7581,16 @@ int main(int argc, char **argv)
|
||||||
int use_gdbstub;
|
int use_gdbstub;
|
||||||
const char *gdbstub_port;
|
const char *gdbstub_port;
|
||||||
#endif
|
#endif
|
||||||
|
uint32_t boot_devices_bitmap = 0;
|
||||||
int i, cdrom_index, pflash_index;
|
int i, cdrom_index, pflash_index;
|
||||||
int snapshot, linux_boot;
|
int snapshot, linux_boot, net_boot;
|
||||||
const char *initrd_filename;
|
const char *initrd_filename;
|
||||||
const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD];
|
const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD];
|
||||||
const char *pflash_filename[MAX_PFLASH];
|
const char *pflash_filename[MAX_PFLASH];
|
||||||
const char *sd_filename;
|
const char *sd_filename;
|
||||||
const char *mtd_filename;
|
const char *mtd_filename;
|
||||||
const char *kernel_filename, *kernel_cmdline;
|
const char *kernel_filename, *kernel_cmdline;
|
||||||
|
const char *boot_devices = "";
|
||||||
DisplayState *ds = &display_state;
|
DisplayState *ds = &display_state;
|
||||||
int cyls, heads, secs, translation;
|
int cyls, heads, secs, translation;
|
||||||
char net_clients[MAX_NET_CLIENTS][256];
|
char net_clients[MAX_NET_CLIENTS][256];
|
||||||
|
@ -7846,20 +7842,34 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_boot:
|
case QEMU_OPTION_boot:
|
||||||
if (strlen(optarg) > MAX_BOOT_DEVICES) {
|
boot_devices = optarg;
|
||||||
fprintf(stderr, "qemu: too many boot devices\n");
|
/* We just do some generic consistency checks */
|
||||||
exit(1);
|
{
|
||||||
}
|
/* Could easily be extended to 64 devices if needed */
|
||||||
strncpy(boot_device, optarg, MAX_BOOT_DEVICES);
|
const unsigned char *p;
|
||||||
#if defined(TARGET_SPARC) || defined(TARGET_I386)
|
|
||||||
#define BOOTCHARS "acdn"
|
boot_devices_bitmap = 0;
|
||||||
#else
|
for (p = boot_devices; *p != '\0'; p++) {
|
||||||
#define BOOTCHARS "acd"
|
/* Allowed boot devices are:
|
||||||
#endif
|
* a b : floppy disk drives
|
||||||
if (strlen(boot_device) != strspn(boot_device, BOOTCHARS)) {
|
* c ... f : IDE disk drives
|
||||||
fprintf(stderr, "qemu: invalid boot device "
|
* g ... m : machine implementation dependant drives
|
||||||
"sequence '%s'\n", boot_device);
|
* n ... p : network devices
|
||||||
exit(1);
|
* It's up to each machine implementation to check
|
||||||
|
* if the given boot devices match the actual hardware
|
||||||
|
* implementation and firmware features.
|
||||||
|
*/
|
||||||
|
if (*p < 'a' || *p > 'q') {
|
||||||
|
fprintf(stderr, "Invalid boot device '%c'\n", *p);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (boot_devices_bitmap & (1 << (*p - 'a'))) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Boot device '%c' was given twice\n",*p);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
boot_devices_bitmap |= 1 << (*p - 'a');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_fda:
|
case QEMU_OPTION_fda:
|
||||||
|
@ -8243,23 +8253,23 @@ int main(int argc, char **argv)
|
||||||
kqemu_allowed = 0;
|
kqemu_allowed = 0;
|
||||||
#endif
|
#endif
|
||||||
linux_boot = (kernel_filename != NULL);
|
linux_boot = (kernel_filename != NULL);
|
||||||
|
net_boot = (boot_devices_bitmap >> ('n' - 'a')) && 0xF;
|
||||||
if (!linux_boot &&
|
|
||||||
(!strchr(boot_device, 'n')) &&
|
/* XXX: this should not be: some embedded targets just have flash */
|
||||||
|
if (!linux_boot && net_boot == 0 &&
|
||||||
hd_filename[0] == '\0' &&
|
hd_filename[0] == '\0' &&
|
||||||
(cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
|
(cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
|
||||||
fd_filename[0] == '\0')
|
fd_filename[0] == '\0')
|
||||||
help(1);
|
help(1);
|
||||||
|
|
||||||
/* boot to floppy or the default cd if no hard disk defined yet */
|
/* boot to floppy or the default cd if no hard disk defined yet */
|
||||||
if (!boot_device[0]) {
|
if (!boot_devices[0]) {
|
||||||
if (hd_filename[0] != '\0')
|
if (hd_filename[0] != '\0')
|
||||||
boot_device[0] = 'c';
|
boot_devices = "c";
|
||||||
else if (fd_filename[0] != '\0')
|
else if (fd_filename[0] != '\0')
|
||||||
boot_device[0] = 'a';
|
boot_devices = "a";
|
||||||
else
|
else
|
||||||
boot_device[0] = 'd';
|
boot_devices = "d";
|
||||||
boot_device[1] = 0;
|
|
||||||
}
|
}
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
|
|
||||||
|
@ -8299,20 +8309,28 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TARGET_I386
|
#ifdef TARGET_I386
|
||||||
if (strchr(boot_device, 'n')) {
|
/* XXX: this should be moved in the PC machine instanciation code */
|
||||||
for (i = 0; i < nb_nics; i++) {
|
if (net_boot != 0) {
|
||||||
|
int netroms = 0;
|
||||||
|
for (i = 0; i < nb_nics && i < 4; i++) {
|
||||||
const char *model = nd_table[i].model;
|
const char *model = nd_table[i].model;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
if (model == NULL)
|
if (net_boot & (1 << i)) {
|
||||||
model = "ne2k_pci";
|
if (model == NULL)
|
||||||
snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", bios_dir, model);
|
model = "ne2k_pci";
|
||||||
if (get_image_size(buf) > 0) {
|
snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", bios_dir, model);
|
||||||
option_rom[nb_option_roms] = strdup(buf);
|
if (get_image_size(buf) > 0) {
|
||||||
nb_option_roms++;
|
if (nb_option_roms >= MAX_OPTION_ROMS) {
|
||||||
break;
|
fprintf(stderr, "Too many option ROMs\n");
|
||||||
}
|
exit(1);
|
||||||
|
}
|
||||||
|
option_rom[nb_option_roms] = strdup(buf);
|
||||||
|
nb_option_roms++;
|
||||||
|
netroms++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (i == nb_nics) {
|
if (netroms == 0) {
|
||||||
fprintf(stderr, "No valid PXE rom found for network device\n");
|
fprintf(stderr, "No valid PXE rom found for network device\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -8492,7 +8510,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
machine->init(ram_size, vga_ram_size, boot_device,
|
machine->init(ram_size, vga_ram_size, boot_devices,
|
||||||
ds, fd_filename, snapshot,
|
ds, fd_filename, snapshot,
|
||||||
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
|
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue