
      HED DISC BOOTSTRAP ROUTINES 
      ORG 14000B
* 
* 
*        ISS VERSION
* 
* 
* 
*     THIS PRE-BOOT PROCESSOR RESIDES ON TRACK 0, SECTOR 0 OF 
*  EACH DISC. 
*     IT IS LOADED INTO CORE AT LOCATION BSORG BY THE CORE-RESIDENT 
*  PAPER TAPE/DISC BOOTSTRAP LOADER. IT BEGINS EXECUTION AT LOCATION
*  BSEXC,I  BY READING IN THE DISC BOOTSTRAP FROM BLOCKS 1 & 2
*  AND THEN JUMPS TO IT.
*     THIS PROCESS MAY BE SIMULATED BY LOADING THE PAPER TAPE OF
*  THE LOADER AND STARTING EXECUTION AT 14000B. 
* 
BSLDR EQU *         ORIGIN OF PRE-BOOT PROCESSOR
BSORG EQU 2011B     LOCATION LOADED TO BY CORE-RES. 
*                                    PT/DISC BOOTSTRAP LOADER 
BSEXC EQU 2055B     LOCATION CONTAINING THE ADDRESS 
*                                    WHERE EXECUTION BEGINS 
BSBGN EQU BSLDR-2000B     BIAS FOR ADDRESSES
* 
      JMP BSLD      DISC RELOAD STARTING POINT
      BSS BSORG-2000B-1  FORCE THE TEMPLET TO START 
*                                         AT LOCATION BSORG 
* 
*                                  *
**  SECTOR 0 TEMPLET STARTS HERE  **
*                                  *
LBLBF BSS 32        32-WORD LABEL BUFFER
      BSS BSEXC-BSORG-32 FORCE PRE-BOOT TO START AT 
*                                         LOCATION BSEXC
* 
      DEF *+1-BSBGN PRE-BOOT STARTING ADDRESS 
* 
*  CHECK IF STATUS IS OK AFTER READING IN THE PRE-BOOT PROCESSOR
* 
      NOP           SAVE FOR POSSIBLE MODIFICATION
*                                     OF PROTECTED LOADER IN FUTURE 
      CLC 0,C       CLEAR CONTROL & COMMAND FF'S
      STC BSDAT,C   SET UP DATA CHANNEL 
      LDA BSTUS     GET STATUS COMMAND
      JSB BSCMD 
      LDA BSWDC     USE THE WORD COUNT
BSWTE INA,SZA,RSS   COUNT & TEST
      JMP BSLD0     TOOK TOO LONG 
      SFS BSDAT     WAIT FOR FLAG ON DATA CHANNEL 
      JMP BSWTE 
      LIA BSDAT     LOAD STATUS WORD
      SZA           IS STATUS OK? 
      JMP BSLD0     NO
      HLT 77B       HALT TO PROTECT CORE-RES LOADER 
      JMP BSLD
      SKP 
BSLD0 CLC 0,C       ZAP I/O 
      HLT 1         IRRECOVERABLE 
      JMP *-1         HALT
      SPC 3 
* 
*                  ROUTINE TO ISSUE COMMAND 
* 
BSCMD NOP 
      OTA BSCOM    COMMAND OUT TO COMMAND CHANNEL 
      CLC BSCOM    DROP ENCODE
      STC BSCOM,C  GIVE EDGE ON ENCODE
      JMP BSCMD,I 
* 
*                  WAIT FOR DATA WORD 
* 
BSWTD NOP 
      LDA BSWDC    USE THE WORD COUNT 
BSWTF EQU * 
      INA,SZA,RSS  COUNT AND TEST 
      JMP BSERR    TOOK TOO LONG
      SFS BSDAT    WAIT FOR FLAG ON DATA CHANNEL
      JMP BSWTF 
      JMP BSWTD,I  RETURN 
