convert_to_ints() converts all the string resolutions in the resolutions property of the QEMU,VGA node and converts them to an int array.
Signed-off-by: John Arbuckle programmingkidx@gmail.com --- arch/ppc/qemu/init.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c index 6f21814..b6c7db0 100644 --- a/arch/ppc/qemu/init.c +++ b/arch/ppc/qemu/init.c @@ -619,6 +619,83 @@ id_cpu(void) } }
+ +/* convert ASCII string to number */ +static int atoi(const char *str) +{ + int result = 0; + while (*str) { + result = result * 10 + *str - '0'; + str++; + } + return result; +} + +void convert_to_ints(void); + +/* Converts the QEMU,VGA node's resolutions property to int's*/ +void convert_to_ints(void) +{ + const int max_buffer_size = 200; + char *orig_property; + char buffer[max_buffer_size]; + int index, count, value, addr, len; + char c; + + count = 0; + index = 0; + push_str("/pci/QEMU,VGA"); + fword("find-package"); + if (POP() == 0) { + fword("cr"); + push_str("convert-to-ints(): could not find package /pci/QEMU,VGA!"); + fword("type"); + fword("cr"); + return; + } + fword("active-package!"); + push_str("resolutions"); + fword("active-package"); + fword("get-package-property"); + if (POP() == -1) { + fword("cr"); + push_str("convert-to-ints(): could not find resolutions property!"); + fword("type"); + fword("cr"); + return; + } + len = POP(); + addr = POP(); + orig_property = (char *) malloc(len); + strncpy(orig_property, (char *)addr, len); + c = orig_property[0]; + while(c != '\0') { + if (c == 'x' || c == ',') { + buffer[index] = '\0'; + value = atoi(buffer); + count++; + if (count == 3) { + count = 1; + fword("encode+"); + continue; + } + PUSH(value); + fword("encode-int"); + index = -1; + } + else { + buffer[index] = c; + } + index++; + c = *(++orig_property); + } + fword("encode+"); + push_str("resolutions"); + fword("property"); + free(orig_property); +} + + static void go(void); unsigned int start_elf(unsigned long entry_point, unsigned long param);
@@ -632,6 +709,10 @@ go(void) fword("insert-copyright-property"); }
+ /* Used to support user specified resolutions */ + fword("copy-resolutions-property"); + convert_to_ints(); + feval("saved-program-state >sps.entry @"); addr = POP();
@@ -1078,3 +1159,4 @@ arch_of_init(void) bind_func("platform-boot", boot); bind_func("(go)", go); } +