Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / arch / ppc / pearpc / pearpc.fs
1 \   pearpc specific initialization code
2
3 \   Copyright (C) 2005 Stefan Reinauer
4
5 \   This program is free software; you can redistribute it and/or
6 \   modify it under the terms of the GNU General Public License
7 \   as published by the Free Software Foundation
8
9
10
11 \ -------------------------------------------------------------------------
12 \ initialization
13 \ -------------------------------------------------------------------------
14
15 : make-openable ( path )
16   find-dev if
17     begin ?dup while
18       \ install trivial open and close methods
19       dup active-package! is-open
20       parent
21     repeat
22   then
23 ;
24
25 : preopen ( chosen-str node-path )
26   2dup make-openable
27   
28   " /chosen" find-device
29   open-dev ?dup if
30     encode-int 2swap property
31   else
32     2drop
33   then
34 ;
35
36 \ preopen device nodes (and store the ihandles under /chosen)
37 :noname
38   " rtc" " /pci/isa/rtc" preopen
39   " memory" " /memory" preopen
40   " mmu" " /cpu@0" preopen
41   \ " stdout" " /packages/terminal-emulator" preopen
42   " stdout" " /pci/pci6666,6666" preopen
43   " stdin" " /pci/via-cuda/adb" preopen
44
45 ; SYSTEM-initializer
46
47
48 \ -------------------------------------------------------------------------
49 \ device tree fixing
50 \ -------------------------------------------------------------------------
51
52 \ add decode-address methods
53 : (make-decodable) ( phandle -- )
54
55     dup " #address-cells" rot get-package-property 0= if
56       decode-int nip nip
57       over " decode-unit" rot find-method if 2drop else
58         ( save phandle ncells )
59       
60         over active-package!
61         case
62           1 of ['] parse-hex " decode-unit" is-xt-func endof
63           3 of
64             " bus-range" active-package get-package-property 0= if
65               decode-int nip nip
66               ['] encode-unit-pci " encode-unit" is-xt-func
67               " decode-unit" is-func-begin
68                 ['] (lit) , ,
69                 ['] decode-unit-pci-bus ,
70               is-func-end
71             then
72           endof
73         endcase
74       then
75     then
76     drop
77 ;
78     
79 : init-pearpc-tree ( -- )
80   active-package
81   
82   iterate-tree-begin
83   begin ?dup while
84
85     dup (make-decodable)
86     
87     iterate-tree
88   repeat
89
90   active-package!
91 ;
92
93 \ use the tty interface if available
94 : activate-tty-interface
95   " /packages/terminal-emulator" find-dev if drop
96     " /pci/via-cuda/adb" " input-device" $setenv
97     " /pci/pci6666,6666" " output-device" $setenv
98   then
99 ;
100
101 :noname
102   " keyboard" input
103 ; CONSOLE-IN-initializer
104
105
106 \ -------------------------------------------------------------------------
107 \ pre-booting
108 \ -------------------------------------------------------------------------
109
110 : update-chosen
111   " /chosen" find-device
112   stdin @ encode-int " stdin" property
113   stdout @ encode-int " stdout" property
114   " /pci/isa/interrupt-controller" find-dev if encode-int " interrupt-controller" property then
115   device-end
116 ;