コード例 #1
0
ファイル: timervblank.c プロジェクト: michalsc/AROS
int vblank_Init(struct TimerBase *LIBBASE)
{
    LIBBASE->tb_VBlankInt.is_Node.ln_Pri  = 0;
    LIBBASE->tb_VBlankInt.is_Node.ln_Type = NT_INTERRUPT;
    LIBBASE->tb_VBlankInt.is_Node.ln_Name = LIBBASE->tb_Device.dd_Library.lib_Node.ln_Name;
    LIBBASE->tb_VBlankInt.is_Code         = (VOID_FUNC)VBlankInt;
    LIBBASE->tb_VBlankInt.is_Data	  = LIBBASE;

    AddIntServer(INTB_VERTB, &LIBBASE->tb_VBlankInt);
    return TRUE; /* We can't fail */
}
コード例 #2
0
ファイル: bus_ppc460.c プロジェクト: michalsc/AROS
/* Actually a quick hack. Proper implementation really needs HIDDizing this code. */
static BOOL ata460_CreateInterrupt(struct ata_Bus *bus)
{
    bus->ab_IntHandler.is_Node.ln_Type = NT_INTERRUPT;
    bus->ab_IntHandler.is_Node.ln_Name = "Sam460ex SATA/IDE";
    bus->ab_IntHandler.is_Node.ln_Pri  = 0;
    bus->ab_IntHandler.is_Code = (VOID_FUNC)ata460_Interrupt;
    bus->ab_IntHandler.is_Data = bus;

    AddIntServer(INTB_KERNEL + bus->ab_IRQ, &bus->ab_IntHandler);

    return TRUE;
}
コード例 #3
0
static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR LIBBASE)
{
    /* Setup the timer.device data */
    LIBBASE->tb_CurrentTime.tv_secs = 0;
    LIBBASE->tb_CurrentTime.tv_micro = 0;
    LIBBASE->tb_VBlankTime.tv_secs = 0;
    LIBBASE->tb_VBlankTime.tv_micro = 1000000 / (SysBase->VBlankFrequency * SysBase->PowerSupplyFrequency);
    LIBBASE->tb_Elapsed.tv_secs = 0;
    LIBBASE->tb_Elapsed.tv_micro = 0;

    D(kprintf("Timer period: %ld secs, %ld micros\n",
	LIBBASE->tb_VBlankTime.tv_secs, LIBBASE->tb_VBlankTime.tv_micro));

    LIBBASE->tb_MiscFlags = TF_GO;

    /* Initialise the lists */
    NEWLIST( &LIBBASE->tb_Lists[0] );
    NEWLIST( &LIBBASE->tb_Lists[1] );
    NEWLIST( &LIBBASE->tb_Lists[2] );
    NEWLIST( &LIBBASE->tb_Lists[3] );
    NEWLIST( &LIBBASE->tb_Lists[4] );

    /* Start the timer2 */
    outb((inb(0x61) & 0xfd) | 1, 0x61); /* Enable the timer (set GATE on) */
    outb(0xb6, 0x43);   /* Binary mode on Timer2, count mode 3? */
    outb(0x00, 0x42);   /* We're counting whole range */
    outb(0x00, 0x42);

    LIBBASE->tb_prev_tick = 0xffff;

    /* Start up the interrupt server. This is shared between us and the
	HIDD that deals with the vblank */
    LIBBASE->tb_VBlankInt.is_Node.ln_Pri = 0;
    LIBBASE->tb_VBlankInt.is_Node.ln_Type = NT_INTERRUPT;
    LIBBASE->tb_VBlankInt.is_Node.ln_Name = (STRPTR)MOD_NAME_STRING;
    LIBBASE->tb_VBlankInt.is_Code = (APTR)&VBlankInt;
    LIBBASE->tb_VBlankInt.is_Data = LIBBASE;

    AddIntServer(INTB_TIMERTICK, &LIBBASE->tb_VBlankInt);

    /* VBlank EMU */

    LIBBASE->tb_vblank_timerequest.tr_node.io_Command = TR_ADDREQUEST;
    LIBBASE->tb_vblank_timerequest.tr_node.io_Device = (struct Device *)TimerBase;
    LIBBASE->tb_vblank_timerequest.tr_node.io_Unit = (struct Unit *)UNIT_MICROHZ;
    LIBBASE->tb_vblank_timerequest.tr_time.tv_secs = 0;
    LIBBASE->tb_vblank_timerequest.tr_time.tv_micro = 1000000 / SysBase->VBlankFrequency;

    SendIO(&LIBBASE->tb_vblank_timerequest.tr_node);

    return TRUE;
}
コード例 #4
0
ファイル: _functab.c プロジェクト: cycl0ne/poweros_raspi
struct TimerBase *timer_InitDev(struct TimerBase *TimerBase, UINT32 *segList, struct SysBase *SysBase)
{
	TimerBase->Device.dd_Library.lib_OpenCnt = 0;
	TimerBase->Device.dd_Library.lib_Node.ln_Pri = 0;
	TimerBase->Device.dd_Library.lib_Node.ln_Type = NT_DEVICE;
	TimerBase->Device.dd_Library.lib_Node.ln_Name = (STRPTR)DevName;
	TimerBase->Device.dd_Library.lib_Version = VERSION;
	TimerBase->Device.dd_Library.lib_Revision = REVISION;
	TimerBase->Device.dd_Library.lib_IDString = (STRPTR)Version;

