Implement the add-resolutions word. It will copy the user resolutions in the options node's resolutions property to the QEMU,VGA node's fb-modes property.
Signed-off-by: John Arbuckle programmingkidx@gmail.com --- This patch depends on the vga resolutions patch. Moved the code to the vga.fs file. Replaced local variables with values.
arch/ppc/qemu/init.c | 2 +- drivers/vga.fs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c index 6f21814..df873ce 100644 --- a/arch/ppc/qemu/init.c +++ b/arch/ppc/qemu/init.c @@ -631,7 +631,7 @@ go(void) if (find_dev("/rom/macos")) { fword("insert-copyright-property"); } - + feval("add-resolutions"); feval("saved-program-state >sps.entry @"); addr = POP();
diff --git a/drivers/vga.fs b/drivers/vga.fs index 0411462..fb3749f 100644 --- a/drivers/vga.fs +++ b/drivers/vga.fs @@ -225,4 +225,80 @@ headerless
qemu-vga-driver-init
+ +\ Adds user's resolutions from /Options node's resolutions property to +\ /pci/QEMU,VGA node's fb-modes property. +\ Turns a string of "widthxheight,..." into an array of ints. + +0 value fb-mode-addr +0 value fb-mode-len +0 value res-value +0 value res-addr +0 value res-len + +: add-resolutions ( -- ) + decimal + " /options" " find-device" evaluate ( -- ) + " resolutions" " active-package" evaluate + " get-package-property" evaluate ( -- res-addr res-len false ) + abort" " \ Fail quietly because user resolutions are optional + to res-len + to res-addr + + \ Add the first resolution value to the array + 0 0 res-addr res-len + " >number" evaluate + to res-len to res-addr + drop encode-int + to fb-mode-len to fb-mode-addr + res-addr res-len 1 " /string" evaluate + to res-len to res-addr + + begin + res-len 0 = not + while + 0 0 + res-addr res-len + " >number" evaluate ( ud1 c-addr1 u1 -- ud2 0 c-addr2 u2 ) + to res-len + to res-addr + drop + to res-value + + \ go to the next number after 'x' or ',' + res-addr res-len 1 " /string" evaluate + to res-len + to res-addr + + \ Encode and add res-value to array + fb-mode-addr fb-mode-len res-value ( -- fb-mode-addr fb-mode-len res-value ) + encode-int ( -- new-fb-mode-addr new-fb-mode-len ) + encode+ ( -- new-fb-mode-addr new-fb-mode-len ) + to fb-mode-len + to fb-mode-addr + repeat + + \ Get the original resolutions + " /pci/QEMU,VGA" " find-device" evaluate ( -- ) + " fb-modes" " active-package" evaluate + get-package-property ( -- prop-addr prop-len false ) + abort" Could not find fb-modes property in QEMU,VGA node!" ( -- prop-addr prop-len ) + + \ Needed to fix a limit of encode+ + encode-bytes ( -- new-prop-addr new-prop-len ) + + fb-mode-addr fb-mode-len ( -- new-prop-addr new-prop-len fb-mode-addr fb-mode-len ) + 2swap ( -- fb-mode-addr fb-mode-len new-prop-addr new-prop-len ) + + \ Add user resolutions first then add built-in resolutions if space permits + encode+ ( -- new-addr new-len ) + to fb-mode-len + to fb-mode-addr + + \ Update fb-modes property + " /pci/QEMU,VGA" " find-device" evaluate + fb-mode-addr fb-mode-len + " fb-modes" property +; + end0