home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / util / rsx2.lbr / RSX.MZC / RSX.MAC
Encoding:
Text File  |  1993-06-09  |  5.6 KB  |  222 lines

  1. ;Revised (along with companion LOADRSX and SETRSX modules) to
  2. ;install below alien RSXs, including Plu*Perfect's non
  3. ;page-aligned stuff.  Many thanks to Plu's Bridger Mitchell
  4. ;for his diagnostic skills.  SETRSX now gives a polite and
  5. ;informative "RSX active" message on "warm boot".
  6. ;Bruce Morgen - June 13, 1987
  7.  
  8. ;UPDATED source to LBRDSK23 version - Bruce Morgen June 10, 1987
  9.  
  10. ;This source is copyright 1984 by Jim Lopushinsky to discourage
  11. ;commercial use.
  12. ;
  13. ;This is the RSX manager that is relocated just below the CCP for use
  14. ;with LBRDISK and other relocatable software that conforms to the
  15. ;RSX format as documented by Digital Research for CP/M Plus
  16. ;
  17. ;March 5/84
  18.  
  19. ;This code is written using Zilog mnemonics, although no Z80 specific
  20. ;instructions are used.  I learned Zilog before Intel, and I find
  21. ;them easier to use and less confusing.
  22. ;
  23. ;To compile and link, see the instructions in SETRSX.MAC
  24. ;
  25. ;The RSX manager supports BDOS function 59, Call RSX manager, altho
  26. ;somewhat differently than the equivalent function in CP/M Plus.
  27. ;
  28. ;Entry parameters:
  29. ;
  30. ;    C     59 (3BH)  Call RSX manager function
  31. ;
  32. ;    DE    0    Remove any inactive RSXs (identical to CP/M Plus)
  33. ;
  34. ;        Address    Add RSX which is already relocated at address
  35. ;            in [DE]
  36. ;
  37. ;          0FFFFH    Remove The RSX manager and any RSXs below it.
  38. ;
  39.  
  40.     .z80
  41.  
  42. bdos    equ    5
  43.  
  44. ;...........
  45. ;
  46. ;This is the RSX header.  It conforms to the CP/M Plus definition
  47. ;so that a minimum of changes are needed if and when the user
  48. ;upgrades to CP/M Plus.  The CP/M Plus loader performs these 
  49. ;functions, and SETRSX is not needed in that version of CP/M
  50. ;
  51. ;
  52. serial:    db    0,0,0,0,0,0    ;Room for serial number. Must begin on
  53.                 ;a page boundary.
  54.     jp    ftest        ;This is where location 6 points to.
  55. next:    jp    6        ;jump to next RSX or the BDOS
  56. prev:    dw    7        ;pointer to previous RSX or location 6
  57. remove:    db    0,0        ;remove flag and non-banked flag
  58. name:    db    'RSX     '    ;name of this RSX (must be 8 bytes)
  59. loader:    db    255,0,0        ;loader flag, and 2 reserved flags
  60. ;
  61. ;End of RSX header. The length must be 27 (1BH) bytes.
  62. ;
  63. wbadr:    dw    wboot        ;SETRSX uses this.
  64. wbsav:    dw    0        ;BIOS WBOOT save
  65.     dw    0        ;Added in LBRDSK23 version
  66.  
  67. ;........
  68. ;
  69. ;
  70. ;All BDOS calls are intercepted here.  We only need to check for function
  71. ;59 (Call RSX manager)
  72. ;
  73.  
  74. ftest:
  75.     ld    a,c        ;get BDOS function
  76.     cp    59        ;is it for us?
  77.     jp    nz,next        ;nope.  on to BDOS
  78.     ld    a,d        ;Is DE zero?
  79.     or    e
  80.     jp    z,chkrsx    ;Yep.  go and remove inactive RSXs
  81.     inc    de        ;is DE FFFFH ?
  82.     ld    a,d
  83.     or    e
  84.     jp    z,rmvrsx    ;Yep. go and kill ourselves.
  85.     dec    de        ;adjust back
  86.     ld    hl,(toptpa)    ;Get top of TPA address
  87.     ld    a,h
  88.     or    l        ;Are we setting up the RSX manager?
  89.     jp    nz,tpaok    ;nope.
  90.     ld    hl,(bdos+1)    ;Need to get top of TPA from 6 if we
  91.                 ;are setting up the RSX manager
  92. tpaok:
  93.     ld    e,18h        ;point to loader flag
  94.     ld    a,(de)
  95.     ld    b,a        ;save loader flag in B
  96.     xor    a        ;just a zero
  97.     ld    e,0dh
  98.     ld    (de),a        ;zero high byte of PREV
  99.     dec    de        ;e = 0ch
  100.     ld    a,7
  101.     ld    (de),a        ;low byte of PREV = 7
  102.     ld    l,e        ;point to PREV in next RSX
  103.     ld    e,0bh        ;point to NEXT in this RSX
  104.     ld    a,b        ;get loader flag
  105.     or    a
  106.     jp    nz,isldr    ;skip over if we are doing the RSX manager
  107.     ld    (hl),e        ;set up PREV pointer in next RSX
  108.     inc    hl
  109.     ld    (hl),d
  110.     dec    hl
  111. ;isldr:
  112.     inc    hl
  113. ISLDR:    ex    de,hl
  114.     ld    (hl),d        ;set up NEXT pointer in this RSX
  115.     dec    hl
  116. ;    ld    (hl),6
  117.  
  118.     LD    A,(BDOS+1)
  119.     JP    NZ,ISLDR2
  120.     LD    A,6
  121. ISLDR2:    LD    (HL),A
  122.  
  123.     ld    l,6
  124.     ld    (bdos+1),hl    ;update location 6
  125.     ld    (toptpa),hl    ;update top of TPA address
  126.     ret
  127.  
  128. ;...........
  129. ;
  130. ;
  131. ;Here if we are to remove ourselves, and everything below.
  132. ;
  133.  
  134. rmvrsx:
  135.     ld    hl,(wbsav)    ;get old BIOS WBOOT vector
  136.     ex    de,hl
  137.     ld    hl,(1)        ;get address of BIOS WBOOT
  138.     inc    hl        ;go over jump inst
  139.     ld    (hl),e        ;restore old bios vector
  140.     inc    hl
  141.     ld    (hl),d
  142.     rst    0        ;of to BIOS WBOOT.
  143.  
  144. ;...........
  145. ;
  146. ;
  147. ;CHKRSX  remove any inactive RSXs.
  148. ;
  149.  
  150. chkrsx:
  151.     ld    hl,(toptpa)    ;get top of TPA
  152.     ld    b,h        ;save page in B
  153. rsxlp:
  154.     ld    h,b        ;get page address
  155.     ld    l,18h        ;point to loader flag
  156.     inc    (hl)
  157.     dec    (hl)
  158.     ret    nz        ;all done if we reached the loader
  159.     ld    l,0bh        ;point to NEXT RSX page
  160.     ld    b,(hl)        ;get next page
  161.     ld    l,0eh        ;point to remove flag
  162.     ld    a,(hl)
  163.     or    a        ;test remove flag
  164.     jp    z,rsxlp        ;skip over if remove flag=0
  165.     ld    l,0ch        ;point to PREV location
  166.     ld    e,(hl)        ;get prev RSX address in DE
  167.     inc    hl
  168.     ld    d,(hl)
  169.     ld    a,b        ;get next RSX page address
  170.     ld    (de),a        ;set up prev RSX NEXT pointer to skip
  171.                 ;this RSX
  172.     dec    de
  173.     ld    a,6
  174.     ld    (de),a
  175.     inc    de
  176.     ld    h,b        ;get next RSX page address
  177.     ld    l,0ch        ;HL points to next RSX PREV address
  178.     ld    (hl),e        ;set up next RSX PREV pointer to skip
  179.                 ;this RSX
  180.     inc    hl
  181.     ld    (hl),d
  182.     ld    a,d
  183.     or    a        ;test PREV page address
  184.     jp    nz,rsxlp    ;loop if PREV doesn't point to page 0
  185.     ld    l,6
  186.     ld    (bdos+1),hl    ;adjust location 6
  187.     ld    (toptpa),hl    ;and top of TPA address
  188.     jp    rsxlp        ;loop for more.
  189.  
  190. ;...........
  191. ;
  192. ;Warm boots are intercepted here.  Inactive RSXs are removed, location 6
  193. ;is restored (in case DDT or SID was used), and a jump to CCP+3.
  194. ;
  195. WBMSG:    DB    13,10,'RSX active$'
  196.  
  197. wboot:
  198.     ld    sp,stack    ;need some stack
  199.     ld    hl,(toptpa)    ;get top of TPA
  200.     ld    (bdos+1),hl    ;restore location 6
  201.     call    chkrsx        ;remove any inactive RSXs
  202. ;    ld    hl,(next+1)    ;get BDOS address
  203. ;    ld    l,0
  204. ;    ld    de,-7fdh    ;offset to CCP entry from BDOS
  205.     LD    C,9
  206.     LD    DE,WBMSG
  207.     CALL    BDOS
  208.     LD    HL,(1)
  209.     LD    DE,0EA00H
  210.     add    hl,de        ;form CCP entry address
  211.     ld    a,(4)        ;pick up drive/user code
  212.     ld    c,a        ;CCP wants it in C
  213.     jp    (hl)        ;off to CCP.
  214.  
  215. ;
  216. ;
  217. toptpa:    dw    0        ;top of TPA address
  218.     ds    4        ;2 level stack needed
  219.     DS    6        ;ADDED in LBRDSK23 version - b/m
  220. stack    equ    $
  221.     end
  222.