zoukankan      html  css  js  c++  java
  • 精彩代码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

  • 相关阅读:
    Elasticsearch聚合 之 Date Histogram聚合
    Elasticsearch聚合 之 Terms
    Elasticsearch分析聚合
    mysql-聚合函数
    flask学习笔记(-操作数据库)
    在VS中调试javascript脚本
    jquery获取设置input值
    jquery后加Dom绑定事件
    Juicer——a fast template engine
    ASP.NET 一般处理程序
  • 原文地址:https://www.cnblogs.com/caesarxu/p/3254357.html
Copyright © 2011-2022 走看看