IA-32结构c语言描述

/*
 64位段描述符伪代码;
*/
typedef struct {
    unsigned  int  base24_31:8;    /* 基地址的最高8位 */
    unsigned  int  g:1;    /* granularity表段长度单位,0字节,1表示 4KB */
    unsigned  int  d_b:1;  /* default operation size 存取方式0=16 ??1=32 ? */
    unsigned  int  unused:1;           /* 为0 */
    unsigned  int  avl:1;              /* avalaible供系统使用 */
    unsigned  int  seg_limit_16_19:4;  /* 段长度的最高4位 */
    unsigned  int  p:1;    /* segment present0表示该段不在内存中 */
    unsigned  int  dpl:2;  /* Descriptor privilege level特权级 */
    unsigned  int  s:1;                /* 类型,1表示系统,0表示代码或数据 */
    unsigned  int  type:4;             /* 段的类型, */
    unsigned  int  base_0_23:24;       /* 基地址低24 位 */
    unsigned  int  seg_limit_0_15:16;  /* 段长度低16位 */
};
/*
 16位段寄存器
*/
typedef struct {
    unsigned  short seg_idx:13;  /* 13段描述项下标 */
    unsigned  short ti:1;          /* 类型,1为LDT,0为GDT */
    unsigned  short rpl:2;        /* 请求特权级别, */
};
寻址:先用GDTR中的基址找到相应描述符表,然后使用16位寄存器中的下标找到描述符项;
/*
 页式内存管理的线性地址结构
*/
typedef struct {
    unsigned  int  dir:10;     /* 页目录表 */
    unsigned  int  page:10;    /* 二级页表 */
    unsigned  int  offset:12;  /* 二级页表中的偏移 */
};
线性地址转物理地址:从CR3中取页目录基址,以dir为下标指出二级页表位置,以page为下标指出页面描述符,
          用页面描述符中的基址+offset,即物理地址
/*
 页目录结构
*/
typedef struct {
    unsigned  int  ptba:20;        /* 二级页表基地址的高20位 */
    unsigned  int  avail:3;        /* 系统使用 */
    unsigned  int  g:1;            /* 全局性页面 */
    unsigned  int  ps:1;           /* 页面大小,0==4K */
    unsigned  int  reserved:1;    /*  */
    unsigned  int  a:1;            /* 已被访问过 */
    unsigned  int  pcd:1;          /* 不使用缓冲存储器 */
    unsigned  int  pwt:1;          /* 用于缓冲 */
    unsigned  int  u_s:1;          /* 0系统权限,1用户权限 */
    unsigned  int  r_w:1;          /* 只读或只写 */
    unsigned  int  p:1;            /* 为0时表示相应的页面不在内存中 */
};

 

 

//reactos定义tss

typedef struct _KTSS

{

    USHORT Backlink;/*前一个任务链接域,允许用iret返回到这个任务*/

    USHORT Reserved0;

    ULONG Esp0;/*栈中偏移*/

    USHORT Ss0;/*nt内核只有两个特权极,所以这里只定义了特权级0的栈*/

    USHORT Reserved1;

    ULONG NotUsed1[4];

    ULONG CR3;/*页表目录基址*/

    ULONG Eip;/*任务切换前eip*/

    ULONG EFlags;/*eflags寄存器*/

    ULONG Eax;/*通用寄存器*/

    ULONG Ecx;

    ULONG Edx;

    ULONG Ebx;

    ULONG Esp;

    ULONG Ebp;

    ULONG Esi;

    ULONG Edi;/*通用寄存器*/

    USHORT Es;/*段选择子*/

    USHORT Reserved2;

    USHORT Cs;/*段选择子*/

    USHORT Reserved3;

    USHORT Ss;/*段选择子*/

    USHORT Reserved4;

    USHORT Ds;/*段选择子*/

    USHORT Reserved5;

    USHORT Fs;/*段选择子*/

    USHORT Reserved6;

    USHORT Gs;/*段选择子*/

    USHORT Reserved7;

    USHORT LDT;/*LDT段选择子*/

    USHORT Reserved8;

    USHORT Flags;

    USHORT IoMapBase;/*I/O位置基地址域*/

    KIIO_ACCESS_MAP IoMaps[1];

    UCHAR IntDirectionMap[32];

} KTSS, *PKTSS;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值