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:
j_mayer 2007-11-11 01:50:45 +00:00
parent aba9ee8726
commit 28c5af54c6
5 changed files with 125 additions and 51 deletions

22
hw/pc.c
View file

@ -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)
{
RTCState *s = rtc_state;
int nbds, bds[3] = { 0, };
int val;
int fd0, fd1, nb;
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);
/* set boot devices, and disable floppy signature check if requested */
rtc_set_memory(s, 0x3d,
boot_device2nibble(boot_device[1]) << 4 |
boot_device2nibble(boot_device[0]) );
rtc_set_memory(s, 0x38,
boot_device2nibble(boot_device[2]) << 4 | (fd_bootchk ? 0x0 : 0x1));
#define PC_MAX_BOOT_DEVICES 3
nbds = strlen(boot_device);
if (nbds > PC_MAX_BOOT_DEVICES) {
fprintf(stderr, "Too many boot devices for PC\n");
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 */

View file

@ -74,7 +74,7 @@ static void ppc_core99_init (int ram_size, int vga_ram_size,
qemu_irq *dummy_irq;
int pic_mem_index, dbdma_mem_index, cuda_mem_index;
int ide_mem_index[2];
int ppc_boot_device = boot_device[0];
int ppc_boot_device;
linux_boot = (kernel_filename != NULL);
@ -175,6 +175,19 @@ static void ppc_core99_init (int ram_size, int vga_ram_size,
kernel_size = 0;
initrd_base = 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;

View file

@ -113,7 +113,7 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size,
int vga_bios_size, bios_size;
qemu_irq *dummy_irq;
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);
@ -212,6 +212,25 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size,
kernel_size = 0;
initrd_base = 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;
@ -272,7 +291,7 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size,
pmac_format_nvram_partition(nvr, 0x2000);
dbdma_init(&dbdma_mem_index);
macio_init(pci_bus, 0x0017, 1, pic_mem_index, dbdma_mem_index,
cuda_mem_index, nvr, 0, NULL);

View file

@ -521,7 +521,8 @@ CPUReadMemoryFunc *PPC_prep_io_read[] = {
#define NVRAM_SIZE 0x2000
/* 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,
int snapshot, const char *kernel_filename,
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;
PCIBus *pci_bus;
qemu_irq *i8259;
int ppc_boot_device = boot_device[0];
int ppc_boot_device;
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
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;
initrd_base = 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;