Ejemplo n.º 1
0
LOCAL void bootClear (void)
    {
#ifdef  ROM_RESIDENT

  /* fill from the bottom of memory to the load image */

# if ((STACK_SAVE+SYS_MEM_BOTTOM) > RAM_DST_ADRS)
#error Bad size, (STACK_SAVE+SYS_MEM_BOTTOM) > RAM_DST_ADRS, check RAM_*_ADRS settings
# endif	/* (STACK_SAVE+SYS_MEM_BOTTOM) > RAM_DST_ADRS */
    fillLongs ((UINT *)SYS_MEM_BOTTOM,
       ((UINT)RAM_DST_ADRS - STACK_SAVE - (UINT)SYS_MEM_BOTTOM) / sizeof (long),
        0);

    /* fill from the load image to the top of memory */

    fillLongs ((UINT *)end, ((UINT)SYS_MEM_TOP - (UINT)end) / sizeof(long), 0);

#else /* ROM_RESIDENT */

    /* fill from the bottom of memory to the load image */

# if (SYS_MEM_BOTTOM > RAM_DST_ADRS)
#error Bad size, (STACK_SAVE+SYS_MEM_BOTTOM) > RAM_DST_ADRS, check RAM_*_ADRS settings
# endif	/* SYS_MEM_BOTTOM > RAM_DST_ADRS */
    fillLongs ((UINT *)UNCACHED(SYS_MEM_BOTTOM),
        ((UINT)RAM_DST_ADRS - (UINT)SYS_MEM_BOTTOM) / sizeof (long), 0);

    /*
    * fill from the end of the load image to the stack
    * (end of a decompressed image isn't known, but this is ok as long as
    *  clearing is done before decompression is performed)
    */
    fillLongs ((UINT *)UNCACHED(LD_IMAGE_END),
        ((UINT)RAM_DATA_ADRS - STACK_SAVE - LD_IMAGE_END) / sizeof (long),
        0);

#  ifndef  ROM_COMPRESS
    /*
     * fill past the stack to the top of memory
     * (this section is cleared later with compressed images)
     */

# if (RAM_DATA_ADRS > SYS_MEM_TOP)
#error Bad size, RAM_DATA_ADRS > SYS_MEM_TOP, check LOCAL_MEM SIZE and RAM_HIGH ADRS settings
# endif	/* RAM_DATA_ADRS > SYS_MEM_TOP */
    fillLongs ((UINT *)UNCACHED(RAM_DATA_ADRS),
	((UINT)SYS_MEM_TOP - (UINT)RAM_DATA_ADRS) / sizeof(long), 0);

#  endif /* ROM_COMPRESS */

#endif /* ROM_RESIDENT */

    /*
     * Ensure the boot line is null. This is necessary for those
     * targets whose boot line is excluded from cleaning.
     */

    *(BOOT_LINE_ADRS) = EOS;
    }
Ejemplo n.º 2
0
void PspSpeedTests::fastCopySpeed() {
	PSP_INFO_PRINT("running fastCopy speed test\n");

	uint32 *bufferSrc32 = (uint32 *)memalign(16, MEMCPY_BUFFER_SIZE);
	uint32 *bufferDst32 = (uint32 *)memalign(16, MEMCPY_BUFFER_SIZE);

	// fill buffer 1
	for (int i=0; i<MEMCPY_BUFFER_SIZE/4; i++)
		bufferSrc32[i] = i | (((MEMCPY_BUFFER_SIZE/4)-i)<<16);

	// print buffer
	for (int i=0; i<50; i++)
		PSP_INFO_PRINT("%x ", bufferSrc32[i]);
	PSP_INFO_PRINT("\n");

	byte *bufferSrc = ((byte *)bufferSrc32);
	byte *bufferDst = ((byte *)bufferDst32);

	PSP_INFO_PRINT("\n\ndst and src cached: -----------------\n");
	fastCopyDifferentSizes(bufferDst, bufferSrc);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc);

	PSP_INFO_PRINT("\n\ndst cached, src uncached: -----------------\n");
	bufferSrc = UNCACHED(bufferSrc);
	fastCopyDifferentSizes(bufferDst, bufferSrc);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc);

	PSP_INFO_PRINT("\n\ndst uncached, src uncached: --------------\n");
	bufferDst = UNCACHED(bufferDst);
	fastCopyDifferentSizes(bufferDst, bufferSrc);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc);

	PSP_INFO_PRINT("\n\ndst uncached, src cached: -------------------\n");
	bufferSrc = CACHED(bufferSrc);
	fastCopyDifferentSizes(bufferDst, bufferSrc);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst, bufferSrc+1);
	fastCopyDifferentSizes(bufferDst+1, bufferSrc);


	free(bufferSrc32);
	free(bufferDst32);
}
Ejemplo n.º 3
0
/**
 * playback_thread:  Sound playback thread.  Continually sends the ring
 * buffer data to the OS until signaled to stop.
 *
 * [Parameters]
 *     args: Thread argument size
 *     argp: Thread argument pointer
 * [Return value]
 *     Always zero
 */
