linux简单代码阅读

linux简单代码阅读

ID:34267462

大小:42.81 KB

页数:7页

时间:2019-03-04

linux简单代码阅读_第1页
linux简单代码阅读_第2页
linux简单代码阅读_第3页
linux简单代码阅读_第4页
linux简单代码阅读_第5页
资源描述:

《linux简单代码阅读》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、一、find_first_bit(2)staticinlineintfind_first_bit(constunsignedlong*vaddr,unsignedsize){constunsignedlong*p=vaddr;intres=32;unsignedlongnum;if(!size)return0;size=(size+31)>>5;while(!(num=*p++)){if(!--size)gotoout;}__asm____volatile__("bfffo%1{#0,#0},%0":"

2、=d"(res):"d"(num&-num));res^=31;out:return((long)p-(long)vaddr-4)*8+res;}二、find_next_bit(2)staticinlineintfind_next_bit(constunsignedlong*vaddr,intsize,intoffset){constunsignedlong*p=vaddr+(offset>>5);intbit=offset&31UL,res;if(offset>=size)returnsize;if(

3、bit){unsignedlongnum=*p++&(~0UL<

4、ize-((long)p-(long)vaddr)*8);returnoffset+res;}一、__cpu_set(2人)(kernelcpumask.h)staticinlinevoid__cpu_set(intcpu,volatilecpumask_t*dstp){set_bit(cpu,dstp->bits);}二、__cpu_clear(2人)staticinlinevoid__cpu_clear(intcpu,volatilecpumask_t*dstp){clear_bit(cpu,ds

5、tp->bits);}三、virt_to_phys(2人)staticinlineunsignedlongvirt_to_phys(volatilevoid*address){return__pa((void*)address);}staticinlinevoid*phys_to_virt(unsignedlongaddress){return__va(address);}四、smp_alloc_memory(2人)/**Wearecalledveryearlytogetthelowmemoryfort

6、he*SMPbootuptrampolinepage.*/void__initsmp_alloc_memory(void){trampoline_base=(void*)alloc_bootmem_low_pages(PAGE_SIZE);/**Hastobeinverylowmemorysowecanexecute*real-modeAPcode.*/if(__pa(trampoline_base)>=0x9F000)BUG();/**MaketheSMPtrampolineexecutable:*/

7、trampoline_exec=set_kernel_exec((unsignedlong)trampoline_base,1);}一、current_thread_info(2人)来自#definesmp_processor_id()raw_smp_processor_id()—(smp.h)/*Returnathread_infostruct.*/staticinlinestructthread_info*current_thread_info(void){structthread_info*ti;

8、__asm____volatile__("and.d$sp,%0":"=r"(ti):"0"(~8191UL));returnti;}二、cpu_idle(2人)(kernelprocess.c)Voidcpu_idle(void){set_thread_flag(TIF_POLLING_NRFLAG);while(1){/*FIXME--EV6andLCA45knowhowtopowerdowntheCPU.*/while(!need_

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。