home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference_library / hardware / hard_examples / coldreboot.asm < prev    next >
Assembly Source File  |  1992-08-20  |  3KB  |  62 lines

  1. ;
  2. ; coldboot.asm
  3. ;
  4. ; Here is a source code listing of the only supported reboot code:
  5. ;
  6.  
  7. *   NAME
  8. *       ColdReboot - Official code to reset any Amiga (Version 2)
  9. *
  10. *   SYNOPSIS
  11. *       ColdReboot()
  12. *       void ColdReboot(void);
  13. *
  14. *   FUNCTION
  15. *       Reboot the machine.  All external memory and peripherals will be
  16. *       RESET, and the machine will start its power up diagnostics.
  17. *
  18. *       Rebooting an Amiga in software is very tricky.  Differing memory
  19. *       configurations and processor cards require careful treatment.  This
  20. *       code represents the best available general purpose reset.  The
  21. *       MagicResetCode must be used exactly as specified here. The code
  22. *       _must_ be longword aligned.  Failure to duplicate the code EXACTLY
  23. *       may result in improper operation under certain system configurations.
  24. *
  25. *   RESULT
  26. *    This function never returns.
  27.  
  28.                     INCLUDE "exec/types.i"
  29.                     INCLUDE "exec/libraries.i"
  30.  
  31.                     XDEF    _ColdReboot
  32.                     XREF    _LVOSupervisor
  33.  
  34. ABSEXECBASE         EQU 4           ;Pointer to the Exec library base
  35. MAGIC_ROMEND        EQU $01000000   ;End of Kickstart ROM
  36. MAGIC_SIZEOFFSET    EQU -$14        ;Offset from end of ROM to Kickstart size
  37. V36_EXEC            EQU 36          ;Exec with the ColdReboot() function
  38. TEMP_ColdReboot     EQU -726        ;Offset of the V36 ColdReboot function
  39.  
  40. _ColdReboot:    move.l  ABSEXECBASE,a6
  41.                 cmp.w   #V36_EXEC,LIB_VERSION(a6)
  42.                 blt.s   old_exec
  43.                 jmp     TEMP_ColdReboot(a6)     ;Let Exec do it...
  44.                 ;NOTE: Control flow never returns to here
  45.  
  46. ;---- manually reset the Amiga ---------------------------------------------
  47. old_exec:       lea.l   GoAway(pc),a5           ;address of code to execute
  48.                 jsr     _LVOSupervisor(a6)      ;trap to code at (a5)...
  49.                 ;NOTE: Control flow never returns to here
  50.  
  51. ;-------------- MagicResetCode ---------DO NOT CHANGE-----------------------
  52.                 CNOP    0,4                     ;IMPORTANT! Longword align!
  53. GoAway:         lea.l   MAGIC_ROMEND,a0         ;(end of ROM)
  54.                 sub.l   MAGIC_SIZEOFFSET(a0),a0 ;(end of ROM)-(ROM size)=PC
  55.                 move.l  4(a0),a0                ;Get Initial Program Counter
  56.                 subq.l  #2,a0                   ;now points to second RESET
  57.                 reset                           ;first RESET instruction
  58.                 jmp     (a0)                    ;CPU Prefetch executes this
  59.                 ;NOTE: the RESET and JMP instructions must share a longword!
  60. ;---------------------------------------DO NOT CHANGE-----------------------
  61.                 END
  62.