home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol050 / rom < prev    next >
Encoding:
Text File  |  1984-04-29  |  5.3 KB  |  360 lines

  1. ;ROM - Data Technology Corporation CP/M 2.2 ROM.
  2. ;
  3. ;    +-----------------------+
  4. ;    |            |
  5. ;    |    R O M   B O O T     |
  6. ;    |            |
  7. ;    +-----------------------+
  8. ;
  9. ;
  10. ;
  11. ;    Version number:    2.2D
  12. ;    Version date:    March 19, 1981
  13. ;
  14. ;    Update date:    March 24, 1981
  15. ;
  16. ;            Boots from logical unit 020h (floppy)
  17. ;            if it is ready.  Passes logical unit number
  18. ;            to the BOOT routine in the A register.
  19. ;
  20. ;    Update date:    June 15, 1981
  21. ;            Modified to wait three seconds for boot
  22. ;            LUN from keyboard.
  23. ;
  24. ;    The following code is supplied to customers who
  25. ;    purchase a hard/floppy disk system from DTC.
  26. ;    The following code is written onto track 0 sector 0
  27. ;    of the hard disk.  This routine is read into memory
  28. ;    at location 0 by the user's PROM.   This routine then
  29. ;    loads the rest of the system into memory.
  30. ;
  31. ;
  32. ;    The format of the Hard Disk Boot sectors are as follows:
  33. ;
  34. ;    Logical        Routine
  35. ;    Sector        Name
  36. ;
  37. ;      0        Boot program
  38. ;
  39. ;    1 thru 8    CCP
  40. ;
  41. ;    9 thru 22    BDOS
  42. ;
  43. ;    23 thru 32    DTC CBIOS
  44. ;
  45. ;
  46.  
  47.  
  48. VERS:    EQU    22
  49.  
  50.  
  51. FWA:    EQU    800H - 20H
  52. BTFWA:    EQU    0100h
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.     ORG    FWA
  60.     JMP    START-FWA
  61.  
  62. START:    LXI    B,0800h
  63.     LXI    H,FWA+0800h
  64.  
  65. START1:    DCX    H
  66.     DCX    B
  67.     LDAX    B
  68.     MOV    M,A
  69.     MOV    A,C
  70.     ORA    B
  71.     JNZ    START1-FWA
  72.     JMP    BOOT
  73.  
  74. ;
  75. ;
  76.     ORG    FWA + 20H
  77.  
  78. BOOT:
  79.     IF    I696
  80.     MVI    A,1
  81.     OUT    0FDh        ;disable rom
  82.  
  83. CNIN:    EQU    0        ;Console input port
  84. CONSTS:    EQU    1        ;Console status port
  85.  
  86. RBR:    EQU    2        ;Input status mask
  87.     ENDIF
  88.  
  89.     IF    I796
  90.     MVI    A,80h
  91.     OUT    0EBh        ;disable rom
  92.  
  93. CNIN:    EQU    0ECh        ;Console input port
  94. CONSTS:    EQU    0EDh        ;Console status port
  95.  
  96. RBR:    EQU    2        ;Input status mask
  97.  
  98. PIT:    EQU    0DEh        ;Programmable interval timer
  99.  
  100. ;    Initialize console
  101.     MVI    A,0B6h        ;Set PIT for 9600 baud
  102.     OUT    PIT+1
  103.     MVI    A,8
  104.     OUT    PIT+0
  105.     MVI    A,0
  106.     OUT    PIT+0
  107.     MVI    A,04Eh        ;Setup serial port
  108.     OUT    CONSTS
  109.     MVI    A,037h
  110.     OUT    CONSTS
  111.     IN    CNIN
  112.     ENDIF
  113.  
  114.     LXI    SP,STACK
  115. ;
  116.     LXI    B,3000        ;wait 3 seconds
  117.     CALL    DELAY
  118.     IN    CONSTS
  119.     ANI    RBR
  120.     JZ    BOOTA        ;if no character
  121.     IN    CNIN        ;Get character pressed
  122.     SUI    '0'
  123.     JM    BOOTA
  124.     CPI    4
  125.     JNC    BOOTA
  126.     RRC
  127.     RRC
  128.     RRC
  129.     STA    LUN
  130. BOOTA:
  131.     LXI    D,BTFWA
  132.     LXI    H,CIOPB
  133.     CALL    RDISK
  134.     ORA    A
  135.     JNZ    BOOTA
  136.     MOV    A,C
  137.     ANI    FERR
  138.     JNZ    BOOTA
  139.     LDA    LUN
  140.     JMP    BTFWA
  141. ;
  142. ;
  143. ;
  144. CIOPB:    DB    RDCMD
  145. LUN:    DB    0
  146.     DW    0        ;Read logical sec 0
  147.     DB    2        ;2 sectors in case of floppy
  148.     DB    0        ;Perform retries
  149. ;    Delay a period of time
  150. ;    Enter:    BC no. of milliseconds to delay
  151.  
  152. DELCNT:    EQU    4*1000         ;4 Mhz
  153.  
  154. DELAY:    MVI    A,DELCNT/26
  155. DLAY1:    INX    B
  156.     DCX    B
  157.     DCR    A
  158.     JNZ    DLAY1
  159.     DCX    B
  160.     MOV    A,B
  161.     ORA    C
  162.     JNZ    DELAY
  163.     RET
  164.  
  165. ;    Disk I/O Routines
  166. ;
  167. ;
  168.     IF    I696
  169. ;    E X E C
  170.  
  171. EXEC:    MVI    B,BUSY        ;Wait for not busy.
  172.     MVI    C,BUSY and (not BUSY)
  173.     CALL    WAITM
  174.     RNZ
  175.     
  176.  
  177.     MVI    A,SLCT        ;Alert controller
  178.     OUT    DIO+1
  179. EXEC1:
  180.     MOV    C,B        ;Wait for controller busy
  181.     CALL    WAITM
  182.     RNZ
  183.  
  184.     MVI    A,DODTA        ;Enable data in
  185.     OUT    DIO+1
  186.  
  187. EXEC2:    IN    DIO+2        ;Get status
  188.     XRI    0FFh
  189.     JM    EXEC2        ;If not requesting next byte
  190.     ANI    CMND+DIROUT
  191.     JNZ    EXEC3        ;If CMND or DIROUT false
  192.     MOV    A,M
  193.     INX    H
  194.     OUT    DIO        ;Send byte from command buffer
  195.     JMP    EXEC2
  196.  
  197. EXEC3:    CMP    A        ;Z:=1
  198.     RET
  199. ;
  200. ;
  201. ;
  202. ;
  203. ;    WDISK - Output from memory buffer.
  204. ;    ENTRY:    HL = COMMAND BUFFER ADDRESS
  205. ;        DE = DATA BUFFER ADDRESS
  206. ;
  207.  
  208. WDISK:    CALL    EXEC        ;Output command
  209.     RNZ            ;Return if timeout
  210. WDISK1:    IN    DIO+2        ;Read status
  211.     ORA    A
  212.     JP    WDISK1        ;If request is present
  213.     ANI    CMND
  214.     JNZ    GCMPS        ;If done with transfer
  215.     LDAX    D        ;Get the data byte
  216.     OUT    DIO
  217.     INX    D        ;Advance buffer address
  218.     JMP    WDISK1
  219. ;
  220. ;
  221. ;
  222. ;
  223. ;    RDISK - Input to memory buffer.
  224. ;
  225. ;    Entry:    HL = command buffer address
  226. ;        DE = data buffer address
  227.  
  228. RDISK:    CALL    EXEC
  229.     RNZ            ;Return if timeout
  230. RDISK1:    IN    DIO+2        ;Read status
  231.     ORA    A
  232.     JP    RDISK1        ;If request is present
  233.     ANI    CMND
  234.     JNZ    GCMPS
  235.     IN    DIO
  236.     STAX    D
  237.     INX    D
  238.     JMP    RDISK1
  239. ;
  240. ;
  241. ;
  242. ;
  243. ;    WAITF - Wait for function to complete.
  244.  
  245. WAITF:    MVI    B,REQ+CMND    ;Wait for both REQ and CMND
  246.     MOV    C,B
  247.     CALL    WAITM
  248.     RNZ
  249. ;
  250. ;    Get completion status.
  251.  
  252. GCMPS:    IN    DIO        ;Get completion status
  253.     MOV    C,A
  254.  
  255. GCMP1:    IN    DIO+2
  256.     ORA    A
  257.     JP    GCMP1        ;If REQ not set
  258.  
  259.     MOV    B,A
  260.     IN    DIO        ;Get message byte
  261.     RET
  262.     ENDIF
  263. ;
  264.  
  265. ;
  266. ;
  267. ;
  268.     IF    I796
  269. ;    EXEC - Output the command
  270. ;
  271. ;    Enter:    HL is the command buffer address
  272. ;        DE - data transfer address.
  273.  
  274. EXEC:
  275.     MOV    A,E        ;Output DMA address
  276.     OUT    DIO+2
  277.     MOV    A,D
  278.     OUT    DIO+3
  279.     MOV    A,L
  280.     OUT    DIO+4
  281.     MOV    A,H
  282.     OUT    DIO+5
  283.     MVI    A,0
  284.     OUT    DIO+6
  285.     OUT    DIO+7
  286.     OUT    DIO
  287.     CMP    A        ;Z:=1
  288.     RET
  289.  
  290.  
  291. ;    Disk read/write
  292. ;
  293. ;    Entry:    same as EXEC
  294. ;
  295. RDISK:
  296. WDISK:    CALL    EXEC
  297.     RNZ            ;Return if timeout
  298.  
  299. ;    WAITF - Wait until transfer done
  300. ;
  301. ;    Enter:    none
  302. ;    Exit:    when transfer completed
  303.  
  304. WAITF:    MVI    B,CMDDON    ;Wait for CMDDON
  305.     MOV    C,B
  306.     CALL    WAITM
  307.     RNZ            ;Return if timeout
  308. ;
  309.  
  310. ;    GCMPS - Get completion status
  311. ;
  312. ;    Enter:    none
  313. ;    Exit:    Status in C
  314. GCMPS:    IN    DIO+1
  315.     MOV    C,A
  316.     RET
  317.     ENDIF
  318.  
  319. ;    WAITM - Wait for controller with timeout
  320. ;
  321. ;    Entry:    B=Status mask
  322. ;        C=Status value
  323. ;    Exit:    Z=1 if OK, else timeout with A=C=TERR
  324. ;
  325. WAITM:
  326.     PUSH    D        ;Save D
  327.     PUSH    H
  328.     LXI    H,138        ;Two minute timeout
  329.     LXI    D,0        ;Max wait @4MHZ is 868 ms
  330. WAITML:
  331.     IF    I696
  332.     IN    DIO+2
  333.     ENDIF
  334.     IF    I796
  335.     IN    DIO
  336.     ENDIF
  337.     ANA    B        ;Mask wait bits
  338.     CMP    C        ;Check value
  339.     JZ    WAITM1
  340.     DCX    D        ;Not ready.  Decrement time
  341.     MOV    A,D
  342.     ORA    E
  343.     JNZ    WAITML
  344.     DCX    H
  345.     MOV    A,H
  346.     ORA    L
  347.     JNZ    WAITML
  348.     MVI    B,0        ;Timeout
  349.     MVI    A,TERR
  350.     ORA    A
  351. WAITM1:
  352.     POP    H
  353.     POP    D        ;Restore D
  354.     MOV    C,A        ;Return status in C
  355.     RET
  356. ;
  357.     ORG    FWA + 200H
  358. STACK:
  359.     END
  360.