Is it possible to get a list of all (normal) device drivers?

Anything QL Software or Programming Related.
User avatar
ql_freak
Trump Card
Posts: 174
Joined: Sun Jan 18, 2015 1:29 am

Is it possible to get a list of all (normal) device drivers?

Postby ql_freak » Thu Jan 03, 2019 8:25 pm

Is it possible to get a list (e.g. in a string array) of NORMAL device drivers?

For directory device drivers this is quite easy:

Code: Select all

10140  REMark create string array with list of directory device drivers:
10150  __sys__dirdevs%=0:DIM __sys__dirdev$(19,10)
10160  dd=PEEK_L(VER$(-2)+72):REMark get pointer to list of directory device drivers
10170  FOR i%=0TO 32767:REMark "endless" loop
10180    IF NOT dd:__sys__dirdevs%=i%:__sys__dirdev$(i%)='':EXIT i%
10190    l=PEEK_W(dd+36):__sys__dirdev$(i%)=FILL$('xy',l)
10200    FOR c=1TO l:__sys__dirdev$(i%,c)=CHR$(PEEK(dd+37+c))
10210    PRINT __sys__dirdev$(i%)
10220    dd=PEEK_L(dd)
10230  END FOR i%


But I'm afraid there is no way, to do similar for normal device drivers, as they use the IO.NAME vector in the open routine to decode the device name. And the only location, where the device name seems to be stored is 6 bytes after the IO.NAME call in the open routine (see description in Technical Guide, the description in Adrian Dickens "Advanced User Guide" is not sufficient[!]).


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE§() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
User avatar
tofro
QL Wafer Drive
Posts: 1505
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Is it possible to get a list of all (normal) device drivers?

Postby tofro » Thu Jan 03, 2019 9:06 pm

Peter,

I also cannot see an obvious way, just a kludge:

If you spend a bit of time ;) , you can maybe do it the same way QDOS does it:

The list of possible permutations of max. 4 * 26 characters, an optional number, and an underscore seems manageable.

Trying to FOPEN all possible permutations and collecting those that do not return "not found" (indicating the OS has found a driver that recognised the name, but couldn't handle the attributes) should give you a list of all possible base names in a few seconds. You obviously need to remove the names you have identified as directory device drivers, and you obviously cannot identify the possible channel arguments.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
ql_freak
Trump Card
Posts: 174
Joined: Sun Jan 18, 2015 1:29 am

Re: Is it possible to get a list of all (normal) device drivers?

Postby ql_freak » Thu Jan 03, 2019 9:26 pm

Thank you,

would be a way, but I find it too cumbersome. Perhaps I try to write a Machine code program, which scans the open routine of all device drivers for vector 122 (IO.NAME) and afterwards looks for the next jsr call and look 6 bytes afterwards for the name. Will most probably be more complicated but in principle this could work.


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE§() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
User avatar
pjw
Gold Card
Posts: 472
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: Is it possible to get a list of all (normal) device drivers?

Postby pjw » Thu Jan 03, 2019 11:13 pm

Is this the sort of thing you mean?

Code: Select all

100 REMark SMSQ/E Version
110 :
120 DEFine PROCedure GetDevS
130 LOCal gdl, p, dd$
140 p = PEEK_L(!! 72): REMark SMSQ/E only
150 REMark QDOS: p = PEEK_L(163840 + 72)
160 REMark Minerva/SMSQ/E p = PEEK_L(VER$(-2) + 72)
170 REPeat gdl
180  dd$ = PeekStrg$(p + 36)
190  IF LEN(dd$) > 0: PRINT dd$
200  p = PEEK_L(p): IF p = 0: EXIT gdl
210 END REPeat gdl
220 END DEFine GetDevS
230 :
240 REMark PEEK$ is SMSQ/E or toolkit only
250 DEFine FuNction PeekStrg$(adr)
260 LOCal l%
270 l% = PEEK_W(adr)
280 SELect ON l%: = 1 TO 4: RETurn PEEK$(adr + 2, l%)
290 RETurn ''
300 END DEFine PeekStrg$
310 :

This is SMSQ/E only, but it should be easy enough to make it universal.


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
pjw
Gold Card
Posts: 472
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: Is it possible to get a list of all (normal) device drivers?

Postby pjw » Thu Jan 03, 2019 11:31 pm

Sorry, I misread your question. To get the non-directory drivers is not easy, as programmers can pretty much define these as they like. I dont think theres any way you are guaranteed to get them all.


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
mk79
Gold Card
Posts: 310
Joined: Sun Feb 02, 2014 10:54 am

Re: Is it possible to get a list of all (normal) device drivers?

Postby mk79 » Sat Jan 05, 2019 11:58 pm

As you have noticed in theory there is no way to do this reliably as the OPEN code decides what to handle. In real life a bit of heuristic works fine in most cases. This is the program I use to list drivers for debugging etc.

Code: Select all

2000 :
2010 IF VER$ == "HBA": JOB_NAME "LSD_bas"
2020 OPEN#3,"con_512x240a0x16": INK#3,7: BORDER#3,4,4: CLS#3
2030 Lsd#3
2040 INPUT#3," > ";a$; : CLOSE: STOP
2050 :
2060 DEFine PROCedure Lsd(ch%)
2070   IF ch%=0: ch%=2
2080   PRINT#ch%
2090   sv_drlst=HEX('44')
2100   link=PEEK_L(!!sv_drlst)
2110   IF link=0: PRINT#ch%,'Kein IO-Device gefunden': RETurn
2120   PRINT#ch%,'Serielle IO-Treiber:'
2130   PRINT#ch%,'Link       IO        OPEN      CLOSE     INT2      POLL      SCHD      NAME'
2140 :
2150   REPeat lsd_loop
2160     link_next = PEEK_L(link)
2170     io_adr    = PEEK_L(link+4)
2180     open_adr  = PEEK_L(link+8)
2190     close_adr = PEEK_L(link+12)
2200     int2_adr  = PEEK_L(link-24+4)
2210     poll_adr  = PEEK_L(link-24+12)
2220     schd_adr  = PEEK_L(link-24+20)
2230     str_adr = open_adr: io_name$="---"
2240     FOR n = 1 TO 64
2250       slen = ABS(PEEK_W(str_adr))
2260       str_adr = str_adr + 2
2270       IF slen > 0 AND slen < 8 THEN
2280         io_name$ = ""
2290         FOR i = 1 TO slen
2300           c$ = CHR$(PEEK(str_adr + i - 1))
2310           IF c$(1) < "A" OR c$(1) > "Z": io_name$="+++": NEXT n
2320           io_name$ = io_name$ & c$
2330         END FOR i
2340         EXIT n
2350       END IF
2360     END FOR n
2370 :
2380     PRINT#ch%,HEX$(link,32)!!!HEX$(io_adr,32)!!HEX$(open_adr,32)!!HEX$(close_adr,32)!!HEX$(int2_adr,32)!!HEX$(poll_adr,32)!!HEX$(schd_adr,32)!!io_name$
2390     IF link_next=0:EXIT lsd_loop
2400     link=link_next
2410   END REPeat lsd_loop
2420 :
2430   PRINT#ch%,'fertig'
2440 END DEFine Lsd


User avatar
ql_freak
Trump Card
Posts: 174
Joined: Sun Jan 18, 2015 1:29 am

Re: Is it possible to get a list of all (normal) device drivers?

Postby ql_freak » Mon Jan 07, 2019 8:35 pm

Thank You Marcel!

Very nice program, lists even the name of the REDIR device from Phil Borman.


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE§() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)

Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 1 guest