sudo apt-key adv --fetch-keys http://repos.codelite.org/CodeLite.asc2、查看自己系统信息
sudo lsb_release -a
例如:
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04
Codename: precise
3、根据上面的Codename,选择更新源sudo apt-add-repository "deb http://repos.codelite.org/ubuntu/ precise universe" sudo apt-get update
istro/release Lines to append debian squeeze deb http://repos.codelite.org/debian/ squeeze contrib debian wheezy deb http://repos.codelite.org/debian/ wheezy contrib ubuntu lucid deb http://repos.codelite.org/ubuntu/ lucid universe ubuntu oneiric deb http://repos.codelite.org/ubuntu/ oneiric universe ubuntu precise deb http://repos.codelite.org/ubuntu/ precise universe ubuntu quantal deb http://repos.codelite.org/ubuntu/ quantal universe ubuntu raring deb http://repos.codelite.org/ubuntu/ raring universe
- 安装有Unbuntu12.04的机器或者虚拟机
- 下载最新的稳定版Linux内核源码:下载地址是http://www.kernel.org/,现在最新的稳定版本是3.9.4
- root权限
xz -d linux-3.9.4.tar.xz tar -xvf linux-3.9.4.tar第一条命令大概执行40秒到一分钟
make mrproper
4 配置编译选项
cd ncurses-5.9 ./configure make su root make install
按照你的系统环境制作安装配置文件
make menuconfig根据菜单提示,选择编译配置选项,并保存为配置文件.config
make dep提示没有必要,可能是加载以前配置文件的原因
6 清理编译中间文件
make clean
7 生成新内核
make bzImage时间:13:02 - 13:26
make modules
9 安装modules
make modules_install
10 建立要载入ramdisk的映像文件
mkinittramfs -o /boot/initrd-linux3.9.4.img 3.9.4
make install
12 配置grub引导程序
#include <unistd.h>
#include <stdio.h>
int main()
{
syscall(351,1);
return 1;
}
sudo dmesg -c
linux内核中memcpy和memmove函数的区别和实现
Kernel version:2.6.32
CPU architecture:ARM
Author:ce123(http://blog.csdn.net/ce123)
- memcpy是把src指向的对象中的size个字符拷贝到dest所指向的对象中,返回指向结果对象的指针.
- memmove也是把src指向的对象中的size个字符拷贝到dest所指向的对象中,返回指向结果对象的指针,但这两个函数在处理内存区域重叠的方式不同.
内存重叠问题是指目的地址的内存空间的首地址,包含在源内存空间中,这两段内存空间有了交集,因而在使用memcpy进行内存复制操作时,这段重叠的内存空间会被破坏.这种情况在应用程序级代码中一般不会出现的,而在驱动或内核级代码中要十分小心,尽量使用memmove函数.
memcpy对内存空间有要求的,dest和src所指向的内存空间不能重叠,否则复制的数据是错误的.下面具体讲解一下这个错误是如何产生的.
如果内存空间布局入下图所示:
src所指向的内存空间后面部分数据被新拷贝的数据给覆盖了(也就是dest<=src+size).所以拷贝到最后,原来的数据肯定不是原来的数据,拷贝的数据也不是想要的数据,使用memcpy函数可以得到错误的结果.
再者,如果内存空间布局入下图所示:
虽然原来的数据不再是原来的数据(dest+size>=src),但拷贝的数据是原来的数据,使用memcpy函数可以得到正确的结果.因此,在使用memcpy这个函数之前,还需要做一个判断,如果dest<=src你才能使用这个函数不过完全没有必要,你直接使用memmove函数就可以了.memmove在拷贝之前就做了一个判断,如果dest <= src,就按照memcpy的思路拷贝,如果dest>src怎么办呢,看函数,它是从后面往前拷贝,这样就能正确拷贝数据了.根据上面的分析,理解下面的代码应该是一件很容易的事情.
551 #ifndef __HAVE_ARCH_MEMCPY
552 /**
553 * memcpy - Copy one area of memory to another
554 * @dest: Where to copy to
555 * @src: Where to copy from
556 * @count: The size of the area.
557 *
558 * You should not use this function to access IO space, use memcpy_toio()
559 * or memcpy_fromio() instead.
560 */
561 void *memcpy(void *dest, const void *src, size_t count)
562 {
563 char *tmp = dest;
564 const char *s = src;
565
566 while (count--)
567 *tmp++ = *s++;
568 return dest;
569 }
570 EXPORT_SYMBOL(memcpy);
571 #endif
572
573 #ifndef __HAVE_ARCH_MEMMOVE
574 /**
575 * memmove - Copy one area of memory to another
576 * @dest: Where to copy to
577 * @src: Where to copy from
578 * @count: The size of the area.
579 *
580 * Unlike memcpy(), memmove() copes with overlapping areas.
581 */
582 void *memmove(void *dest, const void *src, size_t count)
583 {
584 char *tmp;
585 const char *s;
586
587 if (dest <= src) {
588 tmp = dest;
589 s = src;
590 while (count--)
591 *tmp++ = *s++;
592 } else {
593 tmp = dest;
594 tmp += count;
595 s = src;
596 s += count;
597 while (count--)
598 *--tmp = *--s;
599 }
600 return dest;
601 }
602 EXPORT_SYMBOL(memmove);
603 #endif