[openfirmware] [commit] r2383 - cpu/x86/pc dev/isa

repository service svn at openfirmware.info
Sat Jul 16 14:18:36 CEST 2011


Author: wmb
Date: Sat Jul 16 14:18:36 2011
New Revision: 2383
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2383

Log:
Support for memory-mapped x86 UARTs.

Modified:
   cpu/x86/pc/report.fth
   dev/isa/diaguart.fth

Modified: cpu/x86/pc/report.fth
==============================================================================
--- cpu/x86/pc/report.fth	Sat Jul 16 14:16:14 2011	(r2382)
+++ cpu/x86/pc/report.fth	Sat Jul 16 14:18:36 2011	(r2383)
@@ -3,23 +3,37 @@
 
 \ write a byte to an ISA port
 : isa-c!   ( n a - )  "  # dx mov   # al mov   al dx out " evaluate  ;
+: mem-c!   ( n a -- )  " >r # r> #) byte mov" evaluate  ;
 
+: ureg!  ( byte offset -- )
+   [ifdef] mem-uart-base
+      mem-uart-base + mem-c!
+   [else]
+      h# 3f8 + isa-c!
+   [then]
+;
 [ifdef] debug-startup
 : init-com1  ( -- )
-   h#  1  h# 3fc  isa-c!	\ DTR on
-   h# 80  h# 3fb  isa-c!	\ Enable divisor latch
-   h# 01  h# 3f8  isa-c!	\ Baud rate divisor low - 115200 baud
-   h#  0  h# 3f9  isa-c!	\ Baud rate divisor high - 115200 baud
-   h#  3  h# 3fb  isa-c!	\ 8 bits, no parity
-   h#  0  h# 3f9  isa-c!        \ Interrupts off
-   h#  1  h# 3fa  isa-c!        \ Enable FIFO
+   h#  1  4 ureg!	\ DTR on
+   h# 80  3 ureg!	\ Enable divisor latch
+   h# 01  0 ureg!	\ Baud rate divisor low - 115200 baud
+   h#  0  1 ureg!	\ Baud rate divisor high - 115200 baud
+   h#  3  3 ureg!	\ 8 bits, no parity
+   h#  0  1 ureg!        \ Interrupts off
+   h#  1  2 ureg!        \ Enable FIFO
 ;
 
 \ Assembler macro to assemble code to send the character "char" to COM1
 : report  ( char -- )
+[ifdef] mem-uart-base
+   " begin   h# 20 #  mem-uart-base 5 + #) byte test  0<> until" evaluate
+   ( char )  " # mem-uart-base #) byte mov" evaluate
+   " begin   h# 20 #  mem-uart-base 5 + #) byte test  0<> until" evaluate
+[else]
    " begin   h# 3fd # dx mov   dx al in   h# 20 # al and  0<> until" evaluate
    ( char )  " # al mov   h# 3f8 # dx mov  al dx out  " evaluate
    " begin   h# 3fd # dx mov  dx al in   h# 20 # al and  0<> until" evaluate
+[then]
 ;
 [else]
 : init-com1  ( -- )  ;

Modified: dev/isa/diaguart.fth
==============================================================================
--- dev/isa/diaguart.fth	Sat Jul 16 14:16:14 2011	(r2382)
+++ dev/isa/diaguart.fth	Sat Jul 16 14:18:36 2011	(r2383)
@@ -4,10 +4,15 @@
 headerless
 d# 1843200 constant uart-clock-frequency
 
-h# 3f8 value uart-base	\ Virtual address of UART; set later
+h# 3f8 value uart-base	\ Virtual address of UART; perhaps overridden later
 
+[ifdef] mem-uart-base
+: uart@  ( reg# -- byte )  mem-uart-base +  c@  ;	\ Read from a UART register
+: uart!  ( byte reg# -- )  mem-uart-base +  c!  ;	\ Write to a UART register
+[else]
 : uart@  ( reg# -- byte )  uart-base +  pc@  ;	\ Read from a UART register
 : uart!  ( byte reg# -- )  uart-base +  pc!  ;	\ Write to a UART register
+[then]
 
 : baud  ( baud-rate -- )
    uart-clock-frequency d# 16 /  swap rounded-/    ( baud-rate-divisor )
@@ -20,11 +25,13 @@
 ;
 
 : inituarts  ( -- )
+[ifndef] mem-uart-base
    3 3 uart!  		\ 8 bits, no parity
    7 2 uart!		\ Clear and enable FIFOs
 \   d# 38400 baud
 \   d# 9600 baud
    d# 115200 baud
+[then]
 ;
 
 : ukey?    ( -- flag )  5 uart@      1 and  0<>  ;  \ Test for rcv character



More information about the openfirmware mailing list