• 精彩代码linux/include/asm/system.h


    00001 #define move_to_user_mode() 
    00002 __asm__ ("movl %%esp,%%eax
    	" 
    00003     "pushl $0x17
    	" 
    00004     "pushl %%eax
    	" 
    00005     "pushfl
    	" 
    00006     "pushl $0x0f
    	" 
    00007     "pushl $1f
    	" 
    00008     "iret
    " 
    //特权变换iret
    00009 "1: movl $0x17,%%eax " 00010 "movw %%ax,%%ds " 00011 "movw %%ax,%%es " 00012 "movw %%ax,%%fs " 00013 "movw %%ax,%%gs" 00014 :::"ax")
    //以上比较精彩部分2013-08-13
    00015 00016 #define sti() __asm__ ("sti"::) 00017 #define cli() __asm__ ("cli"::) 00018 #define nop() __asm__ ("nop"::) 00019 00020 #define iret() __asm__ ("iret"::) 00021 00022 #define _set_gate(gate_addr,type,dpl,addr) 00023 __asm__ ("movw %%dx,%%ax " 00024 "movw %0,%%dx " 00025 "movl %%eax,%1 " 00026 "movl %%edx,%2" 00027 : 00028 : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), 00029 "o" (*((char *) (gate_addr))), 00030 "o" (*(4+(char *) (gate_addr))), 00031 "d" ((char *) (addr)),"a" (0x00080000)) 00032 00033 #define set_intr_gate(n,addr) 00034 _set_gate(&idt[n],14,0,addr)
    //idt[] gdt[] 在汇编中有定义,c中是head.h(linux/include/linux/head.h)
    00035 00036 #define set_trap_gate(n,addr) 00037 _set_gate(&idt[n],15,0,addr) 00038 00039 #define set_system_gate(n,addr) 00040 _set_gate(&idt[n],15,3,addr)
    //以上4个#define 连着看
    00041 00042 #define _set_seg_desc(gate_addr,type,dpl,base,limit) { 00043 *(gate_addr) = ((base) & 0xff000000) | 00044 (((base) & 0x00ff0000)>>16) | 00045 ((limit) & 0xf0000) | 00046 ((dpl)<<13) | 00047 (0x00408000) | 00048 ((type)<<8); 00049 *((gate_addr)+1) = (((base) & 0x0000ffff)<<16) | 00050 ((limit) & 0x0ffff); } 00051 00052 #define _set_tssldt_desc(n,addr,type) 00053 __asm__ ("movw $104,%1 " 00054 "movw %%ax,%2 " 00055 "rorl $16,%%eax " 00056 "movb %%al,%3 " 00057 "movb $" type ",%4 " 00058 "movb $0x00,%5 " 00059 "movb %%ah,%6 " 00060 "rorl $16,%%eax" 00061 ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), 00062 "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) 00063 ) 00064 00065 #define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x89") 00066 #define set_ldt_desc(n,addr) _set_tssldt_desc(((char *) (n)),((int)(addr)),"0x82") 00067

    //代码出自linux 0.11  linux/include/asm/system.h

  • 相关阅读:
    SpringMVC请求静态资源
    Spring视图和视图解析器
    @ModelAttribute运行流程
    SpringMVC模型数据处理
    SpringMVC简单映射请求参数介绍
    队列和栈的问题
    非比较排序——计数排序、基数排序、桶排序
    递归
    对数器的使用
    常见的比较排序
  • 原文地址:https://www.cnblogs.com/caesarxu/p/3254357.html
Copyright © 2020-2023  润新知