* 
* 
BSTUS OCT 010000    STATUS COMMAND
BSRCL OCT 020000    RECALIBRATE COMMAND 
BSEEK OCT 030000    POSITION COMMAND
BSRDC OCT 040000    READ COMMAND
BSHS  OCT 000002    HEAD 0 SECTOR 2 
BSDMC ABS 120000B+BSDAT  DMA CONTROL WORD 
BSCAD DEF FBINI,I   INPUT BIT AND CORE ADDRESS
FBSTA DEF FBST
BSWDC DEC -512      NEGATIVE WORD COUNT 
* 
* 
*         ROUTINE TO WAIT FOR THE COMMAND CHANNEL FLAG
*     THEN TO CHECK THE DRIVE STATUS. 
* 
BSWAT NOP 
      CLA 
BSWAX EQU * 
      LDB BSHS,I   WASTE TIME 
      INA,SZA,RSS  COUNT AND TEST 
      JMP BSERR    TOOK TOO LONG, CROAK 
      SFS BSCOM    WAIT FOR COMMAND FLAG
      JMP BSWAX    LOOP 
* 
*                  STATUS ROUTINE 
* 
      STC BSDAT,C  SET UP DATA CHANNEL
      LDA BSTUS    GET STATUS COMMAND 
      JSB BSCMD 
      JSB BSWTD    WAIT FOR WORD
      LIA BSDAT    LOAD STATUS WORD 
      SZA,RSS      SKIP IF BAD STATUS 
      JMP BSWAT,I  STATUS OKAY, RETURN
BSERR EQU * 
      CLC 0,C      ZAP I/O
      HLT 2         RECOVERABLE HALT
* 
*         RECALIBRATE.
* 
      LDA BSRCL    LOAD RECALIBRATE COMMAND,
      JSB BSCMD      ISSUE IT,
      JSB BSWAT        AND WAIT FOR RESULTS.
* 
* 
*     SEEK TO CYL 0, HD/S 0/2 
* 
BSLD  EQU *        ENTRY AND RETRY ADDRESS
      CLA          CYLINDER 0 
      OTA BSDAT    OUT TO DATA CHANNEL
      STC BSDAT,C  SET ENCODE 
      LDA BSEEK    LOAD SEEK COMMAND
      JSB BSCMD      AND DO IT
      JSB BSWTD    WAIT FOR CYLINDER WORD TO GO 
      LDA BSHS     LOAD HEAD 0, SECTOR 2
      OTA BSDAT    WORD OUT TO DATA CHANNEL 
      STC BSDAT,C  ENCODE HIGH
      JSB BSWTD    WAIT FOR HD/S WORD TO GO 
      JSB BSWAT    WAIT FOR SEEK TO FINISH
* 
*     SET UP DMA
* 
      LDA BSDMC    LOAD DMA CONTROL WORD
      OTA DMAH     AND PUT OUT TO DMA HIGH
      CLC DMAL     SET UP FOR CORE ADDRESS
      LDA BSCAD    GET CORE ADDRESS 
      OTA DMAL
      STC DMAL     SET UP FOR WORD COUNT
      LDA BSWDC    GET NEGATIVE WORD COUNT
      OTA DMAL
      STC BSDAT,C  SET ENCODE, CLEAR SRQ
      STC DMAH,C   START DMA CHANNEL
* 
*     ISSUE READ
* 
      LDA BSRDC    GET READ COMMAND 
      JSB BSCMD    ISSUE READ COMMAND 
      JSB BSWAT    WAIT FOR READ TO FINISH
      JMP FBSTA,I   JUMP OVER SST 
      SKP 
*                                                    *
**  THIS ROUTINE WRITES THE PRE-BOOT PROCESSOR      **
*** AND THE DISC BOOTSTRAP TO EACH OF THE ACTIVE   ***
**  DISCS                                           **
*                                                    *
WDLTE NOP 
      LDA WM8       MOVE EIGHT SELECT CODES 
      STA FBTM2       FROM THE SYSTEM 
      LDA FBEQT         DISC DRIVER TABLES
      STA FBTM1           INTO THE BOOTSTRAP
*                                      LOADER TABLES
      LDB DKTBW     => DISC SELECT CODE TABLE 
WDMSC EQU * 
      LDA B,I       LOAD SELECT CODE
      STA FBTM1,I   STORE INTO BOOTSTRAP
      INB 
      ISZ FBTM1 
      ISZ FBTM2     CHECK COUNTER 
      JMP WDMSC 
