1280924Sdteske\ Copyright (c) 2000 Daniel C. Sobral <dcs@FreeBSD.org> 265618Sdcs\ All rights reserved. 365618Sdcs\ 465618Sdcs\ Redistribution and use in source and binary forms, with or without 565618Sdcs\ modification, are permitted provided that the following conditions 665618Sdcs\ are met: 765618Sdcs\ 1. Redistributions of source code must retain the above copyright 865618Sdcs\ notice, this list of conditions and the following disclaimer. 965618Sdcs\ 2. Redistributions in binary form must reproduce the above copyright 1065618Sdcs\ notice, this list of conditions and the following disclaimer in the 1165618Sdcs\ documentation and/or other materials provided with the distribution. 1265618Sdcs\ 1365618Sdcs\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1465618Sdcs\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1565618Sdcs\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1665618Sdcs\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1765618Sdcs\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1865618Sdcs\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1965618Sdcs\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2065618Sdcs\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2165618Sdcs\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2265618Sdcs\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2365618Sdcs\ SUCH DAMAGE. 2465618Sdcs\ 2565618Sdcs\ $FreeBSD: releng/11.0/sys/boot/forth/pnp.4th 280924 2015-03-31 22:32:35Z dteske $ 2665618Sdcs 27186789Sluigi 28186789Sluigi\ The following pnp code is used in pnp.4th and pnp.c 29186789Sluigistructure: STAILQ_HEAD 30186789Sluigi ptr stqh_first \ type* 31186789Sluigi ptr stqh_last \ type** 32186789Sluigi;structure 33186789Sluigi 34186789Sluigistructure: STAILQ_ENTRY 35186789Sluigi ptr stqe_next \ type* 36186789Sluigi;structure 37186789Sluigi 38186789Sluigistructure: pnphandler 39186789Sluigi ptr pnph.name 40186789Sluigi ptr pnph.enumerate 41186789Sluigi;structure 42186789Sluigi 43186789Sluigistructure: pnpident 44186789Sluigi ptr pnpid.ident \ char* 45186789Sluigi sizeof STAILQ_ENTRY cells member: pnpid.link \ pnpident 46186789Sluigi;structure 47186789Sluigi 48186789Sluigistructure: pnpinfo \ sync with sys/boot/config/bootstrap.h 49186789Sluigi ptr pnpi.desc 50186789Sluigi int pnpi.revision 51186789Sluigi ptr pnpi.module \ (char*) module args 52186789Sluigi int pnpi.argc 53186789Sluigi ptr pnpi.argv 54186789Sluigi ptr pnpi.handler \ pnphandler 55186789Sluigi sizeof STAILQ_HEAD member: pnpi.ident \ pnpident 56186789Sluigi sizeof STAILQ_ENTRY member: pnpi.link \ pnpinfo 57186789Sluigi;structure 58186789Sluigi\ end of pnp support 59186789Sluigi 6065618Sdcspnpdevices drop 6165618Sdcs 6265618Sdcs: enumerate 6365618Sdcs pnphandlers begin 6465618Sdcs dup @ 6565618Sdcs while 6665618Sdcs ." Probing " dup @ pnph.name @ dup strlen type ." ..." cr 6765618Sdcs 0 over @ pnph.enumerate @ ccall drop 6865618Sdcs cell+ 6965618Sdcs repeat 7065618Sdcs; 7165618Sdcs 7265618Sdcs: summary 7365618Sdcs ." PNP scan summary:" cr 7465618Sdcs pnpdevices stqh_first @ 7565618Sdcs begin 7665618Sdcs dup 7765618Sdcs while 7865618Sdcs dup pnpi.ident stqh_first @ pnpid.ident @ dup strlen type 7965618Sdcs dup pnpi.desc @ ?dup if 8065618Sdcs ." : " 8165618Sdcs dup strlen type 8265618Sdcs then 8365618Sdcs cr 8465618Sdcs pnpi.link stqe_next @ 8565618Sdcs repeat 8665618Sdcs drop 8765618Sdcs; 8865618Sdcs 8965618Sdcs: compare-pnpid ( addr addr' -- flag ) 9065618Sdcs begin 9165618Sdcs over c@ over c@ <> if drop drop false exit then 9265618Sdcs over c@ over c@ and 9365618Sdcs while 9465618Sdcs char+ swap char+ swap 9565618Sdcs repeat 9665618Sdcs c@ swap c@ or 0= 9765618Sdcs; 9865618Sdcs 9965618Sdcs: search-pnpid ( id -- flag ) 10065618Sdcs >r 10165618Sdcs pnpdevices stqh_first @ 10265618Sdcs begin ( pnpinfo ) 10365618Sdcs dup 10465618Sdcs while 10565618Sdcs dup pnpi.ident stqh_first @ 10665618Sdcs begin ( pnpinfo pnpident ) 10765618Sdcs dup pnpid.ident @ r@ compare-pnpid 10865618Sdcs if 10965618Sdcs r> drop 11065618Sdcs \ XXX Temporary debugging message 11165618Sdcs ." Found " pnpid.ident @ dup strlen type 11265618Sdcs pnpi.desc @ ?dup if 11365618Sdcs ." : " dup strlen type 11465618Sdcs then cr 11565618Sdcs \ drop drop 11665618Sdcs true 11765618Sdcs exit 11865618Sdcs then 11965618Sdcs pnpid.link stqe_next @ 12065618Sdcs ?dup 0= 12165618Sdcs until 12265618Sdcs pnpi.link stqe_next @ 12365618Sdcs repeat 12465618Sdcs r> drop 12565618Sdcs drop 12665618Sdcs false 12765618Sdcs; 12865618Sdcs 12965618Sdcs: skip-space ( addr -- addr' ) 13065618Sdcs begin 13165618Sdcs dup c@ bl = 13265618Sdcs over c@ 9 = or 13365618Sdcs while 13465618Sdcs char+ 13565618Sdcs repeat 13665618Sdcs; 13765618Sdcs 13865618Sdcs: skip-to-space ( addr -- addr' ) 13965618Sdcs begin 14065618Sdcs dup c@ bl <> 14165618Sdcs over c@ 9 <> and 14265618Sdcs over c@ and 14365618Sdcs while 14465618Sdcs char+ 14565618Sdcs repeat 14665618Sdcs; 14765618Sdcs 14865618Sdcs: premature-end? ( addr -- addr flag ) 14965618Sdcs postpone dup postpone c@ postpone 0= 15065618Sdcs postpone if postpone exit postpone then 15165618Sdcs; immediate 15265618Sdcs 15365618Sdcs0 value filename 15465618Sdcs0 value timestamp 15565618Sdcs0 value id 15665618Sdcs 15765618Sdcsonly forth also support-functions 15865618Sdcs 15965618Sdcs: (load) load ; 16065618Sdcs 16165618Sdcs: check-pnpid ( -- ) 16265618Sdcs line_buffer .addr @ 16365618Sdcs \ Search for filename 16465618Sdcs skip-space premature-end? 16565618Sdcs dup to filename 16665618Sdcs \ Search for end of filename 16765618Sdcs skip-to-space premature-end? 16865618Sdcs 0 over c! char+ 16965618Sdcs \ Search for timestamp 17065618Sdcs skip-space premature-end? 17165618Sdcs dup to timestamp 17265618Sdcs skip-to-space premature-end? 17365618Sdcs 0 over c! char+ 17465618Sdcs \ Search for ids 17565618Sdcs begin 17665618Sdcs skip-space premature-end? 17765618Sdcs dup to id 17865618Sdcs skip-to-space dup c@ >r 17965618Sdcs 0 over c! char+ 18065618Sdcs id search-pnpid if 18165618Sdcs filename dup strlen 1 ['] (load) catch if 18265618Sdcs drop drop drop 18365618Sdcs ." Error loading " filename dup strlen type cr 18465618Sdcs then 18565618Sdcs r> drop exit 18665618Sdcs then 18765618Sdcs r> 0= 18865618Sdcs until 18965618Sdcs; 19065618Sdcs 19165618Sdcs: load-pnp 19265618Sdcs 0 to end_of_file? 19365618Sdcs reset_line_reading 19487636Sjhb s" /boot/pnpid.conf" O_RDONLY fopen fd ! 19565618Sdcs fd @ -1 <> if 19665618Sdcs begin 19765618Sdcs end_of_file? 0= 19865618Sdcs while 19965618Sdcs read_line 20065618Sdcs check-pnpid 20165618Sdcs repeat 20265618Sdcs fd @ fclose 20365618Sdcs then 20465618Sdcs; 20565618Sdcs 206