ChorusOS 4.0 Porting Guide

dbg_start()

The dbg_start() function starts the debug agent driver and the debug agent. Example 3-7 is dbg_start() source code provided in kernel/snippet/nucleus/boot_tools/dbg_start.c.


Example 3-7 dbg_start()

    void
dbg_start(void* cookie)
{
    int i;

    /*
     * Launch debuging console driver
     */
    for (i = 0; i < bootConf->numBins; ++i) {
        BinDesc* bin = &bootConf->binDesc[i];
        if (bin->type == BIN_DBG_DRIVER) {
            (* (DbgDriverEntry) bin->entry)(bootConf, cookie);
        }
    }

    /*
     * Launch debuging agent
     */
    for (i = 0; i < bootConf->numBins; ++i) {
        BinDesc* bin = &bootConf->binDesc[i];
        if (bin->type == BIN_DBG_AGENT) {
            (* (DbgAgentEntry) bin->entry)(bootConf);
        }
    }

    _stdc_consInit(bootConf->dbgOps.consRead,
                   bootConf->dbgOps.consWrite);
}

dbg_start() retrieves the descriptor pointing to the debug agent driver binary from the bootConf structure. It then calls the debug agent driver's entry point, passing it the address of bootConf and the opaque value that came from the initial loader. Once the driver has been started, dbg_start() retrieves the descriptor pointing to the debug agent itself. It calls the debug agent entry point, passing it the address of bootConf.

dbg_start() assumes that the debug agent and its driver are already installed.

Finaly, dbg_start() makes console IO available for the bootstrap program by intializing its printf()/scanf() support library.