Пример #1
0
void module_init_encode_cyril(ptu32_t para)
{
    static struct tagCharset encoding;
   //加载字库
     printf("Init the code\n");
    LanguageCode=GetLanguagecodeFromFile(FileName);

    encoding.max_len = 1;
    encoding.mb_to_ucs4 = __cyril_mb_to_ucs4;
    encoding.ucs4_to_mb = __cyril_ucs4_to_mb;
    encoding.mbs_to_ucs4s = __cyril_mbs_to_ucs4s;
    encoding.ucs4s_to_mbs = __cyril_ucs4s_to_mbs;
    if( Charset_NlsInstallCharset(&encoding, cn_nls_charset_cyril))
    {
        printf("cyril encoding install sucess\n\r");
        return 1;
    }else
    {
        Djy_SaveLastError(EN_GK_CHARSET_INSTALL_ERROR);
        printf("cyril encoding install fail\n\r");
        return 0;
    }


}
Пример #2
0
//----安装输入设备-------------------------------------------------------------
//功能: 把输入设备登记到资源结点中
//参数: device_name,目标设备的资源名
//返回: 输入设备ID,-1表示失败
//-----------------------------------------------------------------------------
s32 Stddev_InstallDevice(char *device_name,enum _STDIN_INPUT_TYPE_ stdin_type,
                         void *myprivate)
{
    struct tagStdinDeviceRsc *djy_stdin;

    if(Rsc_SearchSon(&s_ptStdinDeviceRscTree->stdin_device_node,device_name))
    {
        return -1;
    }
    else
    {
        djy_stdin = Mb_Malloc(g_ptStdinDevicePool,0);
        if(djy_stdin != NULL)
        {
            Rsc_AddSon(&s_ptStdinDeviceRscTree->stdin_device_node,
                    &djy_stdin->stdin_device_node,sizeof(struct tagStdinDeviceRsc),
                    RSC_STDIN_OUT,device_name);
            djy_stdin->input_type = stdin_type;
            djy_stdin->stdin_private = (ptu32_t)myprivate;
            djy_stdin->input_counter = 0;
            djy_stdin->FocusMsgQ = tg_pDefaultFocusMsgQ;
            g_s32NextId += 1;
            djy_stdin->device_id = g_s32NextId;
            return djy_stdin->device_id;
        }
        else
        {
            Djy_SaveLastError(EN_MEM_TRIED);
            printf("内存不足\n\r");
            return -1;
        }

    }
}
Пример #3
0
//----创建线程-----------------------------------------------------------------
//功能:为事件类型创建线程,初始化上下文环境,安装执行函数,构成完整线程
//参数:evtt_id,待创建的线程所服务的事件类型id
//返回:新创建的线程指针
//注: 移植敏感函数
//-----------------------------------------------------------------------------
struct  tagThreadVm *__CreateThread(struct  tagEventType *evtt,u32 *stack_size)
{
    struct  tagThreadVm  *result;
    ptu32_t  len;

    //计算线程栈:线程+最大单个api需求的栈
    len = evtt->stack_size+CN_KERNEL_STACK+sizeof(struct  tagThreadVm);
    //栈顶需要对齐,malloc函数能保证栈底是对齐的,对齐长度可以使栈顶对齐
    len = align_up_sys(len);
    result=(struct  tagThreadVm  *)__MallocStack(len);
    *stack_size = len;
    if(result==NULL)
    {
        Djy_SaveLastError(EN_MEM_TRIED);   //内存不足,返回错误
        return result;
    }
#if CN_CFG_STACK_FILL != 0
    len = M_CheckSize(result);
    memset(result,CN_CFG_STACK_FILL,len);
#endif