static int playback_thread(SceSize args, void *argp)
{
    PSPSoundBufferDesc * const buffer_desc = *(PSPSoundBufferDesc **)argp;

    /* Temporary buffer for dummy audio data when the emulator falls behind
     * real time (filled with the last sample sent to avoid clicks).  This
     * thread is only launched once, so "static" is safe. */
    static uint32_t dummy_buffer[BUFFER_SIZE];  // 1 stereo sample = 32 bits
    static uint32_t last_sample;                // Last stereo sample played

    while (!buffer_desc->stop) {
        const unsigned int next_play = buffer_desc->next_play;
//static int x;int now=sceKernelGetSystemTimeLow();if(now-x>100000){printf("--- audio stat: %u %u %u %u cp=%u np=%u nw=%u\n",UNCACHED(buffer_desc->write_ready[0]),UNCACHED(buffer_desc->write_ready[1]),UNCACHED(buffer_desc->write_ready[2]),UNCACHED(buffer_desc->write_ready[3]),buffer_desc->cur_play,next_play,UNCACHED(buffer_desc->next_write));x=now;}
        if (!UNCACHED(buffer_desc->write_ready[next_play])) {  // i.e., ready for playback
            const void *buffer = buffer_desc->buffer[next_play];
            last_sample = ((const uint32_t *)buffer)[BUFFER_SIZE - 1];
            sceAudioOutputBlocking(buffer_desc->channel, muted ? 0 : 0x8000,
                                   buffer);
#ifdef DUMP_AUDIO
            sceIoWrite(dump_fd, buffer, BUFFER_SIZE*4);
#endif
            UNCACHED(buffer_desc->write_ready[buffer_desc->cur_play]) = 1;
            buffer_desc->cur_play = next_play;
            buffer_desc->next_play = (next_play + 1) % NUM_BUFFERS;
        } else {
            const uint32_t sample = last_sample;  // Help out optimizer
            uint32_t *ptr32 = dummy_buffer;
            unsigned int i;
            for (i = 0; i < BUFFER_SIZE; i += 8) {
                ptr32[i+0] = sample;
                ptr32[i+1] = sample;
                ptr32[i+2] = sample;
                ptr32[i+3] = sample;
                ptr32[i+4] = sample;
                ptr32[i+5] = sample;
                ptr32[i+6] = sample;
                ptr32[i+7] = sample;
            }
            sceAudioOutputBlocking(buffer_desc->channel, muted ? 0 : 0x8000,
                                   dummy_buffer);
        }
    }

    sceAudioChRelease(buffer_desc->channel);
    memset(buffer_desc, 0, sizeof(*buffer_desc));
    return 0;
}
Ejemplo n.º 4
0
/**
 * psp_sound_get_audio_space:  Return the number of samples immediately
 * available for outputting audio data.
 *
 * [Parameters]
 *     None
 * [Return value]
 *     Number of samples available
 */
static u32 psp_sound_get_audio_space(void)
{
    if (UNCACHED(stereo_buffer.write_ready[stereo_buffer.next_write])) {
        return BUFFER_SIZE - stereo_buffer.saved_samples;
    } else {
        return 0;
    }
}
Ejemplo n.º 5
0
/**
 * psp_sound_update_audio:  Output audio data.
 *
 * [Parameters]
 *      leftchanbuffer: Left channel sample array, as _signed_ 16-bit samples
 *     rightchanbuffer: Right channel sample array, as _signed_ 16-bit samples
 *         num_samples: Number of samples in sample arrays
 * [Return value]
 *     None
 */
