Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / southbridge / isa-devices / serial / serial.tok
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: serial.tok
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42id: @(#)serial.tok 1.6 06/02/16
43purpose:
44copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47Fcode-Version3
48
49headerless
50h# 8 constant tty-size
51h# 1 constant #channels
52my-address constant tty-base
53
54" serial" 2dup name
55( serial ) device-type
56[ifdef] su16552?
57" su16552" encode-string " su16550" encode-string encode+
58[else]
59" su16550" encode-string
60[then]
61" su" encode-string encode+ " compatible" property
62
631 encode-int " interrupts" property
64
65: en+ ( xdr,len int -- xdr',len' ) encode-int encode+ ;
66
67\ Phys.hi Phys.lo Size
68\ ------- ------- ----
69my-space encode-int tty-base en+ tty-size en+ " reg" property
70
71fload ${BP}/dev/utilities/get-option.fth
72
73: default-tty-mode " 9600,8,n,1,-" ;
74: default-rmc-mode " 115200,8,n,1,-" ;
75: (default-ttya-mode) " ttya-mode" default-tty-mode get-string-option ;
76: (default-ttyb-mode) " ttyb-mode" default-tty-mode get-string-option ;
77
78defer default-ttya-mode
79defer default-ttyb-mode
80
81: $= ( adr1 len1 adr2 len2 -- equal? )
82 rot tuck <> if 3drop false exit then ( adr1 adr2 len1 )
83 comp 0=
84;
85
86: init-tty ( -- )
87 " console" get-my-property 0= if
88 decode-string 2swap 2drop
89 2dup " ttya" $= if
90 2drop
91 ['] (default-ttya-mode)
92 else
93 " rmc" $= if
94 ['] default-rmc-mode
95 else
96 ['] (default-ttyb-mode)
97 then
98 then
99 else
100 ['] default-tty-mode
101 then
102 dup to default-ttya-mode to default-ttyb-mode
103;
104init-tty
105
106fload ${BP}/dev/serial/mode-data.fth
107[ifdef] hw-flow-ctrl?
108 fload ${BP}/dev/serial/su16550/jbos/io.fth
109[else]
110 fload ${BP}/dev/serial/su16550/io.fth
111[then]
112fload ${BP}/dev/serial/mode-decode.fth
113d# 115200 is max-baud
114fload ${BP}/dev/serial/ttydriver.fth
115
116: write ( adr len -- #written ) uwrite ;
117
118end0