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

📄 debugos.c

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 C
📖 第 1 页 / 共 3 页
字号:
        }    }    ReturnValue->pointHandle = (word) b;    LogInfo(LOG_DEBUGOS, ("handle = %x head_bp = %x free_bps = %x.\n",              ReturnValue->pointHandle, (word) head_bp, (word) free_bps));    return RDIError_NoError;}int angelOS_ClearBreak(word OSinfo1, word OSinfo2, word Handle){    struct BreakPoint *b, *p, **pp;    word status, n;    LogInfo(LOG_DEBUGOS, ( "angelOS_ClearBreak: Handle = %x.\n", Handle));    b = (struct BreakPoint *)Handle;    if (b == NULL)        return RDIError_NoSuchPoint;    for (pp = &head_bp; (p = *pp) != b; pp = &p->next)    {        LogInfo(LOG_DEBUGOS, ( "Current bp address = %x.\n", (word) p));        if (p == NULL)            return RDIError_NoSuchPoint;    }    if (--b->count != 0)        return RDIError_NoError;    *pp = b->next;    LogInfo(LOG_DEBUGOS, ( "Freeing breakpoint %d.\n", b->bpno));    free_bps |= (1 << b->bpno);    status = angelOS_MemWrite(OSinfo1, OSinfo2, b->address,                              b->size == bs_32bit ? 4 : 2,                              (byte *) (&(b->inst)), &n);    if (status != RDIError_NoError)    {        LogWarning(LOG_DEBUGOS, ( "Memwrite error in CB.\n"));        return status;    }    LogInfo(LOG_DEBUGOS, ( "Leaving angelOS_ClearBreak function.\n"));    return RDIError_NoError;}int angelOS_SetWatch(word OSinfo1, word OSinfo2,                 struct SetPointValue *SetData,                 struct PointValueReturn *ReturnValue){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    IGNORE(ReturnValue);    IGNORE(SetData);    return RDIError_UnimplementedMessage;}int angelOS_ClearWatch(word OSinfo1, word OSinfo2, word Handle){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    IGNORE(Handle);    return RDIError_UnimplementedMessage;}int angelOS_BreakPointStatus(word OSinfo1, word OSinfo2, word Handle,                         word * Hw, word * Type){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    IGNORE(Handle);    IGNORE(Hw);    IGNORE(Type);    return RDIError_UnimplementedMessage;}int angelOS_WatchPointStatus(word OSinfo1, word OSinfo2, word Handle,                         word * Hw, word * Type){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    IGNORE(Handle);    IGNORE(Hw);    IGNORE(Type);    return RDIError_UnimplementedMessage;}int angelOS_SetupStep(word OSinfo1, word OSinfo2, word StepCount,                  void **handle){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    IGNORE(StepCount);    IGNORE(handle);    return RDIError_UnimplementedMessage;}int angelOS_DoStep(void *handle){    IGNORE(handle);    return RDIError_UnimplementedMessage;}int angelOS_Execute(word OSinfo1, word OSinfo2){    IGNORE(OSinfo1);    IGNORE(OSinfo2);    LogInfo(LOG_DEBUGOS, ( "angelOS_Execute\n"));    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;}int angelOS_InitialiseApplication(word OSinfo1, word OSinfo2){    /*     * Set up the stack pointer and stack limit.     * Note that doing this isn`t relied on as the C Library will     * initialise this and the heap using the HeapInfo SWI or     * user provided __heap* and __stack* symbols.     */    word data[3];    LogInfo(LOG_DEBUGOS, ( "angelOS_InitialiseApplication\n"));    Angel_FlushApplicationCallbacks();    /*     * 960603 KWelton     *     * We are mimicking an ADP packet here, so the data should be     * stored little-endian, regardless of the target's natural     * byte sex     */    PWRITE32(LE, data, ((unsigned)angel_heapstackdesc.stacklimit));    PWRITE32(LE, data + 1, 0);    PWRITE32(LE, data + 2, ((unsigned)angel_heapstackdesc.stacktop));    return angelOS_CPUWrite(OSinfo1, OSinfo2, ADP_CPUmode_Current,                    (1 << reg_sl | 1 << reg_fp | 1 << reg_sp), (byte *) data);}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 Dbg_CoProDesc *cpd){    int ret_code = RDIError_Error;    LogInfo(LOG_DEBUGOS, ( "angelOS_DescribeCoPro\n"));#ifdef SUPPORT_SYSTEM_COPROCESSOR    /*     * 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 Dbg_CoProDesc *cpd){    int ret_code;    LogInfo(LOG_DEBUGOS, ( "angelOS_RequestCoProDesc\n"));#ifdef SUPPORT_SYSTEM_COPROCESSOR    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 + -