Commit 95efd11c121ed5ba9677f9fbaf0cefa8e52cb02e

Authored by blueswir1
1 parent 992e5acd

Add support for -prom-env command line options

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6129 c046a42c-6fe2-441c-8c8c-71466251a162
hw/mac_nvram.c
... ... @@ -23,6 +23,8 @@
23 23 * THE SOFTWARE.
24 24 */
25 25 #include "hw.h"
  26 +#include "firmware_abi.h"
  27 +#include "sysemu.h"
26 28 #include "ppc_mac.h"
27 29  
28 30 /* debug NVR */
... ... @@ -122,26 +124,35 @@ void macio_nvram_map (void *opaque, target_phys_addr_t mem_base)
122 124 cpu_register_physical_memory(mem_base, s->size, s->mem_index);
123 125 }
124 126  
125   -static uint8_t nvram_chksum (const uint8_t *buf, int n)
126   -{
127   - int sum, i;
128   - sum = 0;
129   - for(i = 0; i < n; i++)
130   - sum += buf[i];
131   - return (sum & 0xff) + (sum >> 8);
132   -}
133   -
134   -/* set a free Mac OS NVRAM partition */
  127 +/* Set up a system OpenBIOS NVRAM partition */
135 128 void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len)
136 129 {
137   - uint8_t *buf;
138   - char partition_name[12] = "wwwwwwwwwwww";
139   -
140   - buf = nvr->data;
141   - buf[0] = 0x7f; /* free partition magic */
142   - buf[1] = 0; /* checksum */
143   - buf[2] = len >> 8;
144   - buf[3] = len;
145   - memcpy(buf + 4, partition_name, 12);
146   - buf[1] = nvram_chksum(buf, 16);
  130 + unsigned int i;
  131 + uint32_t start = 0, end;
  132 + struct OpenBIOS_nvpart_v1 *part_header;
  133 +
  134 + // OpenBIOS nvram variables
  135 + // Variable partition
  136 + part_header = (struct OpenBIOS_nvpart_v1 *)nvr->data;
  137 + part_header->signature = OPENBIOS_PART_SYSTEM;
  138 + pstrcpy(part_header->name, sizeof(part_header->name), "system");
  139 +
  140 + end = start + sizeof(struct OpenBIOS_nvpart_v1);
  141 + for (i = 0; i < nb_prom_envs; i++)
  142 + end = OpenBIOS_set_var(nvr->data, end, prom_envs[i]);
  143 +
  144 + // End marker
  145 + nvr->data[end++] = '\0';
  146 +
  147 + end = start + ((end - start + 15) & ~15);
  148 + OpenBIOS_finish_partition(part_header, end - start);
  149 +
  150 + // free partition
  151 + start = end;
  152 + part_header = (struct OpenBIOS_nvpart_v1 *)&nvr->data[start];
  153 + part_header->signature = OPENBIOS_PART_FREE;
  154 + pstrcpy(part_header->name, sizeof(part_header->name), "free");
  155 +
  156 + end = len;
  157 + OpenBIOS_finish_partition(part_header, end - start);
147 158 }
... ...
qemu-doc.texi
... ... @@ -2343,6 +2343,18 @@ The following options are specific to the PowerPC emulation:
2343 2343  
2344 2344 Set the initial VGA graphic mode. The default is 800x600x15.
2345 2345  
  2346 +@item -prom-env string
  2347 +
  2348 +Set OpenBIOS variables in NVRAM, for example:
  2349 +
  2350 +@example
  2351 +qemu-system-ppc -prom-env 'auto-boot?=false' \
  2352 + -prom-env 'boot-device=hd:2,\yaboot' \
  2353 + -prom-env 'boot-args=conf=hd:2,\yaboot.conf'
  2354 +@end example
  2355 +
  2356 +These variables are not used by Open Hack'Ware.
  2357 +
2346 2358 @end table
2347 2359  
2348 2360 @c man end
... ...
sysemu.h
... ... @@ -108,7 +108,7 @@ extern int kqemu_allowed;
108 108 extern const char *option_rom[MAX_OPTION_ROMS];
109 109 extern int nb_option_roms;
110 110  
111   -#ifdef TARGET_SPARC
  111 +#if defined(TARGET_SPARC) || defined(TARGET_PPC)
112 112 #define MAX_PROM_ENVS 128
113 113 extern const char *prom_envs[MAX_PROM_ENVS];
114 114 extern unsigned int nb_prom_envs;
... ...
... ... @@ -231,7 +231,7 @@ int old_param = 0;
231 231 #endif
232 232 const char *qemu_name;
233 233 int alt_grab = 0;
234   -#ifdef TARGET_SPARC
  234 +#if defined(TARGET_SPARC) || defined(TARGET_PPC)
235 235 unsigned int nb_prom_envs = 0;
236 236 const char *prom_envs[MAX_PROM_ENVS];
237 237 #endif
... ... @@ -4185,7 +4185,7 @@ static const QEMUOption qemu_options[] = {
4185 4185 { "semihosting", 0, QEMU_OPTION_semihosting },
4186 4186 #endif
4187 4187 { "name", HAS_ARG, QEMU_OPTION_name },
4188   -#if defined(TARGET_SPARC)
  4188 +#if defined(TARGET_SPARC) || defined(TARGET_PPC)
4189 4189 { "prom-env", HAS_ARG, QEMU_OPTION_prom_env },
4190 4190 #endif
4191 4191 #if defined(TARGET_ARM)
... ... @@ -5049,7 +5049,7 @@ int main(int argc, char **argv, char **envp)
5049 5049 case QEMU_OPTION_name:
5050 5050 qemu_name = optarg;
5051 5051 break;
5052   -#ifdef TARGET_SPARC
  5052 +#if defined(TARGET_SPARC) || defined(TARGET_PPC)
5053 5053 case QEMU_OPTION_prom_env:
5054 5054 if (nb_prom_envs >= MAX_PROM_ENVS) {
5055 5055 fprintf(stderr, "Too many prom variables\n");
... ...