Topic : TOS - The Operating System Author : Version : tos.hyp (December 19, 2008) Subject : Programmieren/Atari Nodes : 3010 Index Size : 93790 HCP-Version : 5 Compiled on : Atari @charset : atarist @lang : @default : Title @help : @options : +g -i -s +x +zz -t4 @width : 70 View Ref-File13.6.2 Definition of the driver daisy chain TOS Basis of the GDPS is the vector $41C which is unused by the operating system. Normally this vector contains 0L. In GDPS this vector points to the header of the first device driver in the chain. This header is built up as follows (rAdr=relative Address, S=Size): rAdr S Meaning OH L Pointer to the next driver header, or 0 in last driver of the chain 4H L 'GDPS' = 0x47445053 magic string as identifier for GDPS From this follows the method for linking a driver in and out of the chain. 1. Linking in of a driver The driver copies the vector placed at 0x41C into its header. Subsequently it enters the address of its header into 0x41C. Assembler example (to be executed in supervisor-mode): len header(pe),a0 * Address of the GDPS header clr.l (a0) * Initialize NEXT to 0 cmp.l 0x41C,a0 * = old value beq unten * Yes, no endless chaining! move.l 0x41C,(a0) * sonst NEXT eintragen move.l a0,0x41C * and link header into the chain 2. Unlinking of a driver The driver searches the chain for the pointer to its header. It then replaces it with a pointer found in its header. Assembler example (to be executed in supervisor-mode): move.l #0x41C,a0 lea header(pe),a1 search: cmp.l (a0),a1 beq found move.l (a0),a0 bra search found: move.l (a1),(a0) 3. Searching for a driver Searches for a driver too should be performed in supervisor-mode. As the operating system does not set the variable 0x41C to 0 at a warm start, one has to check for the magic string for each vector found. There follows a sample routine in GFA Basic notation that writes the found and valid vectors into an integer array: DIM vector%(31) ! Here addresses of the drivers lie index%=0 ! Initialize counter to 0 adr%=SLPEEK($41C) ! Address of the first driver WHILE adr%<>0 AND SLPEEK(adr%+4)=$47445053 ! Test: Address valid and magic OK? vector%(index%)=adr% ! If yes, remember address inc index% ! Increment counter by one WEND PRINT index%;" Driver found!"