• Linux/CRC校验

    2012-12-24 11:22:38
    CRC即循环冗余校验码(Cyclic Redundancy Check):是数据通信领域中最常用的一种差错校验码,其特征是信息字段和校验字段的长度可以任意选定。 CRC校验实用程序库在数据存储和数据通讯领域,为了保证数据的正确...

    简介

    CRC即循环冗余校验码(Cyclic Redundancy Check):是数据通信领域中最常用的一种差错校验码,其特征是信息字段和校验字段的长度可以任意选定。

    CRC校验实用程序库在数据存储和数据通讯领域,为了保证数据的正确,就不得不采用检错的手段。

    以下是CRC32的C语言实现,经过测试,能够正确运行:


    原理

    crc校验原理
    利用CRC进行检错的过程可简单描述为:在发送端根据要传送的k位二进制码序列,以一定的规则产生一个校验用的r位监督码(CRC码),附在原始信息后边,构成一个新的二进制码序列数共k+r位,然后发送出去。在接收端,根据信息码和CRC码之间所遵循的规则进行检验,以确定传送中是否出错。这个规则,在差错控制理论中称为“生成多项式”。


    测试代码由gzshun贡献

    #include <stdio.h>   
    #include <stdlib.h>   
    #include <string.h>   
    #include <errno.h>   
    #include <unistd.h>   
    #include <fcntl.h>   
    #include <sys/stat.h>   
      
    #define BUFSIZE     1024*4   
      
    static unsigned int crc_table[256];  
    const static char * program_name = "crc32";  
      
    static void usage(void);  
    static void init_crc_table(void);  
    static unsigned int crc32(unsigned int crc, unsigned char * buffer, unsigned int size);  
    static int calc_img_crc(const char * in_file, unsigned int * img_crc);  
      
    static void usage(void)  
    {  
        fprintf(stderr, "Usage: %s input_file\n", program_name);  
    }  
      
    /* 
    **初始化crc表,生成32位大小的crc表 
    **也可以直接定义出crc表,直接查表, 
    **但总共有256个,看着眼花,用生成的比较方便. 
    */  
    static void init_crc_table(void)  
    {  
        unsigned int c;  
        unsigned int i, j;  
          
        for (i = 0; i < 256; i++) {  
            c = (unsigned int)i;  
            for (j = 0; j < 8; j++) {  
                if (c & 1)  
                    c = 0xedb88320L ^ (c >> 1);  
                else  
                    c = c >> 1;  
            }  
            crc_table[i] = c;  
        }  
    }  
      
    /*计算buffer的crc校验码*/  
    static unsigned int crc32(unsigned int crc,unsigned char *buffer, unsigned int size)  
    {  
        unsigned int i;  
        for (i = 0; i < size; i++) {  
            crc = crc_table[(crc ^ buffer[i]) & 0xff] ^ (crc >> 8);  
        }  
        return crc ;  
    }  
      
    /* 
    **计算大文件的CRC校验码:crc32函数,是对一个buffer进行处理, 
    **但如果一个文件相对较大,显然不能直接读取到内存当中 
    **所以只能将文件分段读取出来进行crc校验, 
    **然后循环将上一次的crc校验码再传递给新的buffer校验函数, 
    **到最后,生成的crc校验码就是该文件的crc校验码.(经过测试) 
    */  
    static int calc_img_crc(const char *in_file, unsigned int *img_crc)  
    {  
        int fd;  
        int nread;  
        int ret;  
        unsigned char buf[BUFSIZE];  
        /*第一次传入的值需要固定,如果发送端使用该值计算crc校验码, 
        **那么接收端也同样需要使用该值进行计算*/  
        unsigned int crc = 0xffffffff;   
      
        fd = open(in_file, O_RDONLY);  
        if (fd < 0) {  
            printf("%d:open %s.\n", __LINE__, strerror(errno));  
            return -1;  
        }  
              
        while ((nread = read(fd, buf, BUFSIZE)) > 0) {  
            crc = crc32(crc, buf, nread);  
        }  
        *img_crc = crc;  
      
        close(fd);  
          
        if (nread < 0) {  
            printf("%d:read %s.\n", __LINE__, strerror(errno));  
            return -1;  
        }  
          
        return 0;  
    }  
      
    int main(int argc, char **argv)  
    {  
        int ret;  
        unsigned int img_crc;  
        const char *in_file = argv[1];  
      
        if (argc < 2) {  
            usage();  
            exit(1);  
        }  
      
        init_crc_table();  
          
        ret = calc_img_crc(in_file, &img_crc);  
        if (ret < 0) {  
            exit(1);  
        }  
      
        printf("The crc of %s is:%u\n", in_file, img_crc);  
      
        return 0;  
    }  








    展开全文
  • linuxCRC校验

    2017-06-12 15:28:25
    一.CRC的定义CRC即循环冗余校验码(Cyclic Redundancy Check[1] ):是数据通信领域中最常用的一种查错校验码,其特征是信息字段和校验字段的长度可以任意选定。循环冗余检查(CRC)是一种数据传输检错功能,对数据...

    一.CRC的定义

    CRC即循环冗余校验码(Cyclic Redundancy Check[1] ):是数据通信领域中最常用的一种查错校验码,其特征是信息字段和校验字段的长度可以任意选定。循环冗余检查(CRC)是一种数据传输检错功能,对数据进行多项式计算,并将得到的结果附在帧的后面,接收设备也执行类似的算法,以保证数据传输的正确性和完整性。


    二.工作原理

    循环冗余校验码(CRC)的基本原理是:在K位信息码后再拼接R位的校验码,整个编码长度为N位,因此,这种编码也叫(N,K)码。对于一个给定的(N,K)码,可以证明存在一个最高次幂为N-K=R的多项式G(x)。根据G(x)可以生成K位信息的校验码,而G(x)叫做这个CRC码的生成多项式。 校验码的具体生成过程为:假设要发送的信息用多项式C(X)表示,将C(x)左移R位(可表示成C(x)*2R),这样C(x)的右边就会空出R位,这就是校验码的位置。用 C(x)*2R 除以生成多项式G(x)得到的余数就是校验码。
    任意一个由二进制位串组成的代码都可以和一个系数仅为‘0’和‘1’取值的多项式一一对应。例如:代码1010111对应的多项式为x6+x4+x2+x+1,而多项式为x5+x3+x2+x+1对应的代码101111。


    三 .基本概念

    • 对应关系
      多项式和二进制数有直接对应关系:X的最高幂次对应二进制数的最高位,以下各位对应多项式的各幂次,有此幂次项对应1,无此幂次项对应0。可以看出:X的最高幂次为R,转换成对应的二进制数有R+1位。
      多项式包括生成多项式G(X)和信息多项式C(X)。
      如生成多项式为G(X)=X4+X3+X+1, 可转换为二进制数码11011。
      而发送信息位 101111,可转换为数据多项式为C(X)=X5+X3+X2+X+1。
    • 生成多项式
      是接受方和发送方的一个约定,也就是一个二进制数,在整个传输过程中,这个数始终保持不变。
      在发送方,利用生成多项式对信息多项式做模2除生成校验码。在接收方利用生成多项式对收到的编码多项式做模2除检测和确定错误位置。
      应满足以下条件:
      A、生成多项式的最高位和最低位必须为1。
      B、当被传送信息(CRC码)任何一位发生错误时,被生成多项式做除后应该使余数不为0。
      C、不同位发生错误时,应该使余数不同。
      D、对余数继续做除,应使余数循环。
    • 校验码位数
      CRC校验码位数 = 生成多项式位数 - 1。注意有些生成多项式的简记式中将生成多项式的最高位1省略了。
    • 生成步骤
      1、将X的最高次幂为R的生成多项式G(X)转换成对应的R+1位二进制数。
      2、将信息码左移R位,相当于对应的信息多项式C(X)*2R。
      3、用生成多项式(二进制数)对信息码做除,得到R位的余数(注意:这里的二进制做除法得到的余数其实是模2除法得到的余数,并不等于其对应十进制数做除法得到的余数。)。
      4、将余数拼到信息码左移后空出的位置,得到完整的CRC码。

    【例】假设使用的生成多项式是G(X)=X3+X+1。4位的原始报文为1010,求编码后的报文。
    解:
    1、将生成多项式G(X)=X3+X+1转换成对应的二进制除数1011。
    2、此题生成多项式有4位(R+1)(注意:4位的生成多项式计算所得的校验码为3位,R为校验码位数),要把原始报文C(X)左移3(R)位变成1010 000
    3、用生成多项式对应的二进制数对左移3位后的原始报文进行模2除(高位对齐),相当于按位异或:
    1010000
    1011
    ——————
    0001000
    0001011
    ——————
    0000011
    得到的余位011,所以最终编码为:1010 011


    若设码字长度为N,信息字段为K位,校验字段为R位(N=K+R),则对于CRC码集中的任一码字,存在且仅存在一个R次多项式g(x),使得
    V(x)=A(x)g(x)=xRm(x)+r(x);
    其中: m(x)为K次原始的信息多项式, r(x)为R-1次校验多项式(即CRC校验和),
    g(x)称为生成多项式:
    g(x)=g0+g1x1+ g2x2+…+g(R-1)x(R-1)+gRxR
    发送方通过指定的g(x)产生CRC码字,接收方则通过该g(x)来验证收到的CRC码字。


    四.生成方式

    借助于模2除法则,其余数为校验字段。

    例如:信息字段代码为: 1011001;对应m(x)=x6+x4+x3+1
    假设生成多项式为:g(x)=x4+x3+1;则对应g(x)的代码为: 11001
    x4m(x)=x10+x8+x7+x4 对应的代码记为:10110010000;
    采用模2除法则: 得余数为: 1010(即校验字段为:1010)
    发送方:发出的传输字段为: 1 0 1 1 0 0 1 1010
    信息字段 校验字段
    接收方:使用相同的生成码进行校验:接收到的字段/生成码(二进制除法)
    如果能够除尽,则正确,
    给出余数(1010)的计算步骤:
    除法没有数学上的含义,而是采用计算机的模二除法,即除数和被除数做异或运算。进行异或运算时除数和被除数最高位对齐,按位异或。
    10110010000
    ^11001
    ——————
    01111010000


    1111010000
    ^11001

    ——————
    0011110000


    11110000
    ^11001

    ——————
    00111000


    111000
    ^11001

    ——————
    001010

    则四位CRC校验码就为:1010。
    利用CRC进行检错的过程可简单描述为:在发送端根据要传送的k位二进制码序列,以一定的规则产生一个校验用的r位监督码(CRC码),附在原始信息后边,构成一个新的二进制码序列数共k+r位,然后发送出去。在接收端,根据信息码和CRC码之间所遵循的规则进行检验,以确定传送中是否出错。这个规则,在差错控制理论中称为“生成多项式”。

    展开全文
  • crc32进行了介绍,对于zlib解压缩库中的crc32的实现给出简单讲解。通过代码示例,给出了在zlib中解压缩数据和crc32结合使用。

    最近项目里为了减少传输数据量,需要进行数据的压缩和解压。网上搜索和之前项目中看到是使用到了zlib一个比较小巧的库,具体的地址请查看官网。如果仅仅是数据的解压缩,那直接跟从官网的教程就好。该地址简单的给出了压缩和解压的实现。但是想做我们的项目是有一些历史的原因还引用了crc32的校验,所以在解压和压缩之前都需要对数据进行crc生成和校验。经过了的一段时间摸索,最终流程也终于走通了。

    crc32

    crc32介绍

    crc32校验

    对于crc校验,一般有两种方式。

    • 单独对crc校验码进行校验。在这种方式中,原始数据和crc校验码是分开存储,分开进行校验的;
    • 对原始数据crc校验码一起进行校验,进行校验的时候是不知道哪一部分是数据,哪一部分是crc校验码的。采用这种方法比较方便在使用起来,下面代码示例也是采用的这一种方式。

    zlib

    压缩算法介绍

    常用的压缩算法基本上是两种,这个在zlib库里也有介绍。
    - huffman编码,它主要是采用变长的字符进行压缩编码。出现的概率越高,其编码越短,最终编码长度相应的就越短。
    - lz777,这个大家自行搜索吧,主要是通过一个距离标识来说明下一个字符的位置。

    zlib与crc32使用

    该测试代码主要是包括压缩、解压两个函数。在测试代码中对压缩的数据生成crc校验码,并把校验码追加到压缩数据的末尾,成为最终的压缩的数据。解压函数就对最终的压缩数据(原始压缩数据与crc校验码)进行解压操作。

    解压函数

    int DeCompress(const unsigned char * src, long src_len, unsigned char * dest, long * dest_len)
    {
        z_stream stream;
        int err;
        if (crc32(0, src, src_len) != 0xFFFFFFFF)
        {   
            printf("crc error: %d\n", Z_BUF_ERROR);
            return Z_BUF_ERROR;
        }   
    
        stream.next_in = (Bytef*)src;
        stream.avail_in = (uInt)src_len;
        /* Check for src > 64K on 16-bit machine: */
        if ((uLong)stream.avail_in != src_len) return Z_BUF_ERROR;
    
        stream.next_out = dest;
        stream.avail_out = (uInt)*dest_len;
        if ((uLong)stream.avail_out != *dest_len) return Z_BUF_ERROR;
    
        stream.zalloc = (alloc_func)0;
        stream.zfree = (free_func)0;
    
        err = inflateInit2(&stream, -MAX_WBITS); 
        //err = inflateInit(&stream);
        if (err != Z_OK) return err;
    
        err = inflate(&stream, Z_FINISH);
        if (err != Z_STREAM_END) 
        {   
            inflateEnd(&stream);
            if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 
                return Z_DATA_ERROR;
            return err;
        }   
        *dest_len = stream.total_out;
    
        err = inflateEnd(&stream);
        return err;
    }

    压缩函数

    int Compress(const unsigned char * src, long src_len, unsigned char * dest, long * dest_len)
    {
        z_stream stream;
        int err = 0;
    
        stream.zalloc = (alloc_func)0;
        stream.zfree = (free_func)0;
        // setup "a" as the input and "b" as the compressed output
        stream.avail_in = (uInt)src_len; // size of input, string + terminator
        stream.next_in = (Bytef *) src; // input char array
        stream.avail_out = (uInt) *dest_len; // size of output
        stream.next_out = (Bytef *)dest; // output char array
    
    
        deflateInit2(&stream, Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY );
        deflate(&stream, Z_FINISH); // the actual compression work.
        deflateEnd(&stream);
    
        // This is one way of getting the size of the output
        *dest_len = stream.total_out;
        return err;
    }

    测试代码

    int main()
    {
        unsigned char a[] = "123123123123123123123";
        unsigned char b[124];
    
        size_t size = sizeof(b);
        Compress(a, sizeof(a), b, (long int  *)(&size));
        printf("a: %s, compress size: %lu\n", a, size);
    
    
        uLong crc = crc32(0L, Z_NULL, 0); 
        printf("crc: %lu, char: %u\n", crc, b[size + 1]);
        crc = ~crc32(crc, b, size);
        b[8] = (crc & 0xFF);
        b[9] = ((crc >> 8) & 0xFF);
        b[10] = ((crc >> 16) & 0xFF);
        b[11] = ((crc >> 24) & 0xFF);
        b[12] = 0;
        size = size + 4;
    
        unsigned char c[124];
        long int s = 124;
    
        DeCompress(b, size, c, (long int  *)(&s));
        printf("a: %s, c: %s\n", a, c); 
        return 1;
    }

    稍微提一下,在这种当中遇到的问题:
    1、crc检查失败,直接返回失败了。
    这个当时脑残的是对解压之前的数据做了crc校验码,然后追加到数据末尾。但是解压的时候是对压缩后的数据做crc校验,所以肯定有问题。
    然后理清逻辑之后对压缩后的数据生成crc校验码,然后追加到压缩到数据的末尾。但是还是有问题,看到之前项目代码发现,他们对crc校验码做了取反,不知为何。后来加上取反,crc校验通过了。

    2、解压的时候,数据一直无法正常解压出来。
    这个地方是因为开始我是参考了官网上给定教程,压缩的时候是使用了deflateInit方法,调试了很久也没调试出来。后来发现,解压的时候方法是inflateInit2,那压缩的时候是不是也有deflateInit与deflateInit2方法的区别,查了文档发现果然是有deflateInit2的方法的。查看deflateInit2方法使用,调试,修改,程序通过,正确输出压缩之前的方法。
    所以这里需要注意的是对于压缩和解压有两套方法调用的,分别是inflateInit与deflateInit、inflateInit2与deflateInit2,每一套参数传递的参数不同,最后结果也不同。使用其中一个压缩方法压缩数据,那就必须使用另外与其一样的解压方法进行解压数据,否则数据就会错误。

    展开全文
  • linux kernel API 汇总

    2018-06-26 15:13:27
    Linux kernel API Data Types Doubly Linked Lists void list_add(struct list_head * new, struct list_head * head) void list_add_tail(struct list_head * new, struct list_head * head) void __list_de...

    Linux kernel API

    773 个 Linux 内核 API

    Data Types

    Doubly Linked Lists

    void list_add(struct list_head * new, struct list_head * head)
    void list_add_tail(struct list_head * new, struct list_head * head)
    void __list_del_entry(struct list_head * entry)
    void list_replace(struct list_head * old, struct list_head * new)
    void list_del_init(struct list_head * entry)
    void list_move(struct list_head * list, struct list_head * head)
    void list_move_tail(struct list_head * list, struct list_head * head)
    int list_is_last(const struct list_head * list, const struct list_head * head)
    int list_empty(const struct list_head * head)
    int list_empty_careful(const struct list_head * head)
    void list_rotate_left(struct list_head * head)
    int list_is_singular(const struct list_head * head)
    void list_cut_position(struct list_head * list, struct list_head * head, struct list_head * entry)
    void list_splice(const struct list_head * list, struct list_head * head)
    void list_splice_tail(struct list_head * list, struct list_head * head)
    void list_splice_init(struct list_head * list, struct list_head * head)
    void list_splice_tail_init(struct list_head * list, struct list_head * head)
    list_entry(ptr, type, member)
    list_first_entry(ptr, type, member)
    list_last_entry(ptr, type, member)
    list_first_entry_or_null(ptr, type, member)
    list_next_entry(pos, member)
    list_prev_entry(pos, member)
    list_for_each(pos, head)
    list_for_each_prev(pos, head)
    list_for_each_safe(pos, n, head)
    list_for_each_prev_safe(pos, n, head)
    list_for_each_entry(pos, head, member)
    list_for_each_entry_reverse(pos, head, member)
    list_prepare_entry(pos, head, member)
    list_for_each_entry_continue(pos, head, member)
    list_for_each_entry_continue_reverse(pos, head, member)
    list_for_each_entry_from(pos, head, member)
    list_for_each_entry_safe(pos, n, head, member)
    list_for_each_entry_safe_continue(pos, n, head, member)
    list_for_each_entry_safe_from(pos, n, head, member)
    list_for_each_entry_safe_reverse(pos, n, head, member)
    list_safe_reset_next(pos, n, member)
    hlist_for_each_entry(pos, head, member)
    hlist_for_each_entry_continue(pos, member)
    hlist_for_each_entry_from(pos, member)
    hlist_for_each_entry_safe(pos, n, head, member)

    Basic C Library Functions

    String Conversions

    unsigned long long simple_strtoull(const char * cp, char ** endp, unsigned int base)
    unsigned long simple_strtoul(const char * cp, char ** endp, unsigned int base)
    long simple_strtol(const char * cp, char ** endp, unsigned int base)
    long long simple_strtoll(const char * cp, char ** endp, unsigned int base)
    int vsnprintf(char * buf, size_t size, const char * fmt, va_list args)
    int vscnprintf(char * buf, size_t size, const char * fmt, va_list args)
    int snprintf(char * buf, size_t size, const char * fmt, …)
    int scnprintf(char * buf, size_t size, const char * fmt, …)
    int vsprintf(char * buf, const char * fmt, va_list args)
    int sprintf(char * buf, const char * fmt, …)
    int vbin_printf(u32 * bin_buf, size_t size, const char * fmt, va_list args)
    int bstr_printf(char * buf, size_t size, const char * fmt, const u32 * bin_buf)
    int bprintf(u32 * bin_buf, size_t size, const char * fmt, …)
    int vsscanf(const char * buf, const char * fmt, va_list args)
    int sscanf(const char * buf, const char * fmt, …)
    int kstrtol(const char * s, unsigned int base, long * res)
    int kstrtoul(const char * s, unsigned int base, unsigned long * res)
    int kstrtoull(const char * s, unsigned int base, unsigned long long * res)
    int kstrtoll(const char * s, unsigned int base, long long * res)
    int kstrtouint(const char * s, unsigned int base, unsigned int * res)
    int kstrtoint(const char * s, unsigned int base, int * res)
    int kstrtobool(const char * s, bool * res)

    String Manipulation

    int strncasecmp(const char * s1, const char * s2, size_t len)
    char * strcpy(char * dest, const char * src)
    char * strncpy(char * dest, const char * src, size_t count)
    size_t strlcpy(char * dest, const char * src, size_t size)
    ssize_t strscpy(char * dest, const char * src, size_t count)
    char * strcat(char * dest, const char * src)
    char * strncat(char * dest, const char * src, size_t count)
    size_t strlcat(char * dest, const char * src, size_t count)
    int strcmp(const char * cs, const char * ct)
    int strncmp(const char * cs, const char * ct, size_t count)
    char * strchr(const char * s, int c)
    char * strchrnul(const char * s, int c)
    char * strrchr(const char * s, int c)
    char * strnchr(const char * s, size_t count, int c)
    char * skip_spaces(const char * str)
    char * strim(char * s)
    size_t strlen(const char * s)
    size_t strnlen(const char * s, size_t count)
    size_t strspn(const char * s, const char * accept)
    size_t strcspn(const char * s, const char * reject)
    char * strpbrk(const char * cs, const char * ct)
    char * strsep(char * s, const char ct)
    bool sysfs_streq(const char * s1, const char * s2)
    int match_string(const char const array, size_t n, const char * string)
    void * memset(void * s, int c, size_t count)
    void memzero_explicit(void * s, size_t count)
    void * memcpy(void * dest, const void * src, size_t count)
    void * memmove(void * dest, const void * src, size_t count)
    __visible int memcmp(const void * cs, const void * ct, size_t count)
    void * memscan(void * addr, int c, size_t size)
    char * strstr(const char * s1, const char * s2)
    char * strnstr(const char * s1, const char * s2, size_t len)
    void * memchr(const void * s, int c, size_t n)
    void * memchr_inv(const void * start, int c, size_t bytes)
    char * strreplace(char * s, char old, char new)

    Bit Operations

    void set_bit(long nr, volatile unsigned long * addr)
    void __set_bit(long nr, volatile unsigned long * addr)
    void clear_bit(long nr, volatile unsigned long * addr)
    void __change_bit(long nr, volatile unsigned long * addr)
    void change_bit(long nr, volatile unsigned long * addr)
    int test_and_set_bit(long nr, volatile unsigned long * addr)
    int test_and_set_bit_lock(long nr, volatile unsigned long * addr)
    int __test_and_set_bit(long nr, volatile unsigned long * addr)
    int test_and_clear_bit(long nr, volatile unsigned long * addr)
    int __test_and_clear_bit(long nr, volatile unsigned long * addr)
    int test_and_change_bit(long nr, volatile unsigned long * addr)
    int test_bit(int nr, const volatile unsigned long * addr)
    unsigned long __ffs(unsigned long word)
    unsigned long ffz(unsigned long word)
    int ffs(int x)
    int fls(int x)
    int fls64(__u64 x)

    Basic Kernel Library Functions

    Bitmap Operations

    void __bitmap_shift_right(unsigned long * dst, const unsigned long * src, unsigned shift, unsigned nbits)
    void __bitmap_shift_left(unsigned long * dst, const unsigned long * src, unsigned int shift, unsigned int nbits)
    unsigned long bitmap_find_next_zero_area_off(unsigned long * map, unsigned long size, unsigned long start, unsigned int nr, unsigned long align_mask, unsigned long align_offset)
    int __bitmap_parse(const char * buf, unsigned int buflen, int is_user, unsigned long * maskp, int nmaskbits)
    int bitmap_parse_user(const char __user * ubuf, unsigned int ulen, unsigned long * maskp, int nmaskbits)
    int bitmap_print_to_pagebuf(bool list, char * buf, const unsigned long * maskp, int nmaskbits)
    int bitmap_parselist_user(const char __user * ubuf, unsigned int ulen, unsigned long * maskp, int nmaskbits)
    void bitmap_remap(unsigned long * dst, const unsigned long * src, const unsigned long * old, const unsigned long * new, unsigned int nbits)
    int bitmap_bitremap(int oldbit, const unsigned long * old, const unsigned long * new, int bits)
    void bitmap_onto(unsigned long * dst, const unsigned long * orig, const unsigned long * relmap, unsigned int bits)
    (*) For these marked lines, if we hadn’t first done bitmap_fold()
    into tmp, then the result would have been empty.
    void bitmap_fold(unsigned long * dst, const unsigned long * orig, unsigned int sz, unsigned int nbits)
    int bitmap_find_free_region(unsigned long * bitmap, unsigned int bits, int order)
    void bitmap_release_region(unsigned long * bitmap, unsigned int pos, int order)
    int bitmap_allocate_region(unsigned long * bitmap, unsigned int pos, int order)
    unsigned int bitmap_from_u32array(unsigned long * bitmap, unsigned int nbits, const u32 * buf, unsigned int nwords)
    unsigned int bitmap_to_u32array(u32 * buf, unsigned int nwords, const unsigned long * bitmap, unsigned int nbits)
    void bitmap_copy_le(unsigned long * dst, const unsigned long * src, unsigned int nbits)
    int __bitmap_parselist(const char * buf, unsigned int buflen, int is_user, unsigned long * maskp, int nmaskbits)
    int bitmap_pos_to_ord(const unsigned long * buf, unsigned int pos, unsigned int nbits)
    unsigned int bitmap_ord_to_pos(const unsigned long * buf, unsigned int ord, unsigned int nbits)

    Command-line Parsing

    int get_option(char * str, int pint)
    char * get_options(const char * str, int nints, int * ints)
    unsigned long long memparse(const char * ptr, char ** retptr)

    CRC Functions

    u8 crc7_be(u8 crc, const u8 * buffer, size_t len)
    u16 crc16(u16 crc, u8 const * buffer, size_t len)
    u16 crc_itu_t(u16 crc, const u8 * buffer, size_t len)
    u16 crc_ccitt(u16 crc, u8 const * buffer, size_t len)

    idr/ida Functions

    void idr_preload(gfp_t gfp_mask)
    int idr_alloc(struct idr * idr, void * ptr, int start, int end, gfp_t gfp_mask)
    int idr_alloc_cyclic(struct idr * idr, void * ptr, int start, int end, gfp_t gfp_mask)
    void idr_remove(struct idr * idp, int id)
    void idr_destroy(struct idr * idp)
    int idr_for_each(struct idr * idp, int (fn) (int id, void *p, void *data, void data)
    void * idr_get_next(struct idr * idp, int * nextidp)
    void * idr_replace(struct idr * idp, void * ptr, int id)
    void idr_init(struct idr * idp)
    int ida_pre_get(struct ida * ida, gfp_t gfp_mask)
    int ida_get_new_above(struct ida * ida, int starting_id, int * p_id)
    void ida_remove(struct ida * ida, int id)
    void ida_destroy(struct ida * ida)
    int ida_simple_get(struct ida * ida, unsigned int start, unsigned int end, gfp_t gfp_mask)
    void ida_simple_remove(struct ida * ida, unsigned int id)
    void ida_init(struct ida * ida)

    Memory Management in Linux

    The Slab Cache

    void * kmalloc(size_t size, gfp_t flags)
    void * kmalloc_array(size_t n, size_t size, gfp_t flags)
    void * kcalloc(size_t n, size_t size, gfp_t flags)
    void * kzalloc(size_t size, gfp_t flags)
    void * kzalloc_node(size_t size, gfp_t flags, int node)
    void * kmem_cache_alloc(struct kmem_cache * cachep, gfp_t flags)
    void * kmem_cache_alloc_node(struct kmem_cache * cachep, gfp_t flags, int nodeid)
    void kmem_cache_free(struct kmem_cache * cachep, void * objp)
    void kfree(const void * objp)
    size_t ksize(const void * objp)
    void kfree_const(const void * x)
    char * kstrdup(const char * s, gfp_t gfp)
    const char * kstrdup_const(const char * s, gfp_t gfp)
    char * kstrndup(const char * s, size_t max, gfp_t gfp)
    void * kmemdup(const void * src, size_t len, gfp_t gfp)
    void * memdup_user(const void __user * src, size_t len)
    void * memdup_user_nul(const void __user * src, size_t len)
    int get_user_pages_fast(unsigned long start, int nr_pages, int write, struct page ** pages)

    User Space Memory Access

    unsigned long __copy_to_user_inatomic(void __user * to, const void * from, unsigned long n)
    unsigned long __copy_to_user(void __user * to, const void * from, unsigned long n)
    unsigned long __copy_from_user(void * to, const void __user * from, unsigned long n)
    unsigned long clear_user(void __user * to, unsigned long n)
    unsigned long __clear_user(void __user * to, unsigned long n)
    unsigned long _copy_to_user(void __user * to, const void * from, unsigned n)
    unsigned long _copy_from_user(void * to, const void __user * from, unsigned n)

    More Memory Management Functions

    int read_cache_pages(struct address_space * mapping, struct list_head * pages, int (filler) (void , struct page , void data)
    void page_cache_sync_readahead(struct address_space * mapping, struct file_ra_state * ra, struct file * filp, pgoff_t offset, unsigned long req_size)
    void page_cache_async_readahead(struct address_space * mapping, struct file_ra_state * ra, struct file * filp, struct page * page, pgoff_t offset, unsigned long req_size)
    void delete_from_page_cache(struct page * page)
    int filemap_flush(struct address_space * mapping)
    int filemap_fdatawait_range(struct address_space * mapping, loff_t start_byte, loff_t end_byte)
    int filemap_fdatawait(struct address_space * mapping)
    int filemap_write_and_wait_range(struct address_space * mapping, loff_t lstart, loff_t lend)
    int replace_page_cache_page(struct page * old, struct page * new, gfp_t gfp_mask)
    int add_to_page_cache_locked(struct page * page, struct address_space * mapping, pgoff_t offset, gfp_t gfp_mask)
    void add_page_wait_queue(struct page * page, wait_queue_t * waiter)
    void unlock_page(struct page * page)
    void end_page_writeback(struct page * page)
    void __lock_page(struct page * page)
    pgoff_t page_cache_next_hole(struct address_space * mapping, pgoff_t index, unsigned long max_scan)
    pgoff_t page_cache_prev_hole(struct address_space * mapping, pgoff_t index, unsigned long max_scan)
    struct page * find_get_entry(struct address_space * mapping, pgoff_t offset)
    struct page * find_lock_entry(struct address_space * mapping, pgoff_t offset)
    struct page * pagecache_get_page(struct address_space * mapping, pgoff_t offset, int fgp_flags, gfp_t gfp_mask)
    unsigned find_get_pages_contig(struct address_space * mapping, pgoff_t index, unsigned int nr_pages, struct page ** pages)
    unsigned find_get_pages_tag(struct address_space * mapping, pgoff_t * index, int tag, unsigned int nr_pages, struct page ** pages)
    unsigned find_get_entries_tag(struct address_space * mapping, pgoff_t start, int tag, unsigned int nr_entries, struct page * entries, pgoff_t indices)
    ssize_t generic_file_read_iter(struct kiocb * iocb, struct iov_iter * iter)
    int filemap_fault(struct vm_area_struct * vma, struct vm_fault * vmf)
    struct page * read_cache_page(struct address_space * mapping, pgoff_t index, int (filler) (void , struct page , void data)
    struct page * read_cache_page_gfp(struct address_space * mapping, pgoff_t index, gfp_t gfp)
    ssize_t __generic_file_write_iter(struct kiocb * iocb, struct iov_iter * from)
    ssize_t generic_file_write_iter(struct kiocb * iocb, struct iov_iter * from)
    int try_to_release_page(struct page * page, gfp_t gfp_mask)
    int zap_vma_ptes(struct vm_area_struct * vma, unsigned long address, unsigned long size)
    int vm_insert_page(struct vm_area_struct * vma, unsigned long addr, struct page * page)
    int vm_insert_pfn(struct vm_area_struct * vma, unsigned long addr, unsigned long pfn)
    int vm_insert_pfn_prot(struct vm_area_struct * vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot)
    int remap_pfn_range(struct vm_area_struct * vma, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t prot)
    int vm_iomap_memory(struct vm_area_struct * vma, phys_addr_t start, unsigned long len)
    void unmap_mapping_range(struct address_space * mapping, loff_t const holebegin, loff_t const holelen, int even_cows)
    int follow_pfn(struct vm_area_struct * vma, unsigned long address, unsigned long * pfn)
    void vm_unmap_aliases(void)
    void vm_unmap_ram(const void * mem, unsigned int count)
    void * vm_map_ram(struct page ** pages, unsigned int count, int node, pgprot_t prot)
    void unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
    void unmap_kernel_range(unsigned long addr, unsigned long size)
    void vfree(const void * addr)
    void vunmap(const void * addr)
    void * vmap(struct page ** pages, unsigned int count, unsigned long flags, pgprot_t prot)
    void * vmalloc(unsigned long size)
    void * vzalloc(unsigned long size)
    void * vmalloc_user(unsigned long size)
    void * vmalloc_node(unsigned long size, int node)
    void * vzalloc_node(unsigned long size, int node)
    void * vmalloc_32(unsigned long size)
    void * vmalloc_32_user(unsigned long size)
    int remap_vmalloc_range_partial(struct vm_area_struct * vma, unsigned long uaddr, void * kaddr, unsigned long size)
    int remap_vmalloc_range(struct vm_area_struct * vma, void * addr, unsigned long pgoff)
    struct vm_struct * alloc_vm_area(size_t size, pte_t ** ptes)
    unsigned long __get_pfnblock_flags_mask(struct page * page, unsigned long pfn, unsigned long end_bitidx, unsigned long mask)
    void set_pfnblock_flags_mask(struct page * page, unsigned long flags, unsigned long pfn, unsigned long end_bitidx, unsigned long mask)
    void * alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask)
    unsigned long nr_free_zone_pages(int offset)
    unsigned long nr_free_pagecache_pages(void)
    int find_next_best_node(int node, nodemask_t * used_node_mask)
    void free_bootmem_with_active_regions(int nid, unsigned long max_low_pfn)
    void sparse_memory_present_with_active_regions(int nid)
    void get_pfn_range_for_nid(unsigned int nid, unsigned long * start_pfn, unsigned long * end_pfn)
    unsigned long absent_pages_in_range(unsigned long start_pfn, unsigned long end_pfn)
    unsigned long node_map_pfn_alignment(void)
    unsigned long find_min_pfn_with_active_regions(void)
    void free_area_init_nodes(unsigned long * max_zone_pfn)
    void set_dma_reserve(unsigned long new_dma_reserve)
    void setup_per_zone_wmarks(void)
    int alloc_contig_range(unsigned long start, unsigned long end, unsigned migratetype)
    void mempool_destroy(mempool_t * pool)
    mempool_t * mempool_create(int min_nr, mempool_alloc_t * alloc_fn, mempool_free_t * free_fn, void * pool_data)
    int mempool_resize(mempool_t * pool, int new_min_nr)
    void * mempool_alloc(mempool_t * pool, gfp_t gfp_mask)
    void mempool_free(void * element, mempool_t * pool)
    struct dma_pool * dma_pool_create(const char * name, struct device * dev, size_t size, size_t align, size_t boundary)
    void dma_pool_destroy(struct dma_pool * pool)
    void * dma_pool_alloc(struct dma_pool * pool, gfp_t mem_flags, dma_addr_t * handle)
    void dma_pool_free(struct dma_pool * pool, void * vaddr, dma_addr_t dma)
    struct dma_pool * dmam_pool_create(const char * name, struct device * dev, size_t size, size_t align, size_t allocation)
    void dmam_pool_destroy(struct dma_pool * pool)
    void balance_dirty_pages_ratelimited(struct address_space * mapping)
    void tag_pages_for_writeback(struct address_space * mapping, pgoff_t start, pgoff_t end)
    int write_cache_pages(struct address_space * mapping, struct writeback_control * wbc, writepage_t writepage, void * data)
    int generic_writepages(struct address_space * mapping, struct writeback_control * wbc)
    int write_one_page(struct page * page, int wait)
    void wait_for_stable_page(struct page * page)
    void truncate_inode_pages_range(struct address_space * mapping, loff_t lstart, loff_t lend)
    void truncate_inode_pages(struct address_space * mapping, loff_t lstart)
    void truncate_inode_pages_final(struct address_space * mapping)
    unsigned long invalidate_mapping_pages(struct address_space * mapping, pgoff_t start, pgoff_t end)
    int invalidate_inode_pages2_range(struct address_space * mapping, pgoff_t start, pgoff_t end)
    int invalidate_inode_pages2(struct address_space * mapping)
    void truncate_pagecache(struct inode * inode, loff_t newsize)
    void truncate_setsize(struct inode * inode, loff_t newsize)
    void pagecache_isize_extended(struct inode * inode, loff_t from, loff_t to)
    void truncate_pagecache_range(struct inode * inode, loff_t lstart, loff_t lend)

    Kernel IPC facilities

    IPC utilities

    int ipc_init(void)
    void ipc_init_ids(struct ipc_ids * ids)
    void ipc_init_proc_interface(const char * path, const char * header, int ids, int (show) (struct seq_file , void *)
    struct kern_ipc_perm * ipc_findkey(struct ipc_ids * ids, key_t key)
    int ipc_get_maxid(struct ipc_ids * ids)
    int ipc_addid(struct ipc_ids * ids, struct kern_ipc_perm * new, int size)
    int ipcget_new(struct ipc_namespace * ns, struct ipc_ids * ids, const struct ipc_ops * ops, struct ipc_params * params)
    int ipc_check_perms(struct ipc_namespace * ns, struct kern_ipc_perm * ipcp, const struct ipc_ops * ops, struct ipc_params * params)
    int ipcget_public(struct ipc_namespace * ns, struct ipc_ids * ids, const struct ipc_ops * ops, struct ipc_params * params)
    void ipc_rmid(struct ipc_ids * ids, struct kern_ipc_perm * ipcp)
    void * ipc_alloc(int size)
    void ipc_free(void * ptr)
    void * ipc_rcu_alloc(int size)
    int ipcperms(struct ipc_namespace * ns, struct kern_ipc_perm * ipcp, short flag)
    void kernel_to_ipc64_perm(struct kern_ipc_perm * in, struct ipc64_perm * out)
    void ipc64_perm_to_ipc_perm(struct ipc64_perm * in, struct ipc_perm * out)
    struct kern_ipc_perm * ipc_obtain_object_idr(struct ipc_ids * ids, int id)
    struct kern_ipc_perm * ipc_lock(struct ipc_ids * ids, int id)
    struct kern_ipc_perm * ipc_obtain_object_check(struct ipc_ids * ids, int id)
    int ipcget(struct ipc_namespace * ns, struct ipc_ids * ids, const struct ipc_ops * ops, struct ipc_params * params)
    int ipc_update_perm(struct ipc64_perm * in, struct kern_ipc_perm * out)
    struct kern_ipc_perm * ipcctl_pre_down_nolock(struct ipc_namespace * ns, struct ipc_ids * ids, int id, int cmd, struct ipc64_perm * perm, int extra_perm)
    int ipc_parse_version(int * cmd)

    FIFO Buffer

    kfifo interface

    DECLARE_KFIFO_PTR(fifo, type)
    DECLARE_KFIFO(fifo, type, size)
    INIT_KFIFO(fifo)
    DEFINE_KFIFO(fifo, type, size)
    kfifo_initialized(fifo)
    kfifo_esize(fifo)
    kfifo_recsize(fifo)
    kfifo_size(fifo)
    kfifo_reset(fifo)
    kfifo_reset_out(fifo)
    kfifo_len(fifo)
    kfifo_is_empty(fifo)
    kfifo_is_full(fifo)
    kfifo_avail(fifo)
    kfifo_skip(fifo)
    kfifo_peek_len(fifo)
    kfifo_alloc(fifo, size, gfp_mask)
    kfifo_free(fifo)
    kfifo_init(fifo, buffer, size)
    kfifo_put(fifo, val)
    kfifo_get(fifo, val)
    kfifo_peek(fifo, val)
    kfifo_in(fifo, buf, n)
    kfifo_in_spinlocked(fifo, buf, n, lock)
    kfifo_out(fifo, buf, n)
    kfifo_out_spinlocked(fifo, buf, n, lock)
    kfifo_from_user(fifo, from, len, copied)
    kfifo_to_user(fifo, to, len, copied)
    kfifo_dma_in_prepare(fifo, sgl, nents, len)
    kfifo_dma_in_finish(fifo, len)
    kfifo_dma_out_prepare(fifo, sgl, nents, len)
    kfifo_dma_out_finish(fifo, len)
    kfifo_out_peek(fifo, buf, n)

    relay interface support

    relay interface

    int relay_buf_full(struct rchan_buf * buf)
    void relay_reset(struct rchan * chan)
    struct rchan * relay_open(const char * base_filename, struct dentry * parent, size_t subbuf_size, size_t n_subbufs, struct rchan_callbacks * cb, void * private_data)
    size_t relay_switch_subbuf(struct rchan_buf * buf, size_t length)
    void relay_subbufs_consumed(struct rchan * chan, unsigned int cpu, size_t subbufs_consumed)
    void relay_close(struct rchan * chan)
    void relay_flush(struct rchan * chan)
    int relay_mmap_buf(struct rchan_buf * buf, struct vm_area_struct * vma)
    void * relay_alloc_buf(struct rchan_buf * buf, size_t * size)
    struct rchan_buf * relay_create_buf(struct rchan * chan)
    void relay_destroy_channel(struct kref * kref)
    void relay_destroy_buf(struct rchan_buf * buf)
    void relay_remove_buf(struct kref * kref)
    int relay_buf_empty(struct rchan_buf * buf)
    void wakeup_readers(unsigned long data)
    void __relay_reset(struct rchan_buf * buf, unsigned int init)
    void relay_close_buf(struct rchan_buf * buf)
    int relay_hotcpu_callback(struct notifier_block * nb, unsigned long action, void * hcpu)
    int relay_late_setup_files(struct rchan * chan, const char * base_filename, struct dentry * parent)
    int relay_file_open(struct inode * inode, struct file * filp)
    int relay_file_mmap(struct file * filp, struct vm_area_struct * vma)
    unsigned int relay_file_poll(struct file * filp, poll_table * wait)
    int relay_file_release(struct inode * inode, struct file * filp)
    size_t relay_file_read_subbuf_avail(size_t read_pos, struct rchan_buf * buf)
    size_t relay_file_read_start_pos(size_t read_pos, struct rchan_buf * buf)
    size_t relay_file_read_end_pos(struct rchan_buf * buf, size_t read_pos, size_t count)

    Module Support

    Module Loading

    int __request_module(bool wait, const char * fmt, …)
    struct subprocess_info * call_usermodehelper_setup(char * path, char * argv, char * envp, gfp_t gfp_mask, int (init) (struct subprocess_info *info, struct cred *new, void (*cleanup) (struct subprocess_info *info, void data)
    int call_usermodehelper_exec(struct subprocess_info * sub_info, int wait)
    int call_usermodehelper(char * path, char * argv, char * envp, int wait)

    Hardware Interfaces

    Interrupt Handling

    bool synchronize_hardirq(unsigned int irq)
    void synchronize_irq(unsigned int irq)
    int irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify * notify)
    int irq_set_vcpu_affinity(unsigned int irq, void * vcpu_info)
    void disable_irq_nosync(unsigned int irq)
    void disable_irq(unsigned int irq)
    bool disable_hardirq(unsigned int irq)
    void enable_irq(unsigned int irq)
    int irq_set_irq_wake(unsigned int irq, unsigned int on)
    void irq_wake_thread(unsigned int irq, void * dev_id)
    int setup_irq(unsigned int irq, struct irqaction * act)
    void remove_irq(unsigned int irq, struct irqaction * act)
    void free_irq(unsigned int irq, void * dev_id)
    int request_threaded_irq(unsigned int irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long irqflags, const char * devname, void * dev_id)
    int request_any_context_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char * name, void * dev_id)
    bool irq_percpu_is_enabled(unsigned int irq)
    void free_percpu_irq(unsigned int irq, void __percpu * dev_id)
    int request_percpu_irq(unsigned int irq, irq_handler_t handler, const char * devname, void __percpu * dev_id)
    int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which, bool * state)
    int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, bool val)

    DMA Channels

    int request_dma(unsigned int dmanr, const char * device_id)
    void free_dma(unsigned int dmanr)

    Resources Management

    struct resource * request_resource_conflict(struct resource * root, struct resource * new)
    int reallocate_resource(struct resource * root, struct resource * old, resource_size_t newsize, struct resource_constraint * constraint)
    struct resource * lookup_resource(struct resource * root, resource_size_t start)
    struct resource * insert_resource_conflict(struct resource * parent, struct resource * new)
    void insert_resource_expand_to_fit(struct resource * root, struct resource * new)
    resource_size_t resource_alignment(struct resource * res)
    int release_mem_region_adjustable(struct resource * parent, resource_size_t start, resource_size_t size)
    int request_resource(struct resource * root, struct resource * new)
    int release_resource(struct resource * old)
    int region_intersects(resource_size_t start, size_t size, unsigned long flags, unsigned long desc)
    int allocate_resource(struct resource * root, struct resource * new, resource_size_t size, resource_size_t min, resource_size_t max, resource_size_t align, resource_size_t (alignf) (void , const struct resource , resource_size_t, resource_size_t, void alignf_data)
    int insert_resource(struct resource * parent, struct resource * new)
    int remove_resource(struct resource * old)
    int adjust_resource(struct resource * res, resource_size_t start, resource_size_t size)
    struct resource * __request_region(struct resource * parent, resource_size_t start, resource_size_t n, const char * name, int flags)
    void __release_region(struct resource * parent, resource_size_t start, resource_size_t n)
    int devm_request_resource(struct device * dev, struct resource * root, struct resource * new)
    void devm_release_resource(struct device * dev, struct resource * new)

    MTRR Handling

    int arch_phys_wc_add(unsigned long base, unsigned long size)

    PCI Support Library

    unsigned char pci_bus_max_busnr(struct pci_bus * bus)
    int pci_find_capability(struct pci_dev * dev, int cap)
    int pci_bus_find_capability(struct pci_bus * bus, unsigned int devfn, int cap)
    int pci_find_next_ext_capability(struct pci_dev * dev, int start, int cap)
    int pci_find_ext_capability(struct pci_dev * dev, int cap)
    int pci_find_next_ht_capability(struct pci_dev * dev, int pos, int ht_cap)
    int pci_find_ht_capability(struct pci_dev * dev, int ht_cap)
    struct resource * pci_find_parent_resource(const struct pci_dev * dev, struct resource * res)
    struct pci_dev * pci_find_pcie_root_port(struct pci_dev * dev)
    int __pci_complete_power_transition(struct pci_dev * dev, pci_power_t state)
    int pci_set_power_state(struct pci_dev * dev, pci_power_t state)
    pci_power_t pci_choose_state(struct pci_dev * dev, pm_message_t state)
    int pci_save_state(struct pci_dev * dev)
    void pci_restore_state(struct pci_dev * dev)
    struct pci_saved_state * pci_store_saved_state(struct pci_dev * dev)
    int pci_load_saved_state(struct pci_dev * dev, struct pci_saved_state * state)
    int pci_load_and_free_saved_state(struct pci_dev * dev, struct pci_saved_state ** state)
    int pci_reenable_device(struct pci_dev * dev)
    int pci_enable_device_io(struct pci_dev * dev)
    int pci_enable_device_mem(struct pci_dev * dev)
    int pci_enable_device(struct pci_dev * dev)
    int pcim_enable_device(struct pci_dev * pdev)
    void pcim_pin_device(struct pci_dev * pdev)
    void pci_disable_device(struct pci_dev * dev)
    int pci_set_pcie_reset_state(struct pci_dev * dev, enum pcie_reset_state state)
    bool pci_pme_capable(struct pci_dev * dev, pci_power_t state)
    void pci_pme_active(struct pci_dev * dev, bool enable)
    int __pci_enable_wake(struct pci_dev * dev, pci_power_t state, bool runtime, bool enable)
    int pci_wake_from_d3(struct pci_dev * dev, bool enable)
    int pci_prepare_to_sleep(struct pci_dev * dev)
    int pci_back_from_sleep(struct pci_dev * dev)
    bool pci_dev_run_wake(struct pci_dev * dev)
    u8 pci_common_swizzle(struct pci_dev * dev, u8 * pinp)
    void pci_release_region(struct pci_dev * pdev, int bar)
    int pci_request_region(struct pci_dev * pdev, int bar, const char * res_name)
    int pci_request_region_exclusive(struct pci_dev * pdev, int bar, const char * res_name)
    void pci_release_selected_regions(struct pci_dev * pdev, int bars)
    int pci_request_selected_regions(struct pci_dev * pdev, int bars, const char * res_name)
    void pci_release_regions(struct pci_dev * pdev)
    int pci_request_regions(struct pci_dev * pdev, const char * res_name)
    int pci_request_regions_exclusive(struct pci_dev * pdev, const char * res_name)
    void pci_set_master(struct pci_dev * dev)
    void pci_clear_master(struct pci_dev * dev)
    int pci_set_cacheline_size(struct pci_dev * dev)
    int pci_set_mwi(struct pci_dev * dev)
    int pci_try_set_mwi(struct pci_dev * dev)
    void pci_clear_mwi(struct pci_dev * dev)
    void pci_intx(struct pci_dev * pdev, int enable)
    bool pci_intx_mask_supported(struct pci_dev * dev)
    bool pci_check_and_mask_intx(struct pci_dev * dev)
    bool pci_check_and_unmask_intx(struct pci_dev * dev)
    int pci_wait_for_pending_transaction(struct pci_dev * dev)
    void pci_reset_bridge_secondary_bus(struct pci_dev * dev)
    int __pci_reset_function(struct pci_dev * dev)
    int __pci_reset_function_locked(struct pci_dev * dev)
    int pci_reset_function(struct pci_dev * dev)
    int pci_try_reset_function(struct pci_dev * dev)
    int pci_probe_reset_slot(struct pci_slot * slot)
    int pci_reset_slot(struct pci_slot * slot)
    int pci_try_reset_slot(struct pci_slot * slot)
    int pci_probe_reset_bus(struct pci_bus * bus)
    int pci_reset_bus(struct pci_bus * bus)
    int pci_try_reset_bus(struct pci_bus * bus)
    int pcix_get_max_mmrbc(struct pci_dev * dev)
    int pcix_get_mmrbc(struct pci_dev * dev)
    int pcix_set_mmrbc(struct pci_dev * dev, int mmrbc)
    int pcie_get_readrq(struct pci_dev * dev)
    int pcie_set_readrq(struct pci_dev * dev, int rq)
    int pcie_get_mps(struct pci_dev * dev)
    int pcie_set_mps(struct pci_dev * dev, int mps)
    int pcie_get_minimum_link(struct pci_dev * dev, enum pci_bus_speed * speed, enum pcie_link_width * width)
    int pci_select_bars(struct pci_dev * dev, unsigned long flags)
    int pci_add_dynid(struct pci_driver * drv, unsigned int vendor, unsigned int device, unsigned int subvendor, unsigned int subdevice, unsigned int class, unsigned int class_mask, unsigned long driver_data)
    const struct pci_device_id * pci_match_id(const struct pci_device_id * ids, struct pci_dev * dev)
    int __pci_register_driver(struct pci_driver * drv, struct module * owner, const char * mod_name)
    void pci_unregister_driver(struct pci_driver * drv)
    struct pci_driver * pci_dev_driver(const struct pci_dev * dev)
    struct pci_dev * pci_dev_get(struct pci_dev * dev)
    void pci_dev_put(struct pci_dev * dev)
    void pci_stop_and_remove_bus_device(struct pci_dev * dev)
    struct pci_bus * pci_find_bus(int domain, int busnr)
    struct pci_bus * pci_find_next_bus(const struct pci_bus * from)
    struct pci_dev * pci_get_slot(struct pci_bus * bus, unsigned int devfn)
    struct pci_dev * pci_get_domain_bus_and_slot(int domain, unsigned int bus, unsigned int devfn)
    struct pci_dev * pci_get_subsys(unsigned int vendor, unsigned int device, unsigned int ss_vendor, unsigned int ss_device, struct pci_dev * from)
    struct pci_dev * pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev * from)
    struct pci_dev * pci_get_class(unsigned int class, struct pci_dev * from)
    int pci_dev_present(const struct pci_device_id * ids)
    void pci_msi_mask_irq(struct irq_data * data)
    void pci_msi_unmask_irq(struct irq_data * data)
    int pci_msi_vec_count(struct pci_dev * dev)
    int pci_msix_vec_count(struct pci_dev * dev)
    int pci_enable_msix(struct pci_dev * dev, struct msix_entry * entries, int nvec)
    int pci_msi_enabled(void)
    int pci_enable_msi_range(struct pci_dev * dev, int minvec, int maxvec)
    int pci_enable_msix_range(struct pci_dev * dev, struct msix_entry * entries, int minvec, int maxvec)
    struct irq_domain * pci_msi_create_irq_domain(struct fwnode_handle * fwnode, struct msi_domain_info * info, struct irq_domain * parent)
    int pci_bus_alloc_resource(struct pci_bus * bus, struct resource * res, resource_size_t size, resource_size_t align, resource_size_t min, unsigned long type_mask, resource_size_t (alignf) (void , const struct resource , resource_size_t, resource_size_t, void alignf_data)
    void pci_bus_add_device(struct pci_dev * dev)
    void pci_bus_add_devices(const struct pci_bus * bus)
    struct pci_ops * pci_bus_set_ops(struct pci_bus * bus, struct pci_ops * ops)
    ssize_t pci_read_vpd(struct pci_dev * dev, loff_t pos, size_t count, void * buf)
    ssize_t pci_write_vpd(struct pci_dev * dev, loff_t pos, size_t count, const void * buf)
    int pci_set_vpd_size(struct pci_dev * dev, size_t len)
    void pci_cfg_access_lock(struct pci_dev * dev)
    bool pci_cfg_access_trylock(struct pci_dev * dev)
    void pci_cfg_access_unlock(struct pci_dev * dev)
    enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev * pdev)
    int __ht_create_irq(struct pci_dev * dev, int idx, ht_irq_update_t * update)
    int ht_create_irq(struct pci_dev * dev, int idx)
    void ht_destroy_irq(unsigned int irq)
    int pci_scan_slot(struct pci_bus * bus, int devfn)
    unsigned int pci_rescan_bus(struct pci_bus * bus)
    struct pci_slot * pci_create_slot(struct pci_bus * parent, int slot_nr, const char * name, struct hotplug_slot * hotplug)
    void pci_destroy_slot(struct pci_slot * slot)
    void pci_hp_create_module_link(struct pci_slot * pci_slot)
    void pci_hp_remove_module_link(struct pci_slot * pci_slot)
    int pci_enable_rom(struct pci_dev * pdev)
    void pci_disable_rom(struct pci_dev * pdev)
    void __iomem * pci_map_rom(struct pci_dev * pdev, size_t * size)
    void pci_unmap_rom(struct pci_dev * pdev, void __iomem * rom)
    void __iomem * pci_platform_rom(struct pci_dev * pdev, size_t * size)
    int pci_enable_sriov(struct pci_dev * dev, int nr_virtfn)
    void pci_disable_sriov(struct pci_dev * dev)
    int pci_num_vf(struct pci_dev * dev)
    int pci_vfs_assigned(struct pci_dev * dev)
    int pci_sriov_set_totalvfs(struct pci_dev * dev, u16 numvfs)
    int pci_sriov_get_totalvfs(struct pci_dev * dev)
    ssize_t pci_read_legacy_io(struct file * filp, struct kobject * kobj, struct bin_attribute * bin_attr, char * buf, loff_t off, size_t count)
    ssize_t pci_write_legacy_io(struct file * filp, struct kobject * kobj, struct bin_attribute * bin_attr, char * buf, loff_t off, size_t count)
    int pci_mmap_legacy_mem(struct file * filp, struct kobject * kobj, struct bin_attribute * attr, struct vm_area_struct * vma)
    int pci_mmap_legacy_io(struct file * filp, struct kobject * kobj, struct bin_attribute * attr, struct vm_area_struct * vma)
    void pci_adjust_legacy_attr(struct pci_bus * b, enum pci_mmap_state mmap_type)
    void pci_create_legacy_files(struct pci_bus * b)
    int pci_mmap_resource(struct kobject * kobj, struct bin_attribute * attr, struct vm_area_struct * vma, int write_combine)
    void pci_remove_resource_files(struct pci_dev * pdev)
    int pci_create_resource_files(struct pci_dev * pdev)
    ssize_t pci_write_rom(struct file * filp, struct kobject * kobj, struct bin_attribute * bin_attr, char * buf, loff_t off, size_t count)
    ssize_t pci_read_rom(struct file * filp, struct kobject * kobj, struct bin_attribute * bin_attr, char * buf, loff_t off, size_t count)
    void pci_remove_sysfs_dev_files(struct pci_dev * pdev)

    PCI Hotplug Support Library

    int __pci_hp_register(struct hotplug_slot * slot, struct pci_bus * bus, int devnr, const char * name, struct module * owner, const char * mod_name)
    int pci_hp_deregister(struct hotplug_slot * slot)
    int pci_hp_change_slot_info(struct hotplug_slot * slot, struct hotplug_slot_info * info)

    Firmware Interfaces

    DMI Interfaces

    int dmi_check_system(const struct dmi_system_id * list)
    const struct dmi_system_id * dmi_first_match(const struct dmi_system_id * list)
    const char * dmi_get_system_info(int field)
    int dmi_name_in_vendors(const char * str)
    const struct dmi_device * dmi_find_device(int type, const char * name, const struct dmi_device * from)
    bool dmi_get_date(int field, int * yearp, int * monthp, int * dayp)
    int dmi_walk(void (decode) (const struct dmi_header , void , void private_data)
    bool dmi_match(enum dmi_field f, const char * str)

    EDD Interfaces

    ssize_t edd_show_raw_data(struct edd_device * edev, char * buf)
    void edd_release(struct kobject * kobj)
    int edd_dev_is_type(struct edd_device * edev, const char * type)
    struct pci_dev * edd_get_pci_dev(struct edd_device * edev)
    int edd_init(void)

    Security Framework

    int security_init(void)
    int security_module_enable(const char * module)
    struct dentry * securityfs_create_file(const char * name, umode_t mode, struct dentry * parent, void * data, const struct file_operations * fops)
    struct dentry * securityfs_create_dir(const char * name, struct dentry * parent)
    void securityfs_remove(struct dentry * dentry)

    Audit Interfaces

    struct audit_buffer * audit_log_start(struct audit_context * ctx, gfp_t gfp_mask, int type)
    void audit_log_format(struct audit_buffer * ab, const char * fmt, …)
    void audit_log_end(struct audit_buffer * ab)
    void audit_log(struct audit_context * ctx, gfp_t gfp_mask, int type, const char * fmt, …)
    void audit_log_secctx(struct audit_buffer * ab, u32 secid)
    int audit_alloc(struct task_struct * tsk)
    void __audit_free(struct task_struct * tsk)
    void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4)
    void __audit_syscall_exit(int success, long return_code)
    struct filename * __audit_reusename(const __user char * uptr)
    void __audit_getname(struct filename * name)
    void __audit_inode(struct filename * name, const struct dentry * dentry, unsigned int flags)
    int auditsc_get_stamp(struct audit_context * ctx, struct timespec * t, unsigned int * serial)
    int audit_set_loginuid(kuid_t loginuid)
    void __audit_mq_open(int oflag, umode_t mode, struct mq_attr * attr)
    void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec * abs_timeout)
    void __audit_mq_notify(mqd_t mqdes, const struct sigevent * notification)
    void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr * mqstat)
    void __audit_ipc_obj(struct kern_ipc_perm * ipcp)
    void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode)
    int __audit_socketcall(int nargs, unsigned long * args)
    void __audit_fd_pair(int fd1, int fd2)
    int __audit_sockaddr(int len, void * a)
    int __audit_signal_info(int sig, struct task_struct * t)
    int __audit_log_bprm_fcaps(struct linux_binprm * bprm, const struct cred * new, const struct cred * old)
    void __audit_log_capset(const struct cred * new, const struct cred * old)
    void audit_core_dumps(long signr)
    int audit_rule_change(int type, __u32 portid, int seq, void * data, size_t datasz)
    int audit_list_rules_send(struct sk_buff * request_skb, int seq)
    int parent_len(const char * path)
    int audit_compare_dname_path(const char * dname, const char * path, int parentlen)

    Accounting Framework

    long sys_acct(const char __user * name)
    void acct_collect(long exitcode, int group_dead)
    void acct_process(void)

    Block Devices

    struct backing_dev_info * blk_get_backing_dev_info(struct block_device * bdev)
    void blk_delay_queue(struct request_queue * q, unsigned long msecs)
    void blk_start_queue_async(struct request_queue * q)
    void blk_start_queue(struct request_queue * q)
    void blk_stop_queue(struct request_queue * q)
    void blk_sync_queue(struct request_queue * q)
    void __blk_run_queue_uncond(struct request_queue * q)
    void __blk_run_queue(struct request_queue * q)
    void blk_run_queue_async(struct request_queue * q)
    void blk_run_queue(struct request_queue * q)
    void blk_queue_bypass_start(struct request_queue * q)
    void blk_queue_bypass_end(struct request_queue * q)
    void blk_cleanup_queue(struct request_queue * q)
    struct request_queue * blk_init_queue(request_fn_proc * rfn, spinlock_t * lock)
    struct request * blk_make_request(struct request_queue * q, struct bio * bio, gfp_t gfp_mask)
    void blk_rq_set_block_pc(struct request * rq)
    void blk_requeue_request(struct request_queue * q, struct request * rq)
    void part_round_stats(int cpu, struct hd_struct * part)
    void blk_add_request_payload(struct request * rq, struct page * page, int offset, unsigned int len)
    blk_qc_t generic_make_request(struct bio * bio)
    blk_qc_t submit_bio(int rw, struct bio * bio)
    int blk_insert_cloned_request(struct request_queue * q, struct request * rq)
    unsigned int blk_rq_err_bytes(const struct request * rq)
    struct request * blk_peek_request(struct request_queue * q)
    void blk_start_request(struct request * req)
    struct request * blk_fetch_request(struct request_queue * q)
    bool blk_update_request(struct request * req, int error, unsigned int nr_bytes)
    void blk_unprep_request(struct request * req)
    bool blk_end_request(struct request * rq, int error, unsigned int nr_bytes)
    void blk_end_request_all(struct request * rq, int error)
    bool blk_end_request_cur(struct request * rq, int error)
    bool blk_end_request_err(struct request * rq, int error)
    bool __blk_end_request(struct request * rq, int error, unsigned int nr_bytes)
    void __blk_end_request_all(struct request * rq, int error)
    bool __blk_end_request_cur(struct request * rq, int error)
    bool __blk_end_request_err(struct request * rq, int error)
    void rq_flush_dcache_pages(struct request * rq)
    int blk_lld_busy(struct request_queue * q)
    void blk_rq_unprep_clone(struct request * rq)
    int blk_rq_prep_clone(struct request * rq, struct request * rq_src, struct bio_set * bs, gfp_t gfp_mask, int (bio_ctr) (struct bio , struct bio , void , void * data)
    void blk_start_plug(struct blk_plug * plug)
    void blk_pm_runtime_init(struct request_queue * q, struct device * dev)
    int blk_pre_runtime_suspend(struct request_queue * q)
    void blk_post_runtime_suspend(struct request_queue * q, int err)
    void blk_pre_runtime_resume(struct request_queue * q)
    void blk_post_runtime_resume(struct request_queue * q, int err)
    void blk_set_runtime_active(struct request_queue * q)
    void __blk_drain_queue(struct request_queue * q, bool drain_all)
    struct io_context * rq_ioc(struct bio * bio)
    struct request * __get_request(struct request_list * rl, int rw_flags, struct bio * bio, gfp_t gfp_mask)
    struct request * get_request(struct request_queue * q, int rw_flags, struct bio * bio, gfp_t gfp_mask)
    bool blk_attempt_plug_merge(struct request_queue * q, struct bio * bio, unsigned int * request_count, struct request ** same_queue_rq)
    int blk_cloned_rq_check_limits(struct request_queue * q, struct request * rq)
    bool blk_end_bidi_request(struct request * rq, int error, unsigned int nr_bytes, unsigned int bidi_bytes)
    bool __blk_end_bidi_request(struct request * rq, int error, unsigned int nr_bytes, unsigned int bidi_bytes)
    int blk_rq_map_user_iov(struct request_queue * q, struct request * rq, struct rq_map_data * map_data, const struct iov_iter * iter, gfp_t gfp_mask)
    int blk_rq_unmap_user(struct bio * bio)
    int blk_rq_map_kern(struct request_queue * q, struct request * rq, void * kbuf, unsigned int len, gfp_t gfp_mask)
    void blk_release_queue(struct kobject * kobj)
    void blk_queue_prep_rq(struct request_queue * q, prep_rq_fn * pfn)
    void blk_queue_unprep_rq(struct request_queue * q, unprep_rq_fn * ufn)
    void blk_set_default_limits(struct queue_limits * lim)
    void blk_set_stacking_limits(struct queue_limits * lim)
    void blk_queue_make_request(struct request_queue * q, make_request_fn * mfn)
    void blk_queue_bounce_limit(struct request_queue * q, u64 max_addr)
    void blk_queue_max_hw_sectors(struct request_queue * q, unsigned int max_hw_sectors)
    void blk_queue_chunk_sectors(struct request_queue * q, unsigned int chunk_sectors)
    void blk_queue_max_discard_sectors(struct request_queue * q, unsigned int max_discard_sectors)
    void blk_queue_max_write_same_sectors(struct request_queue * q, unsigned int max_write_same_sectors)
    void blk_queue_max_segments(struct request_queue * q, unsigned short max_segments)
    void blk_queue_max_segment_size(struct request_queue * q, unsigned int max_size)
    void blk_queue_logical_block_size(struct request_queue * q, unsigned short size)
    void blk_queue_physical_block_size(struct request_queue * q, unsigned int size)
    void blk_queue_alignment_offset(struct request_queue * q, unsigned int offset)
    void blk_limits_io_min(struct queue_limits * limits, unsigned int min)
    void blk_queue_io_min(struct request_queue * q, unsigned int min)
    void blk_limits_io_opt(struct queue_limits * limits, unsigned int opt)
    void blk_queue_io_opt(struct request_queue * q, unsigned int opt)
    void blk_queue_stack_limits(struct request_queue * t, struct request_queue * b)
    int blk_stack_limits(struct queue_limits * t, struct queue_limits * b, sector_t start)
    int bdev_stack_limits(struct queue_limits * t, struct block_device * bdev, sector_t start)
    void disk_stack_limits(struct gendisk * disk, struct block_device * bdev, sector_t offset)
    void blk_queue_dma_pad(struct request_queue * q, unsigned int mask)
    void blk_queue_update_dma_pad(struct request_queue * q, unsigned int mask)
    int blk_queue_dma_drain(struct request_queue * q, dma_drain_needed_fn * dma_drain_needed, void * buf, unsigned int size)
    void blk_queue_segment_boundary(struct request_queue * q, unsigned long mask)
    void blk_queue_virt_boundary(struct request_queue * q, unsigned long mask)
    void blk_queue_dma_alignment(struct request_queue * q, int mask)
    void blk_queue_update_dma_alignment(struct request_queue * q, int mask)
    void blk_queue_write_cache(struct request_queue * q, bool wc, bool fua)
    void blk_execute_rq_nowait(struct request_queue * q, struct gendisk * bd_disk, struct request * rq, int at_head, rq_end_io_fn * done)
    int blk_execute_rq(struct request_queue * q, struct gendisk * bd_disk, struct request * rq, int at_head)
    int blkdev_issue_flush(struct block_device * bdev, gfp_t gfp_mask, sector_t * error_sector)
    int blkdev_issue_discard(struct block_device * bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
    int blkdev_issue_write_same(struct block_device * bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, struct page * page)
    int blkdev_issue_zeroout(struct block_device * bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, bool discard)
    struct request * blk_queue_find_tag(struct request_queue * q, int tag)
    void blk_free_tags(struct blk_queue_tag * bqt)
    void blk_queue_free_tags(struct request_queue * q)
    struct blk_queue_tag * blk_init_tags(int depth, int alloc_policy)
    int blk_queue_init_tags(struct request_queue * q, int depth, struct blk_queue_tag * tags, int alloc_policy)
    int blk_queue_resize_tags(struct request_queue * q, int new_depth)
    void blk_queue_end_tag(struct request_queue * q, struct request * rq)
    int blk_queue_start_tag(struct request_queue * q, struct request * rq)
    void blk_queue_invalidate_tags(struct request_queue * q)
    void __blk_queue_free_tags(struct request_queue * q)
    int blk_rq_count_integrity_sg(struct request_queue * q, struct bio * bio)
    int blk_rq_map_integrity_sg(struct request_queue * q, struct bio * bio, struct scatterlist * sglist)
    int blk_integrity_compare(struct gendisk * gd1, struct gendisk * gd2)
    void blk_integrity_register(struct gendisk * disk, struct blk_integrity * template)
    void blk_integrity_unregister(struct gendisk * disk)
    int blk_trace_ioctl(struct block_device * bdev, unsigned cmd, char __user * arg)
    void blk_trace_shutdown(struct request_queue * q)
    void blk_add_trace_rq(struct request_queue * q, struct request * rq, unsigned int nr_bytes, u32 what)
    void blk_add_trace_bio(struct request_queue * q, struct bio * bio, u32 what, int error)
    void blk_add_trace_bio_remap(void * ignore, struct request_queue * q, struct bio * bio, dev_t dev, sector_t from)
    void blk_add_trace_rq_remap(void * ignore, struct request_queue * q, struct request * rq, dev_t dev, sector_t from)
    int blk_mangle_minor(int minor)
    int blk_alloc_devt(struct hd_struct * part, dev_t * devt)
    void blk_free_devt(dev_t devt)
    void disk_replace_part_tbl(struct gendisk * disk, struct disk_part_tbl * new_ptbl)
    int disk_expand_part_tbl(struct gendisk * disk, int partno)
    void disk_block_events(struct gendisk * disk)
    void disk_unblock_events(struct gendisk * disk)
    void disk_flush_events(struct gendisk * disk, unsigned int mask)
    unsigned int disk_clear_events(struct gendisk * disk, unsigned int mask)
    struct hd_struct * disk_get_part(struct gendisk * disk, int partno)
    void disk_part_iter_init(struct disk_part_iter * piter, struct gendisk * disk, unsigned int flags)
    struct hd_struct * disk_part_iter_next(struct disk_part_iter * piter)
    void disk_part_iter_exit(struct disk_part_iter * piter)
    struct hd_struct * disk_map_sector_rcu(struct gendisk * disk, sector_t sector)
    int register_blkdev(unsigned int major, const char * name)
    void add_disk(struct gendisk * disk)
    struct gendisk * get_gendisk(dev_t devt, int * partno)
    struct block_device * bdget_disk(struct gendisk * disk, int partno)

    Char devices

    int register_chrdev_region(dev_t from, unsigned count, const char * name)
    int alloc_chrdev_region(dev_t * dev, unsigned baseminor, unsigned count, const char * name)
    int __register_chrdev(unsigned int major, unsigned int baseminor, unsigned int count, const char * name, const struct file_operations * fops)
    void unregister_chrdev_region(dev_t from, unsigned count)
    void __unregister_chrdev(unsigned int major, unsigned int baseminor, unsigned int count, const char * name)
    int cdev_add(struct cdev * p, dev_t dev, unsigned count)
    void cdev_del(struct cdev * p)
    struct cdev * cdev_alloc(void)
    void cdev_init(struct cdev * cdev, const struct file_operations * fops)

    Miscellaneous Devices

    int misc_register(struct miscdevice * misc)
    void misc_deregister(struct miscdevice * misc)

    Clock Framework

    struct clk_notifier
    struct clk_notifier_data
    int clk_notifier_register(struct clk * clk, struct notifier_block * nb)
    int clk_notifier_unregister(struct clk * clk, struct notifier_block * nb)
    long clk_get_accuracy(struct clk * clk)
    int clk_set_phase(struct clk * clk, int degrees)
    int clk_get_phase(struct clk * clk)
    bool clk_is_match(const struct clk * p, const struct clk * q)
    int clk_prepare(struct clk * clk)
    void clk_unprepare(struct clk * clk)
    struct clk * clk_get(struct device * dev, const char * id)
    struct clk * devm_clk_get(struct device * dev, const char * id)
    int clk_enable(struct clk * clk)
    void clk_disable(struct clk * clk)
    unsigned long clk_get_rate(struct clk * clk)
    void clk_put(struct clk * clk)
    void devm_clk_put(struct device * dev, struct clk * clk)
    long clk_round_rate(struct clk * clk, unsigned long rate)
    int clk_set_rate(struct clk * clk, unsigned long rate)
    bool clk_has_parent(struct clk * clk, struct clk * parent)
    int clk_set_rate_range(struct clk * clk, unsigned long min, unsigned long max)
    int clk_set_min_rate(struct clk * clk, unsigned long rate)
    int clk_set_max_rate(struct clk * clk, unsigned long rate)
    int clk_set_parent(struct clk * clk, struct clk * parent)
    struct clk * clk_get_parent(struct clk * clk)
    struct clk * clk_get_sys(const char * dev_id, const char * con_id)

    参考

    https://kernel.readthedocs.io/en/sphinx-samples/kernel-api.html

    展开全文
  • Linux DVB api 笔记

    2011-02-10 10:38:00
    Linux DVB interface <br />Demux 用途:硬件解复用 设备路径: /dev/dvb/adapter0/demux0 <br />数据类型: dmx_output_t <br />typedef enum { DMX_OUT_DECODER,...

    Linux DVB interface

    Demux
    用途:硬件解复用
    设备路径: /dev/dvb/adapter0/demux0

    数据类型:
    dmx_output_t

    typedef enum
    {
    DMX_OUT_DECODER,
    DMX_OUT_TAP,
    DMX_OUT_TS_TAP
    } dmx_output_t;

    DMX_OUT_TAP:将流输出到调用ioctl的demux设备上
    DMX_OUT_TS_TAP:将流输出到逻辑 DVR设备上 /dev/dvb/adapter0/dvr0 。输出一个ts流到该设备。并且复用所有设置了该标志的流。

    函数调用
    open: 在 /dev/dvb/adapter0/demux0 上使用,将会分配以后一个新的filter并返回一个handle用来持续的控制该filter。
    该函数的每一次返回的文件描述附,是一个单独filter的引用。

    /dev/dvb/adapter0/dvr0 是一个逻辑设备用来检索传输流。从该设备读取,将得到一个传输流,该流包含了所有设置了DMX_OUT_TS_TAP标志的filter的PES包。

    read()
    读取filtered中的数据。可能是secion或者PES数据。数据被存储在驱动内部的循环缓冲区中。

    当返回的是secion数据,驱动则总是返回完整的单独section(即使有足够的空间放入其他数据)。如果数据超过缓冲区大小则在下次调用时继续返回。

    内部缓冲默认为2*4096bytes(secion的两倍大小)

    为了能够读取,必须通过ioctl设置要过滤的secion或者PES。并指定DMX_START 或者ioctl时指定DMX_IMMEDIATE_START 标记。

    write()
    仅对/dev/dvb/adapter0/dvr0管用,还是在内部于物理demux设备关联

    ioctl()
    DMX_START 开始filter
    DMX_STOP 对应的停止

    DMX_SET_FILTER
    设置filter

    struct dmx_sct_filter_params
    {
    uint16_t pid;
    dmx_filter_t filter;
    uint32_t timeout;
    uint32_t flags;
    #define DMX_CHECK_CRC 1
    #define DMX_ONESHOT 2
    #define DMX_IMMEDIATE_START 4
    };

    timeout:设置读取secion超时,0为永不超时
    flags:指定了是否CRC检查,仅读取一次,DMX_SET_FILTER后立即开始filter

    DMX_SET_PES_FILTER
    用来设置一个PES filter。传输流的目标必须设定,一个PES可以直接送入video decoder。如果该filter之前设置过,则会取消当前的filter。并清空缓冲区。

    DMX_SET_BUFFER_SIZE
    设置缓冲区大小,默认2*4096bytes

    DMX_GET_EVENT
    返回一个事件,必须在阻塞模式下。

    DMX_GET_STC
    设置当前系统STC system time counter?

    --------------------------------------------------------
    DVB Video Device
    这种设备提供MPEG2视频硬件解码,可通过 /dev/dvb/adapter0/video0 访问。
    该设备仅负责控制MPEG视频流解码,不负责将画面显示在TV或者显示器上。在PC上,这通常由video4linux设备负责,还负责scale和定义输出窗口。(疑问是下面api介绍了显示相关设置,但不由该设备负责,那怎么确定由哪个v4l2设备负责显示呢?)
    ioctl也处理SPU(sub picture unit)

    数据类型
    typedef enum {
    VIDEO_FORMAT_4_3,
    VIDEO_FORMAT_16_9
    } video_format_t;
    指定视频格式

    typedef enum {
    VIDEO_PAN_SCAN,
    VIDEO_LETTER_BOX,
    VIDEO_CENTER_CUT_OUT
    } video_display_format_t;
    当视频流和应用程序的显示格式不同时,需要指定。

    typedef enum {
    VIDEO_SOURCE_DEMUX,
    VIDEO_SOURCE_MEMORY
    } video_stream_source_t;
    指定视频源,可以是demux设备,也可以来自内存,来自内存这靠用户write写入数据。

    VIDEO_GET_CAPABILITIES
    获得视频能力

    VIDEO_SET_SYSTEM

    typedef enum {
    VIDEO_SYSTEM_PAL,
    VIDEO_SYSTEM_NTSC,
    VIDEO_SYSTEM_PALN,
    VIDEO_SYSTEM_PALNc,
    VIDEO_SYSTEM_PALM,
    VIDEO_SYSTEM_NTSC60,
    VIDEO_SYSTEM_PAL60,
    VIDEO_SYSTEM_PALM60
    } video_system_t;

    函数

    ioctl
    VIDEO_STOP
    停止当前流

    VIDEO_PLAY
    开始当前流

    VIDEO_FREEZE
    暂停当前流

    VIDEO_CONTINUE
    继续当前流

    VIDEO_SELECT_SOURCE

    VIDEO_SET_BLANK
    当流停止时清空屏幕

    展开全文
  • C语言 CRC32校验算法

    2016-01-20 22:44:21
    #include #include #include typedef signed char s8; typedef unsigned char u8; typedef signed short s16; typedef unsigned short u16; typedef signed int s32; typedef unsigned int u32;...typedef sign
  • [Linux C编程]校验方法

    2016-11-07 18:34:11
    校验方法 奇偶校验 根据被传输的一组二进制代码的数位中“1”的个数是奇数或偶数来进行校验。采用奇数的称为奇校验,反之,称为偶校验。采用何种校验是事先规定好的。通常专门设置一个奇偶校验位,用它使这组代码...
  • How to use Linux kernel crypto compression -v0.1 2018.10.8 Sherlock ...This doc shares the crypto compression API in Linux kernel. Linux kernel crypto subsystem supports different algorithms includi...
  • crc32校验算法

    2015-11-18 19:17:59
    CRC即循环冗余校验码(Cyclic Redundancy Check):是数据通信领域中最常用的一种差错校验码,其特征是信息字段和校验字段的长度可以任意选定。 CRC校验实用程序库在数据存储和数据通讯领域,为了保证数据的...
  • Linux内核API》 《Linux内核API》 版本 作者 参与者 完成日期 备注 YanlzLinux_Kernel_V01_1.0 严立钻 ...
  • 众所周知,利用Linux下的rand函数可以生成范围在0到RAND_MAX(在stdlib.h中定义,值为2147483647)的数值,但是一般来讲,为了达到更好的随机效果,需要利用srand函数设置相应的随机种子(或者说随机数的起始值),...
  • linux内核编译

    2018-10-28 18:21:32
    按照韦东山课程上说的进行内核比编译的时候出现了如下的错误: ...andrew@andrew-Thurley:/work/svn_linux/linux$ make s3c2410_defconfig Makefile:416: *** mixed implicit and normal rules: deprecated synta...
  • 下面以最新的Linux 2.6.20内核为例,介绍比较常用的一些Linux内核配置选项,其他选项读者可以参考系统提供的帮助信息。 需要说明的是,在内核配置中,某项选择Y表示把该项选择进内核,选择M则表示把该项编译成...
  • 1.API 说明 为了方便用户使用,这里列出了常用的 API,并给出了相关的使用说明。 注:更多详细 API 内容请参阅 ARM mbedtls API 手册。 应用层 API 应用层 API 是提供给用户在 App 中直接使用的 API,这部分 API ...
  • 根据自己的需求下载对应的Linux内核版本 二、Linux内核源代码的目录结构 Linux内核源代码包含如下目录: arch:包含和硬件体系结构相关的代码,每种平台占一个相应的目录,如i386、arm、arm64、 powerpc、mips...
  • Linux服务篇--SSL

    2019-04-08 10:25:28
    本章概要 安全机制 对称和非对称加密 散列算法 gpg PKI和CA openssl 证书管理 ssh服务和dropbear aide Sudo TCP Wrappers PAM模块 1、数据安全与加密算法 1.1 数据加密 安全机制 信息安全防护的目标 ......
  • CRC32校验

    2010-10-25 15:20:00
    它给我的文件是在实机中(linux)下导出的文件,而我们开发是在windows下开发的,大体给大家介绍下这个文件的的结构 简单的就是这样,其实乱七八糟的有上百个片段内容,现在我们要分析的就是头信息中的CRC值和文件...
  • linux内核符号表

    2017-03-16 18:25:27
    所谓内核符号表就是在内核内部函数或变量中可供外部引用的函数和变量的符号表...beyes@linux-beyes:/> cat /proc/kallsyms | morec0100000 T _textc0100000 T startup_32c0100054 t default_entryc01000b0 T startup_32
  • Linux免费提供源代码,并且具有与Unix类似的为人们所熟悉的应用程序编程环境,这一切造就了它今天的巨大成功。通过互联网从专家处即时获得的高质量的免费支持也发挥了重要作用,它促成了一个庞大的L
1 2 3 4 5 ... 20
收藏数 6,567
精华内容 2,626
热门标签