static void psp_sound_update_audio(u32 *leftchanbuffer, u32 *rightchanbuffer,
                                   u32 num_samples)
{
    const unsigned int next_write = stereo_buffer.next_write;

    if (!leftchanbuffer || !rightchanbuffer
     || !UNCACHED(stereo_buffer.write_ready[next_write])
     || num_samples == 0
     || num_samples > BUFFER_SIZE - stereo_buffer.saved_samples
    ) {
        if (!meUtilityIsME()) {  // Can't write to stderr on the ME
            DMSG("Invalid parameters: %p %p %u (status: wr=%d ss=%d)",
                 leftchanbuffer, rightchanbuffer, (unsigned int)num_samples,
                 UNCACHED(stereo_buffer.write_ready[next_write]),
                 stereo_buffer.saved_samples);
        }
        return;
    }

    const int32_t *in_l = (int32_t *)leftchanbuffer;
    const int32_t *in_r = (int32_t *)rightchanbuffer;
    int16_t *out =
        &stereo_buffer.buffer[next_write][stereo_buffer.saved_samples * 2];

    uint32_t i;
    for (i = 0; i < num_samples; i++) {
        const int32_t lval = *in_l++;
        const int32_t rval = *in_r++;
        *out++ = bound(lval, -0x8000, 0x7FFF);
        *out++ = bound(rval, -0x8000, 0x7FFF);
    }

    stereo_buffer.saved_samples += num_samples;
    if (stereo_buffer.saved_samples >= BUFFER_SIZE) {
        if (meUtilityIsME()) {
            /* Make sure the playback thread sees all the audio data */
            meUtilityDcacheWritebackInvalidateAll();
        }
        UNCACHED(stereo_buffer.write_ready[next_write]) = 0;
        stereo_buffer.saved_samples = 0;
        stereo_buffer.next_write = (next_write + 1) % NUM_BUFFERS;
    }
}
Ejemplo n.º 6
0
void romStart
    (
    FAST int startType      /* start type */
    )
    {
#if (CPU_FAMILY == PPC) || (CPU_FAMILY == MIPS)

    /*
     * For PPC and MIPS, the call to vxSdaInit() must be the first operation
     * in sysStart(). This is because vxSdaInit() sets the SDA registers
     * (r2 and r13 on PPC, gp on MIPS) to the SDA base values. No C code
     * must be placed before this call.
     */

    _WRS_ASM ("");   /* code barrier to prevent compiler moving vxSdaInit() */
    vxSdaInit ();    /* this MUST be the first operation in usrInit() for PPC */
    _WRS_ASM ("");   /* code barrier to prevent compiler moving vxSdaInit() */

#endif	/* (CPU_FAMILY == PPC) || (CPU_FAMILY == MIPS) */

    /* relocate the data segment into RAM */

    copyLongs ((UINT *)ROM_DATA_ADRS, (UINT *)UNCACHED(RAM_DATA_ADRS),
        ((UINT)wrs_kernel_data_end - (UINT)RAM_DATA_ADRS) / sizeof (long));

#ifdef BSP_BOOT_CACHE_SYNC

    /* Text has been copied from flash, call BSP provided cacheTextUpdate */

    BSP_BOOT_CACHE_SYNC;
#endif /* BSP_BOOT_CACHE_SYNC */

    /* If cold booting, clear memory to avoid parity errors */

#ifdef ROMSTART_BOOT_CLEAR
    if (startType & BOOT_CLEAR)
        bootClear();
#endif

#ifdef BSP_BOOT_CACHE_SYNC_POST
    BSP_BOOT_CACHE_SYNC_POST;
#endif /* BSP_BOOT_CACHE_SYNC_POST */

    /* and jump to the entry */

#ifdef INCLUDE_UEFI_BOOT_SUPPORT
    /* For UEFI we must pass the UEFI memory map and ACPI pointer */
    usrInit (startType, pRomUefiMemAddr, pRomUefiAcpiAddr);
#else
    usrInit (startType);
#endif

    }