* 
      LDA MHAD
      STA TMP3W,I   INITIALIZE FNZSC
WDLA  EQU * 
      JSB FNZSW,I   FIND NEXT SELECT CODE 
      JMP WDLTE,I   NO LABEL FOUND
      JSB RDLBB,I   READ IN ORIGINAL LABEL
      JMP BDLBB     CHECKSUM ERROR
      DLD TLRT+TLSL APPEND SYSTEM LEVEL          [B]
      DST LBLBF+8     & FEATURE CODE
      JSB WTLBB,I   WRITE BACK LABEL & PRE-BOOT PROC
      CLB,INB       DISC BOOTSTRAP GOES ON BLK 1 & 2
      LDA WM512     WORD COUNT FOR BOOTSTRAP
      JSB DAIRW,I   FIX DISC ADDRESS
      LDB FBAD      CORE ADDRESS FOR OUTPUT 
      JSB DISCW,I   WRITE ON
      LDA TMP3W,I   CHECK FOR 
      CPA MHAD        WRAP AROUND 
      JMP WDLTE,I 
      JMP WDLA
* 
* 
BDLBB LDA TMP1W,I   INSERT                       [B]
      ADA ASCBW       DISC # INTO                [B]
      STA DIS#B,I       MESSAGE                  [B]
      LDA WD36      ABORT                        [B]
      LDB BDLBC       LOAD                       [B]
      JMP ERRIA,I 
      SKP 
ASCBW ASC 1, 0                                   [B]
ASRW  DEF TTY35 
BDLBC DEF BDLBL 
CLMSA DEF CLMSW 
DAIRW DEF DAIR
DIS#B DEF DIS#                                   [B]
DISCW DEF DISCZ 
DKTBW DEF DKTBL     => DISC SELECT CODE TABLE 
ERRIA DEF ERRIN 
FBAD  DEF FBINI 
FNZSW DEF FNZSC 
ILSIC DEF ILSI
NTSEW DEF NTSE
RCOPW DEF RCOP
RDLBB DEF RDLBL 
RNPTW DEF RNPRT     NUMBER OF PORTS?
RTSWB DEF RTSWP 
SPFRA DEF SPFR
SYSCW DEF SYSCD                                  [B]
TMP1W DEF TEMP1                                  [B]
TMP2W DEF TEMP2 
WTLBB DEF WTLBL 
TMP3W DEF TEMP3 
WM512 DEC -512
WM8   DEC -8
WD36  DEC 36                                     [B]
WD47  DEC 47
      HED DISC RELOAD 
LDKC  EQU * 
      LDA WD47
      LDB NTSEW     => "... NOT SLEPT"
      JSB ASRW,I    PRINT THE ERROR MESSAGE 
      LDA SLEPT     LOAD THE SLEPT FLAG 
      HLT 
      STA SLEPT     SO OVERRIDE IS EASY 
*                               * 
**                             ** 
***  DISC RELOAD ENTERS HERE  *** 
**                             ** 
*                               * 
LDLIB EQU * 
      CLC 0,C 
      LDA SLEPT     CHECK THE FLAG TO SEE IF THE
      SZA             RULES HAVE BEEN FOLLOWED
      JMP LDKC      SYSTEM NOT SLEPT
*                                    TELL THE DISC DRIVER THAT
      STA MBUSY       IT CAN GO AHEAD 
* 
*                                                          *
**   SECTION TO RESTORE SORTED SELECT CODE TABLE TO THE   **
***  SYSTEM DISC DRIVER TABLE.                           ***
**                                                        **
*                                                          *
      LDA FBEQT     => BOOTSTRAP SELECT CODE TABLE
      STA FBTM1 
      LDA WM8       NUMBER OF ALLOWED DISCS 
      STA FBTM2 
      LDB DKTBW     => DISC SELECT CODE TABLE 
LDLAA EQU * 
      LDA FBTM1,I   LOAD SELECT CODE FROM BOOTSTRAP 
      STA B,I       STORE INTO SYSTEM TABLE 
      INB           ADVANCE 
      ISZ FBTM1       POINTERS
      ISZ FBTM2 
      JMP LDLAA 
