// Version for floppy discs on 8086 TRIPOS || (C) Copyright 1979 Tripos Research Group || University of Cambridge || Computer Laboratory SECTION "disc" GET "libhdr" GET "manhdr" GLOBAL $( deviceid : ug+1 physical.unit: ug+2 logical.unit : ug+3 string.to.number : ug+4 $) GET "STRTONUM" LET start(discname) = VALOF $( LET argv = VEC 20 LET seglist = VEC 4 LET file.handler.pri = rootnode!rtn.tasktab!task.filehandler!tcb.pri LET file.handler.seglist = rootnode!rtn.tasktab!task.filehandler!tcb.seglist LET initialisation.obj = "SYS:L.FILE-HANDLER-INITIALISATION" LET handler.obj.prefix = "SYS:L.FILE-HANDLER" LET handler.obj = VEC 20 LET lv.disc = devicename(discname) LET res, res2, restart.code, version, n.cache.slots = ?, ?, ?, ?, ? LET new.file.handler = ? LET envec = // floppy disc definition TABLE 10, || length of table 256, || block size 0, || sector origin 1, || number of surfaces 1, || sectors per block 13, || blocks per track 1, || number of reserved blocks 8, || pre-allocation factor 1, || interleave factor 15, || lower cylinder 76 || upper cylinder FOR i = 0 TO handler.obj.prefix%0 DO handler.obj%i := handler.obj.prefix%i deviceid := -2 physical.unit := discname%3-'0' logical.unit := discname%0=3 -> 0, discname%5-'0' res := rdargs("READ/S,VERSION/K,CACHESLOTS/K", argv, 20) IF res=0 RESULTIS error("Bad discnames for mount of *"%S:*"*N", 20, 120, discname) IF lv.disc=0 RESULTIS error("Device *"%S:*" unknown*N", 20, 0, discname) UNLESS !lv.disc=0 RESULTIS error("Device *"%S:*" already mounted*N", 20, 0, discname) restart.code := argv!0\=0 version := argv!1 UNLESS version=0 DO $( FOR i = 1 TO version%0 DO handler.obj%[handler.obj.prefix%0+i] := version%i handler.obj%0 := handler.obj.prefix%0 + version%0 || construct version name $) TEST argv!2=0 THEN n.cache.slots := 3 ELSE $( TEST string.to.number(argv!2) THEN n.cache.slots := result2 ELSE RESULTIS error("Bad CACHESLOTS number %S*N", 20, 100, argv!2) $) FOR i = 0 TO envec!0 DO argv!i := envec!i FOR i = 0 TO 3 DO seglist!i := file.handler.seglist!i seglist!4 := loadseg(initialisation.obj) IF seglist!4=0 RESULTIS error("Can't load %S*N", 20, result2, initialisation.obj) UNLESS version=0 DO $( seglist!3 := loadseg(handler.obj) IF seglist!3=0 THEN $( unloadseg(seglist!4) RESULTIS error("Can't load %S*N", 20, result2, handler.obj) $) $) FOR pri = file.handler.pri TO file.handler.pri-500 BY -1 DO $( new.file.handler := createtask(seglist, 212, pri) UNLESS new.file.handler=0 BREAK $) IF new.file.handler=0 RESULTIS error("Can't create new task*N", 20, result2) IF sendpkt(-1, new.file.handler, 0, ?, ?, 1, deviceid, physical.unit, n.cache.slots, argv, restart.code)=0 RESULTIS error("Attempt to mount *"%S:*" failed*N", 20, result2, discname) !lv.disc := new.file.handler RESULTIS -1 || success $) AND error(message, rc, res2, discname) = VALOF $( writef(message, discname) result2 := res2 RESULTIS 1 $)