Search
lxdream.org :: lxdream/src/asic.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/asic.c
changeset 1:eea311cfd33e
next2:42349f6ea216
author nkeynes
date Sat Mar 13 00:03:32 2004 +0000 (15 years ago)
permissions -rw-r--r--
last change This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches.
file annotate diff log raw
nkeynes@1
     1
#include <assert.h>
nkeynes@1
     2
#include "dream.h"
nkeynes@1
     3
#include "mem.h"
nkeynes@1
     4
#include "sh4/intc.h"
nkeynes@1
     5
#include "asic.h"
nkeynes@1
     6
#include "maple.h"
nkeynes@1
     7
#define MMIO_IMPL
nkeynes@1
     8
#include "asic.h"
nkeynes@1
     9
/*
nkeynes@1
    10
 * Open questions:
nkeynes@1
    11
 *   1) Does changing the mask after event occurance result in the
nkeynes@1
    12
 *      interrupt being delivered immediately?
nkeynes@1
    13
 *   2) If the pending register is not cleared after an interrupt, does
nkeynes@1
    14
 *      the interrupt line remain high? (ie does the IRQ reoccur?)
nkeynes@1
    15
 * TODO: Logic diagram of ASIC event/interrupt logic.
nkeynes@1
    16
 *
nkeynes@1
    17
 * ... don't even get me started on the "EXTDMA" page, about which, apparently,
nkeynes@1
    18
 * practically nothing is publicly known...
nkeynes@1
    19
 */
nkeynes@1
    20
nkeynes@1
    21
void asic_init( void )
nkeynes@1
    22
{
nkeynes@1
    23
    register_io_region( &mmio_region_ASIC );
nkeynes@1
    24
    register_io_region( &mmio_region_EXTDMA );
nkeynes@1
    25
    mmio_region_ASIC.trace_flag = 0; /* Because this is called so often */
nkeynes@1
    26
    asic_event( EVENT_GDROM_CMD );
nkeynes@1
    27
}
nkeynes@1
    28
nkeynes@1
    29
void mmio_region_ASIC_write( uint32_t reg, uint32_t val )
nkeynes@1
    30
{
nkeynes@1
    31
    switch( reg ) {
nkeynes@1
    32
        case PIRQ0:
nkeynes@1
    33
        case PIRQ1:
nkeynes@1
    34
        case PIRQ2:
nkeynes@1
    35
            /* Clear any interrupts */
nkeynes@1
    36
            MMIO_WRITE( ASIC, reg, MMIO_READ(ASIC, reg)&~val );
nkeynes@1
    37
            break;
nkeynes@1
    38
        case MAPLE_STATE:
nkeynes@1
    39
            MMIO_WRITE( ASIC, reg, val );
nkeynes@1
    40
            if( val & 1 ) {
nkeynes@1
    41
                uint32_t maple_addr = MMIO_READ( ASIC, MAPLE_DMA) &0x1FFFFFE0;
nkeynes@1
    42
//                maple_handle_buffer( maple_addr );
nkeynes@1
    43
		WARN( "Maple request initiated, halting" );
nkeynes@1
    44
                MMIO_WRITE( ASIC, reg, 0 );
nkeynes@1
    45
                sh4_stop();
nkeynes@1
    46
            }
nkeynes@1
    47
            break;
nkeynes@1
    48
        default:
nkeynes@1
    49
            MMIO_WRITE( ASIC, reg, val );
nkeynes@1
    50
            WARN( "Write to ASIC (%03X <= %08X) [%s: %s]",
nkeynes@1
    51
                  reg, val, MMIO_REGID(ASIC,reg), MMIO_REGDESC(ASIC,reg) );
nkeynes@1
    52
    }
nkeynes@1
    53
}
nkeynes@1
    54
nkeynes@1
    55
int32_t mmio_region_ASIC_read( uint32_t reg )
nkeynes@1
    56
{
nkeynes@1
    57
    int32_t val;
nkeynes@1
    58
    switch( reg ) {
nkeynes@1
    59
        case PIRQ0:
nkeynes@1
    60
        case PIRQ1:
nkeynes@1
    61
        case PIRQ2:
nkeynes@1
    62
            val = MMIO_READ(ASIC, reg);
nkeynes@1
    63
//            WARN( "Read from ASIC (%03X => %08X) [%s: %s]",
nkeynes@1
    64
//                  reg, val, MMIO_REGID(ASIC,reg), MMIO_REGDESC(ASIC,reg) );
nkeynes@1
    65
            return val;            
nkeynes@1
    66
        case G2STATUS:
nkeynes@1
    67
            return 0; /* find out later if there's any cases we actually need to care about */
nkeynes@1
    68
        default:
nkeynes@1
    69
            val = MMIO_READ(ASIC, reg);
nkeynes@1
    70
            WARN( "Read from ASIC (%03X => %08X) [%s: %s]",
nkeynes@1
    71
                  reg, val, MMIO_REGID(ASIC,reg), MMIO_REGDESC(ASIC,reg) );
nkeynes@1
    72
            return val;
nkeynes@1
    73
    }
nkeynes@1
    74
           
nkeynes@1
    75
}
nkeynes@1
    76
nkeynes@1
    77
void asic_event( int event )
nkeynes@1
    78
{
nkeynes@1
    79
    int offset = ((event&0x60)>>3);
nkeynes@1
    80
    int result = (MMIO_READ(ASIC, PIRQ0 + offset))  |=  (1<<(event&0x1F));
nkeynes@1
    81
nkeynes@1
    82
    if( result & MMIO_READ(ASIC, IRQA0 + offset) )
nkeynes@1
    83
        intc_raise_interrupt( INT_IRQ13 );
nkeynes@1
    84
    if( result & MMIO_READ(ASIC, IRQB0 + offset) )
nkeynes@1
    85
        intc_raise_interrupt( INT_IRQ11 );
nkeynes@1
    86
    if( result & MMIO_READ(ASIC, IRQC0 + offset) )
nkeynes@1
    87
        intc_raise_interrupt( INT_IRQ9 );
nkeynes@1
    88
}
nkeynes@1
    89
nkeynes@1
    90
nkeynes@1
    91
nkeynes@1
    92
MMIO_REGION_WRITE_FN( EXTDMA, reg, val )
nkeynes@1
    93
{
nkeynes@1
    94
    MMIO_WRITE( EXTDMA, reg, val );
nkeynes@1
    95
}
nkeynes@1
    96
nkeynes@1
    97
MMIO_REGION_READ_FN( EXTDMA, reg )
nkeynes@1
    98
{
nkeynes@1
    99
    switch( reg ) {
nkeynes@1
   100
        case GDBUSY: return 0;
nkeynes@1
   101
        default:
nkeynes@1
   102
            return MMIO_READ( EXTDMA, reg );
nkeynes@1
   103
    }
nkeynes@1
   104
}
nkeynes@1
   105
.