예제 #1
0
static int __out_write(struct _reent *r, int fd, const char *ptr, int len) {
	u32 level;
	u16 l;

	if (!ptr || len <= 0)
		return -1;
	LWP_MutexLock(console_mutex);
	if (video_active) {
		dot_video->write_r(r, fd, ptr, len);
	} else {
		if (log_active) {
			l = (log_next + 1) % log_size;
			if (log[l])
				free(log[l]);
			log[l] = strndup(ptr, len);

			log_next = l;
		}
	}

	if (gecko) {
		level = IRQ_Disable();
		usb_sendbuffer(1, ptr, len);
		IRQ_Restore(level);
	}
	LWP_MutexUnlock(console_mutex);
	return len;
}
예제 #2
0
// Setup OS Tick.
int32_t  OS_Tick_Setup (uint32_t freq, IRQHandler_t handler) {
  uint32_t load;
  uint32_t prio;
  uint32_t bits;

  if (freq == 0U) {
    return (-1);
  }

  PTIM_PendIRQ = 0U;

  // Private Timer runs with the system frequency
  load = (SystemCoreClock / freq) - 1U;

  // Disable Private Timer and set load value
  PTIM_SetControl   (0U);
  PTIM_SetLoadValue (load);

  // Disable corresponding IRQ
  IRQ_Disable     (PrivTimer_IRQn);
  IRQ_ClearPending(PrivTimer_IRQn);

  // Determine number of implemented priority bits
  IRQ_SetPriority (PrivTimer_IRQn, 0xFFU);

  prio = IRQ_GetPriority (PrivTimer_IRQn);

  // At least bits [7:4] must be implemented
  if ((prio & 0xF0U) == 0U) {
    return (-1);
  }

  for (bits = 0; bits < 4; bits++) {
    if ((prio & 0x01) != 0) {
      break;
    }
    prio >>= 1;
  }
  
  // Adjust configured priority to the number of implemented priority bits
  prio = (PTIM_IRQ_PRIORITY << bits) & 0xFFUL;

  // Set Private Timer interrupt priority
  IRQ_SetPriority(PrivTimer_IRQn, prio-1U);

  // Set edge-triggered IRQ
  IRQ_SetMode(PrivTimer_IRQn, IRQ_MODE_TRIG_EDGE);

  // Register tick interrupt handler function
  IRQ_SetHandler(PrivTimer_IRQn, handler);

  // Enable corresponding interrupt
  IRQ_Enable (PrivTimer_IRQn);

  // Set bits: IRQ enable and Auto reload
  PTIM_SetControl (0x06U);

  return (0);
}
/*
 *
 * Function Name:  cslDsiDisInt
 *
 * Description:
 *
 */
