易截截图软件、单文件、免安装、纯绿色、仅160KB

linux内核空间申请超过2MB连续空间的实现函数。

 /*
kmalloc can apply 128KB memory only. This func support any continous memory allocate more than 2MB.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#define KMEM_PAGES        //apply more than one page
#define KMEM_DEBUG        //debug message switch
/*
// Pure 2^n version of get_order
static __inline__ __attribute_const__ int get_order(unsigned long size)
{
    int order;
    size = (size - 1) >> (PAGE_SHIFT - 1);
    order = -1;
    do {
        size >>= 1;
        order++;
    } while (size);
    return order;
}
*/
/*
alloc memory for DMA using in kernel space.
*/
void *kmem_alloc(size_t size, dma_addr_t *dma_handle, unsigned long flags)
{
    struct page *page;        //start page address
    void *cpu_addr = NULL;        //cpu io address
    struct page *end;        //end of pages
    unsigned int  PageOrder=0;
    
    size = PAGE_ALIGN(size);    //must be times of 4KB
    PageOrder=get_order(size);
#ifdef CONFIG_ISOLATE_HIGHMEM        //allocate in high memory
    page = alloc_pages(GFP_HIGHUSER, PageOrder);
#else                                //allocate from low memory
    page = alloc_pages(GFP_KERNEL, PageOrder);        //get_order(size) means how many 4KB page do you want to apply. 2^n
#end


相关文档:

实战Linux Bluetooth编程(三) HCI层编程

1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI)  就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......

linux获取文件的路径名及其文件名的方法

1、简单测试实例
 for i in `find . -type f -name "*.c"`
do
  echo $i
  basename $i    获取*.c文件名
  dirname $i        获取*.c对应的目录名
done
2、实际应用
diff Linux源码,并将有不一样的源码整理在一起,要求:文件 ......

linux中ELF加载过程分析

sys_execve
   | - do_execve
|
| - search_binary_handler         
           |- linux_binfmt= elf_format
       |- elf_format-> load_elf_binary
| -&nbs ......

Linux下RPC的hello world

Linux 下面使用RPC需要使用到命令rpcgen.
在Linux下开发RPC程序流程如下:
1.写一个rpc程序,
       如test.x
2.使用rpcgen生成必须的文件,通常是客户端和服务器端以及头文件
       $rpcgen test.x
3.使用rpcgen生成服务器端和客户端的C语言代码
&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号