提交 95efd11c 编写于 作者: B blueswir1

Add support for -prom-env command line options

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6129 c046a42c-6fe2-441c-8c8c-71466251a162
上级 992e5acd
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "hw.h" #include "hw.h"
#include "firmware_abi.h"
#include "sysemu.h"
#include "ppc_mac.h" #include "ppc_mac.h"
/* debug NVR */ /* debug NVR */
...@@ -122,26 +124,35 @@ void macio_nvram_map (void *opaque, target_phys_addr_t mem_base) ...@@ -122,26 +124,35 @@ void macio_nvram_map (void *opaque, target_phys_addr_t mem_base)
cpu_register_physical_memory(mem_base, s->size, s->mem_index); cpu_register_physical_memory(mem_base, s->size, s->mem_index);
} }
static uint8_t nvram_chksum (const uint8_t *buf, int n) /* Set up a system OpenBIOS NVRAM partition */
{
int sum, i;
sum = 0;
for(i = 0; i < n; i++)
sum += buf[i];
return (sum & 0xff) + (sum >> 8);
}
/* set a free Mac OS NVRAM partition */
void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len) void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len)
{ {
uint8_t *buf; unsigned int i;
char partition_name[12] = "wwwwwwwwwwww"; uint32_t start = 0, end;
struct OpenBIOS_nvpart_v1 *part_header;
buf = nvr->data;
buf[0] = 0x7f; /* free partition magic */ // OpenBIOS nvram variables
buf[1] = 0; /* checksum */ // Variable partition
buf[2] = len >> 8; part_header = (struct OpenBIOS_nvpart_v1 *)nvr->data;
buf[3] = len; part_header->signature = OPENBIOS_PART_SYSTEM;
memcpy(buf + 4, partition_name, 12); pstrcpy(part_header->name, sizeof(part_header->name), "system");
buf[1] = nvram_chksum(buf, 16);
end = start + sizeof(struct OpenBIOS_nvpart_v1);
for (i = 0; i < nb_prom_envs; i++)
end = OpenBIOS_set_var(nvr->data, end, prom_envs[i]);
// End marker
nvr->data[end++] = '\0';
end = start + ((end - start + 15) & ~15);
OpenBIOS_finish_partition(part_header, end - start);
// free partition
start = end;
part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start];
part_header->signature = OPENBIOS_PART_FREE;
pstrcpy(part_header->name, sizeof(part_header->name), "free");
end = len;
OpenBIOS_finish_partition(part_header, end - start);
} }
...@@ -2343,6 +2343,18 @@ The following options are specific to the PowerPC emulation: ...@@ -2343,6 +2343,18 @@ The following options are specific to the PowerPC emulation:
Set the initial VGA graphic mode. The default is 800x600x15. Set the initial VGA graphic mode. The default is 800x600x15.
@item -prom-env string
Set OpenBIOS variables in NVRAM, for example:
@example
qemu-system-ppc -prom-env 'auto-boot?=false' \
-prom-env 'boot-device=hd:2,\yaboot' \
-prom-env 'boot-args=conf=hd:2,\yaboot.conf'
@end example
These variables are not used by Open Hack'Ware.
@end table @end table
@c man end @c man end
......
...@@ -108,7 +108,7 @@ extern int kqemu_allowed; ...@@ -108,7 +108,7 @@ extern int kqemu_allowed;
extern const char *option_rom[MAX_OPTION_ROMS]; extern const char *option_rom[MAX_OPTION_ROMS];
extern int nb_option_roms; extern int nb_option_roms;
#ifdef TARGET_SPARC #if defined(TARGET_SPARC) || defined(TARGET_PPC)
#define MAX_PROM_ENVS 128 #define MAX_PROM_ENVS 128
extern const char *prom_envs[MAX_PROM_ENVS]; extern const char *prom_envs[MAX_PROM_ENVS];
extern unsigned int nb_prom_envs; extern unsigned int nb_prom_envs;
......
...@@ -231,7 +231,7 @@ int old_param = 0; ...@@ -231,7 +231,7 @@ int old_param = 0;
#endif #endif
const char *qemu_name; const char *qemu_name;
int alt_grab = 0; int alt_grab = 0;
#ifdef TARGET_SPARC #if defined(TARGET_SPARC) || defined(TARGET_PPC)
unsigned int nb_prom_envs = 0; unsigned int nb_prom_envs = 0;
const char *prom_envs[MAX_PROM_ENVS]; const char *prom_envs[MAX_PROM_ENVS];
#endif #endif
...@@ -4185,7 +4185,7 @@ static const QEMUOption qemu_options[] = { ...@@ -4185,7 +4185,7 @@ static const QEMUOption qemu_options[] = {
{ "semihosting", 0, QEMU_OPTION_semihosting }, { "semihosting", 0, QEMU_OPTION_semihosting },
#endif #endif
{ "name", HAS_ARG, QEMU_OPTION_name }, { "name", HAS_ARG, QEMU_OPTION_name },
#if defined(TARGET_SPARC) #if defined(TARGET_SPARC) || defined(TARGET_PPC)
{ "prom-env", HAS_ARG, QEMU_OPTION_prom_env }, { "prom-env", HAS_ARG, QEMU_OPTION_prom_env },
#endif #endif
#if defined(TARGET_ARM) #if defined(TARGET_ARM)
...@@ -5049,7 +5049,7 @@ int main(int argc, char **argv, char **envp) ...@@ -5049,7 +5049,7 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_name: case QEMU_OPTION_name:
qemu_name = optarg; qemu_name = optarg;
break; break;
#ifdef TARGET_SPARC #if defined(TARGET_SPARC) || defined(TARGET_PPC)
case QEMU_OPTION_prom_env: case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) { if (nb_prom_envs >= MAX_PROM_ENVS) {
fprintf(stderr, "Too many prom variables\n"); fprintf(stderr, "Too many prom variables\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册