ppc64: Don't set Kp bit on SLB
[openbios.git] / forth / device / extra.fs
blob9ca6b78e32cbdcc04d078db8672cd60730269635
1 \ tag: Useful device related functions
2 \
3 \ Copyright (C) 2003, 2004 Samuel Rydh
4 \
5 \ See the file "COPYING" for further information about
6 \ the copyright and warranty status of this work.
7 \
10 : parent ( phandle -- parent.phandle|0 )
11 >dn.parent @
14 \ -------------------------------------------------------------------
15 \ property helpers
16 \ -------------------------------------------------------------------
18 : int-property ( value name-str name-len -- )
19 rot encode-int 2swap property
22 \ -------------------------------------------------------------------------
23 \ property utils
24 \ -------------------------------------------------------------------------
26 \ like property (except it takes a phandle as an argument)
27 : encode-property ( buf len propname propname-len phandle -- )
28 dup 0= abort" null phandle"
30 my-self >r 0 to my-self
31 active-package >r active-package!
33 property
35 r> active-package!
36 r> to my-self
39 \ -------------------------------------------------------------------
40 \ device tree iteration
41 \ -------------------------------------------------------------------
43 : iterate-tree ( phandle -- phandle|0 )
44 ?dup 0= if device-tree @ exit then
46 \ children first
47 dup child if
48 child exit
49 then
51 \ then peers
52 dup peer if
53 peer exit
54 then
56 \ then peer of a parent
57 begin >dn.parent @ dup while
58 dup peer if peer exit then
59 repeat
62 : iterate-tree-begin ( -- first_node )
63 device-tree @
67 \ -------------------------------------------------------------------
68 \ device tree iteration
69 \ -------------------------------------------------------------------
71 : iterate-device-type ( lastph|0 type-str type-len -- 0|nextph )
72 rot
73 begin iterate-tree ?dup while
75 2dup " device_type" r@ get-package-property if 0 0 then
76 dup 0> if 1- then
77 strcmp 0= if 2drop r> exit then
79 repeat
80 2drop 0
83 \ -------------------------------------------------------------------
84 \ device tree "cut and paste"
85 \ -------------------------------------------------------------------
87 \ add a subtree to the current device node
88 : link-nodes ( phandle -- )
89 \ reparent phandle and peers
90 dup begin ?dup while
91 dup >dn.parent active-package !
92 >dn.peer @
93 repeat
95 \ add to list of children
96 active-package >dn.child
97 begin dup @ while @ >dn.peer repeat dup . !
100 : link-node ( phandle -- )
101 0 over >dn.peer !
102 link-nodes