VS code 阅读内核代码

在这里插入图片描述

注:以下均基于 全志 芯片修改,其他芯片对应修改即可。

一、添加头文件路径

(1)ctrl+shift+P:输入 edit,然后选择以下文件编辑
c_cpp_properties.json

(2)打开 c_cpp_properties.json ,修改如下(根据需求添加头文件路径):

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/include", 
                "${workspaceFolder}/include/linux", 
                "${workspaceFolder}/arch/arm/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

二、隐藏多余的文件

(1)ctrl+shift+P:输入 work,然后选择以下文件编辑
settings.json

(2)打开settings.json,修改如下:

{
    "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.o":true,
        "**/*.su":true, 
        "**/*.cmd":true,
        "Documentation":true, 
 
        /* 屏蔽不用的架构相关的文件 */
        "arch/alpha":true,
        "arch/arc":true,
        "arch/arm64":true,
        "arch/avr32":true,
        "arch/[b-z]*":true,
        "arch/arm/plat*":true,   
        "arch/arm/mach-[a-r]*":true,   
        "arch/arm/mach-[t-z]*":true,  
        "arch/arm/mach-s3*":true, 
        "arch/arm/mach-s5*":true, 
        "arch/arm/mach-sa*":true, 
        "arch/arm/mach-sd*":true,
        "arch/arm/mach-sh*":true,
        "arch/arm/mach-si*":true,
        "arch/arm/mach-so*":true, 
        "arch/arm/mach-sp*":true, 
        "arch/arm/mach-st*":true, 

        /* 屏蔽排除不用的配置文件 */
        "arch/arm/configs/[a-r]*":true, 
        "arch/arm/configs/[t-z]*":true, 
        "arch/arm/configs/s3*":true, 
        "arch/arm/configs/s5*":true, 
        "arch/arm/configs/sa*":true, 
        "arch/arm/configs/sd*":true,
        "arch/arm/configs/sh*":true,
        "arch/arm/configs/si*":true,
        "arch/arm/configs/so*":true, 
        "arch/arm/configs/sp*":true, 
        "arch/arm/configs/st*":true, 
 
        /* 屏蔽掉不用的DTB文件 */
        "arch/arm/boot/dts/[a-r]*":true, 
        "arch/arm/boot/dts/[t-z]*":true, 
        "arch/arm/boot/dts/s3*":true, 
        "arch/arm/boot/dts/s5*":true, 
        "arch/arm/boot/dts/sa*":true, 
        "arch/arm/boot/dts/sd*":true,
        "arch/arm/boot/dts/sh*":true,
        "arch/arm/boot/dts/si*":true,
        "arch/arm/boot/dts/so*":true, 
        "arch/arm/boot/dts/sp*":true, 
        "arch/arm/boot/dts/st*":true, 
        "arch/arm/boot/dts/*.tmp":true,
    },
    "files.exclude": {
        "**/.git*": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,  
        "**/*.o":true,
        "**/*.su":true, 
        "**/*.cmd":true,
        "Documentation":true, 
 
        /* 屏蔽不用的架构相关的文件 */
        "arch/alpha":true,
        "arch/arc":true,
        "arch/arm64":true,
        "arch/avr32":true,
        "arch/[b-z]*":true,
        "arch/arm/plat*":true,   
        "arch/arm/mach-[a-r]*":true,   
        "arch/arm/mach-[t-z]*":true,
        "arch/arm/mach-s3*":true, 
        "arch/arm/mach-s5*":true, 
        "arch/arm/mach-sa*":true, 
        "arch/arm/mach-sd*":true,
        "arch/arm/mach-sh*":true,
        "arch/arm/mach-si*":true,
        "arch/arm/mach-so*":true, 
        "arch/arm/mach-sp*":true, 
        "arch/arm/mach-st*":true, 
        
        /* 屏蔽排除不用的配置文件 */
        "arch/arm/configs/[a-r]*":true, 
        "arch/arm/configs/[t-z]*":true, 
        "arch/arm/configs/s3*":true, 
        "arch/arm/configs/s5*":true, 
        "arch/arm/configs/sa*":true, 
        "arch/arm/configs/sd*":true,
        "arch/arm/configs/sh*":true,
        "arch/arm/configs/si*":true,
        "arch/arm/configs/so*":true, 
        "arch/arm/configs/sp*":true, 
        "arch/arm/configs/st*":true, 

        /* 屏蔽掉不用的DTB文件 */
        "arch/arm/boot/dts/[a-r]*":true, 
        "arch/arm/boot/dts/[t-z]*":true, 
        "arch/arm/boot/dts/s3*":true, 
        "arch/arm/boot/dts/s5*":true, 
        "arch/arm/boot/dts/sa*":true, 
        "arch/arm/boot/dts/sd*":true,
        "arch/arm/boot/dts/sh*":true,
        "arch/arm/boot/dts/si*":true,
        "arch/arm/boot/dts/so*":true, 
        "arch/arm/boot/dts/sp*":true, 
        "arch/arm/boot/dts/st*":true, 
        "arch/arm/boot/dts/sun4*":true, 
        "arch/arm/boot/dts/sun5*":true, 
        "arch/arm/boot/dts/sun6*":true, 
        "arch/arm/boot/dts/sun7*":true, 
        "arch/arm/boot/dts/sun8i-a*":true, 
        "arch/arm/boot/dts/sun8i-v3*":true, 
        "arch/arm/boot/dts/sun8i-v4*":true, 
        "arch/arm/boot/dts/sun8i-h2*":true, 
        "arch/arm/boot/dts/suniv*":true, 
        "arch/arm/boot/dts/sunxi-ban*":true, 
        "arch/arm/boot/dts/sun8i-q*":true, 
        "arch/arm/boot/dts/sun8i-r*":true, 
        "arch/arm/boot/dts/sun8i-s*":true, 
        "arch/arm/boot/dts/sun8i-t*":true, 
        "arch/arm/boot/dts/sun9*":true, 
        "arch/arm/boot/dts/*.orig":true, 
        "arch/arm/boot/dts/*.dtb":true, 
        "arch/arm/boot/dts/*.tmp":true, 
    }
}

参考:VScode 内核源码阅读与修改设置

posted @ 2021-03-13 14:02  红豆の布丁  阅读(200)  评论(0编辑  收藏  举报