⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debugos.c

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 C
📖 第 1 页 / 共 4 页
字号:
    if (rb == NULL)    {        LogError(LOG_DEBUGOS, ( "angelOS_Execute: No application!\n"));    }    else    {        LogInfo(LOG_DEBUGOS, ( "angelOS_Execute: From PC = %08lx, CPSR = %08lx\n",                               rb->pc, rb->cpsr));    }        Angel_BlockApplication(0);    return RDIError_NoError;}int angelOS_InterruptExecution(word OSinfo1, word OSinfo2){    LogInfo(LOG_DEBUGOS, ( "angelOS_InterruptExecution\n"));    IGNORE(OSinfo1);    IGNORE(OSinfo2);    Angel_BlockApplication(1);    return RDIError_NoError;}/* should this be in a header? */extern void debug_ThreadStopped(word OSinfo1, word OSinfo2, unsigned int event,                                unsigned int subcode);extern void angelOS_ThreadStopped(word type){    LogInfo(LOG_DEBUGOS, ( "Entered function angelOS_ThreadStopped.\n"));    Angel_BlockApplication(1);    angelOS_PrintState(ADP_HandleUnknown, ADP_HandleUnknown);    Angel_QueueCallback((angel_CallbackFn) debug_ThreadStopped, TP_AngelCallBack,                        (void *)ADP_HandleUnknown,                        (void *)ADP_HandleUnknown,                        (void *)type,                        NULL);    return;}int AngelOS_SetHandler(int VectorID, void (*handler) (),                   void *(*oldHandler) ()){    IGNORE(VectorID);    IGNORE(handler);    IGNORE(oldHandler);    return RDIError_UnimplementedMessage;}struct AngelOSInfo *angelOS_ReturnInfo(void){    return &OSinfo_struct;}/* *        Function:  angelOS_InitialiseApplication * *         Purpose:  Initialise the application context to 'default' values, *                   which are usable at least until the applicatio itself *                   can insert the correct ones. Note that in addition to *                   this initialisatin, the debugger may well use CPUwrite *                   to change other things, notably the CPU mode and PC *                   values. *                    *                   Rationale: The IRQ/FIQ/UND/ABT stacks are set up as for *                   Angel tasks; this will usually be ok, as you usually *                   won't be playing with these modes, and usually appl use *                   won't interfere with Angel use. However, if you intend *                   to use these modes you *should* initialise the stacks to *                   point at your own memory. Be aware though this may well *                   mean that Ange will use a few words of your stacks as it *                   enters it's own exception handler. *                    *                   The USR mode stack etc is set to the values obtained from *                   SWI GETHEAPDESC; this is what Angel has historically done, *                   and seems sane enough. To match this, the stack limit is *                   set to the appl stack limit. The SVC stack cannot be set *                   to the same value -- if in USR mode and you do a SWI then *                   Angel will use the base of your USR stack, overwriting *                   values which the program will reload later and usually *                   resulting in a crash. *                    *                   If the debugger starts the application in SVC mode, then *                   a better value for SL would have been the appl svc stack *                   limit, but as r10 is not banked btw. usr and svc we have *                   to choose. I have arbitrarily chosen to prefer USR. *                    *                   Lastly, the cpsr is set to interrupts disabled state for *                   those interrupts which are not shared with Angel, preventing *                   potential spurious interrupts. *                    * *       Arguments:  OSinfo1, OSinfo2 -- unused. * *         Returns:  RDIError_NoError - all ok *                   RDIError_Error - couldn't find the appl task! * *   Pre-conditions: Serialiser initialised, application task created. * *  Post-conditions: Serialiser initialised, application task created and set *                   up. *                    */int angelOS_InitialiseApplication(word OSinfo1, word OSinfo2){    angel_TaskQueueItem *appltqi;    IGNORE(OSinfo1);    IGNORE(OSinfo2);    LogInfo(LOG_DEBUGOS, ( "angelOS_InitialiseApplication\n"));    appltqi = Angel_AccessApplicationTask();    if (appltqi)    {        unsigned svcstacktop;	/*	 * Give the SYS module the chance to do things too...	 */	Angel_SysApplInit();        LogInfo(LOG_DEBUGOS, ( "zeroing rb... \n"));        /* clear out the register context, so we start in a known state */        memset(&appltqi->rb, 0, sizeof(angel_RegBlock));        LogInfo(LOG_DEBUGOS, ( "setting exception regs rb... \n"));        /*         * set up the non-SVC exception mode's SP/LR registers to the         * Angel stack values, as they must be pointing somewhere         * valid.         */        Angel_SetupExceptionRegisters(appltqi);        /* set up SVC/USR mode state to point at the appl heap area.         * these registers must also be valid from initialisation,         * as you can't return from a SWI, including the GETHEAPDESC         * SWI, unless you have a valid stack pointer.         */        svcstacktop   = Angel_StackBase + Angel_ApplSVCStackOffset;        /* svc limit = "Angel_StackBase + Angel_ApplSVCStackLimitOffset", but         * we must choose between USR and SVC limits -- prefer USR ATM         */        appltqi->rb.r13svc = svcstacktop;        appltqi->rb.r13usr = (unsigned)angel_heapstackdesc.stacktop;        appltqi->rb.r10usr = (unsigned)angel_heapstackdesc.stacklimit;        appltqi->rb.r11usr = 0;        appltqi->rb.cpsr = NotAngelInterruptMask | USR32mode;        return RDIError_NoError;    }    else        return RDIError_Error;}int angelOS_End(word debugID){    /*     * The host debugger is shutting down the debug session with ID debugID,     * so reset the debug session. Currently we do nothing - the host     * should renegotiate the baud rate back to the default if appropriate.     */    IGNORE(debugID);    LogInfo(LOG_DEBUGOS, ( "angelOS_End\n"));    return RDIError_NoError;}int angelOS_MemInfo(word * meminfo){    /* TODO: Change this as required. */    meminfo = 0;    return RDIError_NoError;}int angelOS_DescribeCoPro(byte cpno, struct CP_CoProDesc *cpd){    int ret_code = RDIError_Error;    LogInfo(LOG_DEBUGOS, ( "angelOS_DescribeCoPro\n"));#if defined(SYSTEM_COPROCESSOR_SUPPORTED) && SYSTEM_COPROCESSOR_SUPPORTED > 0    /*     * Check that this is for the system coprocessor - only one     * supported by this code currently     */    if (cpno == 15)    {        int i;        ret_code = RDIError_NoError;        if (cpd->entries > SYS_COPROC_MAX_REGS)        {            sys_coproc_reg_entries = SYS_COPROC_MAX_REGS;            ret_code = RDIError_OutOfStore;        }        else            sys_coproc_reg_entries = cpd->entries;        for (i = 0; i < sys_coproc_reg_entries; ++i)            sys_coproc_regdesc[i] = cpd->regdesc[i];    }    else        ret_code = RDIError_UnknownCoPro;#else    IGNORE(cpno);    IGNORE(cpd);    ret_code = RDIError_UnknownCoPro;#endif    return ret_code;}int angelOS_RequestCoProDesc(byte cpno, struct CP_CoProDesc *cpd){    int ret_code;    LogInfo(LOG_DEBUGOS, ( "angelOS_RequestCoProDesc\n"));#if defined(SYSTEM_COPROCESSOR_SUPPORTED) && SYSTEM_COPROCESSOR_SUPPORTED > 0    if (cpno == 15)    {        int i;        ret_code = RDIError_NoError;        /* cpd->entries is set to space available before call to this fn. */        if (sys_coproc_reg_entries > cpd->entries)            ret_code = RDIError_BufferFull;        else            cpd->entries = sys_coproc_reg_entries;        for (i = 0; i < cpd->entries; ++i)            cpd->regdesc[i] = sys_coproc_regdesc[i];    }    else        ret_code = RDIError_UnknownCoPro;#else    IGNORE(cpno);    IGNORE(cpd);    ret_code = RDIError_UnknownCoPro;#endif    return ret_code;}int angelOS_VectorCatch(word OSinfo1, word OSinfo2, word VectorCatch){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    /* TODO: Do something with VectorCatch? */    IGNORE(VectorCatch);    return RDIError_NoError;}int angelOS_SemiHosting_SetState(word OSinfo1, word OSinfo2,                             word SemiHosting_State){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    angelOS_SemiHostingEnabled = SemiHosting_State;    return RDIError_NoError;}int angelOS_SemiHosting_GetState(word OSinfo1, word OSinfo2,                             word * SemiHosting_State){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    *SemiHosting_State = angelOS_SemiHostingEnabled;    return RDIError_NoError;}int angelOS_SemiHosting_SetVector(word OSinfo1, word OSinfo2,                              word SemiHosting_Vector){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    LogWarning(LOG_DEBUGOS, ( "WARNING: SemiHosting_SetVector not implemented!\n"));    IGNORE(SemiHosting_Vector);    return RDIError_UnimplementedMessage;}int angelOS_SemiHosting_GetVector(word OSinfo1, word OSinfo2,                              word * SemiHosting_Vector){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    LogInfo(LOG_DEBUGOS, ( "SemiHosting Vector always 8\n"));    *SemiHosting_Vector = 8;    return RDIError_NoError;}int angelOS_Ctrl_Log(word OSinfo1, word OSinfo2, word * LogSetting){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    /* Mask out logsetting from debug_Status  and shift into correct posn. */    *LogSetting = (debug_Status & 0x6) >> 1;    return RDIError_NoError;}int angelOS_Ctrl_SetLog(word OSinfo1, word OSinfo2, word LogSetting){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    debug_Status &= 0xFFF9;     /* Remove previous setting. */    debug_Status |= (LogSetting << 1);  /* Set the new one. */    return RDIError_NoError;}int angelOS_CanChangeSHSWI(void){    /* Has to be done at compile-time for Angel */    return RDIError_Error;}static word loadagent_address = (word) - 1;static word loadagent_size;static word loadagent_sofar;int angelOS_LoadConfigData(word OSinfo1, word OSinfo2,                       word nbytes, byte const *data){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    if (loadagent_address == (word) - 1)        return RDIError_NotInDownload;    if (nbytes + loadagent_sofar > loadagent_size)        return RDIError_BadConfigData;    __rt_memcpy((byte *) loadagent_address + loadagent_sofar, data, nbytes);    loadagent_sofar += nbytes;    return RDIError_NoError;}void angelOS_ExecuteNewAgent(word start_address){    void (*exe) (void) = NULL;    ansibodge a;    IGNORE(start_address);    a.w = loadagent_address;    exe = a.vfn;    LogInfo(LOG_DEBUGOS, ( "angelOS_ExecuteNewAgent: jumping to %08x\n", exe));    Angel_EnterSVC();    exe();}int angelOS_LoadAgent(word OSinfo1, word OSinfo2, word loadaddress,                  word nbytes){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    LogInfo(LOG_DEBUGOS, ( "angelOS_LoadAgent: to %08x size %d.\n", loadaddress, nbytes));    /* Do some checking and possible transformations on loadaddress */    /* FOR NOW just force it to constant set in devconf.h */    IGNORE(loadaddress);    loadagent_address = Angel_DownloadAgentArea;    loadagent_size = nbytes;    loadagent_sofar = 0;    return RDIError_NoError;}/* EOF debugos.c */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -