[OpenBIOS] [commit] r1214 - in trunk/openbios-devel: arch/sparc32 drivers include/drivers

repository service svn at openbios.org
Mon Aug 19 09:40:30 CEST 2013


Author: mcayland
Date: Mon Aug 19 09:40:29 2013
New Revision: 1214
URL: http://tracker.coreboot.org/trac/openbios/changeset/1214

Log:
tcx.fs: move DAC programming from C to tcx.fs

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>

Modified:
   trunk/openbios-devel/arch/sparc32/console.c
   trunk/openbios-devel/drivers/sbus.c
   trunk/openbios-devel/drivers/tcx.fs
   trunk/openbios-devel/include/drivers/drivers.h

Modified: trunk/openbios-devel/arch/sparc32/console.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/console.c	Mon Aug 19 09:40:26 2013	(r1213)
+++ trunk/openbios-devel/arch/sparc32/console.c	Mon Aug 19 09:40:29 2013	(r1214)
@@ -22,32 +22,12 @@
 
 #define VMEM_BASE 0x00800000ULL
 #define VMEM_SIZE (1024*768*1)
-#define DAC_BASE  0x00200000ULL
-#define DAC_SIZE  16
 
 unsigned char *vmem;
-volatile uint32_t *dac;
 
 void tcx_init(uint64_t base)
 {
     vmem = (unsigned char *)ofmem_map_io(base + VMEM_BASE, VMEM_SIZE);
-    dac = (uint32_t *)ofmem_map_io(base + DAC_BASE, DAC_SIZE);
-}
-
-/* ( r g b index -- ) */
-void tcx_hw_set_color(void)
-{
-    int index = POP();
-    int b = POP();
-    int g = POP();
-    int r = POP();
-
-    if( VIDEO_DICT_VALUE(video.depth) == 8 ) {
-        dac[0] = index << 24;
-        dac[1] = r << 24; // Red
-        dac[1] = g << 24; // Green
-        dac[1] = b << 24; // Blue
-    }
 }
 
 #endif

Modified: trunk/openbios-devel/drivers/sbus.c
==============================================================================
--- trunk/openbios-devel/drivers/sbus.c	Mon Aug 19 09:40:26 2013	(r1213)
+++ trunk/openbios-devel/drivers/sbus.c	Mon Aug 19 09:40:29 2013	(r1214)
@@ -141,207 +141,8 @@
 static void
 ob_tcx_init(unsigned int slot, const char *path)
 {
-    phandle_t chosen;
-
     push_str(path);
     fword("find-device");
-
-    PUSH(slot);
-    fword("encode-int");
-    PUSH(0x00800000);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00100000);
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x02000000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00400000);
-    } else {
-        PUSH(0x00000001);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x04000000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00400000);
-    } else {
-        PUSH(0x00000001);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x06000000);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00800000);
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x0a000000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00400000);
-    } else {
-        PUSH(0x00000001);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x0c000000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00800000);
-    } else {
-        PUSH(0x00000001);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x0e000000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00800000);
-    } else {
-        PUSH(0x00000001);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00700000);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00001000);
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00200000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00004000);
-    } else {
-        PUSH(0x00000004);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00301000);
-    } else {
-        PUSH(0x00300000);
-    }
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00001000);
-    } else {
-        PUSH(0x0000081c);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00000000);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00010000);
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00240000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00004000);
-    } else {
-        PUSH(0x00000004);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    PUSH(slot);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00280000);
-    fword("encode-int");
-    fword("encode+");
-    if (graphic_depth == 24) {
-        PUSH(0x00008000);
-    } else {
-        PUSH(0x00000001);
-    }
-    fword("encode-int");
-    fword("encode+");
-
-    push_str("reg");
-    fword("property");
-
-    PUSH((int)graphic_depth);
-    fword("encode-int");
-    push_str("depth");
-    fword("property");
-
-    if (graphic_depth == 8) {
-        push_str("true");
-        fword("encode-string");
-        push_str("tcx-8-bit");
-        fword("property");
-    }
-
-    /* Even with a 24-bit enabled TCX card, the control plane is
-       used in 8-bit mode. So force the video subsystem into 8-bit
-       mode before initialisation. */
-    if (graphic_depth == 24) {
-        VIDEO_DICT_VALUE(video.depth) = 8;
-        VIDEO_DICT_VALUE(video.rb) = VIDEO_DICT_VALUE(video.w);
-
-        chosen = get_cur_dev();
-        set_int_property(chosen, "linebytes", VIDEO_DICT_VALUE(video.rb));
-    }
-
-    bind_func("hw-set-color", tcx_hw_set_color);
 }
 
 static void