* 
*                                    *
**  CHECK FOR VALID SYS LEVEL CODE  **
*                                    *
      LDA MHAD      READ IN 
      STA TMP2W,I     DISC LABEL
      JSB RDLBB,I       ON DISC 0 
      JMP BDLBB     CHECKSUM ERROR
      LDA LBLBF+8   IS THE SYSTEM LEVEL CODE ON DISC
      CPA SYSCW,I     SAME AS THAT OF LOADER?    [B]
      RSS           YES - OK
      JMP ILSIC,I   NO - ERROR
* 
      JSB RCOPW,I   ASK FOR CONFIGURATION OPTIONS 
      RSS           NONE. SKIP QUESTION 
      JSB RNPTW,I   ASK NUMBER OF PORTS 
      JSB RTSWB,I   RETURN OLD SWAP TRACKS TO ADTS
      JSB CLMSA,I   CLAIM DISC SPACE FOR SWAP AREAS 
      JMP SPFRA,I 
      HED FINAL DISC BOOTSTRAP
      ORG 14500B
* 
* 
*         THIS ROUTINE IS THE FINAL DISC RELOAD BOOTSTRAP.
*         DURING THE BOOTSTRAP PROCESS, THIS ROUTINE CHECKS TO
*     ENSURE THAT ALL OF THE REQUIRED DRIVES ARE ON LINE. 
*     WHEN ALL OF THE LABELS HAVE BEEN VERIFIED, THE SYSTEM 
*     AND LOADER ARE READ FROM LOGICAL PACK ZERO AND THE
*     BOOTSTRAP JUMPS TO THE LDLIB SECTION WHICH
*     COMPLETES THE DISC RELOAD.
* 
FBINI EQU * 
* 
*                                      *
**  SYSTEM SEGMENT INFORMATION TABLE  **
*                                      *
* 
*  THE FIRST WORD OF THE TABLE GIVES THE NUMBER OF SEGMENTS.  THE 
*  FOUR WORD SEGMENT ENTRIES ARE THE LENGTH OF THE SEGMENT IN 
*  -WORDS, THE ABSOLUTE CORE ADDRESS, AND THE DISC ADDRESS. 
*      THE EXTRA ENTRIES APPENDED TO THE END OF THE TABLE 
*  ARE FOR THE USE OF THE DISC BOOTSTRAP AND REPRESENT THE
*  EQUIPMENT TABLE, THE DIREC TABLE, AND THE
*  TWO HALVES OF THE LOADER.
* 
MLTBL EQU * 
      DEC -8
      ABS 2B-30B        INTERRUPT LOCATIONS 
      OCT 2 
      BSS 2 
      ABS EQTSE-2000B   BASE PAGE 
      ABS EQTSE 
      BSS 2 
      ABS LSLTB-LSLTE   SYSTEM LINKAGE AREA 
      DEF LSLTB 
      BSS 2 
MLDLS EQU * 
      ABS DIREU-42000B  SYSTEM SEGMENT 1
      DEF DIREU 
      BSS 2 
      ABS 42000B-52000B SYSTEM SEGMENT 2
      OCT 42000 
      BSS 2 
      ABS 52000B-62000B SYSTEM SEGMENT 3
      OCT 52000 
      BSS 2 
      ABS 62000B-72000B SYSTEM SEGMENT 4
      OCT 62000 
      BSS 2 
      ABS 72000B-77700B SYSTEM SEGMENT 5
      OCT 72000 
      BSS 2 
MLTBE EQU * 
      ABS EQTB-EQTSE    EQUIPMENT TABLE SEGMENT 
      DEF EQTB
      BSS 2 
MLTBF EQU * 
      ABS DIREC-DIREU   DIREC TABLE SEGMENT 
      DEF DIREC 
      BSS 2 
MLTLC EQU * 
      ABS SAT-26000B    LOADER SEGMENT 2         [B]
      DEF SAT                                    [B]
      BSS 2 
      ABS 2000B-FBINI   LOADER SEGMENT 1
      OCT 2000
      BSS 2 
      ABS 26000B-DIREC  DISC DRIVER SEGMENT 
      OCT 26000 
      BSS 2 
