PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/test/hrc/forth/full/walktree.fth

https://github.com/mediogre/colorite
Forth | 61 lines | 57 code | 4 blank | 0 comment | 13 complexity | 88417e37fd66d20a0b647382046392f8 MD5 | raw file
  1. \ Walk by device's of tree in BootMon LNM 2000
  2. cr ." Device tree parsing"
  3. forth definitions decimal anew task-walktree.fth
  4. defer workfornode \ Work that must executed on node point
  5. ' noop is workfornode
  6. : ptrmethwork ( Phandle AdrM LM -- )
  7. 2 pick ( A L Phandle ) find-method ( XtW 1 | endVoc 0 )
  8. if space execute drop then ( Phandle ) ;
  9. : testonnode ( Phandle ) s" TEST" ptrmethwork ( -- ) ;
  10. : diagonnode ( Phandle ) s" TEST" ptrmethwork ( -- ) ;
  11. ' testonnode value ptstnode
  12. ' diagonnode value ptdiagnode
  13. : endnode ( -- ) ." /" s" name" get-my-property not if type then ( ) ;
  14. : tagshows ( ChPhandle ) cr dup . dup nodehandle ! endnode
  15. workfornode ( Phandle ) >code siblinghandle @ ( SiblHandle ) ;
  16. : nodetarget-devs ( Phandle -- )
  17. dup nodehandle @ swap dup nodehandle ! >code childhandle @ dup
  18. if begin
  19. tagshows dup
  20. nodehandle @nt ihandle @ dup if ( showinst ) else drop then
  21. not
  22. until drop
  23. else drop then nodehandle ! ( Phandle -- ) ;
  24. : walkbylevel ( Phandle )
  25. begin ( Phandle )
  26. dup chnglevelnode ( Phandle )
  27. nodetarget-devs
  28. dup >code childhandle @ dup
  29. if \ Child are exists
  30. downtochild swap drop ( Phandle )
  31. else \ No child consist
  32. drop siblingorup ( Phandle )
  33. then ( Phandle )
  34. dup not
  35. until drop ( -- ) ;
  36. : gotree ( -- ) nodehandle @ 0 leveltree !
  37. roothandle @ dup . ( ascii / emit ) walkbylevel nodehandle ! ( -- ) ;
  38. : tsttree ( -- ) ptstnode is workfornode gotree ( -- ) ;
  39. : diagtree ( -- ) ptdiagnode is workfornode gotree ( -- ) ;
  40. : diagnostic ( -- ) cr ." Device diagnostics..." cr diagtree ( -- ) ;
  41. : fulltest ( -- ) cr ." Full device diagnostics..." cr tsttree ( -- ) ;
  42. : startbm ( -- ) cr ." BootMon v1.0a Russia Moscow SRISS 2000"
  43. use-nvramrc? if execscript then
  44. initbootmon
  45. diag-switch? if diagnostic else fulltest then
  46. selectIO
  47. auto-boot? if gotoboot else cr ." I'm ready" then ( -- ) ;
  48. 0 [IF]
  49. HEX \ For testing setprop operations
  50. 20 STRING ZSTR
  51. : TSP
  52. S" SELFTEST" ZSTR ST!
  53. ZSTR + 1+ 0 SWAP C!
  54. S" DISABLE NAVSEGDA" HERE 200 + SWAP MOVE
  55. 10 HERE 200 + ZSTR DROP B41C SETPROP ;
  56. DECIMAL
  57. [THEN]