home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / c / rkrm / expansion / autoboot.asm next >
Assembly Source File  |  1992-09-03  |  12KB  |  309 lines

  1. *
  2. * Copyright (c) 1992 Commodore-Amiga, Inc.
  3. * This example is provided in electronic form by Commodore-Amiga, Inc. for 
  4. * use with the "Amiga ROM Kernel Reference Manual: Devices", 3rd Edition, 
  5. * published by Addison-Wesley (ISBN 0-201-56775-X).
  6. * The "Amiga ROM Kernel Reference Manual: Devices" contains additional 
  7. * information on the correct usage of the techniques and operating system 
  8. * functions presented in these examples.  The source and executable code 
  9. * of these examples may only be distributed in free electronic form, via 
  10. * bulletin board or as part of a fully non-commercial and freely 
  11. * redistributable diskette.  Both the source and executable code (including 
  12. * comments) must be included, without modification, in any copy.  This 
  13. * example may not be published in printed form or distributed with any
  14. * commercial product.  However, the programming techniques and support
  15. * routines set forth in these examples may be used in the development
  16. * of original executable software products for Commodore Amiga computers.
  17. * All other rights reserved.
  18. * This example is provided "as-is" and is subject to change; no
  19. * warranties are made.  All use is at your own risk. No liability or
  20. * responsibility is assumed.
  21. *
  22. **********************************************************************
  23. *
  24. * Sample autoboot code fragment
  25. *
  26. **********************************************************************
  27.  
  28. **
  29. **
  30. ** These are the calling conventions for the Diag routine
  31. **
  32. ** A7 -- points to at least 2K of stack
  33. ** A6 -- ExecBase
  34. ** A5 -- ExpansionBase
  35. ** A3 -- your board's ConfigDev structure
  36. ** A2 -- Base of diag/init area that was copied
  37. ** A0 -- Base of your board
  38. **
  39. ** Your Diag routine should return a non-zero value in D0 for success.
  40. ** If this value is NULL, then the diag/init area that was copied
  41. ** will be returned to the free memory pool.
  42. **
  43.  
  44.             INCLUDE "exec/types.i"
  45.             INCLUDE "exec/nodes.i"
  46.             INCLUDE "exec/resident.i"
  47.             INCLUDE "libraries/configvars.i"
  48.  
  49.             ; LVO's resolved by linking with library amiga.lib
  50.             XREF   _LVOFindResident
  51.  
  52. ROMINFO     EQU      1
  53. ROMOFFS     EQU     $0
  54.  
  55. * ROMINFO defines whether you want the AUTOCONFIG information in
  56. * the beginning of your ROM (set to 0 if you instead have PALS
  57. * providing the AUTOCONFIG information instead)
  58. *
  59. * ROMOFFS is the offset from your board base where your ROMs appear.
  60. * Your ROMs might appear at offset 0 and contain your AUTOCONFIG
  61. * information in the high nibbles of the first $40 words ($80 bytes).
  62. * Or, your autoconfig ID information may be in a PAL, with your
  63. * ROMs possibly being addressed at some offset (for example $2000)
  64. * from your board base.  This ROMOFFS constant will be used as an
  65. * additional offset from your configured board address when patching 
  66. * structures which require absolute pointers to ROM code or data.
  67.  
  68. *----- We'll store Version and Revision in serial number
  69. VERSION        EQU    37        ; also the high word of serial number
  70. REVISION    EQU    1        ; also the low word of serial number
  71.  
  72. * See the Addison-Wesley Amiga Hardware Manual for more info.
  73.  
  74. MANUF_ID    EQU    2011        ; CBM assigned (2011 for hackers only)
  75. PRODUCT_ID    EQU    1        ; Manufacturer picks product ID
  76.  
  77. BOARDSIZE       EQU     $40000          ; How much address space board decodes
  78. SIZE_FLAG    EQU     3        ; Autoconfig 3-bit flag for BOARDSIZE
  79.                     ;   0=$800000(8meg)  4=$80000(512K)
  80.                     ;   1=$10000(64K)    5=$100000(1meg)
  81.                     ;   2=$20000(128K)   6=$200000(2meg)
  82.                     ;   3=$40000(256K)   7=$400000(4meg)
  83.  
  84.             CODE
  85.  
  86.  
  87. *******  RomStart  ***************************************************
  88. **********************************************************************
  89.  
  90. RomStart:
  91.  
  92.     IFGT    ROMINFO
  93. ;
  94. ;   ExpansionRom structure
  95. ;
  96. ;   Note - If you implement your ExpansionRom and ExpansionControl
  97. ;   with PALS, then you can comment out everything until DiagStart:
  98. ;   (ie. Make ROMID EQU 0)
  99.  
  100. *    ; High nibbles of first two words ($00,$02) are er_Type (not inverted)
  101.                         ; er_Type
  102.         dc.w    $D000            ;   11xx normal board type
  103.                         ;   xx0x not in memory free list
  104.                         ;   xxx1 Diag valid (has driver)
  105.         dc.w    (SIZE_FLAG<<12)&$7000    ;   0xxx not chained
  106.                         ;   xnnn flags board size
  107.  
  108. *    ; High nibbles of next two words are er_Product
  109. *    ; These are inverted (~), as are all other words except $40 and $42
  110.  
  111.                         ; er_Product
  112.         dc.w    (~(PRODUCT_ID<<8))&$f000,(~(PRODUCT_ID<<12))&$f000
  113.  
  114.                         ; er_Flags
  115.         dc.w    (~$C000)&$f000        ;   ~1xxx board is moveable
  116.                         ;   ~x1xx board can't be shut up
  117.         dc.w    (~0)&$f000        ;
  118.  
  119.         dc.w    (~0)&$f000,(~0)&$f000    ; er_Reserved03
  120.  
  121.                         ; er_Manufacturer
  122.         dc.w    (~(MANUF_ID))&$f000,(~(MANUF_ID<<4))&$f000
  123.         dc.w    (~(MANUF_ID<<8))&$f000,(~(MANUF_ID<<12))&$f000
  124.  
  125.                         ; er_SerialNumber
  126.         dc.w    (~(VERSION))&$f000,(~(VERSION<<4))&$f000
  127.         dc.w    (~(VERSION<<8))&$f000,(~(VERSION<<12))&$f000
  128.         dc.w    (~(REVISION))&$f000,(~(REVISION<<4))&$f000
  129.         dc.w    (~(REVISION<<8))&$f000,(~(REVISION<<12))&$f000
  130.  
  131.                         ; er_InitDiagVec
  132.         dc.w    (~((DiagStart-RomStart)))&$f000
  133.         dc.w    (~((DiagStart-RomStart)<<4))&$f000
  134.         dc.w    (~((DiagStart-RomStart)<<8))&$f000
  135.         dc.w    (~((DiagStart-RomStart)<<12))&$f000
  136.  
  137.         dc.w    (~0)&$f000,(~0)&$f000    ; er_Reserved0c
  138.         dc.w    (~0)&$f000,(~0)&$f000    ; er_Reserved0d
  139.         dc.w    (~0)&$f000,(~0)&$f000    ; er_Reserved0e
  140.         dc.w    (~0)&$f000,(~0)&$f000    ; er_Reserved0f
  141.  
  142.     IFNE    *-RomStart-$40
  143.     FAIL    "ExpansionRom structure not the right size"
  144.     ENDC
  145.  
  146.         ;Note: nibbles $40 and $42 are not to be inverted
  147.         dc.w    (0)&$f000,(0)&$f000    ; ec_Interrupt (no interrupts)
  148.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved11
  149.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_BaseAddress (write only)
  150.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Shutup (write only)
  151.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved14
  152.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved15
  153.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved16
  154.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved17
  155.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved18
  156.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved19
  157.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved1a
  158.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved1b
  159.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved1c
  160.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved1d
  161.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved1e
  162.         dc.w    (~0)&$f000,(~0)&$f000    ; ec_Reserved1f
  163.  
  164.     IFNE    *-RomStart-$80
  165.     FAIL    "Expansion Control structure not the right size"
  166.     ENDC
  167.  
  168.     ENDC    ;ROMINFO
  169.  
  170. *******  DiagStart  **************************************************
  171. DiagStart:  ; This is the DiagArea structure whose relative offset from
  172.             ; your board base appears as the Init Diag vector in your
  173.             ; autoconfig ID information.  This structure is designed
  174.             ; to use all relative pointers (no patching needed).
  175.             dc.b    DAC_WORDWIDE+DAC_CONFIGTIME    ; da_Config
  176.             dc.b    0                              ; da_Flags
  177.             dc.w    EndCopy-DiagStart              ; da_Size
  178.             dc.w    DiagEntry-DiagStart            ; da_DiagPoint
  179.             dc.w    BootEntry-DiagStart            ; da_BootPoint
  180.             dc.w    DevName-DiagStart              ; da_Name
  181.             dc.w    0                              ; da_Reserved01
  182.             dc.w    0                              ; da_Reserved02
  183.  
  184. *******  Resident Structure  *****************************************
  185. Romtag:
  186.             dc.w    RTC_MATCHWORD      ; UWORD RT_MATCHWORD
  187. rt_Match:   dc.l    Romtag-DiagStart   ; APTR  RT_MATCHTAG
  188. rt_End:     dc.l    EndCopy-DiagStart  ; APTR  RT_ENDSKIP
  189.             dc.b    RTW_COLDSTART      ; UBYTE RT_FLAGS
  190.             dc.b    VERSION            ; UBYTE RT_VERSION
  191.             dc.b    NT_DEVICE          ; UBYTE RT_TYPE
  192.             dc.b    20                 ; BYTE  RT_PRI
  193. rt_Name:    dc.l    DevName-DiagStart  ; APTR  RT_NAME
  194. rt_Id:      dc.l    IdString-DiagStart ; APTR  RT_IDSTRING
  195. rt_Init:    dc.l    Init-RomStart      ; APTR  RT_INIT
  196.  
  197.  
  198. ******* Strings referenced in Diag Copy area  ************************
  199. DevName:    dc.b    'abc.device',0                      ; Name string
  200. IdString    dc.b    'abc ',48+VERSION,'.',48+REVISION   ; Id string
  201.   
  202. DosName:    dc.b    'dos.library',0                ; DOS library name
  203.  
  204. DosDevName: dc.b    'ABC',0        ; dos device name for MakeDosNode()
  205.