home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / ForcePRAM.sit / ForceAppleTalk.a < prev    next >
Text File  |  1994-03-01  |  4KB  |  137 lines

  1.     Title    'Force AppleTalk and LAP settings' ;
  2. *
  3. * Module for "Force" shell.
  4. * Ben Cranston March 1, 1994
  5. *
  6.     Print    Off            ; Here be includes
  7.     Include    'RomEqu.a'        ;
  8.     Include    'Traps.a'        ;
  9.     Print    On,NoGen        ; Here be includes
  10.     Main                ; Begin module
  11. *
  12. S    Record    {A6Link},Decr        ; Stack frame
  13. A6Link    DS.L    1            ; Caller's A6
  14. SPB    DS    SpBlock            ; Slot Parameter Block
  15. Curr    DS.L    1            ; Current PRAM value
  16. Want    DS.L    1            ; Desired PRAM value
  17. Flag    DS.W    1            ; Desired PRAM setup flags
  18. Boot    DS.W    1            ; Set if reboot required
  19. SS    Equ    *            ; Stack size
  20.     EndR                ; Stack frame
  21. *
  22. * Get resource containing the desired PRAM contents.
  23. *
  24.     Link    A6,#S.SS        ; Make local frame
  25.     Clr.W    S.Boot(A6)        ; Initially set no reboot
  26.     Tst.L    D1            ; Was our data resource present?
  27.     BEq.W    @999            ; If not then just return
  28.     Move.L    D1,A0            ; Get resource handle
  29.     Move.L    (A0),A0            ; Get pointer
  30.     Move.W    (A0),S.Flag(A6)        ; Get desired value
  31. *
  32.     Eject                ;
  33. *
  34. * Test if AppleTalk is to be turned off entirely.
  35. *
  36.     Clr.L    S.Want(A6)        ; Initially set AppleTalk OFF
  37.     Move.B    S.Flag+0(A6),D1        ; Get master flag
  38.     BEq.S    @030            ; Is AppleTalk to be turned off entirely?
  39. *
  40. * Test if LocalTalk is wanted.
  41. *
  42.     Move.B    #1,S.Want+3(A6)        ; Set AppleTalk on LocalTalk
  43.     Cmp.B    #1,D1            ; Want LocalTalk or EtherTalk?
  44.     BEq.S    @030            ; Want EtherTalk, skip
  45. *
  46. * Find Ethernet card address to complete the desired PRAM value.
  47. *
  48.     LEA    S.SPB(A6),A0        ; Get spBlock address
  49.     Move.B    S.Flag+1(A6),spBlock.spSlot(A0) ; Set slot to start searching at
  50.     Clr.B    spBlock.spId(A0)    ; Find any resource number
  51.     Clr.B    spBlock.spExtDev(A0)    ; External device zero?
  52.     Clr.B    spBlock.spHwDev(A0)    ; Ignore external hardware
  53.     Move.B    #3,spBlock.spTBMask(A0)    ; Look at Category and CType
  54.     Move.W    #catNetwork,spBlock.spCategory(A0) ; Network category
  55.     Move.W    #typEtherNet,spBlock.spCType(A0) ; EtherNet type
  56.     _sNextTypesRsrc            ; Get next sResource info
  57.     BNE.W    @900            ; If nofind then get out
  58.     Move.B    spBlock.spSlot(A0),S.Want+0(A6) ; Get network card slot number
  59.     Move.B    spBlock.spId(A0),S.Want+1(A6) ; Get slot resource ID number
  60.     Clr.B    S.Want+2(A6)        ; Clear unused field
  61.     Move.B    #$A,D1            ; Get EtherTalk Phase 2 code
  62.     Cmp.B    #2,S.Flag+0(A6)        ; Did he want Phase 1?
  63.     BNE.S    @020            ; If not then assume Phase 2
  64.     Move.B    #$2,D1            ; Get EtherTalk Phase 1 code
  65. @020    ;
  66.     Move.B    D1,S.Want+3(A6)        ; Set Phase 1 / Phase 2 code
  67. *
  68.     Eject                ;
  69. *
  70. * Read PRAM for AppleTalk On/Off selection, decide if we must change it.
  71. *
  72. @030    ;
  73.     Move.L    #$00010013,D0        ; Byte 13
  74.     LEA    S.Curr(A6),A0        ; Point to stack space
  75.     _ReadXPram            ; Read current setting from parameter RAM
  76.     BNE.S    @900            ; If error then get out
  77.     Move.B    #1,D1            ; Get "ON" value
  78.     Tst.L    S.Want(A6)        ; Do we want it on?
  79.     BNE.S    @040            ; Yes, go set it ON
  80.     Move.B    #2,D1            ; Else get "OFF" value
  81. @040    ;
  82.     LEA    S.Curr(A6),A0        ; Get address of current value
  83.     Move.B    (A0),D2            ; Get current value
  84.     And.B    #$0F,D2            ; Get AppleTalk config bits
  85.     Cmp.B    D2,D1            ; Is it the desired value?
  86.     BEq.S    @050            ; Yes, go check LAP status
  87. *
  88. * Rewrite AppleTalk On/Off selection in PRAM and force reboot.
  89. *
  90.     Move.B    (A0),D2            ; Get current value
  91.     And.B    #$F0,D2            ; Keep upper 4 bits
  92.     Or.B    D1,D2            ; Use our lower bits
  93.     Move.B    D2,(A0)            ; Set current value
  94.     Move.L    #$00010013,D0        ; Bytes E0 thru E3
  95.     _WriteXPram            ; Write back to parameter RAM
  96.     Move.W    #1,S.Boot(A6)        ; Set flag to force reboot
  97.     Tst.L    S.Want(A6)        ; Did we want it off?
  98.     BEq.S    @999            ; Yes, we are done
  99. *
  100.     Eject                ;
  101. *
  102. * Read PRAM for AppleTalk LAP selection, decide if we must change it.
  103. *
  104. @050    ;
  105.     Move.L    #$000400E0,D0        ; Bytes E0 thru E3
  106.     LEA    S.Curr(A6),A0        ; Point to stack space
  107.     _ReadXPram            ; Read current from parameter RAM
  108.     BNE.S    @900            ; If error then get out
  109.     Move.B    S.Curr+1(A6),D1        ; Get current alt atalk type
  110.     Cmp.B    S.Want+1(A6),D1        ; Same as desired?
  111.     BNE.S    @060            ; No, must reset and reboot
  112.     Move.B    S.Curr+3(A6),D1        ; Get current alt level
  113.     Cmp.B    S.Want+3(A6),D1        ; Same as desired?
  114.     BEq.S    @999            ; If so then skip
  115. *
  116. * Rewrite AppleTalk LAP selection in PRAM and force reboot.
  117. *
  118. @060    ;
  119.     LEA    S.Want(A6),A0        ; Get address of desired
  120.     Move.L    #$000400E0,D0        ; Bytes E0 thru E3
  121.     _WriteXPram            ; Write back to parameter RAM
  122.     Move.W    #1,S.Boot(A6)        ; Set flag to force reboot
  123.     Bra.S    @999            ; Return to driver
  124. *
  125. * Some kind of error, just return OK status.
  126. *
  127. @900    ;
  128.     Clr.W    S.Boot(A6)        ; Set no reboot
  129. *
  130. @999    ;
  131.     Move.W    S.Boot(A6),D0        ; Set return value
  132.     UnLk    A6            ; Drop local frame
  133.     RTS                ; Return to INIT31
  134. *
  135.     EndMain                ; Keep MPW happy
  136.     End                ; ForceAppleTalk.a
  137.