Ejemplo n.º 7
0
void romStart
    (
    FAST int startType      /* start type */
    )
    {
    volatile FUNCPTR absEntry;

#if (CPU_FAMILY == PPC) || (CPU_FAMILY == MIPS)

    /*
     * For PPC and MIPS, the call to vxSdaInit() must be the first operation
     * in sysStart(). This is because vxSdaInit() sets the SDA registers
     * (r2 and r13 on PPC, gp on MIPS) to the SDA base values. No C code
     * must be placed before this call.
     */

    _WRS_ASM ("");   /* code barrier to prevent compiler moving vxSdaInit() */
    vxSdaInit ();    /* this MUST be the first operation in usrInit() for PPC */
    _WRS_ASM ("");   /* code barrier to prevent compiler moving vxSdaInit() */

#endif	/* (CPU_FAMILY == PPC) || (CPU_FAMILY == MIPS) */

    absEntry = (volatile FUNCPTR) RAM_DST_ADRS;

    /* copy the main image into RAM */

    copyLongs ((UINT *)ROM_DATA(binArrayStart),
        (UINT *)UNCACHED(RAM_DST_ADRS),
        (binArrayEnd - binArrayStart) / sizeof (long));

#ifdef BSP_BOOT_CACHE_SYNC

    /* Text has been copied from flash, call BSP provided cacheTextUpdate */

    BSP_BOOT_CACHE_SYNC;
#endif /* BSP_BOOT_CACHE_SYNC */

#if     ((CPU_FAMILY == ARM) && ARM_THUMB)
     absEntry = (FUNCPTR)((UINT32)absEntry | 1);         /* force Thumb state */
#endif  /* CPU_FAMILY == ARM */

#ifdef BSP_BOOT_CACHE_SYNC

    /* Text has been copied from flash, call BSP provided cacheTextUpdate */

    BSP_BOOT_CACHE_SYNC;
#endif /* BSP_BOOT_CACHE_SYNC */

    /* If cold booting, clear memory to avoid parity errors */

#ifdef ROMSTART_BOOT_CLEAR
    if (startType & BOOT_CLEAR)
        bootClear();
#endif

#ifdef BSP_BOOT_CACHE_SYNC_POST
    BSP_BOOT_CACHE_SYNC_POST;
#endif /* BSP_BOOT_CACHE_SYNC_POST */

#if (CPU_FAMILY == MIPS)
    /* mapped ROMs have start address in kseg2 so it needs to be modified
     * so we jump to uncached space
     */
    absEntry = (FUNCPTR)KX_TO_K0(absEntry);
#endif /* (CPU_FAMILY == MIPS) */

    /* and jump to the entry */


#ifdef INCLUDE_UEFI_BOOT_SUPPORT
    /* For UEFI we must pass the UEFI memory map and ACPI pointer */
    absEntry (startType, pRomUefiMemAddr, pRomUefiAcpiAddr);
#else
    absEntry (startType);
#endif

    }