	TimerBase->Timer_SysBase = SysBase;
	
    /* Setup the timer.device data */
	TimerBase->CurrentTime.tv_secs  = 0;
	TimerBase->CurrentTime.tv_micro = 0;

    TimerBase->VBlankTime.tv_secs = 0;
    TimerBase->VBlankTime.tv_micro = STC_FREQ_HZ / TICK; //TimerPeriod;
    TimerBase->Elapsed.tv_secs = 0;
    TimerBase->Elapsed.tv_micro = 0;

	NewList((struct List *) &TimerBase->Lists[UNIT_MICROHZ] );
	NewList((struct List *) &TimerBase->Lists[UNIT_VBLANK] );
	NewList((struct List *) &TimerBase->Lists[UNIT_ECLOCK] );
	NewList((struct List *) &TimerBase->Lists[UNIT_WAITUNTIL] );
	NewList((struct List *) &TimerBase->Lists[UNIT_WAITECLOCK] );

	//DPrintF("[Timer] TimerBase: %x, OpenDevice: %x\n", TimerBase, timer_BeginIO);
	// VBL (100hz) Timer
	TimerBase->Timer3IntServer = CreateIntServer(DevName, TIMER_INT_PRI, Timer3IRQServer, TimerBase);
	AddIntServer(IRQ_TIMER3, TimerBase->Timer3IntServer);

	// EClock Timer
	TimerBase->Timer1IntServer = CreateIntServer(DevName, TIMER_INT_PRI, Timer1IRQServer, TimerBase);
	AddIntServer(IRQ_TIMER1, TimerBase->Timer1IntServer);
	
