1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
13 VARIABLE chosen-memory-ih 0 chosen-memory-ih !
16 \ Maintain "available" property.
17 \ Sun has a single memory node with "available" property
18 \ and separate memory controller nodes.
19 \ We corespond memory nodes with their respective memory controllers
20 \ and use /chosen/memory as default memory node to hold the "available" map
21 \ NOTE -> /chosen/memory is expected 2B initialized before using claim/release
24 : (chosen-memory-ph) ( -- phandle )
25 chosen-memory-ih @ ?dup 0= IF
26 s" memory" get-chosen IF
27 decode-int nip nip dup chosen-memory-ih !
30 ELSE ihandle>phandle THEN
33 : (set-available-prop) ( prop plen -- )
35 (chosen-memory-ph) ?dup 0<> IF set-property ELSE
36 cr ." Can't find chosen memory node - "
37 ." no available property created" cr
42 : update-available-property ( available-ptr -- )
43 dup >r available>size@
44 0= r@ available AVAILABLE-SIZE /available * + >= or IF
45 available r> available - encode-bytes (set-available-prop)
47 r> /available + RECURSE
51 : update-available-property available update-available-property ;
53 \ \\\\\\\\\\\\\\ Exported Interface:
55 \ IEEE 1275 implementation:
57 \ Claim the region with given start address and size (if align parameter is 0);
58 \ alternatively claim any region of given alignment
60 \ Throw an exception if failed
62 : claim ( [ addr ] len align -- base ) claim update-available-property ;
65 \ IEEE 1275 implementation:
67 \ Free the region with given start address and size
69 : release ( addr len -- ) release update-available-property ;
71 update-available-property