[OpenBIOS] [PATCH 07/14] display: move creation of "display" and "screen" properties to Forth

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Thu Aug 8 00:51:11 CEST 2013


This means we can remove this code from vga_vbe_init() and move it
in to the generic display system. As part of this, we alter the
"input" and "output" words so that they update the stdin/stdout
handles under /chosen.

While we are here, fix up the various architectures so that they
don't call "input" and "output" themselves - this is now handled
by the Forth console.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 openbios-devel/arch/ppc/qemu/init.c     |   18 ------------------
 openbios-devel/arch/sparc32/openbios.c  |   16 ++--------------
 openbios-devel/arch/sparc64/openbios.c  |   18 ------------------
 openbios-devel/drivers/vga_vbe.c        |   10 +---------
 openbios-devel/forth/admin/iocontrol.fs |   16 ++++++++++++++++
 openbios-devel/forth/device/display.fs  |    8 ++++++++
 6 files changed, 27 insertions(+), 59 deletions(-)

diff --git a/openbios-devel/arch/ppc/qemu/init.c b/openbios-devel/arch/ppc/qemu/init.c
index 345fc69..54ac6f2 100644
--- a/openbios-devel/arch/ppc/qemu/init.c
+++ b/openbios-devel/arch/ppc/qemu/init.c
@@ -870,18 +870,6 @@ arch_of_init(void)
     fword("find-device");
 
     push_str(stdin_path);
-    fword("open-dev");
-    fword("encode-int");
-    push_str("stdin");
-    fword("property");
-
-    push_str(stdout_path);
-    fword("open-dev");
-    fword("encode-int");
-    push_str("stdout");
-    fword("property");
-
-    push_str(stdin_path);
     fword("pathres-resolve-aliases");
     push_str("input-device");
     fword("$setenv");
@@ -891,12 +879,6 @@ arch_of_init(void)
     push_str("output-device");
     fword("$setenv");
 
-    push_str(stdin_path);
-    fword("input");
-
-    push_str(stdout_path);
-    fword("output");
-
 #if 0
     if(getbool("tty-interface?") == 1)
 #endif
diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c
index 40948d1..542ca80 100644
--- a/openbios-devel/arch/sparc32/openbios.c
+++ b/openbios-devel/arch/sparc32/openbios.c
@@ -748,7 +748,6 @@ static void setup_stdio(void)
 {
     char nographic;
     const char *stdin, *stdout;
-    phandle_t chosen;
 
     fw_cfg_read(FW_CFG_NOGRAPHIC, &nographic, 1);
     if (nographic) {
@@ -766,6 +765,8 @@ static void setup_stdio(void)
     push_str("/");
     fword("find-device");
 
+    /* stdin-path/stdout-path properties aren't part of the spec
+       but Solaris needs them */
     push_str(stdin);
     fword("pathres-resolve-aliases");
     fword("encode-string");
@@ -778,16 +779,6 @@ static void setup_stdio(void)
     push_str("stdout-path");
     fword("property");
 
-    chosen = find_dev("/chosen");
-    push_str(stdin);
-    fword("open-dev");
-    set_int_property(chosen, "stdin", POP());
-
-    chosen = find_dev("/chosen");
-    push_str(stdout);
-    fword("open-dev");
-    set_int_property(chosen, "stdout", POP());
-
     push_str(stdin);
     push_str("input-device");
     fword("$setenv");
@@ -796,9 +787,6 @@ static void setup_stdio(void)
     push_str("output-device");
     fword("$setenv");
 
-    push_str(stdin);
-    fword("input");
-
     obp_stdin_path = stdin;
     obp_stdout_path = stdout;
 }
diff --git a/openbios-devel/arch/sparc64/openbios.c b/openbios-devel/arch/sparc64/openbios.c
index b1e5f47..51d181f 100644
--- a/openbios-devel/arch/sparc64/openbios.c
+++ b/openbios-devel/arch/sparc64/openbios.c
@@ -505,30 +505,12 @@ void arch_nvram_get(char *data)
     }
 
     push_str(stdin_path);
-    fword("open-dev");
-    fword("encode-int");
-    push_str("stdin");
-    fword("property");
-
-    push_str(stdout_path);
-    fword("open-dev");
-    fword("encode-int");
-    push_str("stdout");
-    fword("property");
-
-    push_str(stdin_path);
     push_str("input-device");
     fword("$setenv");
 
     push_str(stdout_path);
     push_str("output-device");
     fword("$setenv");
-
-    push_str(stdin_path);
-    fword("input");
-
-    push_str(stdout_path);
-    fword("output");
 }
 
 void arch_nvram_put(char *data)
diff --git a/openbios-devel/drivers/vga_vbe.c b/openbios-devel/drivers/vga_vbe.c
index c03dbc7..02fbfb4 100644
--- a/openbios-devel/drivers/vga_vbe.c
+++ b/openbios-devel/drivers/vga_vbe.c
@@ -55,7 +55,7 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size,
                   unsigned long rom, uint32_t rom_size)
 {
 	phys_addr_t phys;
-	phandle_t ph, chosen, aliases;
+	phandle_t ph;
 	int size;
 
 	phys = fb;
@@ -73,14 +73,6 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size,
     ph = get_cur_dev();
 #endif
 
-	chosen = find_dev("/chosen");
-	push_str(path);
-	fword("open-dev");
-	set_int_property(chosen, "display", POP());
-
-	aliases = find_dev("/aliases");
-	set_property(aliases, "screen", path, strlen(path) + 1);
-
 	if (rom_size >= 8) {
                 const char *p;
 
diff --git a/openbios-devel/forth/admin/iocontrol.fs b/openbios-devel/forth/admin/iocontrol.fs
index 0268ab3..c28adad 100644
--- a/openbios-devel/forth/admin/iocontrol.fs
+++ b/openbios-devel/forth/admin/iocontrol.fs
@@ -36,6 +36,14 @@ variable stdin
     close-dev
   then
   stdin !
+
+  \ update /chosen
+  my-self active-package 0 to my-self
+  " /chosen" find-package if
+   active-package!
+   stdin @ encode-int " stdin" property
+  then
+  active-package! to my-self
 ;
 
 : output    ( dev-str dev-len -- )
@@ -57,6 +65,14 @@ variable stdin
   \ close old stdout
   stdout @ ?dup if close-dev then
   stdout !
+
+  \ update /chosen
+  my-self active-package 0 to my-self
+  " /chosen" find-package if
+   active-package!
+   stdout @ encode-int " stdout" property
+  then
+  active-package! to my-self
 ;
 
 : io    ( dev-str dev-len -- )
diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs
index 6d77dfa..8a895d6 100644
--- a/openbios-devel/forth/device/display.fs
+++ b/openbios-devel/forth/device/display.fs
@@ -356,6 +356,14 @@ defer fb8-invertrect
 
   my-self to display-ih
 
+  \ set /chosen display property
+  my-self active-package 0 to my-self
+  " /chosen" (find-dev) 0<> if
+    active-package!
+    display-ih encode-int " display" property
+  then
+  active-package! to my-self
+
   \ set defer functions to 8bit versions
 
   ['] fb8-draw-character to draw-character
-- 
1.7.10.4




More information about the OpenBIOS mailing list