PageRenderTime 57ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/sys/boot/forth/pnp.4th

https://repo.or.cz/dragonfly/vkernel-mp.git
Forth | 173 lines | 159 code | 14 blank | 0 comment | 6 complexity | 8b85c08ec364eda9b52668a593d1e5d8 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, Unlicense, BSD-3-Clause, ISC, GPL-2.0, AGPL-1.0
  1. \ Copyright (c) 2000 Daniel C. Sobral <dcs@freebsd.org>
  2. \ All rights reserved.
  3. \
  4. \ Redistribution and use in source and binary forms, with or without
  5. \ modification, are permitted provided that the following conditions
  6. \ are met:
  7. \ 1. Redistributions of source code must retain the above copyright
  8. \ notice, this list of conditions and the following disclaimer.
  9. \ 2. Redistributions in binary form must reproduce the above copyright
  10. \ notice, this list of conditions and the following disclaimer in the
  11. \ documentation and/or other materials provided with the distribution.
  12. \
  13. \ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14. \ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. \ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. \ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17. \ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. \ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. \ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. \ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. \ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. \ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. \ SUCH DAMAGE.
  24. \
  25. \ $FreeBSD: src/sys/boot/forth/pnp.4th,v 1.2 2001/12/11 00:49:34 jhb Exp $
  26. \ $DragonFly: src/sys/boot/forth/pnp.4th,v 1.1 2003/11/10 07:08:34 dillon Exp $
  27. pnpdevices drop
  28. : enumerate
  29. pnphandlers begin
  30. dup @
  31. while
  32. ." Probing " dup @ pnph.name @ dup strlen type ." ..." cr
  33. 0 over @ pnph.enumerate @ ccall drop
  34. cell+
  35. repeat
  36. ;
  37. : summary
  38. ." PNP scan summary:" cr
  39. pnpdevices stqh_first @
  40. begin
  41. dup
  42. while
  43. dup pnpi.ident stqh_first @ pnpid.ident @ dup strlen type
  44. dup pnpi.desc @ ?dup if
  45. ." : "
  46. dup strlen type
  47. then
  48. cr
  49. pnpi.link stqe_next @
  50. repeat
  51. drop
  52. ;
  53. : compare-pnpid ( addr addr' -- flag )
  54. begin
  55. over c@ over c@ <> if drop drop false exit then
  56. over c@ over c@ and
  57. while
  58. char+ swap char+ swap
  59. repeat
  60. c@ swap c@ or 0=
  61. ;
  62. : search-pnpid ( id -- flag )
  63. >r
  64. pnpdevices stqh_first @
  65. begin ( pnpinfo )
  66. dup
  67. while
  68. dup pnpi.ident stqh_first @
  69. begin ( pnpinfo pnpident )
  70. dup pnpid.ident @ r@ compare-pnpid
  71. if
  72. r> drop
  73. \ XXX Temporary debugging message
  74. ." Found " pnpid.ident @ dup strlen type
  75. pnpi.desc @ ?dup if
  76. ." : " dup strlen type
  77. then cr
  78. \ drop drop
  79. true
  80. exit
  81. then
  82. pnpid.link stqe_next @
  83. ?dup 0=
  84. until
  85. pnpi.link stqe_next @
  86. repeat
  87. r> drop
  88. drop
  89. false
  90. ;
  91. : skip-space ( addr -- addr' )
  92. begin
  93. dup c@ bl =
  94. over c@ 9 = or
  95. while
  96. char+
  97. repeat
  98. ;
  99. : skip-to-space ( addr -- addr' )
  100. begin
  101. dup c@ bl <>
  102. over c@ 9 <> and
  103. over c@ and
  104. while
  105. char+
  106. repeat
  107. ;
  108. : premature-end? ( addr -- addr flag )
  109. postpone dup postpone c@ postpone 0=
  110. postpone if postpone exit postpone then
  111. ; immediate
  112. 0 value filename
  113. 0 value timestamp
  114. 0 value id
  115. only forth also support-functions
  116. : (load) load ;
  117. : check-pnpid ( -- )
  118. line_buffer .addr @
  119. \ Search for filename
  120. skip-space premature-end?
  121. dup to filename
  122. \ Search for end of filename
  123. skip-to-space premature-end?
  124. 0 over c! char+
  125. \ Search for timestamp
  126. skip-space premature-end?
  127. dup to timestamp
  128. skip-to-space premature-end?
  129. 0 over c! char+
  130. \ Search for ids
  131. begin
  132. skip-space premature-end?
  133. dup to id
  134. skip-to-space dup c@ >r
  135. 0 over c! char+
  136. id search-pnpid if
  137. filename dup strlen 1 ['] (load) catch if
  138. drop drop drop
  139. ." Error loading " filename dup strlen type cr
  140. then
  141. r> drop exit
  142. then
  143. r> 0=
  144. until
  145. ;
  146. : load-pnp
  147. 0 to end_of_file?
  148. reset_line_reading
  149. s" /boot/pnpid.conf" O_RDONLY fopen fd !
  150. fd @ -1 <> if
  151. begin
  152. end_of_file? 0=
  153. while
  154. read_line
  155. check-pnpid
  156. repeat
  157. fd @ fclose
  158. then
  159. ;