MLTBN EQU * 
* 
FBST  EQU * 
      CLA 
      STA FBCYL     SET CYLINDER TO ZERO
      STA FBHDS     SET HEAD/SECTOR TO ZERO 
      LDB FBM32     B _ -32 
      STB FBWD      SET TRANSFER LENGTH TO 32 
      LDB FBLQT     POINTER TO LOGICAL PACK INFO
      STB FBTM1 
      LDB FBSEQ     GET POINTER TO SORT TABLE 
      STB FBTM3 
      LDB FBM8      B _ - 8 
      STB FBTM2     SET COUNT 
FBIZL EQU * 
      STA FBTM3,I   ZERO SORT TABLE 
      STB FBTM1,I   SET SIGN NEGATIVE 
      ISZ FBTM3     ADVANCE SORT TABLE POINTER
      ISZ FBTM1     COUNT UP POINTER. 
      ISZ FBTM2     PROCESS ALL EIGHT 
      JMP FBIZL 
* 
* 
*     READ PACK LABELS, AND VERIFY CHECKSUMS AND ID'S 
*     FOR ALL DRIVES IN DEQT. 
* 
*                                   A = 0 
FBDRL EQU * 
      STA FBTPT     START WITH DRIVE ZERO 
      ADA FBEQT     MAKE POINTER TO SELECT CODE 
      LDA A,I       GET SELECT CODE, UNIT NUMBER
      SZA,RSS       SKIP IF VALID DRIVE 
      JMP FBESL     NO DRIVE PRESENT
      LDB FBTPT     LOAD UNIT NUMBER
      BLF,RBL       * 32
      ADB FBLBA     GENERATE CORE ADDRESS FOR LABEL 
      STB FBTM1     SAVE FOR LATER CHECK
      JSB FBRD      CALL FOR READ 
      LDA FBM32     A _ -32 
      STA FBTM2 
      CCA           A _ - 1 
FBCKL EQU * 
      XOR FBTM1,I   CHECK 
      ISZ FBTM1      THE
      ISZ FBTM2       CHECKSUM
      JMP FBCKL     XOR OF ALL 32 WORDS 
      SZA             SHOULD BE ZERO. 
      JMP FBER3     LABEL NO GOOD 
      LDB FBTPT     B = UNIT NUMBER 
      BLF,RBL 
      ADB FBLBA     B => LABEL BUFFER 
      INB           B => TSB-DOS SPECIFIER
      LDA B,I       A = ID
      XOR FBATS     IS ID TSB 
      SZA           SKIP IF BIT FOR BIT MATCH 
      JMP FBER3     LABEL NOT FOR TSB 
      INB           B => LOGICAL PACK NUMBER
      LDA B,I       A = LOGICAL PACK NUMBER 
      STA FBTM3 
      LDB FBM8      B _ -8
      STB FBTM2 
      LDB FBLQT     POINTER TO LOGICAL NUMBER TABLE 
FBICC EQU * 
      CPA B,I       LOOK FOR DRIVES WITH THE
      JMP FBER4     SAME LOGICAL PACK NUMBER. 
      INB 
      ISZ FBTM2     CHECK COUNT 
      JMP FBICC     LOOK THROUGH ENTIRE TABLE 
      LDB FBTPT     LOAD DISC NUMBER
      ADB FBLQT     B => TABLE ENTRY
      STA B,I       PUT THIS PACK INTO TABLE
      ADA FBEQT     WAS THIS LOGICAL
      LDA A,I         UNIT PRESENT IN 
      SZA,RSS           THE ORIGINAL SYSTEM?
      JMP FBER4     NO
      LDB FBTPT     GET DISC NUMBER 
      ADB FBEQT     LOAD ITS
      LDA B,I         SELECT CODE 
      LDB FBTM3 
      ADB FBSEQ     GENERATE SORT TABLE ADDRESS 
      STA B,I       STORE SELECT CODE INTO SORT TABLE 
* 
FBESL EQU * 
      LDA FBTPT     LOAD UNIT NUMBER
      INA           COUNT UP TO NEXT UNIT 
      CPA FBD8      CHECK FOR DONE
      CLA,RSS       DONE, WE'VE READ ALL LABELS 
      JMP FBDRL     BACK TO READ THE NEXT ONE 
      SKP 
