|
|
1.1 root 1: \ briq specific initialization code
2: \
3: \ Copyright (C) 2004 Greg Watson
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: " stdin" " keyboard" preopen
43:
44: ; SYSTEM-initializer
45:
46:
47: \ -------------------------------------------------------------------------
48: \ device tree fixing
49: \ -------------------------------------------------------------------------
50:
51: \ add decode-address methods
52: : (make-decodable) ( phandle -- )
53:
54: dup " #address-cells" rot get-package-property 0= if
55: decode-int nip nip
56: over " decode-unit" rot find-method if 2drop else
57: ( save phandle ncells )
58:
59: over active-package!
60: case
61: 1 of ['] parse-hex " decode-unit" is-xt-func endof
62: 3 of
63: " bus-range" active-package get-package-property 0= if
64: decode-int nip nip
65: ['] encode-unit-pci " encode-unit" is-xt-func
66: " decode-unit" is-func-begin
67: ['] (lit) , ,
68: ['] decode-unit-pci-bus ,
69: is-func-end
70: then
71: endof
72: endcase
73: then
74: then
75: drop
76: ;
77:
78: : init-briq-tree ( -- )
79: active-package
80:
81: iterate-tree-begin
82: begin ?dup while
83:
84: dup (make-decodable)
85:
86: iterate-tree
87: repeat
88:
89: active-package!
90: ;
91:
92: \ use the tty interface if available
93: : activate-tty-interface
94: " /packages/terminal-emulator" find-dev if drop
95: " /packages/terminal-emulator" " input-device" $setenv
96: " /packages/terminal-emulator" " output-device" $setenv
97: then
98: ;
99:
100: :noname
101: " keyboard" input
102: ; CONSOLE-IN-initializer
103:
104:
105: \ -------------------------------------------------------------------------
106: \ pre-booting
107: \ -------------------------------------------------------------------------
108:
109: : update-chosen
110: " /chosen" find-device
111: stdin @ encode-int " stdin" property
112: stdout @ encode-int " stdout" property
113: " /pci/isa/interrupt-controller" find-dev if encode-int " interrupt-controller" property then
114: device-end
115: ;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.