Ejemplo n.º 8
0
void romStart
    (
    FAST int startType      /* start type */
    )
    {
    volatile FUNCPTR absEntry;

#ifdef MODEM_L2CACHE_TEST
    /* A9 -- Modem A9 */
    writel(0xA9A9A9A9, SHM_MEM_LOADM_ADDR);
#endif

#if (CPU_FAMILY == PPC) || (CPU_FAMILY == MIPS)

    /*
     * For PPC and MIPS, the call to vxSdaInit() must be the first operation
     * in sysStart(). This is because vxSdaInit() sets the SDA registers
     * (r2 and r13 on PPC, gp on MIPS) to the SDA base values. No C code
     * must be placed before this call.
     */

    _WRS_ASM ("");   /* code barrier to prevent compiler moving vxSdaInit() */
    vxSdaInit ();    /* this MUST be the first operation in usrInit() for PPC */
    _WRS_ASM ("");   /* code barrier to prevent compiler moving vxSdaInit() */

#endif	/* (CPU_FAMILY == PPC) || (CPU_FAMILY == MIPS) */

    absEntry = (volatile FUNCPTR) RAM_DST_ADRS;

    /* relocate the data segment of the decompression stub */
#if 0
    copyLongs ((UINT *)ROM_DATA_ADRS, (UINT *)UNCACHED(RAM_DST_ADRS),
              ((UINT)binArrayStart - (UINT)DDR_MCORE_ADDR) / sizeof (long));

    copyLongs ((UINT *)((UINT)ROM_DATA_ADRS + ((UINT)BINARRAYEND_ROUNDOFF -
        (UINT)RAM_DATA_ADRS)), (UINT *)UNCACHED(BINARRAYEND_ROUNDOFF),
    ((UINT)wrs_kernel_data_end - (UINT)binArrayEnd) / sizeof (long));
#endif

#ifdef BSP_BOOT_CACHE_SYNC

    /* Text has been copied from flash, call BSP provided cacheTextUpdate */

    BSP_BOOT_CACHE_SYNC;
#endif /* BSP_BOOT_CACHE_SYNC */

    /* if cold booting, start clearing memory to avoid parity errors */

#ifdef  ROMSTART_BOOT_CLEAR
    if (startType & BOOT_CLEAR)
    /* low memory is cleared up to the stack */
    bootClear();
#endif

    /* rom_mmu_record_time(); */

    rom_mmu_enable();

#ifdef BSP_CONFIG_HI3630
    rom_mmu_l2cache_enable();
#endif

#ifdef MODEM_L2CACHE_TEST

#define MODEM_L2CACHE_TEST_BUFFER_SIZE (0x100000)

    memcpy( (void*)MCORE_TEXT_START_ADDR,
            (void*)MCORE_TEXT_START_ADDR_COMPRESSED,
            MODEM_L2CACHE_TEST_BUFFER_SIZE);

    if (memcmp( (void*)MCORE_TEXT_START_ADDR,
                (void*)MCORE_TEXT_START_ADDR_COMPRESSED,
                MODEM_L2CACHE_TEST_BUFFER_SIZE))
    {
        while (1)
            writel(0xFFFFFFFF, SHM_MEM_LOADM_ADDR);
    }
    else
    {
        while (1)
            writel(0xA5A5A5A5, SHM_MEM_LOADM_ADDR);
    }
    return; /* return to dead loop */

#else

    /* decompress the main image */
    if (UNCMP_RTN (UNCACHED(binArrayStart),
        UNCACHED(RAM_DST_ADRS),
        binArrayEnd - binArrayStart) != OK)
    return;

#endif

#ifdef BSP_CONFIG_HI3630
    rom_mmu_l2cache_disable();
#endif

    rom_mmu_disable();

    /* rom_mmu_record_time(); */

#ifdef BSP_BOOT_CACHE_SYNC

    /* Text has been copied from flash, call BSP provided cacheTextUpdate */

    BSP_BOOT_CACHE_SYNC;
#endif /* BSP_BOOT_CACHE_SYNC */

    /* if cold booting, finish clearing memory */

#ifdef  ROMSTART_BOOT_CLEAR
    if (startType & BOOT_CLEAR)
    /* clear past the stack to the top of memory */
# if (RAM_DATA_ADRS > SYS_MEM_TOP)
#error Bad size, RAM_DATA_ADRS > SYS_MEM_TOP, check LOCAL_MEM SIZE and RAM_HIGH ADRS settings
# endif	/* RAM_DATA_ADRS > SYS_MEM_TOP */
    fillLongs ((UINT *)UNCACHED(RAM_DATA_ADRS),
        ((UINT)SYS_MEM_TOP - (UINT)RAM_DATA_ADRS) / sizeof(long), 0);
#endif

#ifdef BSP_BOOT_CACHE_SYNC_POST
    BSP_BOOT_CACHE_SYNC_POST;
#endif /* BSP_BOOT_CACHE_SYNC_POST */

#if     ((CPU_FAMILY == ARM) && ARM_THUMB)
     absEntry = (FUNCPTR)((UINT32)absEntry | 1);         /* force Thumb state */
#endif  /* CPU_FAMILY == ARM */

#if (CPU_FAMILY == MIPS)
    /* mapped ROMs have start address in kseg2 so it needs to be modified
     * so we jump to unmapped space
     */
    absEntry = (FUNCPTR)KX_TO_K0(absEntry);
#endif /* (CPU_FAMILY == MIPS) */

/* and jump to the entry */

#ifdef INCLUDE_UEFI_BOOT_SUPPORT
    /* For UEFI we must pass the UEFI memory map and ACPI pointer */
    absEntry (startType, pRomUefiMemAddr, pRomUefiAcpiAddr);
#else
    absEntry (startType);
#endif

    }