免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1494 | 回复: 0
打印 上一主题 下一主题

[内核入门] 线性基地址,线性地址是不是同一个概念呢 [复制链接]

论坛徽章:
4
丑牛
日期:2014-01-11 15:11:12亥猪
日期:2014-12-15 22:19:092015年辞旧岁徽章
日期:2015-03-03 16:54:152015年亚洲杯之约旦
日期:2015-03-13 19:45:11
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-10-20 09:45 |只看该作者 |倒序浏览
在GDTR中存放有32位的线性基地址,在下面这段代码中是用红色字体标注出来计算的,这里的线性基地址
该作何理解呢?
!        boot.s
!
! It then loads the system at 0x10000, using BIOS interrupts. Thereafter
! it disables all interrupts, changes to protected mode, and calls the

BOOTSEG = 0x07c0
SYSSEG  = 0x1000                        ! system loaded at 0x10000 (65536).
SYSLEN  = 17                                ! sectors occupied.

entry start
start:
        jmpi        go,#BOOTSEG
go:        mov        ax,cs
        mov        ds,ax
        mov        ss,ax
        mov        sp,#0x400                ! arbitrary value >>512

! ok, we've written the message, now
load_system:
        mov        dx,#0x0000
        mov        cx,#0x0002
        mov        ax,#SYSSEG
        mov        es,ax
        xor        bx,bx
        mov        ax,#0x200+SYSLEN
        int         0x13
        jnc        ok_load
die:        jmp        die

! now we want to move to protected mode ...
ok_load:
        cli                        ! no interrupts allowed !
        mov        ax, #SYSSEG
        mov        ds, ax
        xor        ax, ax
        mov        es, ax
        mov        cx, #0x2000
        sub        si,si
        sub        di,di
        rep
        movw
        mov        ax, #BOOTSEG
        mov        ds, ax
        lidt        idt_48                ! load idt with 0,0
        lgdt        gdt_48                ! load gdt with whatever appropriate

! absolute address 0x00000, in 32-bit protected mode.
        mov        ax,#0x0001        ! protected mode (PE) bit
        lmsw        ax                ! This is it!
        jmpi        0,8                ! jmp offset 0 of segment 8 (cs)

gdt:        .word        0,0,0,0                ! dummy

        .word        0x07FF                ! 8Mb - limit=2047 (2048*4096=8Mb)
        .word        0x0000                ! base address=0x00000
        .word        0x9A00                ! code read/exec
        .word        0x00C0                ! granularity=4096, 386

        .word        0x07FF                ! 8Mb - limit=2047 (2048*4096=8Mb)
        .word        0x0000                ! base address=0x00000
        .word        0x9200                ! data read/write
        .word        0x00C0                ! granularity=4096, 386

idt_48: .word        0                ! idt limit=0
        .word        0,0                ! idt base=0L
gdt_48: .word        0x7ff                ! gdt limit=2048, 256 GDT entries
        .word        0x7c00+gdt,0        ! gdt base = 07xxx
.org 510
        .word   0xAA55
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP