inline int64_t memory_available()
{

#if defined( ZI_OS_LINUX )

    int64_t page_size = static_cast< uint32_t >( sysconf( _SC_PAGE_SIZE ) );
    return page_size * sysconf( _SC_AVPHYS_PAGES );

#elif defined( ZI_OS_MACOS )

    return memory_size();

#elif defined ( ZI_OS_WINDOWS )

#ifdef WIN64
    MEMORYSTATUSEX ms;
#else
    MEMORYSTATUS ms;
#endif

    ms.dwLength = sizeof(ms);
    GlobalMemoryStatus(&ms);

#ifdef WIN64
    return static_cast< int64_t >( ms.ullAvailPhys );
#else
    return static_cast< int64_t >( ms.dwAvailPhys );
#endif

#else
#warning "no memory_size function available"
#endif

}
void cmd_download(const char *arg, void *data, unsigned sz)
{
	char response[MAX_RSP_SIZE];
	unsigned len = hex2unsigned(arg);
	u32 available_memory=0;
	int r;

	init_display_xy();
	download_size = 0;
	available_memory = memory_size()-(u32)download_base;

	dprintf(DBG_LV, "Enter cmd_download Data Length:%d, available_memory:%d\n", len, available_memory);

	if (len > download_max)
	{
		dprintf(DBG_LV, "Data is larger than all partitions size in target.\n");
		fastboot_fail_wrapper("Data is larger than all partitions size in target");
		return;
	}

	if(is_use_ex_download())
	{
		if(available_memory < MEMORY_SIZE_REQ)
		{
			dprintf(DBG_LV, "Insufficient memory for DCACHE\n");
			fastboot_fail_wrapper("Insufficient memory for DCACHE");
			return;
		}
	}
	else
	{
		if (len > available_memory)
		{
			dprintf(DBG_LV, "Insufficient memory for whole image\n");
			fastboot_fail_wrapper("Insufficient memory for whole image");
			return;
		}
	}


	snprintf(response, MAX_RSP_SIZE, "DATA%08x", len);
	if (usb_write(response, strlen(response)) < 0)
	{
		return;
	}

	if(is_use_ex_download())
	{
		//use ex download
		download_ex(len);
	}
	else
	{
		//use normal download
		download_standard(len);
	}

	return;
}
Beispiel #3
0
static void custom_deallocate(void* ptr) {
  assert(ptr);

  g_memory_total_size -= memory_size(ptr);
  g_memory_total_count--;

  memory_deallocate(ptr);
}
Beispiel #4
0
void memory_deallocate(void* ptr)
{
	if (!ptr) return;

	size_t size = memory_size(ptr);

	deallocate(static_cast<size_t*>(ptr) - 1, size + sizeof(size_t));
}
Beispiel #5
0
void memory_deallocate(void* ptr)
{
	if (!ptr) return;

	size_t size = memory_size(ptr);

	deallocate(static_cast<char*>(ptr) - memory_alignment, size + memory_alignment);
}
/*****************************************
 * Routine: board_init
 * Description: Early hardware init.
 *****************************************/
int board_init (void)
{
    /*Warning: DO NOT use "printf" before serial initialize*/
#ifdef CFG_UBOOT_PROFILING
    unsigned int time_disp_init;
    unsigned int time_led_init;
    unsigned int time_pmic6329_init;
    unsigned int time_gpio_init;
    unsigned int time_wdt_init;
    unsigned int time_serial_init;
#endif

    mtk_serial_init();

    mtk_wdt_init(); // Modify mtk_wdt.h can select dummy function.
    mt6577_pinmux_init();
    gd->bd->bi_arch_number = MACH_TYPE_MT6577;	/* board id for linux */
    gd->bd->bi_boot_params = CFG_BOOTARGS_ADDR; /* address of boot parameters */


    gd->fb_base = memory_size() - mt65xx_disp_get_vram_size();

#ifdef CFG_UBOOT_PROFILING
    time_led_init = get_timer(0);
#endif
    leds_init();
    isink0_init(); //turn on isink0, HW connection must be floating or pull low
#ifdef CFG_UBOOT_PROFILING
    printf("[PROFILE] ------- led init takes %d ms -------- \n", get_timer(time_led_init));
#endif

#ifdef CFG_LCD
#ifdef CFG_UBOOT_PROFILING
    time_disp_init = get_timer(0);
#endif
    mt65xx_disp_init((void*)gd->fb_base);
    UBOOT_TRACER;
#ifdef CFG_UBOOT_PROFILING
    printf("[PROFILE] ------- disp init takes %d ms -------- \n", get_timer(time_disp_init));
#endif
#endif



#ifdef CFG_UBOOT_PROFILING
    time_pmic6329_init = get_timer(0);
#endif

    pmic6329_init();

#ifdef CFG_UBOOT_PROFILING
    printf("[PROFILE] ------- pmic6329_init takes %d ms -------- \n", get_timer(time_pmic6329_init));
#endif

    printf("[CHIP]: %x-%x\n", get_chip_eco_ver(), get_chip_ver());
    return 0;
}
void debugsupport_sendBinary(ObjectDesc * self, ObjectDesc * name, struct MemoryProxy_s *data, jint size)
{
#if (defined(DEBUGSUPPORT_DUMP) || defined(MONITOR)) && defined(KERNEL)
	char value[128];
	if (name == 0 || data == 0)
		return;
	stringToChar(name, value, sizeof(value));
	ASSERT(size <= memory_size(data));
	send_binary(value, memory_getMem(data), size);
#endif
}
Beispiel #8
0
void string::operator+=(const string& string){
	if (strlen(string.STR) + strlen(STR) <= max_capacity){
		strcat(strcat(STR, " "), string.STR);
	}
	else{
		char* str_cpy = STR;
		memory_size(strlen(string.STR) + strlen(STR) + 1);
		STR = new char[strlen(string.STR) + strlen(str_cpy) + 1];
		strcpy_s(STR, strlen(STR) + 1, str_cpy);
		strcat(strcat(STR, " "), string.STR);
	}
}
Beispiel #9
0
static void* custom_allocate(size_t size) {
  if(test_runner::_memory_fail_threshold > 0 && test_runner::_memory_fail_threshold < g_memory_total_size + size)
    return 0;
  else {
    void* ptr = memory_allocate(size);

    g_memory_total_size += memory_size(ptr);
    g_memory_total_count++;

    return ptr;
  }
}
Beispiel #10
0
void AtomTable::fill(const std::vector<bf_t> & basis, bool verbose) {
  // Amount of basis functions is
  Nbf=basis.size();

  // Amount of integrals is (complex functions, so symmetry is different..)
  size_t N=Nbf*Nbf*Nbf*Nbf;

  // Make pairs helper
  pairs.clear();
  for(size_t i=0;i<Nbf;i++)
    for(size_t j=0;j<=i;j++) {
      bfpair_t tmp;
      tmp.i=i;
      tmp.j=j;
      pairs.push_back(tmp);
    }

  try {
    ints.reserve(N);
    ints.resize(N);
  } catch(std::bad_alloc err) {
    std::ostringstream oss;

    ERROR_INFO();
    oss << "Was unable to reserve " << memory_size(N*sizeof(double)) << " of memory.\n";
    throw std::runtime_error(oss.str());
  }
  // Initialize with zeros
  for(size_t i=0;i<N;i++)
    ints[i]=0.0;

  Timer t;
  if(verbose) {
    printf("Filling table of integrals ... ");
    fflush(stdout);
  }

  // Fill integrals table
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic)
#endif
  for(size_t i=0;i<Nbf;i++)
    for(size_t j=0;j<Nbf;j++)
      for(size_t k=0;k<Nbf;k++)
	for(size_t l=0;l<Nbf;l++) {
	  ints[idx(i,j,k,l)]=ERI(basis[i],basis[j],basis[k],basis[l]);
	}

  if(verbose) {
    printf("done (%s)\n",t.elapsed().c_str());
    fflush(stdout);
  }
}
Beispiel #11
0
void string::operator =(const string& string){

	if (string.lenght() < strlen(STR) || max_capacity >= string.max_capacity)
	{
		strcpy_s(STR, strlen(STR) + 1, string.STR);
	}
	else{
		memory_size(strlen(string.STR) + 1);
		delete STR;
		STR = new char[max_capacity];

		strcpy_s(STR, max_capacity, string.STR);
	}
}
Beispiel #12
0
void *video_hw_init (void)
{
    static GraphicDevice s_mt65xx_gd;

	memset(&s_mt65xx_gd, 0, sizeof(GraphicDevice));

    s_mt65xx_gd.frameAdrs  = memory_size() - mt65xx_disp_get_vram_size() + fb_size;
    s_mt65xx_gd.winSizeX   = CFG_DISPLAY_WIDTH;
    s_mt65xx_gd.winSizeY   = CFG_DISPLAY_HEIGHT;
    s_mt65xx_gd.gdfIndex   = GDF_16BIT_565RGB;
    s_mt65xx_gd.gdfBytesPP = CFG_DISPLAY_BPP / 8;
    s_mt65xx_gd.memSize    = s_mt65xx_gd.winSizeX * s_mt65xx_gd.winSizeY * s_mt65xx_gd.gdfBytesPP;

    return &s_mt65xx_gd;
}
Beispiel #13
0
//operator =
void string::operator =(const char* string){
	if (string != NULL){
		if (strlen(string) <= strlen(STR)){
			{
				strcpy_s(STR, strlen(STR) + 1, string);
			}
		}
		else{
			memory_size(strlen(string) + 1);
			delete STR;
			STR = new char[max_capacity];

			strcpy_s(STR, max_capacity, string);
		}
	}
}
Beispiel #14
0
static void kdump_ui(struct mrdump_control_block *mrdump_cblock)
{
    video_clean_screen();
    video_set_cursor(0, 0);

    mrdump_status_error("Unknown error\n");
    voprintf_info("Kdump triggerd by '%s'\n", mrdump_mode2string(mrdump_cblock->crash_record.reboot_mode));

    struct aee_timer elapse_time;
    aee_timer_init(&elapse_time);

    uint32_t total_dump_size = memory_size();
    
    aee_timer_start(&elapse_time);
    switch (mrdump_cblock->machdesc.output_device) {
    case MRDUMP_DEV_NULL:
        kdump_null_output(mrdump_cblock, total_dump_size);
        break;
#if 0
    case MRDUMP_DEV_SDCARD:
        kdump_sdcard_output(mrdump_cblock, total_dump_size);
        break;
#endif
    case MRDUMP_DEV_EMMC:
        kdump_emmc_output(mrdump_cblock, total_dump_size);
        break;

    default:
        voprintf_error("Unknown device id %d\n", mrdump_cblock->machdesc.output_device);
    }

    aee_timer_stop(&elapse_time);
    
    voprintf_info("Reset count down %d ...\n", MRDUMP_DELAY_TIME);
    mtk_wdt_restart();

    int timeout = MRDUMP_DELAY_TIME;
    while(timeout-- >= 0) {
        mdelay(1000);
        mtk_wdt_restart();
	voprintf_info("\rsec %d", timeout);
    }
    aee_mrdump_flush_cblock();

    video_clean_screen();
    video_set_cursor(0, 0);
}
Beispiel #15
0
void meta_show_logo()
{
	int len = mboot_common_load_logo(memory_size() - mt6516_disp_get_vram_size(),
                              CFG_META_LOGO_NAME);

#ifdef META_DEBUG
	printf("\n%s 'Meta Logo' Length = %d\n", META_STR_MOD_PREF,len);
#endif
    /* display logo */
    if (len > 0) {
        mt6516_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
        mt6516_backlight_on();
    }
    else
    {
#ifdef META_DEBUG
		printf("%s Load 'Meta Logo' fail\n", META_STR_MOD_PREF);
#endif		
    }
}
Beispiel #16
0
void platform_init_mmu_mappings(void)
{
  /* configure available RAM banks */
  dram_init();

/* Enable D-cache  */
#if 1
  unsigned int addr;
  //unsigned int i = 0;
  unsigned int dram_size = 0;

  dram_size = memory_size();

  for (addr = 0; addr < dram_size; addr += (1024*1024))
  {
    /*virtual to physical 1-1 mapping*/
    arm_mmu_map_section(bi_dram[0].start+addr,bi_dram[0].start+addr, MMU_MEMORY_TYPE_NORMAL_WRITE_BACK_ALLOCATE | MMU_MEMORY_AP_READ_WRITE);
  }
#endif
}
Beispiel #17
0
bool test_file_readline_f2 (Test *test)
{
	Directory *directory;
	File *file;
	char *path;
	char *line;
	size_t bytes_read;

	TITLE ();
	CATCH (!(path = directory_current_path ()));
	CATCH (!string_append (&path, "/stage/readline"));
        /*
                d stage/readline
                f f2
                f f3 \
                         \
                        0 \
                        AB \
                        012 \
                        ABCD \
                        01234 \
                        ABCD \
                        012 \
                        AB \
                        0
                f f1
         */
	CATCH (!(directory = directory_open (path)));
	string_destroy (path);
	CATCH (!directory_read (directory));
	CATCH (!(file = directory_find_file (directory, "f2")));
	CATCH (!file_open (file));
	CATCH (!(line = string_create_with_size (1)));
	CATCH (!file_readline (file, line, &bytes_read));
	CATCH (bytes_read != 0);
	CATCH (memory_size (line) != 1);
	directory_close (directory);
	string_destroy (line);
	PASS ();
}
Beispiel #18
0
void memory_destroy (void *memory)
{
	char *pointer;
	size_t size;
	size_t i;

	if (!memory) {
		error (InvalidArgument);
		return;
	}
	size = memory_size (memory);
	pointer = memory;
	pointer = pointer - sizeof (size_t);
        LOCK ();
	total_destroy_size += sizeof (size_t) + size;
	commit_size -= sizeof (size_t) + size;
        UNLOCK ();
	for (i = 0; i < sizeof (size_t) + size; i++) {
		pointer[i] = (char)rand ();
	}
	free (pointer);
}
Beispiel #19
0
void *memory_grow (void *memory, size_t size)
{
	char *pointer;
	char *pointer_resized;
	size_t size_current;

	if (!memory) {
		error (InvalidArgument);
		return NULL;
	}
	if (size == 0) {
		error (InvalidArgument);
		return NULL;
	}
	size_current = memory_size (memory);
	if (size_current >= size) {
		error (InvalidOperation);
		return NULL;
	}
	if (!size_t_add (sizeof (size_t), size, NULL)) {
		error_code (Overflow, 1);
		return NULL;
	}
        LOCK ();
	if (!unsigned_long_long_add (size - size_current, commit_size, NULL)) {
                UNLOCK ();
		error_code (Overflow, 2);
		return NULL;
	}
	if (!unsigned_long_long_add (size - size_current, total_create_size, NULL)) {
                UNLOCK ();
		error_code (Overflow, 3);
		return NULL;
	}
	if (commit_limit != ULLONG_MAX) {
		if ((size - size_current) + commit_size > commit_limit) {
                        UNLOCK ();
			error (MemoryCommitLimit);
			return NULL;
		}
	}
	if (total_create_limit != ULLONG_MAX) {
		if ((size - size_current) + total_create_size > total_create_limit) {
                        UNLOCK ();
			error (MemoryTotalCreateLimit);
			return NULL;
		}
	}
        total_create_size += size - size_current;
	commit_size += size - size_current;
        UNLOCK ();

	pointer = memory;
	pointer = pointer - sizeof (size_t);
	if (!(pointer_resized = realloc (pointer, sizeof (size_t) + size))) {
                LOCK ();
                total_create_size -= size - size_current;
                commit_size -= size - size_current;
                UNLOCK ();
		error (OutOfMemory);
		return NULL;
	}
	set_size (pointer_resized, size);
	return pointer_resized + sizeof (size_t);
}
void platform_early_init(void)
{
#ifdef LK_PROFILING
    unsigned int time_led_init;
    unsigned int time_pmic6329_init;
    unsigned int time_i2c_init;
    unsigned int time_disp_init;
    unsigned int time_platform_early_init;
    time_platform_early_init = get_timer(0);
#endif
    /* initialize the uart */
    uart_init_early();

    /* initialize the frame buffet information */
    g_fb_size = mt_disp_get_vram_size();
    g_fb_base = memory_size() - g_fb_size;
    dprintf(INFO, "FB base = 0x%x, FB size = %d\n", g_fb_base, g_fb_size);

    platform_init_interrupts();
    platform_early_init_timer();
    mt_gpio_set_default();
#ifdef LK_PROFILING
    time_i2c_init = get_timer(0);
#endif
//    i2c_v1_init();
#ifdef LK_PROFILING
    printf("[PROFILE] ------- i2c init takes %d ms -------- \n", get_timer(time_i2c_init));
#endif

    mtk_wdt_init();
#ifdef LK_PROFILING
    time_led_init = get_timer(0);
#endif
    leds_init();
#ifdef LK_PROFILING
      printf("[PROFILE] ------- led init takes %d ms -------- \n", get_timer(time_led_init));
#endif

    isink0_init();              //turn on PMIC6329 isink0
#ifdef LK_PROFILING
    time_disp_init = get_timer(0);
#endif
    mt_disp_init((void *)g_fb_base);
#ifdef LK_PROFILING
    printf("[PROFILE] ------- disp init takes %d ms -------- \n", get_timer(time_disp_init));
#endif

#ifdef CONFIG_CFB_CONSOLE
    drv_video_init();
#endif

#ifdef LK_PROFILING
    time_pmic6329_init = get_timer(0);
#endif
    pmic6329_init();

	//<2013/01/03-samhuang, improve KPI-0092 to add VIB before show logo.
	lk_vibr_enable();
	//>2013/01/03-samhuang

#ifdef LK_PROFILING
    printf("[PROFILE] ------- pmic6329_init takes %d ms -------- \n", get_timer(time_pmic6329_init));
    printf("[PROFILE] ------- platform_early_init takes %d ms -------- \n", get_timer(time_platform_early_init));
#endif
}
Beispiel #21
0
void platform_early_init(void)
{
#ifdef LK_PROFILING
    unsigned int time_led_init;
    unsigned int time_pmic6329_init;
    unsigned int time_i2c_init;
    unsigned int time_disp_init;
    unsigned int time_platform_early_init;

    time_platform_early_init = get_timer(0);
#endif   
    /* initialize the frame buffet information */
    g_fb_size = mt_disp_get_vram_size();
    g_fb_base = memory_size() - g_fb_size + DRAM_PHY_ADDR;
    dprintf(INFO, "FB base = 0x%x, FB size = %d\n", g_fb_base, g_fb_size);

    platform_init_interrupts();
    platform_early_init_timer();
    mt_gpio_set_default();

    /* initialize the uart */
    uart_init_early();   
#ifdef LK_PROFILING
    time_i2c_init = get_timer(0);
#endif

    mt_i2c_init();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- i2c init takes %d ms -------- \n", get_timer(time_i2c_init));
#endif

    mtk_wdt_init();

#ifdef LK_PROFILING
    time_led_init = get_timer(0);
#endif

#ifndef MACH_FPAG
    leds_init();
#endif

#ifdef LK_PROFILING
      printf("[PROFILE] ------- led init takes %d ms -------- \n", get_timer(time_led_init));
#endif

    isink0_init();              //turn on PMIC6329 isink0

#ifdef LK_PROFILING
    time_disp_init = get_timer(0);
#endif

    mt_disp_init((void *)g_fb_base);
	
#ifdef LK_PROFILING
    printf("[PROFILE] ------- disp init takes %d ms -------- \n", get_timer(time_disp_init));
#endif

#ifdef CONFIG_CFB_CONSOLE
    drv_video_init();
#endif

#ifdef MACH_FPGA
    pwrap_init_lk();
    pwrap_init_for_early_porting();
#endif

#ifdef LK_PROFILING
    time_pmic6329_init = get_timer(0);
#endif
    pmic6320_init();
	
#ifdef LK_PROFILING
    printf("[PROFILE] ------- pmic6329_init takes %d ms -------- \n", get_timer(time_pmic6329_init));
    printf("[PROFILE] ------- platform_early_init takes %d ms -------- \n", get_timer(time_platform_early_init));
#endif
}
void cmd_download(const char *arg, void *data, unsigned sz)
{
	char response[MAX_RSP_SIZE];
	unsigned len = hex2unsigned(arg);
	u32 available_memory=0;
	//int r;

	init_display_xy();
	download_size = 0;
	//available_memory = memory_size()-(u32)download_base;
	// Real code should be: available_memory = memory_size()-((u32)download_base - MEMBASE);
	// download_base - MEMBASE is maximum of nearly 64M, that is more smaller than real RAM size like 1G, so use whole memory for approximation.
	available_memory = memory_size();	

	dprintf(DBG_LV, "Enter cmd_download Data Length:%d, available_memory:%d\n", len, available_memory);

	if (len > download_max)
	{
		dprintf(DBG_LV, "Data is larger than all partitions size in target.\n");
		fastboot_fail_wrapper("Data is larger than all partitions size in target");
		return;
	}

	if(is_use_ex_download(len))
	{
		if(available_memory < MEMORY_SIZE_REQ)
		{
			dprintf(DBG_LV, "Insufficient memory for DCACHE\n");
			fastboot_fail_wrapper("Insufficient memory for DCACHE");
			return;
		}
	}
	else
	{
		if (len > available_memory)
		{
			dprintf(DBG_LV, "Insufficient memory for whole image\n");
			fastboot_fail_wrapper("Insufficient memory for whole image");
			return;
		}
	}


	snprintf(response, MAX_RSP_SIZE, "DATA%08x", len);
	if (usb_write(response, strlen(response)) < 0)
	{
	    dprintf(DBG_LV, "cmd_download -- usb write fail\n");
		return;
	}

	if(is_use_ex_download(len))
	{
		//use ex download
		download_ex(len);
	}
	else
	{
		//use normal download
		download_standard(len);
	}

	return;
}
Beispiel #23
0
string::string(const char*cadena){
	int size = strlen(cadena);
	STR = new char[size + 1];
	memory_size(size + 1);
	strcpy_s(STR, size + 1, cadena);
}
Beispiel #24
0
string::string(){
	STR = new char[20];
	memory_size(20);
}
Beispiel #25
0
string::string(const string& copy){
	int size = strlen(copy.STR);
	STR = new char[size + 1];
	memory_size(size + 1);
	strcpy_s(STR, size + 1, copy.STR);
}
Beispiel #26
0
//#define PMIC_WRAP_PORTING //only for lk early porting
void platform_early_init(void)
{
#ifdef LK_PROFILING
    unsigned int time_led_init;
    unsigned int time_pmic6329_init;
    unsigned int time_platform_early_init;
    unsigned int time_repair_sram;
    unsigned int time_display_early_init;
    unsigned int time_wdt_early_init;
    time_platform_early_init = get_timer(0);
#endif
    /* initialize the uart */
    uart_init_early();
    platform_init_interrupts();
    platform_early_init_timer();
    mt_gpio_set_default();

    #ifdef REPAIR_SRAM_ENABLE_LK_FOR_82_BRINGUP
    #ifdef LK_PROFILING
    time_repair_sram = get_timer(0);
    #endif
    int repair_ret;
    repair_ret = repair_sram();
    if(repair_ret != 0)
    {
        printf("Sram repair failed %d\n", repair_ret);
        while(1);
    }
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- Repair SRAM takes %d ms -------- \n",(int) get_timer(time_repair_sram));
    #endif
    #endif
    //i2c_v1_init();
    #ifdef LK_PROFILING
    time_wdt_early_init = get_timer(0);
    #endif
    mtk_wdt_init();
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- WDT Init  takes %d ms -------- \n", (int)get_timer(time_wdt_early_init));
    #endif
// WDT will be triggered when uncompressing linux image on FPGA
#ifdef MACH_FPGA
    mtk_wdt_disable();
#endif
#ifdef MTK_MT8193_SUPPORT
	mt8193_init();
#endif
/* initialize the frame buffet information */
//FIXME: Disable for MT6582 FPGA Ealry Porting
#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
    #ifdef LK_PROFILING
    time_display_early_init = get_timer(0);
    #endif
    g_fb_size = mt_disp_get_vram_size();
    g_fb_base = memory_size() - g_fb_size + DRAM_PHY_ADDR;
    dprintf(INFO, "FB base = 0x%x, FB size = %d\n", g_fb_base, g_fb_size);
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- Display eraly init takes %d ms -------- \n", (int)get_timer(time_display_early_init));
    #endif
#endif


#ifdef LK_PROFILING
    time_led_init = get_timer(0);
#endif

#ifndef MACH_FPGA
    leds_init();
#endif

#ifdef LK_PROFILING
      printf("[PROFILE] ------- led init takes %d ms -------- \n", get_timer(time_led_init));
#endif

    isink0_init();              //turn on PMIC6329 isink0


    //FIXME: Disable for MT6582 FPGA Ealry Porting
    #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
    if (!(lcm_params->type==LCM_TYPE_DSI && lcm_params->dsi.mode ==CMD_MODE))
        mt_disp_init((void *)g_fb_base);
    #endif

#ifdef PMIC_WRAP_PORTING
    pwrap_init_lk();
    pwrap_init_for_early_porting();
#endif

#ifdef LK_PROFILING
    time_pmic6329_init = get_timer(0);
#endif

    pmic_init();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- pmic_init takes %d ms -------- \n", get_timer(time_pmic6329_init));
    printf("[PROFILE] ------- platform_early_init takes %d ms -------- \n", get_timer(time_platform_early_init));
#endif
}
Beispiel #27
0
int part_load(blkdev_t *bdev, part_t *part, u32 *addr, u32 offset, u32 size)
{
    int ret;
    img_hdr_t *hdr = img_hdr_buf;
    part_hdr_t *part_hdr = &hdr->part_hdr;
    gfh_file_info_t *file_info_hdr = &hdr->file_info_hdr;

    /* specify the read offset */
    u64 src = part->startblk * bdev->blksz + offset;
    u32 dsize = 0, maddr = 0, mode = 0;
    u32 ms;

    /* retrieve partition header. */
    if (blkdev_read(bdev, src, sizeof(img_hdr_t), (u8*)hdr) != 0) {
        print("[%s] bdev(%d) read error (%s)\n", MOD, bdev->type, part->name);
        return -1;
    }
    
    if (part_hdr->info.magic == PART_MAGIC) {

        /* load image with partition header */
        part_hdr->info.name[31] = '\0';

        print("[%s] Image with part header\n", MOD);
        print("[%s] name : %s\n", MOD, part_hdr->info.name);
        print("[%s] addr : %xh mode : %d\n", MOD, part_hdr->info.maddr, part_hdr->info.mode);
        print("[%s] size : %d\n", MOD, part_hdr->info.dsize);
        print("[%s] magic: %xh\n", MOD, part_hdr->info.magic);
    
        maddr = part_hdr->info.maddr;
        dsize = part_hdr->info.dsize;
	mode = part_hdr->info.mode;
        src += sizeof(part_hdr_t);
	
	memcpy(part_info + part_num, part_hdr, sizeof(part_hdr_t));
	part_num++;
    } else {
        print("[%s] %s image doesn't exist\n", MOD, part->name);
        return -1;
    }

    if (maddr == PART_HEADER_MEMADDR) {
        maddr = *addr;
    }
    else if (mode == LOAD_ADDR_MODE_BACKWARD) {
	/* note: if more than one TEE are loaded/verified, the later loaded tee 
	 * MUST BE the active TEE due to secure momory allocation algorithm */
	g_secure_dram_size = maddr;
	/* secure memory is allocated to secure world already */
	maddr = CFG_DRAM_ADDR + memory_size(); 
    }

    ms = get_timer(0);
    if (0 == (ret = blkdev_read(bdev, src, dsize, (u8*)maddr)))
        *addr = maddr;
    ms = get_timer(ms);

    print("\n[%s] load \"%s\" from 0x%llx (dev) to 0x%x (mem) [%s]\n", MOD, 
        part->name, src, maddr, (ret == 0) ? "SUCCESS" : "FAILED");

    if( ms == 0 )
        ms+=1;
    
    print("[%s] load speed: %dKB/s, %d bytes, %dms\n", MOD, ((dsize / ms) * 1000) / 1024, dsize, ms);
    #if CFG_TRUSTONIC_TEE_SUPPORT
    if (part_is_TEE(part)) {
	u32 tee_hdr_size = 0;
	print("verifying TEE...");
	/* verify TEE */
	ret = trustonic_tee_verify(addr, dsize, tee_img_vfy_pubk);
	if (ret) {
	    print("fail, ret = 0x%x\n", ret);
	    return ret;
	}
	print("ok\n");

	ret = trustonic_tee_decrypt(maddr, dsize);
	if (ret)
	    return ret;

	/* return memory occupied by tee hdr to normal world */
	tee_hdr_size = *addr - maddr;
	g_secure_dram_size -= tee_hdr_size;
    }
    #endif

    return ret;
}
Beispiel #28
0
 virtual uint ideal_reg() const  { return Matcher::vector_ideal_reg(memory_size()); }