	return TimerBase;
}
コード例 #5
0
ファイル: arch_clk_init.c プロジェクト: cycl0ne/poweros_x86
void arch_clk_init(SysBase *SysBase)
{
	struct Interrupt *irq;
	irq = CreateIntServer("IRQ0 Clock", -100, clock_handler, SysBase);
//DPrintF("clk_init -> irq: %x -> %x\n",irq, irq->is_Code);


//	monitor_write("Going to AddIntServer\n");
//	monitor_write_hex((UINT32)irq);
//	monitor_write("\nLeaving AddIntServer\n");
	AddIntServer(IRQ_CLK, irq);
	clkcnt =0; // for Dbg
	set_timer(HZ);
}
コード例 #6
0
static void SmallDelay(struct ExecBase *SysBase)
{
    struct Interrupt i;
    
    i.is_Code 	      = (APTR)AHITimerTickCode;
    i.is_Data 	      = FindTask(0);
    i.is_Node.ln_Name = "AROS AHI Driver Timer Tick Server";
    i.is_Node.ln_Pri  = 0;
    i.is_Node.ln_Type = NT_INTERRUPT;
    
    SetSignal(0, SIGBREAKF_CTRL_F);
    AddIntServer(INTB_TIMERTICK, &i);
    Wait(SIGBREAKF_CTRL_F);
    RemIntServer(INTB_TIMERTICK, &i);
}
コード例 #7
0
ファイル: mousehack.c プロジェクト: ApolloniaUK/PUAE
int main(int argc, char **argv)
{
    struct IntuitionBase *ibase;
    struct InputEvent *iev;
    struct IOStdReq *ioreq = 0;
    struct MsgPort *port;

    struct timerequest *timereq = 0;
    struct MsgPort *timeport;
    int oldx = 0, oldy = 0;
    int i;

    i = (*calltrap) (0);
    if (i == 0) {
	fprintf(stderr, "mousehack not needed for this version of UAE.\n");
	exit (0);
    }
    if (i == -1) {
	fprintf(stderr, "mousehack already running.\n");
	exit (5);
    }

    i = AllocSignal (-1);
    if (i < 0)
	goto fail;
    foo.sigbit = 1 << i;

    port = CreatePort(0, 0);
    timeport = CreatePort (0, 0);
    if (port)
	ioreq = CreateStdIO(port);

    if (timeport)
	timereq = CreateStdIO(timeport);

    if (ioreq == 0)
	goto fail;
    if (timereq == 0)
	goto fail;

    iev = AllocMem (sizeof (struct InputEvent), MEMF_CLEAR + MEMF_PUBLIC);
    if (iev == 0)
	goto fail;
    if (OpenDevice ("input.device", 0, ioreq, 0) != 0)
	goto fail;
    if (OpenDevice ("timer.device", 0, timereq, 0) != 0)
	goto fail;

    foo.mx = (ULONG)-1;
    foo.my = (ULONG)-1;
    foo.mt = FindTask (0);
    AddIntServer(INTB_VERTB, &myint);

    ibase = OpenLibrary ("intuition.library", 0);
    SetTaskPri (foo.mt, 20); /* same as input.device */
    for (;;) {
	int newx, newy;

	Wait (foo.sigbit);
	ioreq->io_Command = IND_WRITEEVENT;
	ioreq->io_Length = sizeof (struct InputEvent);
	ioreq->io_Data = iev;
	ioreq->io_Flags = IOF_QUICK;
	iev->ie_Class = IECLASS_POINTERPOS;
	iev->ie_SubClass = 0;
	iev->ie_Code = 0;
	iev->ie_Qualifier = 0;
#if 0
	newx = (*calltrap) (1);
	newy = (*calltrap) (2);

	if (oldy != newy || oldx != newx)
#endif
	{
	    timereq->tr_node.io_Flags = IOF_QUICK;
	    timereq->tr_node.io_Command = TR_GETSYSTIME;
	    DoIO (timereq);
	    iev->ie_TimeStamp = timereq->tr_time;
	    /* Those are signed, so I hope negative values are OK... */
	    /* I wonder why I have to multiply those by 2... but it works,
	     * at least for me. */
	    iev->ie_position.ie_xy.ie_x = foo.mx - ibase->ViewLord.DxOffset*2;
	    iev->ie_position.ie_xy.ie_y = foo.my - ibase->ViewLord.DyOffset*2;

	    oldx = newx;
	    oldy = newy;
	    DoIO(ioreq);
	}
#if 0
	timereq->tr_node.io_Flags = IOF_QUICK;
	timereq->tr_time.tv_secs = 0;
	timereq->tr_time.tv_micro = 20000;
	timereq->tr_node.io_Command = TR_ADDREQUEST;
	DoIO(timereq);
#endif
    }
    fail:
    fprintf (stderr, "Couldn't start mousehack (that's bad!)\n");
    exit (5);
}
コード例 #8
0
struct EMU10kxData*
AllocDriverData( struct pci_dev*    dev,
		 struct DriverBase* AHIsubBase )
