xorg初始化过程分析,xf86DriverlistFromConfig()函数分析

void
InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
{
   

......

        /* Load all driver modules specified in the config file */
        /* If there aren't any specified in the config file, autoconfig them */
        /* FIXME: Does not handle multiple active screen sections, but I'm not
         * sure if we really want to handle that case*/
        configured_device = xf86ConfigLayout.screens->screen->device;
        if ((!configured_device) || (!configured_device->driver)) {
            if (!autoConfigDevice(configured_device)) {
                xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
                return;
            }
        }
        if ((modulelist = xf86DriverlistFromConfig())) {
            xf86LoadModules(modulelist, NULL);
            free(modulelist);

        }

书接上回,上次分析的是autoConfigDevice()函数,

这次继续分析,xf86DriverlistFromConfig()函数,

运行完会产生modulelist指针数组,然后会加载所需的模块,

到这来思路基本上很清晰了。

当然也解决了一个笔者的阅读xserver的最大的问题

没有相关的配置文件,xserver是如何得到一个默认的配置的。

确实比原来的xfree86要先进了。



char **

xf86DriverlistFromConfig(void)
{
    int count = 0;
    int j;
    char **modulearray;
    screenLayoutPtr slp;

    /*
     * make sure the config file has been parsed and that we have a
     * ModulePath set; if no ModulePath was given, use the default
     * ModulePath
     */
    if (xf86configptr == NULL) {
        xf86Msg(X_ERROR, "Cannot access global config data structure\n");
        return NULL;
    }

    /*
     * Walk the list of driver lines in active "Device" sections to
     * determine now many implicitly loaded modules there are.
     *
     */
    if (xf86ConfigLayout.screens) {
        slp = xf86ConfigLayout.screens;
        while ((slp++)->screen) {
            count++;
        }
    }

    /*
     * Handle the set of inactive "Device" sections.
     */
    j = 0;
    while (xf86ConfigLayout.inactives[j++].identifier)
        count++;

    if (count == 0)
        return NULL;

    /*
     * allocate the memory and walk the list again to fill in the pointers
     */
    modulearray = xnfalloc((count + 1) * sizeof(char *));
    count = 0;
    slp = xf86ConfigLayout.screens;
    while (slp->screen) {
        modulearray[count] = slp->screen->device->driver;
        count++;
        slp++;
    }

    j = 0;

    while (xf86ConfigLayout.inactives[j].identifier)
        modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;

    modulearray[count] = NULL;

    /* Remove duplicates */
    for (count = 0; modulearray[count] != NULL; count++) {
        int i;

        for (i = 0; i < count; i++)
            if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
                modulearray[count] = "";
                break;
            }
    }
    return modulearray;

}





引用一下别人的几句话,关键的部分说的不多。
为什么我看懂了代码,也写了相关的 文章,然后才发现了相关的文章?每次都是这样?

InitOutput()是初始化分量较中的一环,处理过程可以分为如下部分:
1)xf86HandleConfigFile 解析xorg.con文件 ,获得xserver的配置信息。
2)xf86BusProbe 获得video的pci信息,例如framebuffer地址等。
3)DoConfigure() 根据配置文件 ,或者传进来的参数做相应的配置
4)xf86LoadModules load xorg.conf中配置的一系列模块
5)以此遍历注册的各个driver,调用其identify,probe函数,这样就根据显卡的型号加载了相应的驱动
6)匹配screen,主要是根据xorg.conf中配置的screen,查询是否有与其匹配的device
7)遍历screen,调用其匹配device驱动的PreInit函数。这样就完成了显卡驱动的预初始化
8)遍历screen,调用AddScreen函数,分配screenInfo.screen[]的一项,并做初始化ScreenInit.这样驱动的初始化基本完成。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值