home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDX500 / CHECK.S < prev    next >
Encoding:
Text File  |  2001-02-09  |  6.3 KB  |  199 lines

  1. ;+
  2. ;  CHECK.S - check for existence of different components in system.
  3. ;-
  4.  
  5. .include    "defs.h"
  6. .include    "68030.s"
  7.  
  8. REGBASE    equ    1            ; most are on odd part of data bus
  9. bSCSI    equ    $FFFF8780+REGBASE    ; base address of SCSI bus
  10. bAT    equ    $FFF00000+REGBASE    ; base address of AT bus
  11. WDC    equ    $FFFF8604        ; base address of ACSI bus
  12.  
  13. ;+
  14. ; chkscsi() - Check if SCSI bus exists
  15. ;
  16. ; Uses: d0, d1, d2, a0, a1
  17. ;-
  18.     .globl    _chkscsi
  19. _chkscsi:                ; check if SCSI exists
  20.     move.l    #0,savssp        ; no stack pointer is saved yet
  21.     move.l    #1,-(sp)        ; find out what mode processor is in
  22.     move.w    #$20,-(sp)        ; Super(1L)
  23.     trap    #1
  24.     addq.w    #6,sp            ; clean up stack
  25.     tst.w    d0            ; in Supervisor mode already?
  26.     bne.s    tscsi            ; if so, go test for SCSI
  27.     clr.l    -(sp)            ; else go to Supervisor mode
  28.     move.w    #$20,-(sp)        ; Super(0L)
  29.     trap    #1
  30.     addq.w    #6,sp            ; clean up stack
  31.     move.l    d0,savssp        ; save original stack pointer
  32. tscsi:    clr.w    result            ; assume SCSI doesn't exist
  33.     movea.l    BERR,a0            ; save original bus error vector
  34.     move.l    #nbus,BERR        ; install our own vector
  35.     movea.l    sp,a1            ; save current stack pointer
  36.     move.b    bSCSI,d1        ; try to access the SCSI bus
  37.     move.w    #1,result        ; if no bus error, SCSI exists
  38. nbus:    move.l    a0,BERR            ; restore original bus error vector
  39.     move.l    a1,sp            ; restore stack pointer
  40. chkret:    tst.l    savssp            ; were we in User mode when started?
  41.     beq.s    tend            ; if not, just return
  42.     move.l    savssp,-(sp)        ; go back to User mode 
  43.     move.w    #$20,-(sp)        ; Super(savssp)
  44.     trap    #1
  45.     addq.w    #6,sp            ; clean up stack
  46. tend:    move.w    result,d0        ; d0 = result
  47.     rts
  48.  
  49.  
  50. ;+
  51. ; chkacsi() - Check if ACSI bus exists
  52. ;
  53. ; Uses: d0, d1, d2, a0, a1
  54. ;-
  55.     .globl    _chkacsi
  56. _chkacsi:                ; check if SCSI exists
  57.     move.l    #0,savssp        ; no stack pointer is saved yet
  58.     move.l    #1,-(sp)        ; find out what mode processor is in
  59.     move.w    #$20,-(sp)        ; Super(1L)
  60.     trap    #1
  61.     addq.w    #6,sp            ; clean up stack
  62.     tst.w    d0            ; in Supervisor mode already?
  63.     bne.s    tacsi            ; if so, go test for SCSI
  64.     clr.l    -(sp)            ; else go to Supervisor mode
  65.     move.w    #$20,-(sp)        ; Super(0L)
  66.     trap    #1
  67.     addq.w    #6,sp            ; clean up stack
  68.     move.l    d0,savssp        ; save original stack pointer
  69. tacsi:    clr.w    result            ; assume SCSI doesn't exist
  70.     movea.l    BERR,a0            ; save original bus error vector
  71.     move.l    #nbus,BERR        ; install our own vector
  72.     movea.l    sp,a1            ; save current stack pointer
  73.     move.w    WDC,d1            ; try to access the ACSI bus
  74.     move.w    #1,result        ; if no bus error, ACSI exists
  75.     bra    nbus
  76.  
  77.  
  78. ;+
  79. ; chkide() - Check if IDE bus exists
  80. ;
  81. ; Uses: d0, d1, d2, a0, a1
  82. ;-
  83.     .globl    _chkide
  84. _chkide:                    ; check if AT bus exists
  85.     move.l    #0,savssp        ; no stack pointer is saved yet
  86.     move.l    #1,-(sp)        ; find out what mode processor is in
  87.     move.w    #$20,-(sp)        ; Super(1L)
  88.     trap    #1
  89.     addq.w    #6,sp            ; clean up stack
  90.     tst.w    d0            ; in Supervisor mode already?
  91.     bne.s    tide            ; if so, go test for AT
  92.     clr.l    -(sp)            ; else go to Supervisor mode
  93.     move.w    #$20,-(sp)        ; Super(0L)
  94.     trap    #1
  95.     addq.w    #6,sp            ; clean up stack
  96.     move.l    d0,savssp        ; save original stack pointer
  97. tide:    clr.w    result            ; assume AT bus doesn't exist
  98.     movea.l    BERR,a0            ; save original bus error vector
  99.     move.l    #nbus,BERR        ; install our own vector
  100.     movea.l    sp,a1            ; save current stack pointer
  101.     move.b    bAT,d1            ; try to access the AT bus
  102.     move.w    #1,result        ; if no bus error, AT exists
  103.     bra    nbus
  104.  
  105.  
  106. ;+
  107. ; chkblit() - Check if BLiTTER exists
  108. ;
  109. ; Uses: d0
  110. ;-
  111.     .globl    _chkblit
  112. _chkblit:
  113.     move.w    #-1,-(sp)
  114.     move.w    #64,-(sp)        ; blitmode(-1)
  115.     trap    #14
  116.     addq.w    #4,sp            ; clean up stack
  117.     btst    #1,d0            ; does BLiTTER exist?
  118.     beq.s    nblit
  119.     moveq    #1,d0            ; return 1 if exists
  120.     rts
  121. nblit:    moveq    #0,d0            ; return 0 if not
  122.     rts
  123.  
  124.  
  125. ;+
  126. ; chkcache() - Check if '030 cache exists
  127. ;
  128. ; Uses: d0, d1, d2, a0, a1
  129. ;-
  130.     .globl    _chkcache
  131. _chkcache:                ; check if '030 cache exists
  132.     move.l    #0,savssp        ; no stack pointer is saved yet
  133.     move.l    #1,-(sp)        ; find out what mode processor is in
  134.     move.w    #$20,-(sp)        ; Super(1L)
  135.     trap    #1
  136.     addq.w    #6,sp            ; clean up stack
  137.     tst.w    d0            ; in Supervisor mode already?
  138.     bne.s    tcache            ; if so, go test for cache
  139.     clr.l    -(sp)            ; else go to Supervisor mode
  140.     move.w    #$20,-(sp)        ; Super(0L)
  141.     trap    #1
  142.     addq.w    #6,sp            ; clean up stack
  143.     move.l    d0,savssp        ; save original stack pointer
  144. tcache:    clr.w    result            ; assume cache doesn't exist
  145.     movea.l    IINS,a0            ; save orig illegal instrn vector
  146.     move.l    #ncache,IINS        ; install our own vector
  147.     movea.l    sp,a1            ; save current stack pointer
  148.     movecacrd0            ; does a cache exist?
  149.     move.w    #1,result        ; if so, set result
  150. ncache:    move.l    a0,IINS            ; restore orig illegal instrn vector
  151.     move.l    a1,sp            ; restore stack pointer
  152.     bra    chkret
  153.  
  154.  
  155. ;+
  156. ; _Stbook() - to find out if driver is being run on the ST Book.
  157. ;
  158. ; Comments:
  159. ;    On the ST Book, the palette registers are only readable.
  160. ; So, to determine if the driver is being run on the ST Book, write
  161. ; to the palette registers, and then read them back.  If what read
  162. ; back isn't the same as what's been written, it IS an ST Book.
  163. ; The palette starts at address $ffff8240.
  164. ;-
  165.     .globl  _stbook
  166. _stbook:
  167.     move.l    #0,savssp        ; no stack pointer is saved yet
  168.     move.l    #1,-(sp)        ; find out what mode processor is in
  169.     move.w    #$20,-(sp)        ; Super(1L)
  170.     trap    #1
  171.     addq.w    #6,sp            ; clean up stack
  172.     tst.w    d0            ; in Supervisor mode already?
  173.     bne.s    tbook            ; if so, go test if it's STBook
  174.     clr.l    -(sp)            ; else go to Supervisor mode
  175.     move.w    #$20,-(sp)        ; Super(0L)
  176.     trap    #1
  177.     addq.w    #6,sp            ; clean up stack
  178.     move.l    d0,savssp        ; save original stack pointer
  179. tbook:    move.l  $ffff8242,d2        ; save palette registers old values
  180.     move.w  #$0555,$ffff8242    ; write new pattern to 1st register
  181.     move.w  #$0222,$ffff8244    ; write new pattern to 2nd register
  182.     move.w  #1,result        ; assume it IS an ST Book
  183.     move.w  $ffff8242,d1        ; read from 1st palette register
  184.     and.w   #$0777,d1        ; mask out useless bits
  185.     cmp.w   #$0555,d1        ; value stays the same?
  186.     bne.s   .0            ; if not, it IS an ST Book
  187.     move.w  $ffff8244,d1        ; read from 2nd palette register
  188.     and.w   #$0777,d1        ; mask out useless bits
  189.     cmp.w   #$0222,d1        ; value stays the same?
  190.     bne.s   .0            ; if not, it IS an ST Book
  191.     move.w  #0,result        ; else, it is NOT an ST Book
  192.     move.l  d2,$ffff8242        ; restore palette registers
  193. .0:    bra    chkret    
  194.  
  195.  
  196. .bss
  197. savssp:    ds.l    1            ; stack pointer
  198. result:    ds.w    1
  199.