    //看实际分配了多少内存,djyos内存分配使用块相联策略,如果分配的内存量大于
    //申请量,可以保证其实际尺寸是对齐的。之所以注释掉,是因为当len大于申请量时,
    //对齐只是实际结果,而不是内存管理的规定动作,如果不注释掉,就要求内存管理
    //模块必须提供对齐的结果,对模块独立性是不利的。
//    len = M_CheckSize(result);
    result->stack_top = (u32*)((ptu32_t)result+len); //栈顶地址,移植敏感
    result->next = NULL;
    result->stack_size = len - sizeof(struct tagThreadVm); //保存栈深度
    result->host_vm = NULL;
    //复位线程并重置线程
    __asm_reset_thread(evtt->thread_routine,result);
    return result;
}
Пример #4
0
// =============================================================================
// 函数功能:__CreateThread
//          创建线程
// 输入参数:evtt,线程关联的evtt
// 输出参数:stack_size,创建的VM的stack的大小
// 返回值  :
// 说明    :将evtt中的内容恢复到创建的VM当中
// =============================================================================
struct  tagThreadVm *__CreateThread(struct  tagEventType *evtt,u32 *stack_size)
{
    struct  tagThreadVm  *result;
    ptu32_t  len;

    //计算虚拟机栈:线程+最大单个api需求的栈
    len = evtt->stack_size+CN_KERNEL_STACK+sizeof(struct  tagThreadVm);
    //栈顶需要对齐,malloc函数能保证栈底是对齐的,对齐长度可以使栈顶对齐
    len = align_up_sys(len);
    result=(struct  tagThreadVm  *)(__MallocStack(len));
    *stack_size = len;
    if(result==NULL)
    {
        Djy_SaveLastError(EN_MEM_TRIED);   //内存不足,返回错误
        return result;
    }
#if CN_CFG_STACK_FILL != 0
    memset(result,CN_CFG_STACK_FILL,len);
#endif
    result->stack_top = (u32*)((ptu32_t)result+len); //栈顶地址,移植敏感
    result->next = NULL;
    result->stack_size = len - sizeof(struct tagThreadVm); //保存栈深度
    result->host_vm = NULL;
    //复位虚拟机并重置线程
    __asm_reset_thread(evtt->thread_routine,result);
    return result;
}
Пример #5
0
void module_init_encode_arabic(ptu32_t para)
{
    static struct Charset encoding;

    int i=0;
   //加载字库
     printf("Init the code\n");
    arabic_file_code=GetLanguagecodeFromFile(ArialFile);
    if(arabic_file_code==NULL)
    {
         printf("Get file code failed!\n");
         return;
    }
    nSections=((struct FontLibHeader*)arabic_file_code)->nSection;
    pSectionInfo=(struct FlSectionInfo *)(arabic_file_code+0x10);

    //打印编码信息
    for(i=0;i<nSections;i++)
        {
     printf("Section=%d ,First=%04x,Last=%04x,Addr=%08x\n",i,pSectionInfo[i].First,\
        pSectionInfo[i].Last,pSectionInfo[i].OffAddr);

    }

    encoding.max_len = 2;
    encoding.EOC_Size = 1;
    encoding.GetOneMb = ArabicGetOneMb;
    encoding.MbToUcs4 = ArabicMbToUcs4;
    encoding.Ucs4ToMb = ArabicUcs4ToMb;
    encoding.MbsToUcs4s = ArabicMbsToUcs4s;
    encoding.Ucs4sToMbs = ArabicUcs4sToMbs;
    if( Charset_NlsInstallCharset(&encoding, CN_NLS_CHARSET_ARABIC))
    {
        printf("arabic encoding install sucess\n\r");
        return 1;
    }else
    {
        Djy_SaveLastError(EN_GK_CHARSET_INSTALL_ERROR);
        printf("arabic encoding install fail\n\r");
        return 0;
    }


}
Пример #6
0
void module_init_encode_arabic(ptu32_t para)
{
    static struct tagCharset encoding;

    int i=0;
   //加载字库
     printf("Init the code\n");
    arabic_file_code=GetLanguagecodeFromFile(ArialFile);
    if(arabic_file_code==NULL)
        {
         printf("Get file code failed!\n");
         return;
    }
    nSections=((struct tagFontLibHeader*)arabic_file_code)->nSection;
    pSectionInfo=(struct tagFlSectionInfo *)(arabic_file_code+0x10);

    //打印编码信息
    for(i=0;i<nSections;i++)
        {
     printf("Section=%d ,First=%04x,Last=%04x,Addr=%08x\n",i,pSectionInfo[i].First,\
        pSectionInfo[i].Last,pSectionInfo[i].OffAddr);

    }

    encoding.max_len = 1;
    encoding.mb_to_ucs4 = __arabic_mb_to_ucs4;
    encoding.ucs4_to_mb = __arabic_ucs4_to_mb;
    encoding.mbs_to_ucs4s = __arabic_mbs_to_ucs4s;
    encoding.ucs4s_to_mbs = __arabic_ucs4s_to_mbs;
    if( Charset_NlsInstallCharset(&encoding, cn_nls_charset_arabic))
    {
        printf("arabic encoding install sucess\n\r");
        return 1;
    }else
    {
        Djy_SaveLastError(EN_GK_CHARSET_INSTALL_ERROR);
        printf("arabic encoding install fail\n\r");
        return 0;
    }


}
Пример #7
0
ptu32_t module_init_font_arabic(ptu32_t para)
{
    static struct FontRsc font_arabic;
  //  __Charset_Gb2312_816_1616LoadFont((u8*)para);  //加载字库
    font_arabic.fi.type = CN_FONT_TYPE_DOT;
    font_arabic.LoadFont = __arabic_load_font;
    font_arabic.UnloadFont = __arabic_unload_font;
    font_arabic.GetBitmap = __arabic_get_char_bitmap;

    if(Gk_FontInstallFont(&font_arabic, cn_font_arabic))
    {
        printf("arabic  font install sucess\n\r");
        return 1;
    }else
    {
        Djy_SaveLastError(EN_GK_FONT_INSTALL_ERROR);
        printf("arabic font install fail\n\r");
        return 0;
    }
}
Пример #8
0
//----安装gb2312 16点阵字体----------------------------------------------------
//功能: 安装gb2312 16点阵字体。
//参数: 无意义
//返回: 1=成功,0=失败
//-----------------------------------------------------------------------------
ptu32_t module_init_font_cyril16(ptu32_t para)
{
    static struct tagFontRsc font_cyril16;
  //  __Charset_Gb2312_816_1616LoadFont((u8*)para);  //加载字库
    font_cyril16.fi.type = CN_FONT_TYPE_DOT;
    font_cyril16.LoadFont = __cyril16_load_font;
    font_cyril16.UnloadFont = __cyril16_unload_font;
    font_cyril16.GetBitmap = __cyril16_get_char_bitmap;

    if(Font_InstallFont(&font_cyril16, cn_font_cyril16))
    {
        printf("cyril  font install sucess\n\r");
        return 1;
    }else
    {
        Djy_SaveLastError(EN_GK_FONT_INSTALL_ERROR);
        printf("cyril font install fail\n\r");
        return 0;
    }
}
Пример #9
0
//----安装ascii字符集----------------------------------------------------------
//功能: 安装ascii字符集,当系统使用西方字符界面时,使用这个字符集。特别注意,
//      gb2312已经包含了英文字符集,使用中文或中英文混合界面的,不需要安装ascii
//      字符集。但是,由于GB2312的字库只包含了全角的英文字符,故还需要安装ascii
//      的字体资源,尺寸(8*8、8*16)可选。
//参数: 无意义
//返回: 1=成功,0=失败
//-----------------------------------------------------------------------------
ptu32_t ModuleInstall_CharsetAscii(ptu32_t para)
{
    static struct tagCharset encoding;

    encoding.max_len = 1;
    encoding.mb_to_ucs4 = Charset_AsciiModuleInitMbToUcs4;
    encoding.ucs4_to_mb = Charset_AsciiModuleInitUcs4ToMb;
    encoding.mbs_to_ucs4s = Charset_AsciiModuleInitMbsToUcs4s;
    encoding.ucs4s_to_mbs = Charset_AsciiModuleInitUcs4sToMbs;
    if( Charset_NlsInstallCharset(&encoding, CN_NLS_CHARSET_ASCII))
    {
        printf("ASCII encoding install sucess\r\n");
        return 1;
    }else
    {
        Djy_SaveLastError(EN_GK_CHARSET_INSTALL_ERROR);
        printf("ASCII encoding install fail\n\r");
        return 0;
    }
}
Пример #10
0
Файл: int.c Проект: djyos/djyos
//----设定中断同步-------------------------------------------------------------
//功能: 阻塞正在处理的事件的线程,直到指定的中断线的中断发生、响应并返回,然后才
//      激活线程。调用前确保该中断线被禁止,调用本函数将导致中断线被使能(是直接
//      使能,不是调用int_save_asyn_line),并在返回后恢复禁止状态。
//参数: ufl_line,等待的目标中断线
//返回: false = 该中断已经被其他线程等待,直接返回。
//      true = 成功同步,并在该中断发生后返回。
//备注: 1.中断是一种临界资源,不宜在中断函数中太多的事情,故中断同步的功能比较简
//      单,每条中断线同一时刻只能有一个线程等待,也不允许设置超时等待
//      2.秉承djyos一贯风格,中断同步函数只能把自己置入等待状态,而不能控制别的
//      线程,故函数原型不能是 bool_t int_sync(ufast_t line,uint16_t event_id)
//      3.实时中断设置等待无效,调用本函数时,如果line已经被设置为实时中断,则
//      直接返回false,如果调用本函数后,line不能被设置为实时中断。
//      4.为正确实现功能,须在调用前确保该中断线是被禁止的。
//-----------------------------------------------------------------------------
bool_t Int_AsynSignalSync(ufast_t ufl_line)
{
    if( (ufl_line > CN_INT_LINE_LAST)
            || (tg_pIntLineTable[ufl_line] == NULL) )
        return false;
    if( !Djy_QuerySch())
    {   //禁止调度,不能进入异步信号同步状态。
        Djy_SaveLastError(EN_KNL_CANT_SCHED);
        return false;
    }
    Int_SaveAsynSignal();   //在操作就绪队列期间不能发生中断
    //实时中断不能设置同步,一个中断只接受一个同步事件
    if((tg_pIntLineTable[ufl_line]->int_type == CN_REAL)
            || (tg_pIntLineTable[ufl_line]->sync_event != NULL))
    {
        Int_RestoreAsynSignal();
        return false; //实时中断或已经有同步事件
    }else
    {
        if(Int_QueryLine(ufl_line) == true)    //中断已经发生,同步条件达到
        {
            Int_ClearLine(ufl_line);
            Int_RestoreAsynSignal();
            return true;
        }
        //以下三行从就绪链表中取出running事件
        __Djy_CutReadyEvent(g_ptEventRunning);
        g_ptEventRunning->next = NULL;
        g_ptEventRunning->previous = NULL;
        g_ptEventRunning->event_status = CN_STS_WAIT_ASYN_SIGNAL;
        tg_pIntLineTable[ufl_line]->sync_event = g_ptEventRunning;
    }
    Int_EnableAsynLine(ufl_line);
    Int_RestoreAsynSignal();      //调用本函数将引发线程切换,正在处理的事件被
                                    //挂起。
    Int_DisableAsynLine(ufl_line);
    g_ptEventRunning->wakeup_from = CN_STS_WAIT_ASYN_SIGNAL;
    g_ptEventRunning->event_status = CN_STS_EVENT_READY;
    return true;
}
Пример #11
0
Файл: utf8.c Проект: djyos/djyos
//----安装utf8字符编码解析器---------------------------------------------------
//功能: 安装utf8字符编码解析器,执行ucs4和编码和utf8编码之间转换。
//参数: 无意义
//返回:1=成功,0=失败
//-----------------------------------------------------------------------------
ptu32_t ModuleInstall_CharsetUtf8(ptu32_t para)
{
    static struct Charset encoding;

    encoding.max_len = 6;
    encoding.EOC_Size = 1;
    encoding.GetOneMb = Utf8GetOneMb;
    encoding.MbToUcs4 = Utf8MbToUcs4;
    encoding.Ucs4ToMb = Utf8Ucs4ToMb;
    encoding.MbsToUcs4s = Utf8MbsToUcs4s;
    encoding.Ucs4sToMbs = Utf8Ucs4sToMbs;
    if( Charset_NlsInstallCharset(&encoding, CN_NLS_CHARSET_UTF8))
    {
        printf("utf8 encoding install sucess\n\r");
        return 1;
    }else
    {
        Djy_SaveLastError(EN_GK_CHARSET_INSTALL_ERROR);
        printf("utf8 encoding install fail\n\r");
        return 0;
    }
}