home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d0xx / d087 / install.lha / Install / Bryce / install.asm next >
Encoding:
Assembly Source File  |  1987-07-08  |  5.9 KB  |  260 lines

  1. ;INSTALL, Public domain.
  2. ;Please tell me about any enhacements,changes,bugs or brain-damage in this
  3. ;code.    bryce@cogsci.berkeley.EDU -or- ucbvax!cogsci!bryce
  4. ;Bryce Nesbitt 1712 Marin Ave.    Berkeley, Ca 94707-2206
  5. ;
  6. ;FUNCTION:
  7. ;   Works just like the CLI INSTALL command.
  8. ;
  9. ;BUGS:
  10. ;   I use ARP.LIBRARY for all my parsing.  You don't have that and I can't
  11. ;   give it to you yet.  Thus this version of INSTALL is hardwired for DF0:
  12. ;
  13. ;   For some reason that is not entirely my fault, if the disk in DF0: is
  14. ;   write-protected INSTALL will merrily report success.
  15. ;
  16. ;   The second "bug" will be worked around in the final ARP release.
  17. ;
  18. ;NOTES:
  19. ;   Assembled with METACOMCO and blink'ed with BLINK
  20. ;
  21.  NOLIST
  22.  INCLUDE 'exec/types.i'
  23.  INCLUDE 'exec/memory.i'
  24.  INCLUDE 'exec/ports.i'
  25.  INCLUDE 'exec/io.i'
  26.  INCLUDE 'libraries/dos.i'
  27.  INCLUDE 'libraries/dosextens.i'
  28.  INCLUDE 'devices/trackdisk.i'
  29.  ;INCLUDE 'lib/exec_lib.i'   ;my peculiarities.
  30.  ;INCLUDE 'lib/dos_lib.i'    ;you don't have these
  31. blink macro
  32.  bchg #1,$bfe001
  33.  endm
  34. jsrlib MACRO
  35.  xref _LVO\1
  36.  jsr _LVO\1(a6)
  37.  ENDM
  38. jmplib MACRO
  39.  xref _LVO\1
  40.  jmp _LVO\1(a6)
  41.  ENDM
  42.  LIST
  43. **************************
  44.  
  45. ;--Get ready...--
  46.         move.l    4,a6
  47.         lea.l    DOSName,a1
  48.         jsrlib    OldOpenLibrary
  49.         move.l    d0,a6
  50.  
  51.         lea.l    bblock,a0
  52.         move.l    a0,a1
  53.  
  54.         move.l    #128+127,d3
  55.         moveq    #0,d0
  56.         move.l    d0,4(a0)
  57.         move.w    #0,CCR
  58. chksum        move.l    (a1)+,d1
  59.         addx.l     d1,d0
  60.         dbra    d3,chksum
  61.         neg.l    d0
  62.         subq.l    #1,d0
  63.         move.l    d0,4(a0)
  64.  
  65.         moveq    #0,d0
  66.         bsr    WRITELBLOCK
  67.         bne.s    e_block
  68.  
  69.         lea.l    yess,a0
  70.         moveq    #yese-yess,d3
  71.         bra.s    in
  72. e_block     lea.l    nos,a0
  73.         moveq    #noe-nos,d3
  74. in        move.l    a0,d2
  75.         jsrlib    Output
  76.         move.l    d0,d1
  77.         beq.s    e_output
  78.         jsrlib    Write
  79.         moveq    #0,d0
  80.         rts
  81. e_memory
  82. e_output
  83. e_deviceproc    moveq    #20,d0
  84.         rts
  85. ;
  86. ; port=CREATEPORTE(),exec
  87. ; d0             a6
  88. ; z=error
  89. ;
  90. ;FUNCTION: Create a nameless message port, 0 priority.
  91. ;RESULT: The port pointer or Z=1 if an error occured.
  92. ;REGISTERS: A6 must contain exec!
  93. ;EXAMPLE:    bsr    CREATEPORTE
  94. ;        beq.s    noport    ;Not enough memory (or signals)
  95. ;
  96.         ;xref    CREATEPORTE
  97. CREATEPORTE    move.l    a2,-(a7)
  98.         move.l    #MEMF_PUBLIC+MEMF_CLEAR,d1
  99.         moveq    #MP_SIZE,d0
  100.         jsrlib    AllocMem
  101.         move.l    d0,a2
  102.         tst.l    d0
  103.         beq.s    cp_nomemory
  104.         moveq    #-1,d0
  105.         jsrlib    AllocSignal    ;d0=return
  106.         moveq    #-1,d1
  107.         cmp.l    d0,d1    ;-1 indicates bad signal
  108.         bne.s    cp_sigok
  109.         move.l    a2,a1
  110.         moveq    #MP_SIZE,d0
  111.         jsrlib    FreeMem
  112. cp_nomemory    move.l    (a7)+,a2
  113.         moveq    #0,d0
  114.         rts
  115.  
  116. cp_sigok    move.b    d0,MP_SIGBIT(a2)
  117.         move.b    #PA_SIGNAL,MP_FLAGS(a2)
  118.         move.b    #NT_MSGPORT,LN_TYPE(a2)
  119.         clr.b    LN_PRI(a2)
  120.         suba.l    a1,a1           ;a1=0/Find this task
  121.         jsrlib    FindTask       ;[d0=this task]
  122.         move.l    d0,MP_SIGTASK(a2)
  123.         lea.l    MP_MSGLIST(a2),a0  ;Point to list header
  124.         NEWLIST a0        ;Init new list macro
  125.         move.l    a2,d0
  126.         move.l    (a7)+,a2    ;cc's NOT affected
  127.         rts
  128. ;
  129. ;DELETEPORTE(port),exec
  130. ;         a1    a6
  131. ;
  132. ;FUNCTION:  Deletes the port by first setting some
  133. ; fields to illegal values then calling FreeMem.
  134. ;RESULT: none
  135. ;REGISTERS: A6 must contain exec!
  136. ;
  137.         ;xref    DELETEPORTE
  138. DELETEPORTE    move.l    a1,-(a7)
  139.         moveq    #-1,d0
  140.         move.b    d0,LN_TYPE(a1)
  141.         move.l    d0,MP_MSGLIST+LH_HEAD(a1)
  142.         moveq    #0,d0    ;Clear upper 3/4 of d0
  143.         move.b    MP_SIGBIT(a1),d0
  144.         jsrlib    FreeSignal
  145.         move.l    (a7)+,a1
  146.         moveq    #MP_SIZE,d0
  147.         jmplib    FreeMem
  148. ;
  149. ;WRITELBLOCK(buffer,block)
  150. ;       a0      d0
  151. ;
  152. WRITELBLOCK    movem.l d2/a3/a6,-(a7)
  153.         move.l    4,a6
  154.            ;move.l    d0,d2
  155.         move.l    a0,a3
  156.         suba.l    #IOTD_SIZE,a7
  157.         moveq    #IOTD_SIZE-1,d0 ;clear the new IORequest (slowly)
  158.         move.l    a7,a0
  159. clearit     clr.b    (a0)+
  160.         dbra    d0,clearit
  161.         bsr    CREATEPORTE
  162.         beq    e_TDport
  163.         move.l    d0,MN_REPLYPORT(a7)
  164.         move.b    #NT_MESSAGE,LN_TYPE(a7)
  165.         lea.l    TrackName,a0
  166.         move.l    a7,a1
  167.         moveq    #0,d0
  168.         moveq    #0,d1
  169.         jsrlib    OpenDevice  ;[a0-name|d0=unit|a1-IO|d1-flags]
  170.         tst.l    d0
  171.         bne.s    e_TDopen
  172.  
  173.         move.w    #CMD_WRITE,IO_COMMAND(a7) ;ETD!!
  174.         move.l    #1024,IO_LENGTH(a7)
  175.            ;moveq    #9,d0
  176.            ;asl.l    d0,d2    ;shift d2 by d0
  177.            ;move.l    d2,IO_OFFSET(a7)
  178.            clr.l   IO_OFFSET(a7)
  179.         move.l    a3,IO_DATA(a7)
  180.         move.l    a7,a1
  181.         jsrlib    DoIO    ;[a1-IO]
  182.         move.b    IO_ERROR(a7),d0    ;cc's set
  183.         bne.s    e_TDerror
  184.  
  185.         move.w    #CMD_UPDATE,IO_COMMAND(a7) ;ETD!!
  186.         ;move.l  #1024,IO_LENGTH(a7)
  187.         ;moveq #0,d2
  188.         ;move.l  d2,IO_OFFSET(a7)
  189.         ;move.l  a3,IO_DATA(a7)
  190.         move.l    a7,a1
  191.         jsrlib    DoIO    ;[a1-IO]
  192.  
  193.         move.w    #TD_MOTOR,IO_COMMAND(a7) ;ETD!!
  194.         clr.l    IO_LENGTH(a7)        ;motor off
  195.         ;moveq     #0,d2
  196.         ;move.l  d2,IO_OFFSET(a7)
  197.         ;move.l  a3,IO_DATA(a7)
  198.         move.l    a7,a1
  199.         jsrlib    DoIO    ;[a1-IO]
  200.         moveq    #0,d7
  201.         move.b    IO_ERROR(a7),d7
  202.         bra    e_good
  203. e_TDerror
  204. e_TDopen
  205. e_TDport    moveq    #-1,d7
  206.  
  207. e_good        move.l    MN_REPLYPORT(a7),a1
  208.         bsr    DELETEPORTE
  209.         adda.l    #IOTD_SIZE,a7       ;cc's not
  210.         movem.l (a7)+,d2/a3/a6       ;cc's not
  211.         move.l    d7,d0
  212.         rts
  213.  
  214.         DATA
  215. ;----------------------------------------------------------------------
  216. ;This is the actual boot-block.  From the descriptions in the RKM I was
  217. ;able to determine the registers.  From there to code was three steps;
  218. ;I tired OpenLibrary on DOS, zilch.  Tried returning the value from
  219. ;FindResident, crash.  And at last the correct answer -> extract the
  220. ;init pointer from the resident structure.
  221. ;
  222. ;Later investigation revealed:
  223. ;At boot-block time DOS.LIBRARY has not been built.  A perfect time to
  224. ;add a totally different DOS!  If you want to call the current DOS you
  225. ;will need a hyper-kludge.
  226. ;The code at the jump address returned by the boot code builds the DOS
  227. ;library, sends a message the does a REMTASK (!).  No hope of using a JSR
  228. ;to return control.
  229. ;
  230. ;This area is checksumed on the fly, so feel free to change it either
  231. ;in source or object form.
  232. ;
  233.         cnop 0,4
  234. bblock        dc.b 'DOS',0    ;Disk Type
  235.         dc.l 0        ;Checksum
  236.         dc.l 880    ;Root block key
  237.  
  238.         move.l    4,a6
  239.         lea.l    DOSName(pc),a1
  240.         jsrlib    FindResident
  241.         move.l    d0,a0
  242.         tst.l    d0
  243.         bne.s    LibOpenOk
  244.         subq.l    #1,d0        ;make -1
  245.         rts            ;failure
  246. DOSName     dc.b    'dos.library',0
  247. LibOpenOk    move.l    $16(a0),a0  ;Initial Jump
  248.         moveq    #0,d0        ;success
  249.         rts
  250. here
  251.         dcb.b 1024-(here-bblock),0  ;Pad block with zeros
  252. ;-- static data --
  253. yess        dc.b 'Disk in drive DF0: is now bootable.',10
  254. yese
  255. nos        dc.b 'Install DF0: failed',10
  256. noe
  257. TrackName    dc.b 'trackdisk.device',0
  258.         END
  259.  
  260.