IDENT ALLOC TITLE DISK ALLOCATOR PARAMS XTEXT MACROS XTEXT SYSCALL XTEXT * EXT OPERCL,IPLIST MACSET OPERCL,IPLIST,ECS * EJECT ********** * MACROS * ********** * * WIDTH MACRO XREG,BITS LOCAL OK MX7 60-BITS BX7 X7*XREG ZR X7,OK RJ SYSERR OK BSS 0 ENDM * * CHECKSUM MACRO XREG CX1 XREG MX7 60-3 BX1 -X7*X1 LX1 21 B_XREG XREG+X1 ENDM * * EXTRACT MACRO XOUT,XIN,BITS,POSITION LOCAL NBITS,NPOS NBITS EQU BITS NPOS EQU POSITION M_XOUT 60-NBITS-NPOS B_XOUT -XOUT*XIN A_XOUT POSITION ENDM * * EJECT ********************** * FRONT END ROUTINES * ********************** * * GET FIXED DISK SPACE FOR HEADER BLOCK * GDSKHDR GETEVH (MAINCL,M.FDISK) GET FREE FIXED SECTOR COUNTER IX3 X7-X4 DECR BY NO OF SECTORS PL X3,GDH1 JUMP IF SUFFICIENT FIXED SECTORS SB6 GDH1 ELSE RECLAIM FIXED SECTORS JP GETFX GDH1 SENDEV (MAINCL,M.FDISK),(,X3) RELEASE SECTOR COUNTER SB6 B7 RETURN LINK JP GETDSK FIND AND ALLOCATE SECTORS * * FREE FIXED DISK SPACE FOR HEADER BLOCK * FDSKHDR SB6 FDH1 JP FREEDSK RELEASE THE SECTORS * + JP B7-1 FDH1 GETEVH (MAINCL,M.FDISK) GET FIXED SECTOR MARGIN COUNTER IX3 X7+X4 INCR BY NO. OF SECTORS FREED SENDEV (MAINCL,M.FDISK),(,X3) RELEASE MARGIN COUNTER * * GET SWAPPED DISK SPACE FOR POINTER BLOCK * GDSKPTR GETEVH (MAINCL,M.SDISK) GET SWAPPED SECTOR MARGIN COUNTER MX3 59 IX3 X7+X3 DECR BY 1 PL X3,GDP1 JUMP IF SUFFICIENT SWAPPED SECTORS SB6 GDP1 ELSE RECLAIM SWAPPED SECTORS JP GETSW GDP1 SENDEV (MAINCL,M.SDISK),(,X3) RELEASE SECTOR COUNTER JP B7 RETURN * * FREE SWAPPED DISK SPACE FOR POINTER BLOCK * FDSKPTR GETEVH (MAINCL,M.SDISK) SX3 1 IX3 X7+X3 SENDEV (MAINCL,M.SDISK),(,X3) JP B7 * * GET SWAPPED DISK SPACE FOR DATA BLOCK * GDSKDAT GETEVH (MAINCL,M.SDISK) IX3 X7-X4 DECR BY NO. OF SECTORS PL X3,GDD1 SB6 GDD1 JP GETSW GDD1 SENDEV (MAINCL,M.SDISK),(,X3) RELEASE COUNTER JP B7 RETURN * * FREE SWAPPED DISK SPACE FOR DATA BLOCK * FDSKDAT SB6 FDD1 JP FREEDSK * + JP B7-1 ALLOCATION ERROR FDD1 GETEVH (MAINCL,M.SDISK) IX3 X7+X4 SENDEV (MAINCL,M.SDISK),(,X3) JP B7 * * EJECT ***************** * MAIN ROUTINES * ***************** * * GETDISK..FIND AND ALLOCATE A BLOCK OF DISK SECTORS * * ON ENTRY, X4=NO OF SECTORS REQUESTED (1,2,4,OR 7) * B6=RETURN (B6-1 IF NO BLOCK FOUND) * ON EXIT, X6=DISK ADDRESS OF OBTAINED BLOCK * USES ALL REGISTERS * * X1 = SCRATCH B1 = CURRENT SECTOR * X2 = BIT MASK B2 = REMAINING SECTORS * X3 = CURRENT UNIT B3 = REMAINING UNITS * X4 = CURRENT ARMPOS B4 = REMAINING ARM POSITIONS * X5 = CURRENT HD GP B5 = REMAINING HD GPS * X6 = STORE SCRATCH B6 = RETURN LINK * X7 = DAT ADDR B7 = OUTER RETURN LINK * * GETDSK SB3 N6638S TOTAL DISK UNITS IN SYSTEM WIDTH X4,3 CONSISTENCY CHECK BX6 X4 SAVE NO OF SECTORS SA6 TEMPV GETDSK2 SB2 GETDSK3 (UNIT LOOP STARTS HERE) JP MASKX2 X2=SECTOR MASK * * RESERVE UNIT AND NOTE SUGGESTIONS LEFT BY PREVIOUS ALLOCATOR * GETDSK3 SA3 MYUNIT MY FAVORITE 6638 GETEVH (MAINCL,X3+M.ADISK) GET ALLOCATION LOCK SA7 TEMPW SAVE IT SB1 X7 SUGGESTED SECTOR AX7 18 SX5 X7 SUGGESTED HD GP AX7 18 LAST KNOWN ARM DESTINATION BX1 X7 * * READ ARM INFO FROM DISK DRIVER * READ (MAINCL,X3+M.BFILE),0,TEMPX,1,GETDSK20 SA4 TEMPX AX4 18+1 SX4 X4 BX1 X4-X1 COMPARE WITH LAST KNOWN ZR X1,GETDSK5 SAME DESTINATION * * START ALLOCATION SEQUENCE AT NEW ARM DESTINATION * BX5 X5-X5 START AT HD GP 0 BX7 X3 LX7 5 BX7 X7+X4 ADDR OF ARM POS TABLE ENTRY REAPT X7,TEMPY READ OPTIMAL STARTING SECTOR SA1 TEMPY SB1 X1 SX7 1 IX7 X1+X7 INCR OPTIMAL STARTING SECTOR SX1 X7-100 TEST FOR WRAP-AROUND NZ X1,GETDSK4 MX1 60-18 BX7 X7*X1 WRAP..SET SECTOR = 0 GETDSK4 SA7 TEMPY WRAPT *,* UPDATE TABLE ENTRY * * DEVELOP DAT ADDRESS * GETDSK5 WIDTH X3,4 CONSISTENCY CHECK WIDTH X4,5 CONSISTENCY CHECK WIDTH X5,5 CONSISTENCY CHECK BX7 X3 UNIT NO. LX7 5 BX7 X7+X4 LX7 5 BX7 X7+X5 INSERT HD GP NO. LX7 1 EACH ENTRY IS 2 WORDS SB2 50 GE B1,B2,GETDSK6 IS SECTOR .GE. 50 LX2 B1,X2 NO...START WITH DAT WORD 1 JP GETDSK7 GETDSK6 SX7 X7+1 YES..START WITH DAT WORD 2 SB2 B1-50 LX2 B2,X2 * GETDSK7 SB4 32 FOR EACH UNIT, DO 32 ARM POSITIONS * GETDSK8 BX1 X3 CONSTRUCT LX1 5 APT BX1 X1+X4 ADDRESS REAPT X1,TEMPY READ APT ENTRY SA1 TEMPY AX1 18 POSITION AVAIL SECTOR COUNT SB2 1 ICK ZR X1,GETDSK16 JUMP IF NO SPACE AT THIS ARM POS SB2 100 ELSE SCAN 100 SECTORS MX6 60-6 BX1 X6*X7 SB5 X7 UGH CHGMAPRW MYSUBP,DENTRY,(MAINCL,M.GFILE),X1+GF.DATF,DATMAP,64, ,(MAINCL,M.GFILE) SX7 B5 UGH * GETDSK9 SB5 32 FOR EACH SECTOR, DO 32 HEAD GROUPS * * * TEST FOR POSSIBLE FREE BLOCK * GETDSK10 MX6 60-6 BX6 -X6*X7 HD GP/SECTOR FROM DAT ADDR SA1 X6+DATMAP BX6 X1*X2 TEST FOR FREE BLOCK NZ X6,GETDSK13 BLOCK NOT FREE * * POSSIBLE FREE BLOCK .. TEST FOR SECTOR 49 WRAP-AROUND * MX6 10 TEST FOR MASK WRAP BX6 X6*X2 ZR X6,GETDSK11 NO...ENTIRE BLOCK FREE AX6 50 YES..POSITION AS PARTIAL MASK SA1 A1+1 BX1 X1*X6 TEST REMAINDER OF BLOCK NZ X1,GETDSK13 ENTIRE BLOCK NOT FREE * * ALLOCATE BLOCK WITH SECTOR 49 WRAP-AROUND * SA1 A1 BX6 X1+X6 ALLOCATE 2ND PIECE OF BLOCK SA6 A1 MX6 10 BX6 -X6*X2 NON-WRAPPED BITS OF MASK SA1 A1-1 BX6 X1+X6 ALLOCATE 1ST PIECE OF BLOCK SA6 A1 JP GETDSK12 GO DEVELOP DISK ADDRESS * * ALLOCATE BLOCK WITHOUT WRAP-AROUND * GETDSK11 BX6 X1+X2 ALLOCATE THE BLOCK SA6 A1 * * DEVELOP DISK ADDRESS OF THE ALLOCATED BLOCK IN X6 * GETDSK12 SX1 B1 SECTOR NO AX7 1 REMOVE LO-ORDER BIT LX7 7 POSITION REST OF DAT ADDRESS BX6 X7+X1 INSERT SECTOR NO. CHECKSUM X6 CONSISTENCY CHECK SA6 TEMPW SAVE DISK ADDR ZRMAP MYSUBP,DENTRY,(MAINCL,M.GFILE) DROP DAT FROM MAP * * DECR AVAIL SECTOR COUNTER IN APT ENTRY * BX7 X3 CONSTRUCT LX7 5 APT BX7 X7+X4 ADDRESS REAPT X7,TEMPY READ APT ENTRY SA1 TEMPY PICK UP APT ENTRY BX7 X1 SA1 TEMPV PICK UP NO OF SECTORS LX1 18 IX7 X7-X1 DECR AVAIL SECTORS SA7 TEMPY WRAPT *,* UPDATE APT ENTRY * * LEAVE SUGGESTIONS FOR NEXT ALLOCATOR * SA1 TEMPV NO. SECTORS REQUESTED SX1 X1+B1 ADD TO LOC OF GOTTEN BLOCK SX1 X1+1 ALLOW FOR DISK DRIVER LAG SX7 X1-100 TEST FOR WRAP AROUND NG X7,GTDSK12A BX1 X7 WRAP AROUND GTDSK12A SX5 X5+1 INCR HD GP NO. SX7 X5-32 TEST FOR WRAP AROUND ZR X7,GTDSK12B WRAP AROUND LX5 18 BX1 X1+X5 INSERT HD GP GTDSK12B LX4 36 BX1 X1+X4 INSERT ARM POS NO. * * RELEASE THE ALLOCATION LOCK ON THE UNIT AND RETURN * SENDEV (MAINCL,X3+M.ADISK),(,X1) SA1 TEMPW RESTORE DISK ADDR BX6 X1 JP B6 * * * TRY NEXT HEAD GROUP * GETDSK13 SX7 X7+2 NEXT DAT ENTRY SX5 X5+1 INCR HD GP NO. SX6 X5-32 TEST FOR WRAP AROUND NZ X6,GETDSK14 NO...PROCEDE SX7 X7-32*2 YES..WRAP TO HD GP 0 SX5 B0 GETDSK14 SB5 B5-1 ANY MORE HD GPS NZ B5,GETDSK10 YES..GO DO NEXT HD GP * NO...MOVE TO NEW SECTOR * TRY NEXT SECTOR * LX2 1 SHIFT MASK ONE SECTOR SB1 B1+1 INCR SECTOR NO. SX6 B1-50 TEST FOR SECTOR 49 WRAP-AROUND ZR X6,GETDSK15 YES..JUMP SX6 B1-100 NO...TEST FOR SECTOR 99 WRAP-AROUND NZ X6,GETDSK16 NO...PROCEDE SB1 B0 YES..WRAP TO SECTOR 0 SX7 X7-1 STEP BACK 1 WORD IN DAT AX2 50 RESET MASK FOR WRAP JP GETDSK16 GETDSK15 SX7 X7+1 AX2 50 RESET MASK FOR WRAP GETDSK16 SB2 B2-1 ANY MORE SECTORS NZ B2,GETDSK9 YES..GO DO NEXT SECTOR * NO...MOVE TO NEW ARM POS * TRY NEXT ARM POS * SA1 TEMPX TEST DIRECTION OF ARM NG X1,GETDSK17 MOVEMENT SX4 X4+1 ARM MOVING POS,INCR POSITION SX7 X7+32*2 INCR DAT ADDRESS SX1 X4-32 NZ X1,GETDSK18 TEST FOR WRAP-AROUND SX4 B0 WRAP TO ARM POS 0 SX7 X7-DAT6638 JP GETDSK18 GETDSK17 SX4 X4-1 ARM MOVING NEG,DECR POSITION SX7 X7-32*2 DECR DAT ADDR PL X4,GETDSK18 TEST FOR WRAP-AROUND SX4 31 WRAP TO ARM POS 31 SX7 X7+DAT6638 GETDSK18 SB4 B4-1 ANY MORE ARM POSITIONS NZ B4,GETDSK8 YES..GO DO NEXT ARM POS * NO...MOVE TO NEW UNIT * * TRY NEXT UNIT * ZRMAP MYSUBP,DENTRY,(MAINCL,M.GFILE) DROP DAT FROM MAP SA4 TEMPW EVENT AS RECEIVED SENDEV (MAINCL,X3+M.ADISK),(,X4) SEND IT BACK SA4 MYUNIT FULL UNIT FALLS SX6 X4+1 OUT OF FAVOR SX7 X6-N6638S NZ X7,GETDSK19 SX6 B0 GETDSK19 SA6 MYUNIT SA4 TEMPV RECALL NO SECTORS NEEDED SB3 B3-1 ANY MORE UNITS NZ B3,GETDSK2 YES..GO DO NEXT UNIT * NO...GO BUY SOME MORE * ALL UNITS FULL (NEVER HAPPENS) * JP B6-1 ERROR RETURN * * FRETURN ON DISK DRIVER FILE * GETDSK20 RJ SYSERR EJECT * * TOGGLE STATUS OF A BLOCK OF DISK SECTORS * * ON ENTRY..X4=NO. OF SECTORS * X5=DISK ADDRESS * * RETURNS: RESULTANT RETURNS * STATUS TO * * ALL FREE B6 * ALL BUSY B6-1 * MIXED SYSERR * * FREEDSK SB1 X4 INDICATE AVAIL SECTOR INCR JP TOGGLE BUSYDSK SB1 X4 INDICATE AVAIL SECTOR DECR SB1 -B1 * * TOGGLE SUMCHECK X5 TEST DISK ADDR CHECKSUM BX7 X4 SA7 TEMPV SAVE NO. OF SECTORS SB2 TOGGL1 JP MASKX2 X2=SECTOR MASK TOGGL1 MX3 60-21 CLEAR CHECK SUM BX3 -X3*X5 AX3 17 UNIT NO. IN X3 GETEVH (MAINCL,X3+M.ADISK) SA7 TEMPW SAVE ALLOCATION LOCK * * ADJUST FREE SECTOR COUNTER IN APT * EXTRACT X7,X5,4+5,5+7 EXTRACT UNIT AND ARMPOS * REAPT X7,TEMPY READ APT ENTRY SA1 TEMPY SX7 B1 AVAIL SECTOR ADJUSTMENT LX7 18 IX7 X1+X7 ADJUST AVAIL SECTOR COUNT SA7 A1 WRAPT *,* * * EXTRACT X7,X5,4+5+5,7 EXTRACT UNIT,ARMPOS AND HDGP * LX7 1 DAT ADDRESS IN X7 MX1 60-7 BX1 -X1*X5 SB1 X1 SECTOR NO. SB2 50 LT B1,B2,TOGGL2 SB1 B1-50 SX7 X7+1 TOGGL2 LX2 B1,X2 POSITION MASK MX1 10 BX1 X2*X1 TEST FOR SECTOR 49 WRAP-AROUND NZ X1,TOGGL3 YES..GO FREE BOTH PIECES * * TOGGLE BLOCK WITHOUT WRAP-AROUND * REDAT X7,DATBUF,1 SA4 DATBUF BX6 X4-X2 SA6 A4 BX1 X6*X2 ZR X1,TOGGL6 JUMP IF ALL FREE SB6 B6-1 BX1 X1-X2 ZR X1,TOGGL6 JUMP IF ALL BUSY * RJ SYSERR MIXED STATUS..CRASH * * TOGGLE BLOCK WITH SECTOR 49 WRAP-AROUND * TOGGL3 SB1 B0 SET 1ST PIECE RESULT CODE SB2 B0 SET 2ND PIECE RESULT CODE BX2 X2-X1 SAVE NON-WRAPPED BITS AX1 50 RESET PARTIAL MASK REDAT X7,DATBUF,2 READ 2 DAT WORDS SA4 DATBUF PICK UP 1ST WORD BX6 X4-X2 TOGGLE 1ST PIECE OF BLOCK SA6 A4 BX4 X6*X2 ZR X4,TOGGL4 JUMP IF 1ST PIECE ALL FREE SB1 1 INDICATE 1ST PIECE ALL BUSY BX4 X4-X2 ZR X4,TOGGL4 JUMP IF 1ST PIECE ALL BUSY SB1 2 INDICATE 1ST PIECE MIXED TOGGL4 SA4 DATBUF+1 BX6 X4-X1 TOGGLE 2ND PIECE OF BLOCK SA6 A4 UPDATE DAT IN CORE BX4 X6*X1 ZR X4,TOGGL4A JUMP IF 2ND PIECE ALL FREE SB2 1 INDICATE 2ND PIECE ALL BUSY BX4 X4-X1 ZR X4,TOGGL4A JUMP IF 2ND PIECE ALL BUSY SB2 2 INDICATE 2ND PIECE MIXED * TOGGL4A EQ B1,B2,TOGGL5 JUMP IF SAME STATUS IN BOTH PIECES RJ SYSERR PIECES DIFFERENT..MIXED STATUS TOGGL5 SB2 B1-2 NZ B2,TOGGL5A RJ SYSERR BOTH PIECES MIXED..CRASH * TOGGL5A SB2 B1-1 NZ B2,TOGGL6 SB6 B6-1 BOTH PIECES BUSY..DECR RETURN ADDR * TOGGL6 WRDAT *,*,* SA1 TEMPW SENDEV (MAINCL,X3+M.ADISK),(,X1) SA4 TEMPV JP B6 EJECT * * SUBROUTINE RECLAIMS FIXED SECTORS * GETFX JP B6 INTERIM NO-OP * * SUBROUTINE RECLAIMS SWAPPED SECTORS * GETSW JP B6 INTERIM NO-OP * * * * * SUBROUTNE FORMS SECTOR BIT MASK IN X2 * MASK MACRO N IFC EQ,/N/SYSERR/ + RJ SYSERR ENDIF IFC NE,/N/SYSERR/ + MX2 60-N BX2 -X2 JP B2 ENDIF ENDM MASK * * MASKX2 SB1 X4 JP B1+MASKX2A MASKX2A MASK SYSERR ILLEGAL MASK 1 64 WORD BLOCK MASK 2 128 WORD BLOCK MASK SYSERR ILLEGAL MASK 4 257 WORD BLOCK MASK SYSERR ILLEGAL MASK SYSERR ILLEGAL MASK 7 513 WORD BLOCK * * SYMBOLS XTEXT OPSYMS XTEXT DATBUF EQU TEMPZ END