decompress kernel

arch/i386/boot/compress/head.S is responsible for decompressed the kernel and move it to 0x100000. when it is executed, the virtual address is 0x1000 for low loaded vmlinux and 0x100000 for high loaded one, which are the same with their physical addresses, respectively.

 

/* check contents of 0x000000 and 0x100000, if not equal, means A20 is enabled. */

  xorl %eax,%eax
1: incl %eax  # check that A20 really IS enabled
  movl %eax,0x000000 # loop forever if it isn't
  cmpl %eax,0x100000
  je 1

 

/* decompress the kernel and jump to it (0x100000) for low loaded kernel */

 subl $16,%esp # place for structure on the stack
 pushl %esp # address of structure as first arg
 call SYMBOL_NAME(decompress_kernel)
 orl  %eax,%eax
 jnz  3f
 xorl %ebx,%ebx
 ljmp $(__KERNEL_CS), $0x10000

 

/* move move_routine_start to 0x1000 and jump to it */

 movl $move_routine_start,%esi
 movl $0x1000,%edi
 movl $move_routine_end,%ecx
 subl %esi,%ecx
 cld
 rep
 movs

 

 popl %esi # discard the address
 popl %esi # low_buffer_start
 popl %ecx # lcount
 popl %edx # high_buffer_start
 popl %eax # hcount
 movl $0x100000,%edi
 cli  # make sure we don't get interrupted
 ljmp $(__KERNEL_CS), $0x1000 # and jump to the move routine

 

/* move hcount from high_buffer_start to 0x100000 and jump to it for high loaded kernel */

move_routine_start:
 rep
 movsb
 movl %edx,%esi
 movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0
 rep
 movsb
 xorl %ebx,%ebx
/*
 * Well, the kernel relies on %esp pointing into low mem,
 * with the decompressor loaded high this is no longer true,
 * so we set esp here.
 */
 mov  $0x90000,%esp
 ljmp $(__KERNEL_CS), $0x100000
move_routine_end:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值