#endif
{
  struct EMU10kxBase* EMU10kxBase = (struct EMU10kxBase*) AHIsubBase;
  struct EMU10kxData* dd;
  UWORD               command_word;

  // FIXME: This should be non-cachable, DMA-able memory
  dd = AllocVec( sizeof( *dd ), MEMF_PUBLIC | MEMF_CLEAR );

  if( dd == NULL )
  {
    Req( "Unable to allocate driver structure." );
    return NULL;
  }


  dd->ahisubbase = AHIsubBase;

  dd->interrupt.is_Node.ln_Type = INTERRUPT_NODE_TYPE;
  dd->interrupt.is_Node.ln_Pri  = 0;
  dd->interrupt.is_Node.ln_Name = (STRPTR) LibName;
  dd->interrupt.is_Code         = (void(*)(void)) &emu10kxinterrupt;
  dd->interrupt.is_Data         = (APTR) dd;

  dd->playback_interrupt.is_Node.ln_Type = INTERRUPT_NODE_TYPE;
  dd->playback_interrupt.is_Node.ln_Pri  = 0;
  dd->playback_interrupt.is_Node.ln_Name = (STRPTR) LibName;
  dd->playback_interrupt.is_Code         = (void(*)(void)) &playbackinterrupt;
  dd->playback_interrupt.is_Data         = (APTR) dd;

  dd->record_interrupt.is_Node.ln_Type = INTERRUPT_NODE_TYPE;
  dd->record_interrupt.is_Node.ln_Pri  = 0;
  dd->record_interrupt.is_Node.ln_Name = (STRPTR) LibName;
  dd->record_interrupt.is_Code         = (void(*)(void)) &recordinterrupt;
  dd->record_interrupt.is_Data         = (APTR) dd;
  
  dd->card.pci_dev = dev;

//  if( pci_set_dma_mask(dd->card.pci_dev, EMU10K1_DMA_MASK) )
//  {
//    printf( "Unable to set DMA mask for card." );
//    goto error;
//  }

  #ifdef __AMIGAOS4__
  command_word = dev->ReadConfigWord( PCI_COMMAND );  
  command_word |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
  dev->WriteConfigWord( PCI_COMMAND, command_word );
  #else
  command_word = pci_read_config_word( PCI_COMMAND, dd->card.pci_dev );
  command_word |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
  pci_write_config_word( PCI_COMMAND, command_word, dd->card.pci_dev );
  #endif

  dd->pci_master_enabled = TRUE;

  // FIXME: How about latency/pcibios_set_master()??

  #ifdef __AMIGAOS4__
  dd->card.iobase  = dev->GetResourceRange(0)->BaseAddress;
  dd->card.length  = ~( dev->GetResourceRange(0)->Size & PCI_BASE_ADDRESS_IO_MASK );
  dd->card.irq     = dev->MapInterrupt();
  dd->card.chiprev = dev->ReadConfigByte( PCI_REVISION_ID);
  dd->card.model   = dev->ReadConfigWord( PCI_SUBSYSTEM_ID);
  dd->card.is_audigy = ( dev->ReadConfigWord( PCI_DEVICE_ID) == PCI_DEVICE_ID_CREATIVE_AUDIGY );
  dd->card.is_aps   = ( dev->ReadConfigLong( PCI_SUBSYSTEM_VENDOR_ID)
		       == EMU_APS_SUBID );

  dev->OutLong(dd->card.iobase + IPR, 0xffffffff);
  dev->OutLong(dd->card.iobase + INTE, 0);

  AddIntServer(dev->MapInterrupt(), &dd->interrupt );
  #else
  dd->card.iobase  = dev->base_address[ 0 ];
  dd->card.length  = ~( dev->base_size[ 0 ] & PCI_BASE_ADDRESS_IO_MASK );
  dd->card.irq     = dev->irq;
  dd->card.chiprev = pci_read_config_byte( PCI_REVISION_ID, dd->card.pci_dev );
  dd->card.model   = pci_read_config_word( PCI_SUBSYSTEM_ID, dd->card.pci_dev );
  dd->card.is_audigy = ( dev->device == PCI_DEVICE_ID_CREATIVE_AUDIGY );
  dd->card.is_aps   = ( pci_read_config_long( PCI_SUBSYSTEM_VENDOR_ID,
					     dd->card.pci_dev )
		       == EMU_APS_SUBID );

  pci_add_intserver( &dd->interrupt, dd->card.pci_dev );
  #endif

  dd->interrupt_added = TRUE;

  /* Initialize chip */
  if( emu10k1_init( &dd->card ) < 0 )
  {
    Req( "Unable to initialize EMU10kx subsystem.");
    return NULL;
  }

  dd->emu10k1_initialized = TRUE;

    
  /* Initialize mixer */

  emu10k1_writeac97( &dd->card, AC97_RESET, 0L);

  Delay( 1 );

  if (emu10k1_readac97( &dd->card, AC97_RESET ) & 0x8000) {
    Req( "ac97 codec not present.");
    return NULL;
  }


  dd->input          = 0;
  dd->output         = 0;
  dd->monitor_volume = Linear2MixerGain( 0, &dd->monitor_volume_bits );
  dd->input_gain     = Linear2RecordGain( 0x10000, &dd->input_gain_bits );
  dd->output_volume  = Linear2MixerGain( 0x10000, &dd->output_volume_bits );

  // No attenuation and natural tone for all outputs
  emu10k1_writeac97( &dd->card, AC97_MASTER_VOL_STEREO, 0x0000 );
  emu10k1_writeac97( &dd->card, AC97_HEADPHONE_VOL,     0x0000 );
  emu10k1_writeac97( &dd->card, AC97_MASTER_VOL_MONO,   0x0000 );
  emu10k1_writeac97( &dd->card, AC97_MASTER_TONE,       0x0f0f );

  emu10k1_writeac97( &dd->card, AC97_RECORD_GAIN,       0x0000 );
  emu10k1_writeac97( &dd->card, AC97_RECORD_SELECT,     InputBits[ 0 ] );

  emu10k1_writeac97( &dd->card, AC97_PCMOUT_VOL,        0x0808 );
  emu10k1_writeac97( &dd->card, AC97_PCBEEP_VOL,        0x0000 );

  emu10k1_writeac97( &dd->card, AC97_LINEIN_VOL,        0x0808 );
  emu10k1_writeac97( &dd->card, AC97_MIC_VOL,           AC97_MUTE | 0x0008 );
  emu10k1_writeac97( &dd->card, AC97_CD_VOL,            0x0808 );
  emu10k1_writeac97( &dd->card, AC97_AUX_VOL,           0x0808 );
  emu10k1_writeac97( &dd->card, AC97_PHONE_VOL,         0x0008 );
  emu10k1_writeac97( &dd->card, AC97_VIDEO_VOL,         0x0808 );


  if (emu10k1_readac97( &dd->card, AC97_EXTENDED_ID ) & 0x0080 )
  {
    sblive_writeptr( &dd->card, AC97SLOT, 0, AC97SLOT_CNTR | AC97SLOT_LFE);
    emu10k1_writeac97( &dd->card, AC97_SURROUND_MASTER, 0x0 );
  }
  
  return dd;
}