trampoline.S
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *
  3.  * Trampoline.S Derived from Setup.S by Linus Torvalds
  4.  *
  5.  * 4 Jan 1997 Michael Chastain: changed to gnu as.
  6.  *
  7.  * Entry: CS:IP point to the start of our code, we are 
  8.  * in real mode with no stack, but the rest of the 
  9.  * trampoline page to make our stack and everything else
  10.  * is a mystery.
  11.  *
  12.  * In fact we don't actually need a stack so we don't
  13.  * set one up.
  14.  *
  15.  * We jump into the boot/compressed/head.S code. So you'd
  16.  * better be running a compressed kernel image or you
  17.  * won't get very far.
  18.  *
  19.  * On entry to trampoline_data, the processor is in real mode
  20.  * with 16-bit addressing and 16-bit data.  CS has some value
  21.  * and IP is zero.  Thus, data addresses need to be absolute
  22.  * (no relocation) and are taken with regard to r_base.
  23.  *
  24.  * If you work on this file, check the object module with objdump
  25.  * --full-contents --reloc to make sure there are no relocation
  26.  * entries except for the gdt one..
  27.  */
  28. #include <linux/linkage.h>
  29. #include <asm/segment.h>
  30. #include <asm/page.h>
  31. .data
  32. .code16
  33. ENTRY(trampoline_data)
  34. r_base = .
  35. wbinvd # Needed for NUMA-Q should be harmless for others
  36. mov %cs, %ax # Code and data in the same place
  37. mov %ax, %ds
  38. mov $1, %bx # Flag an SMP trampoline
  39. cli # We should be safe anyway
  40. movl $0xA5A5A5A5, trampoline_data - r_base
  41. # write marker for master knows we're running
  42. lidt idt_48 - r_base # load idt with 0, 0
  43. lgdt gdt_48 - r_base # load gdt with whatever is appropriate
  44. xor %ax, %ax
  45. inc %ax # protected mode (PE) bit
  46. lmsw %ax # into protected mode
  47. jmp flush_instr
  48. flush_instr:
  49. ljmpl $__KERNEL_CS, $0x00100000
  50. # jump to startup_32 in arch/i386/kernel/head.S
  51. idt_48:
  52. .word 0 # idt limit = 0
  53. .word 0, 0 # idt base = 0L
  54. gdt_48:
  55. .word 0x0800 # gdt limit = 2048, 256 GDT entries
  56. .long gdt_table-__PAGE_OFFSET # gdt base = gdt (first SMP CPU)
  57. .globl SYMBOL_NAME(trampoline_end)
  58. SYMBOL_NAME_LABEL(trampoline_end)