static void cslDsiDisInt(DSI_HANDLE dsiH)
{
#ifdef UNDER_LINUX
	/*disable_irq(dsiH->interruptId); */
#else
	IRQ_Disable(dsiH->interruptId);
#endif
	chal_dsi_ena_int(dsiH->chalH, 0);
	chal_dsi_clr_int(dsiH->chalH, 0xFFFFFFFF);
#ifndef UNDER_LINUX
	IRQ_Clear(dsiH->interruptId);
#endif
}
예제 #4
0
void ds3wiibt_listen(struct ds3wiibt_context *ctx)
{
	u32 level = IRQ_Disable();
	if (ctx->status == DS3WIIBT_STATUS_DISCONNECTED) {
		ctx->status = DS3WIIBT_STATUS_LISTENING;
		ctx->ctrl_pcb = l2cap_new();
		ctx->data_pcb = l2cap_new();
		l2cap_arg(ctx->ctrl_pcb, ctx);
		l2cap_arg(ctx->data_pcb, ctx);
		l2cap_connect_ind(ctx->ctrl_pcb,  &ctx->bdaddr, HIDP_PSM, l2ca_connect_ind_cb);
		l2cap_connect_ind(ctx->data_pcb, &ctx->bdaddr, INTR_PSM, l2ca_connect_ind_cb);
	}
	IRQ_Restore(level);
}
예제 #5
0
static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len)
{
	u32 level;

	if (!ptr || len <= 0 || !gecko)
		return -1;

	LWP_MutexLock(gecko_mutex);
	level = IRQ_Disable();
	usb_sendbuffer(1, ptr, len);
	IRQ_Restore(level);
	LWP_MutexUnlock(gecko_mutex);
	return len;
}
예제 #6
0
파일: wii_audio.c 프로젝트: Allba/showtime
static int
wii_audio_start(audio_mode_t *am, audio_fifo_t *af)
{
  audio_buf_t *ab;
  int tbuf = 0, i;
  uint32_t level;
  int64_t pts;
  media_pipe_t *mp;

  prop_sub_t *s_vol;

  s_vol =
    prop_subscribe(PROP_SUB_DIRECT_UPDATE,
		   PROP_TAG_CALLBACK_FLOAT, set_mastervol, NULL,
		   PROP_TAG_ROOT, prop_mastervol,
		   NULL);

  LWP_InitQueue(&audio_queue);

  AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
  AUDIO_RegisterDMACallback(switch_buffers);

  AUDIO_StartDMA();

  while(1) {
    
    level = IRQ_Disable();
    while(tbuf == cur_buffer)
      LWP_ThreadSleep(audio_queue);
    tbuf = cur_buffer;
    IRQ_Restore(level);

    ab = af_deq(af, 0);
    
    if(am != audio_mode_current) {
      /* We're not the selected audio output anymore, return. */
      if(ab != NULL)
	ab_free(ab);
      break;
    }

    if(ab != NULL) {
      const int16_t *src = (const int16_t *)ab->ab_data;
      int16_t *dst = (int16_t *)buffer[!tbuf];
      for(i = 0; i < ADMA_BUFFER_SIZE / 2; i++)
	*dst++ = (*src++ * audio_vol) >> 16;

      /* PTS is the time of the first frame of this audio packet */

      if((pts = ab->ab_pts) != AV_NOPTS_VALUE && ab->ab_mp != NULL) {

#if 0
	/* Convert the frame delay into micro seconds */

	d = (fr * 1000 / aam->aam_sample_rate) * 1000;

	/* Subtract it from our timestamp, this will yield
	   the PTS for the sample currently played */

	pts -= d;

	/* Offset with user configure delay */
#endif

	pts += am->am_audio_delay * 1000;

	mp = ab->ab_mp;

	hts_mutex_lock(&mp->mp_clock_mutex);
	mp->mp_audio_clock = pts;
	mp->mp_audio_clock_realtime = showtime_get_ts();
	mp->mp_audio_clock_epoch = ab->ab_epoch;

	hts_mutex_unlock(&mp->mp_clock_mutex);

      }
      ab_free(ab);

    } else {
      memset(buffer[!tbuf], 0, ADMA_BUFFER_SIZE);
    }
    DCFlushRange(buffer[!tbuf], ADMA_BUFFER_SIZE);

  }
예제 #7
0
파일: disc.c 프로젝트: smurk-too/wodebrew
s32 Disc_BootPartition(u64 offset, u8 videoselected, u8 cheat, u8 vipatch, u8 patchcountrystring, u32 rtrn) {
    entry_point p_entry;

    s32 ret;

    /* Open specified partition */
    ret = WDVD_OpenPartition(offset, tmd_buffer);
    if (ret < 0)
        return ret;

	char gameid[8];
	memset(gameid, 0, 8);
	memcpy(gameid, (char*)Disc_ID, 6);

	//kill the SD
    SDCard_deInit();

    /* Disconnect Wiimote */
    WPAD_Flush(0);
    WPAD_Disconnect(0);
    WPAD_Shutdown();
	
	// Load Disc IOS
	u32 disc_ios = tmd_buffer[0x18B];
	if (disc_ios != IOS_GetVersion()) {
		WDVD_ClosePartition();
		WDVD_Close();

		ret = IOS_ReloadIOS(disc_ios);
		if (ret < 0) {
			gprintf("Disc IOS %u could not be loaded! (ret = %d)", disc_ios, ret);
			return ret;
		}
		Disc_Init();
		Disc_Open();
		WDVD_OpenPartition(offset, tmd_buffer);
	}	

    /* Setup low memory */
    __Disc_SetLowMem();

    /* Run apploader */
    ret = Apploader_Run(&p_entry, cheat, videoselected, vipatch, patchcountrystring, rtrn);
    if (ret < 0)
        return ret;

    bool cheatloaded = false;

    if (cheat == 1) {
        /* OCARINA STUFF - FISHEARS*/
		cheatloaded = ocarina_do_code() == 1;
		cheatloaded = true;
    }

    /* Set an appropiate video mode */
    __Disc_SetVMode(videoselected);

    /* Set time */
    __Disc_SetTime();

	// Anti-green screen fix
	VIDEO_SetBlack(TRUE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	gprintf("\n\nUSB Loader GX is done.\n\n");

    /* Shutdown IOS subsystems */
	// fix for PeppaPig (from NeoGamma)
	extern void __exception_closeall();
	IRQ_Disable();
	__IOS_ShutdownSubsystems();
	__exception_closeall();

	appentrypoint = (u32) p_entry;

	if (cheat == 1 && cheatloaded)
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"lis %r3, 0x8000\n"
			"ori %r3, %r3, 0x18A8\n"
			"mtctr %r3\n"
			"bctr\n"
		);
	}
	else
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"blr\n"
		);
	}

    return 0;
}
예제 #8
0
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <sys/iosupport.h>

#define UNUSED  __attribute__((unused))

static bool geckoinit = false;

static ssize_t __out_write(struct _reent *r UNUSED, int fd UNUSED, const char *ptr, size_t len)
{
	if(geckoinit && ptr)
	{
		u32 level;
		level = IRQ_Disable();
		usb_sendbuffer_safe(1, ptr, len);
		IRQ_Restore(level);
	}

	return len;
}

static const devoptab_t gecko_out = {
	"stdout",	// device name
	0,			// size of file structure
	NULL,		// device open
	NULL,		// device close
	__out_write,// device write
	NULL,		// device read
	NULL,		// device seek