Exemple #1
0
main(int argc, char *argv[])
{

    if(getuid() != 0)
	die("This program requires to be run as root.\n");

    parse_args(argc, argv);

    if(!no_daemon) daemonize();

    signal(SIGINT, sighandler);
    signal(SIGTERM, sighandler);
    signal(SIGQUIT, sighandler);
    
    uio_init();
    tcpsv_init();

    if(pthread_create(&hw_thread, NULL, hw_thread_entry, NULL) < 0)
	die("HW thread creation error\n");

    for(;;)
    {
	handle_requests();
	handle_streaming();
    }
}
Exemple #2
0
int main() {
    char *argv[] = {"sh", 0};

    if (uio_init() < 0) {
        goto bad;     
    }

    int pid = _fork();
    if (pid == 0) {
        if (_exec("/bin/sh", argv) < 0) {
            goto bad;
        }
    } else if (pid < 0) {
        goto bad;
    }

    if (_wait() < 0) goto bad;
    puts("shell exit.\n");
    for (;;);

bad:    
    puts("Unresolvable fault, check your rootfs.img :(\n");
    /* trigger a genernal protection fault */
    __asm__("int $13"); 
}
BOOL ota_check(void)
{
  ota_bl_info_t bl_info = {0};
  charsto_cfg_t charsto_cfg = {0};
  void  *p_dev = NULL;
  RET_CODE ret = ERR_FAILURE;

  /******char storage init******/
  ret = ATTACH_DRIVER(CHARSTO, warriors, default, default);
  MT_ASSERT(ret == SUCCESS);

  p_dev = dev_find_identifier(NULL, DEV_IDT_TYPE, SYS_DEV_TYPE_CHARSTO);
  MT_ASSERT(NULL != p_dev);

  charsto_cfg.size = CHARSTO_SIZE; //4
  charsto_cfg.spi_clk = FLASH_C_CLK_P6;
  charsto_cfg.rd_mode = SPI_FR_MODE;
  //charsto_cfg.multi_io_rd = 1;
  //charsto_cfg.multi_io_wd = 1;
  ret = dev_open(p_dev, &charsto_cfg);
  MT_ASSERT(ret == SUCCESS);

  /* open uio */
  uio_init();

  mtos_task_delay_ms(M_TASK_DELAY_TIME);

  if(mul_ota_dm_api_check_intact_picec(OTA_DM_BLOCK_PIECE_OTA_BLINFO_ID) == FALSE)
  {
      ui_ota_api_bootload_info_init();
  }

  mul_ota_dm_api_read_bootload_info(&bl_info);
  OS_PRINTF("\r\n[OTA]%s:ota_tri[%d] ",__FUNCTION__, bl_info.ota_status);



  /* flash burning is not finished, force ota*/
  if( bl_info.destroy_flag == TRUE) 
  {
      bl_info.ota_status = OTA_TRI_MODE_FORC;
      mul_ota_dm_api_save_bootload_info(&bl_info);
      return TRUE;
  }

  if(is_force_key_press())
  {
    bl_info.ota_status = OTA_TRI_MODE_AUTO;
    mul_ota_dm_api_save_bootload_info(&bl_info);
    return TRUE;
  }

  if((bl_info.ota_status == OTA_TRI_MODE_AUTO)
  ||(bl_info.ota_status == OTA_TRI_MODE_FORC))
  {
      return TRUE;
  }

  return FALSE;
}
static int InBufferInit(aml_audio_dec_t *audec)
{
       int ret = uio_init(fd_uio);
	if (ret < 0){
		adec_print("uio init error! \n");
		return -1;
	}
	return 0;
}
void drv_init_concerto(void)
{
  RET_CODE ret;
  const drvsvc_handle_t *p_public_drvsvc;

#ifndef WIN32
  hal_otp_init();
#endif

  /* DMA */
  ret = hal_dma_init();
  MT_ASSERT(ret == SUCCESS);

  p_public_drvsvc = drv_public_svr_init();
  MT_ASSERT(p_public_drvsvc != NULL);

  ret = drv_dm_init();
  MT_ASSERT(ret == SUCCESS);

  ret = drv_i2c_init();
  MT_ASSERT(ret == SUCCESS);
  
  ret = drv_hdmi_init(p_public_drvsvc);
  MT_ASSERT(ret == SUCCESS);

  ret = drv_dmx_init();
  MT_ASSERT(ret == SUCCESS);

  ret = drv_video_init();
  MT_ASSERT(ret == SUCCESS);

  ret = drv_display_init();
  MT_ASSERT(ret == SUCCESS);

  mtos_task_sleep(1500);
  OS_PRINTF("LOGO is NOT picture, assuming IFRAME.\n");
  show_startup_iFram();
 
#if 0
  ret = drv_gpe_init();
  MT_ASSERT(ret == SUCCESS);
  ret = drv_jpeg_init();
  MT_ASSERT(ret == SUCCESS);
#endif

  ret = uio_attach_concerto("concerto");
  MT_ASSERT(ret == SUCCESS);
  
  uio_init();

}
static void *adec_armdec_loop(void *args)
{
    int ret;
	int rlen = 0;
	int inlen = 0;
	int dlen = 0;
	int declen = 0;
    aml_audio_dec_t *audec;
    audio_out_operations_t *aout_ops;
    adec_cmd_t *msg = NULL;
	AVPacket apkt;
	char *inbuf = NULL;
	char apkt_end[APACKET_END_SIZE];
	char outbuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
	int outlen = 0;
	AVCodecContext *ctxCodec = NULL;
	AVCodec *acodec = NULL;
	int in_ape_fp = -1;
	int out_ape_fp = -1;
	int audio_handle = -1;
	
	adec_print("adec_armdec_loop start!\n");

	audec = (aml_audio_dec_t *)args;
    aout_ops = &audec->aout_ops;
	av_init_packet(&apkt); 
	//memset(inbuf, 0, READ_ABUFFER_SIZE);
	memset(outbuf, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE);

	//buffer_stream_t init and set adsp_ops param
	audec->bs=malloc(sizeof(buffer_stream_t));
	int ret_value=init_buff(audec->bs);
	if(ret_value==1)
		adec_print("=====pcm buffer init ok buf_size:%d buf_data:0x%x  end:0x%x !\n",audec->bs->buf_length,audec->bs->data,audec->bs->data+1024*1024);
	audec->adsp_ops.dsp_on=1;
	aout_ops->init(audec);
	aout_ops->start(audec);

	ctxCodec = avcodec_alloc_context();
	if(!ctxCodec) {
		adec_print("APE AVCodecContext allocate error!\n");
		ctxCodec = NULL;
	}
	adec_print("ctxCodec!\n");

	
	adec_print("adec_armdec_loop   audec->pcodec = %d, audec->pcodec->ctxCodec = %d!\n", audec->pcodec, audec->pcodec->ctxCodec);
		
	ctxCodec = audec->pcodec->ctxCodec;
	ctxCodec->codec_type = CODEC_TYPE_AUDIO;
		
	adec_print("open codec_id = %d--\n",ctxCodec->codec_id);
	acodec = avcodec_find_decoder(ctxCodec->codec_id);
	if (!acodec) {
		adec_print("acodec not found\n");
	}
	adec_print("open codec_id = %d----------------------------------\n",ctxCodec->codec_id);
		
	if (avcodec_open(ctxCodec, acodec) < 0) {
		adec_print("Could not open acodec = %d\n", acodec);
	}

	out_ape_fp = open("./dump/123.dat", O_CREAT | O_RDWR);
	if (out_ape_fp < 0) {
        adec_print("Create input file failed! fd=%d------------------------------\n", out_ape_fp);
    }
    adec_print("out_ape_fp = %d!", out_ape_fp);
	in_ape_fp = open("./dump/in.dat", O_CREAT | O_RDWR);
	if (in_ape_fp < 0) {
        adec_print("Create input file failed! fd=%d------------------------------\n", out_ape_fp);
    }
    adec_print("in_ape_fp = %d!", in_ape_fp);

	ret = uio_init();
	if (ret < 0){
		adec_print("uio init error! \n");
		goto error;
	}
		
    while (1){

		if (inlen > 0) {
			if (inbuf) {
				free(inbuf);
				inbuf = NULL;
			}
			inbuf = malloc(READ_ABUFFER_SIZE + inlen);
			memcpy(inbuf, apkt_end, inlen);
			rlen = read_buffer(inbuf+inlen, READ_ABUFFER_SIZE);
			rlen += inlen;
		}
		else {
			if (inbuf) {
				free(inbuf);
				inbuf = NULL;
			}
			inbuf = malloc(READ_ABUFFER_SIZE);
			rlen = read_buffer(inbuf+inlen, READ_ABUFFER_SIZE);
		}
		if (out_ape_fp >= 0) {
			write(in_ape_fp, inbuf, rlen);
			adec_print("write ape data in rlen = %d bytes\n",rlen);
		}
		declen = 0;
		if (rlen > 0){
			inlen = rlen;
			while (declen<rlen) {	
				outlen = AVCODEC_MAX_AUDIO_FRAME_SIZE;
				dlen = decode_audio(ctxCodec, outbuf, &outlen, inbuf+declen, inlen);
				if (dlen <= 0){
					adec_print("dlen = %d error----\n",dlen);
					if (inlen > 0) {
						adec_print("packet end %d bytes----\n",inlen);
						memcpy(apkt_end, (uint8_t *)(inbuf+declen), inlen);
					}
					break;
				}
				declen += dlen;
				inlen -= dlen;
				write_pcm_buffer(outbuf, audec->bs,outlen);
				//write_buffer(outbuf, outlen);
				if (outlen > 0) {
					if (out_ape_fp >= 0) {
						write(out_ape_fp, outbuf, outlen);
					}
				}
			} 
		
#if 0			
			outsize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
			apkt.data = inbuffer;
			apkt.size = rlen;
			while (apkt.size > 0){
				dlen = avcodec_decode_audio3(ctxCodec, (int16_t *)outbuffer, &outsize, &apkt);
				if (dlen <= 0){
					adec_print("dlen = %d error----\n",dlen);
				}
				if (outsize > 0) {
					if (out_ape_fp >= 0) {
						write(out_ape_fp, outbuffer, outsize);
						adec_print("write ape data%d bytes\n UUUUUUUU----\n",outsize);
					}
				}				
				declen += dlen;
				apkt.size -= dlen;					
				if (apkt.size > 0){
					apkt.data += dlen;
				}
				else if (apkt.size < 0){
					adec_print("wrong aptk.size = %d, declen = %d, dlen = %d!", apkt.size, declen, dlen);
				}					
			}
#endif			
		}
		else {			
			adec_print("rlen = %d", rlen);
			break;
		}
	}
    close(out_ape_fp);
    close(in_ape_fp);
	
    adec_print("Exit adec_armdec_loop Thread!");

error:	
    pthread_exit(NULL);
    return NULL;
}
Exemple #7
0
void
initRepository(void) {
    static uio_AutoMount autoMountZip = {
        .pattern =      "*.zip",
        .matchType =    match_MATCH_SUFFIX,
        .fileSystemID = uio_FSTYPE_ZIP,
        .mountFlags =   uio_MOUNT_BELOW | uio_MOUNT_RDONLY
    };
    static uio_AutoMount *autoMount[] = {
        &autoMountZip,
        NULL
    };

    uio_init();
    repository = uio_openRepository(0);

    memset(&mountHandles, '\0', sizeof mountHandles);
#if 1
    mountHandles[0] = debugMountOne(repository, "/", uio_FSTYPE_STDIO,
                                    NULL, NULL, "/home/svdb/cvs/sc2/content", autoMount,
                                    uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
#endif
#if 1
    mountHandles[1] = debugMountOne(repository, "/", uio_FSTYPE_STDIO,
                                    NULL, NULL, "/home/svdb/cvs/sc2/src/sc2code/ships",
                                    autoMount, uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
#endif
#if 1
    mountHandles[2] = debugMountOne(repository, "/", uio_FSTYPE_STDIO,
                                    NULL, NULL, "/tmp/vfstest", autoMount, uio_MOUNT_TOP, NULL);
#endif
#if 1
    mountHandles[3] = debugMountOne(repository, "/", uio_FSTYPE_STDIO,
                                    NULL, NULL, "/tmp/vfstest2", autoMount, uio_MOUNT_TOP, NULL);
#endif

    // TODO: should work too:
#if 0
    mountHandle[4] = debugMountOne(repository, "/zip/", uio_FSTYPE_ZIP, NULL,
                                   NULL, "/ziptest/foo.zip", autoMount, uio_MOUNT_TOP, NULL);
#endif
    {
        uio_DirHandle *rootDir;
        rootDir = uio_openDir(repository, "/", 0);
        if (rootDir == NULL) {
            fprintf(stderr, "Could not open '/' dir.\n");
        } else {
#if 1
            mountHandles[4] = debugMountOne(repository, "/example/",
                                            uio_FSTYPE_ZIP, rootDir, "/example2.zip", "/", autoMount,
                                            uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
#endif
#if 1
            mountHandles[5] = debugMountOne(repository, "/example/",
                                            uio_FSTYPE_ZIP, rootDir, "/example/example.zip", "/",
                                            autoMount, uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
#endif
#if 1
            mountHandles[6] = debugMountOne(repository, "/zip/",
                                            uio_FSTYPE_ZIP, rootDir, "/voice.zip", "/", autoMount,
                                            uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
#endif
#if 1
            mountHandles[7] = debugMountOne(repository, "/foo/",
                                            uio_FSTYPE_ZIP, rootDir, "/foo2.zip", "/", autoMount,
                                            uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
#endif
            uio_closeDir(rootDir);
        }
    }
    mountHandles[8] = debugMountOne(repository, "/tmp/",
                                    uio_FSTYPE_STDIO, NULL, NULL, "/tmp/", autoMount,
                                    uio_MOUNT_TOP, NULL);

#if 1
    mountHandles[8] = debugMountOne(repository, "/root/root/",
                                    uio_FSTYPE_STDIO, NULL, NULL, "/", autoMount,
                                    uio_MOUNT_TOP | uio_MOUNT_RDONLY, NULL);
#endif

}

void
unInitRepository(void) {
#if 1
    int i;
//	uio_printMountTree(stderr, repository->mountTree, 0);
//	fprintf(stderr, "\n");
    for (i = 7; i >= 0; i--) {
        if (mountHandles[i] != NULL)
            uio_unmountDir(mountHandles[i]);
//		uio_printMountTree(stderr, repository->mountTree, 0);
//		uio_printMounts(stderr, repository);
//		fprintf(stderr, "\n");
    }
#endif
    uio_closeRepository(repository);
    uio_unInit();
}