1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
\ tag: Utility functions
\
\ deblocker / filesystem support
\
\ Copyright (C) 2003, 2004 Samuel Rydh
\
\ See the file "COPYING" for further information about
\ the copyright and warranty status of this work.
\
dev /packages
\ -------------------------------------------------------------
\ /packages/disk-label (partition handling)
\ -------------------------------------------------------------
[IFDEF] CONFIG_DISK_LABEL
new-device
" disk-label" device-name
external
variable part-handlers \ list with (probe-xt, phandle) elements
variable fs-handlers \ list with (fs-probe-xt, phandle) elements
: find-part-handler ( block0 -- phandle | 0 )
>r part-handlers
begin list-get while
( nextlist dictptr )
r@ over @ execute if
( nextlist dictptr )
na1+ @ r> rot 2drop exit
then
drop
repeat
r> drop 0
;
: find-filesystem ( offs.d ih -- ph | 0 )
>r fs-handlers ( offs.d listhead )
begin list-get while
2over ( offs.d nextlist dictptr offs.d )
r@ ( offs.d nextlist dictptr offs.d ih )
3 pick ( offs.d nextlist dictptr offs.d ih dictptr )
@ ( offs.d nextlist dictptr offs.d ih probe-xt )
execute ( offs.d nextlist dictptr flag? )
if
( offs.d nextlist dictptr )
na1+ ( offs.d nextlist dictptr+1 )
@ ( offs.d nextlist phandle )
r> ( offs.d nextlist phandle ih )
rot ( offs.d phandle ih nextlist )
2drop ( offs.d phandle )
-rot ( phandle offs.d )
2drop ( phandle )
exit
then
drop ( offs.d nextlist )
repeat
2drop ( offs.d )
r> drop 0
;
: register-part-handler ( handler-ph -- )
dup " probe" rot find-method
0= abort" Missing probe method!"
( phandle probe-xt )
part-handlers list-add , ,
;
: register-fs-handler ( handler-ph -- )
dup " probe" rot find-method
0= abort" Missing probe method!"
( phandle probe-xt )
fs-handlers list-add , ,
;
: dma-alloc
" dma-alloc" $call-parent
;
: dma-free
" dma-free" $call-parent
;
: dma-map-in
" dma-map-in" $call-parent
;
: dma-map-out
" dma-map-out" $call-parent
;
: dma-sync
" dma-sync" $call-parent
;
finish-device
\ ---------------------------------------------------------------------------
\ methods to register partion and filesystem packages used by disk-label
\ ---------------------------------------------------------------------------
device-end
: initialise-partition-package ( -- )
" dma-alloc" is-call-parent
" dma-free" is-call-parent
" dma-map-in" is-call-parent
" dma-map-out" is-call-parent
" dma-sync" is-call-parent
;
: initialise-fs-package ( -- )
" dma-alloc" is-call-parent
" dma-free" is-call-parent
" dma-map-in" is-call-parent
" dma-map-out" is-call-parent
" dma-sync" is-call-parent
;
: register-partition-package ( -- )
" register-part-handler" " disk-label" $find-package-method ?dup if
active-package swap execute
initialise-partition-package
else
." [disk-label] internal error" cr
then
;
: register-fs-package ( -- )
" register-fs-handler" " disk-label" $find-package-method ?dup if
active-package swap execute
initialise-fs-package
else
." [misc-files] internal error" cr
then
;
[THEN]
device-end
|