Modified: trunk/openbios-devel/drivers/tcx.fs
==============================================================================
--- trunk/openbios-devel/drivers/tcx.fs	Mon Aug 19 09:40:26 2013	(r1213)
+++ trunk/openbios-devel/drivers/tcx.fs	Mon Aug 19 09:40:29 2013	(r1214)
@@ -35,6 +35,146 @@
 : line-bytes line-bytes-xt @ ;
 
 \
+\ Registers
+\
+
+h# 0 constant tcx-off1
+h# 10000 constant /tcx-off1
+
+h# 200000 constant tcx-off-dac
+h# 4000 constant /tcx-off-dac-24
+h# 4 constant /tcx-off-dac-8
+
+h# 240000 constant tcx-off3
+h# 4000 constant /tcx-off3-24
+h# 4 constant /tcx-off3-8
+
+h# 280000 constant tcx-off4
+h# 8000 constant /tcx-off4-24
+h# 1 constant /tcx-off4-8
+
+h# 301000 constant tcx-off5-24
+h# 300000 constant tcx-off5-8
+h# 1000 constant /tcx-off5-24
+h# 81c constant /tcx-off5-8
+
+h# 700000 constant tcx-off6
+h# 1000 constant /tcx-off6
+
+h# 800000 constant tcx-off-fb
+h# 100000 constant /tcx-off-fb
+
+h# 2000000 constant tcx-off8
+h# 400000 constant /tcx-off8-24
+h# 1 constant /tcx-off8-8
+
+h# 4000000 constant tcx-off9
+h# 400000 constant /tcx-off9-24
+h# 1 constant /tcx-off9-8
+
+h# 6000000 constant tcx-off10
+h# 800000 constant /tcx-off10
+
+h# a000000 constant tcx-off11
+h# 400000 constant /tcx-off11-24
+h# 1 constant /tcx-off11-8
+
+h# c000000 constant tcx-off12
+h# 800000 constant /tcx-off12-24
+h# 1 constant /tcx-off12-8
+
+h# e000000 constant tcx-off13
+h# 800000 constant /tcx-off13-24
+h# 1 constant /tcx-off13-8
+
+: >tcx-reg-spec ( offset size -- encoded-reg )
+  >r 0 my-address d+ my-space encode-phys r> encode-int encode+
+;
+
+: tcx-8bit-reg
+  \ WARNING: order is important (at least to Solaris)
+  tcx-off-fb /tcx-off-fb >tcx-reg-spec
+  tcx-off8 /tcx-off8-8 >tcx-reg-spec encode+
+  tcx-off9 /tcx-off9-8 >tcx-reg-spec encode+
+  tcx-off10 /tcx-off10 >tcx-reg-spec encode+
+  tcx-off11 /tcx-off11-8 >tcx-reg-spec encode+
+  tcx-off12 /tcx-off12-8 >tcx-reg-spec encode+
+  tcx-off13 /tcx-off13-8 >tcx-reg-spec encode+
+  tcx-off6 /tcx-off6 >tcx-reg-spec encode+
+  tcx-off-dac /tcx-off-dac-8 >tcx-reg-spec encode+
+  tcx-off5-8 /tcx-off5-8 >tcx-reg-spec encode+
+  tcx-off1 /tcx-off1 >tcx-reg-spec encode+
+  tcx-off3 /tcx-off3-8 >tcx-reg-spec encode+
+  tcx-off4 /tcx-off4-8 >tcx-reg-spec encode+
+  " reg" property
+;
+
+: tcx-24bit-reg
+  \ WARNING: order is important (at least to Solaris)
+  tcx-off-fb /tcx-off-fb >tcx-reg-spec
+  tcx-off8 /tcx-off8-24 >tcx-reg-spec encode+
+  tcx-off9 /tcx-off9-24 >tcx-reg-spec encode+
+  tcx-off10 /tcx-off10 >tcx-reg-spec encode+
+  tcx-off11 /tcx-off11-24 >tcx-reg-spec encode+
+  tcx-off12 /tcx-off12-24 >tcx-reg-spec encode+
+  tcx-off13 /tcx-off13-24 >tcx-reg-spec encode+
+  tcx-off6 /tcx-off6 >tcx-reg-spec encode+
+  tcx-off-dac /tcx-off-dac-24 >tcx-reg-spec encode+
+  tcx-off5-24 /tcx-off5-24 >tcx-reg-spec encode+
+  tcx-off1 /tcx-off1 >tcx-reg-spec encode+
+  tcx-off3 /tcx-off3-24 >tcx-reg-spec encode+
+  tcx-off4 /tcx-off4-24 >tcx-reg-spec encode+
+  " reg" property
+;
+
+: do-map-in ( offset size -- virt )
+  >r my-space r> " map-in" $call-parent
+;
+
+: do-map-out ( virt size )
+  " map-out" $call-parent
+;
+
+\
+\ DAC
+\
+
+-1 value tcx-dac
+-1 value /tcx-dac
+
+: dac! ( data reg# -- )
+  >r dup 2dup bljoin r> tcx-dac + l!
+;
+
+: color!  ( r g b c# -- )
+  0 dac!       ( r g b )
+  swap rot     ( b g r )
+  4 dac!       ( b g )
+  4 dac!       ( b )
+  4 dac!       (  )
+;
+
+\
+\ Mapping
+\
+
+: dac-map
+  tcx-off-dac /tcx-dac do-map-in to tcx-dac
+;
+
+: map-regs
+  dac-map
+;
+
+external
+
+: hw-set-color
+  color!
+;
+
+headerless
+
+\
 \ Installation
 \
 
@@ -42,14 +182,36 @@
 " display" device-type
 
 : qemu-tcx-driver-install ( -- )
-  openbios-video-addr to frame-buffer-adr
-  default-font set-font
-  openbios-video-width openbios-video-height over char-width / over char-height /
-  fb8-install
+  tcx-dac -1 = if
+    map-regs
+    openbios-video-addr to frame-buffer-adr
+    default-font set-font
+
+    frame-buffer-adr encode-int " address" property
+
+    openbios-video-width openbios-video-height over char-width / over char-height /
+    fb8-install
+  then
 ;
 
 : qemu-tcx-driver-init
 
+  \ Handle differences between 8-bit/24-bit mode
+  depth-bits 8 = if
+    tcx-8bit-reg
+    /tcx-off-dac-8 to /tcx-dac
+    " true" encode-string " tcx-8-bit" property
+  else
+    tcx-24bit-reg
+    /tcx-off-dac-24 to /tcx-dac
+
+    \ Even with a 24-bit enabled TCX card, the control plane is
+    \ used in 8-bit mode. So force the video subsystem into 8-bit
+    \ mode before initialisation.
+    8 depth-bits-xt !
+    openbios-video-width line-bytes-xt !
+  then
+
   h# 1d encode-int " vbporch" property
   h# a0 encode-int " hbporch" property
   h# 06 encode-int " vsync" property

Modified: trunk/openbios-devel/include/drivers/drivers.h
==============================================================================
--- trunk/openbios-devel/include/drivers/drivers.h	Mon Aug 19 09:40:26 2013	(r1213)
+++ trunk/openbios-devel/include/drivers/drivers.h	Mon Aug 19 09:40:29 2013	(r1214)
@@ -47,7 +47,6 @@
 
 /* arch/sparc32/console.c */
 void tcx_init(uint64_t base);
-void tcx_hw_set_color(void);
 void kbd_init(uint64_t base);
 #endif
 #ifdef CONFIG_DRIVER_IDE



More information about the OpenBIOS mailing list