home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / exec / rebooting / ColdReboot.asm next >
Encoding:
Assembly Source File  |  1980-02-04  |  4.6 KB  |  115 lines

  1. ****************************************************************************
  2. *            Amiga Software Reboot, Revisited
  3. *
  4. *                By Bryce Nesbitt
  5. *
  6. *    Copyright 1990 Commodore-Amiga, Inc.  Permission granted to
  7. *    reproduce in full ONLY.  The information contained herein is
  8. *    subject to change without notice, and is provided "as is" without
  9. *    warranty of any kind, either express or implied.  The entire risk
  10. *    as to the use of this information is assumed by the user.
  11. *
  12. *
  13. * Sometimes applications need to be able to reboot the Amiga under software
  14. * control.  However, rebooting the machine is very tricky, and most attempts
  15. * have been flawed.  The RESET instruction, for example, unconfigures all
  16. * memory; after RESET there is no reliable place to run user code.  Most
  17. * reboot code will break whenever the memory or CPU configuration is
  18. * changed.  Other reset code will not work properly on the Amiga 1000.
  19. *
  20. * In fact, rebooting the Amiga is so tricky that even the official reboot
  21. * code published by Commodore will not work in every case. (This article
  22. * replaces "The Official Way to Software Reboot an Amiga" from the
  23. * July/August 1989 issue of Amiga Mail, Exec, page III-9.)  Some versions of
  24. * the A2000 have a 0.1 uf capacitor (C909) on the hardware reset line.
  25. * This capacitor has the effect of rejecting short reset pulses, including
  26. * some of those generated by the CPU RESET instruction.
  27. *
  28. * The ColdReboot() function listed below should be used whenever an
  29. * application needs to reboot the Amiga.  ColdReboot() is the only officially
  30. * supported way to reboot an Amiga under software control.
  31. *
  32. * Even this code will fail under some circumstances.  Certain processor
  33. * cards developed by Great Valley Products (GVP) lock up when the RESET
  34. * instruction is used.  GVP offers an upgrade PAL to fix this problem.
  35. * Likewise, if the user has a 68020 or 68030 coprocessor card and has copied
  36. * the Kickstart ROM image into 32-bit memory with the command SetCPU FASTROM,
  37. * the NewReboot() function will not work properly.  To fix this, give the
  38. * command SetCPU NOFASTROM.
  39. *
  40. * TECHNICAL DESCRIPTION: The code below precalculates a jump address,
  41. * executes a RESET instruction, then relies on CPU prefetch to execute the
  42. * jump.  The precalculated jump is constructed to enter the system ROM at the
  43. * location of a second RESET instruction.
  44. *
  45. *
  46. *
  47. ****************************************************************************
  48. *
  49. *   NAME
  50. *    ColdReboot - Official code to reset any Amiga (Version 2)
  51. *
  52. *   SYNOPSIS
  53. *    ColdReboot()
  54. *
  55. *    void ColdReboot(void);
  56. *
  57. *   FUNCTION
  58. *    Reboot the machine.  All external memory and peripherals will be
  59. *    RESET, and the machine will start its power up diagnostics.
  60. *
  61. *   NOTE
  62. *    Rebooting an Amiga in software is very tricky.    Differing memory
  63. *    configurations and processor cards require careful treatment.  This
  64. *    code represents the best available general purpose reset.
  65. *
  66. *    The MagicResetCode must be used exactly as specified here. The code
  67. *    _must_ be longword aligned.  Failure to duplicate the code EXACTLY
  68. *    may result in improper operation under certain system configurations.
  69. *
  70. *   RESULT
  71. *    This function never returns.
  72. *
  73. ****************************************************************************
  74.  
  75.         INCLUDE "exec/types.i"
  76.         INCLUDE "exec/libraries.i"
  77.  
  78.         XDEF    _ColdReboot
  79.         XREF    _LVOSupervisor
  80.  
  81. ABSEXECBASE        EQU 4        ;Pointer to the Exec library base
  82. MAGIC_ROMEND        EQU $01000000   ;End of Kickstart ROM
  83. MAGIC_SIZEOFFSET    EQU -$14        ;Offset from end of ROM to Kickstart size
  84. V36_EXEC        EQU 36        ;Exec with the ColdReboot() function
  85. TEMP_ColdReboot     EQU -726        ;Offset of the V36 ColdReboot function
  86.  
  87.  
  88. _ColdReboot:    move.l    ABSEXECBASE,a6
  89.         cmp.w    #V36_EXEC,LIB_VERSION(a6)
  90.         blt.s    old_exec
  91.         jmp    TEMP_ColdReboot(a6)     ;Let Exec do it...
  92.         ;NOTE: Control flow never returns to here
  93.  
  94.  
  95. ;---- manually reset the Amiga ---------------------------------------------
  96. old_exec:    lea.l    GoAway(pc),a5           ;address of code to execute
  97.         jsr    _LVOSupervisor(a6)      ;trap to code at (a5)...
  98.         ;NOTE: Control flow never returns to here
  99.  
  100.  
  101. ;-------------- MagicResetCode ---------DO NOT CHANGE-----------------------
  102.         CNOP    0,4            ;IMPORTANT! Longword align!
  103. GoAway:     lea.l    MAGIC_ROMEND,a0     ;(end of ROM)
  104.         sub.l    MAGIC_SIZEOFFSET(a0),a0 ;(end of ROM)-(ROM size)=PC
  105.         move.l    4(a0),a0                ;Get Initial Program Counter
  106.         subq.l    #2,a0            ;now points to second RESET
  107.         reset                ;first RESET instruction
  108.         jmp    (a0)                    ;CPU Prefetch executes this
  109.         ;NOTE: the RESET and JMP instructions must share a longword!
  110. ;---------------------------------------DO NOT CHANGE-----------------------
  111.         END
  112.  
  113.  
  114.  
  115.