debuggers.hg

view xen/arch/x86/boot/x86_64.S @ 22906:700ac6445812

Now add KDB to the non-kdb tree
author Mukesh Rathor
date Thu Feb 03 15:42:41 2011 -0800 (2011-02-03)
parents 924f54145fda
children
line source
1 .code64
3 /* Install relocated data selectors. */
4 lgdt gdt_descr(%rip)
5 mov $(__HYPERVISOR_DS64),%ecx
6 mov %ecx,%ds
7 mov %ecx,%es
8 mov %ecx,%fs
9 mov %ecx,%gs
10 mov %ecx,%ss
12 /* Enable full CR4 features. */
13 mov mmu_cr4_features(%rip),%rcx
14 mov %rcx,%cr4
16 mov stack_start(%rip),%rsp
17 or $(STACK_SIZE-CPUINFO_sizeof),%rsp
19 /* Reset EFLAGS (subsumes CLI and CLD). */
20 pushq $0
21 popf
23 /* Reload code selector. */
24 pushq $(__HYPERVISOR_CS64)
25 leaq 1f(%rip),%rax
26 pushq %rax
27 lretq
28 1: lidt idt_descr(%rip)
30 test %ebx,%ebx
31 jnz start_secondary
33 /* Initialise IDT with simple error defaults. */
34 leaq ignore_int(%rip),%rcx
35 movl %ecx,%eax
36 andl $0xFFFF0000,%eax
37 orl $0x00008E00,%eax
38 shlq $32,%rax
39 movl %ecx,%edx
40 andl $0x0000FFFF,%edx
41 orl $(__HYPERVISOR_CS64<<16),%edx
42 orq %rdx,%rax
43 shrq $32,%rcx
44 movl %ecx,%edx
45 leaq idt_table(%rip),%rdi
46 movl $256,%ecx
47 1: movq %rax,(%rdi)
48 movq %rdx,8(%rdi)
49 addq $16,%rdi
50 loop 1b
52 /* Pass off the Multiboot info structure to C land. */
53 mov multiboot_ptr(%rip),%edi
54 call __start_xen
55 ud2 /* Force a panic (invalid opcode). */
57 /* This is the default interrupt handler. */
58 int_msg:
59 .asciz "Unknown interrupt (cr2=%016lx)\n"
60 hex_msg:
61 .asciz " %016lx"
62 ignore_int:
63 SAVE_ALL
64 movq %cr2,%rsi
65 leaq int_msg(%rip),%rdi
66 xorl %eax,%eax
67 call printk
68 movq %rsp,%rbp
69 0: movq (%rbp),%rsi
70 addq $8,%rbp
71 leaq hex_msg(%rip),%rdi
72 xorl %eax,%eax
73 call printk
74 testq $0xff8,%rbp
75 jnz 0b
76 1: jmp 1b
79 /*** DESCRIPTOR TABLES ***/
81 .data
82 .align 8
83 multiboot_ptr:
84 .long 0
86 .word 0
87 gdt_descr:
88 .word LAST_RESERVED_GDT_BYTE
89 .quad boot_cpu_gdt_table - FIRST_RESERVED_GDT_BYTE
91 .word 0,0,0
92 idt_descr:
93 .word 256*16-1
94 .quad idt_table
96 ENTRY(stack_start)
97 .quad cpu0_stack
99 .section .data.page_aligned, "aw", @progbits
100 .align PAGE_SIZE, 0
101 ENTRY(boot_cpu_gdt_table)
102 .quad 0x0000000000000000 /* unused */
103 .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */
104 .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */
105 .quad 0x0000000000000000 /* reserved */
106 .quad 0x00cffa000000ffff /* 0xe023 ring 3 code, compatibility */
107 .quad 0x00cff2000000ffff /* 0xe02b ring 3 data */
108 .quad 0x00affa000000ffff /* 0xe033 ring 3 code, 64-bit mode */
109 .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */
110 .fill (PER_CPU_GDT_ENTRY - __HYPERVISOR_CS32 / 8 - 1), 8, 0
111 .quad 0x0000910000000000 /* per-CPU entry (limit == cpu) */
113 .align PAGE_SIZE, 0
114 /* NB. Even rings != 0 get access to the full 4Gb, as only the */
115 /* (compatibility) machine->physical mapping table lives there. */
116 ENTRY(boot_cpu_compat_gdt_table)
117 .quad 0x0000000000000000 /* unused */
118 .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */
119 .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */
120 .quad 0x00cfba000000ffff /* 0xe019 ring 1 code, compatibility */
121 .quad 0x00cfb2000000ffff /* 0xe021 ring 1 data */
122 .quad 0x00cffa000000ffff /* 0xe02b ring 3 code, compatibility */
123 .quad 0x00cff2000000ffff /* 0xe033 ring 3 data */
124 .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */
125 .fill (PER_CPU_GDT_ENTRY - __HYPERVISOR_CS32 / 8 - 1), 8, 0
126 .quad 0x0000910000000000 /* per-CPU entry (limit == cpu) */
127 .align PAGE_SIZE, 0