head.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. // 这是内核执行头程序
  2. // Created by longjin.
  3. // 2022/01/20
  4. #include "common/asm.h"
  5. // 以下是来自 multiboot2 规范的定义
  6. // How many bytes from the start of the file we search for the header.
  7. #define MULTIBOOT_SEARCH 32768
  8. #define MULTIBOOT_HEADER_ALIGN 8
  9. // The magic field should contain this.
  10. #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
  11. // This should be in %eax.
  12. #define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
  13. // Alignment of multiboot modules.
  14. #define MULTIBOOT_MOD_ALIGN 0x00001000
  15. // Alignment of the multiboot info structure.
  16. #define MULTIBOOT_INFO_ALIGN 0x00000008
  17. // Flags set in the 'flags' member of the multiboot header.
  18. #define MULTIBOOT_TAG_ALIGN 8
  19. #define MULTIBOOT_TAG_TYPE_END 0
  20. #define MULTIBOOT_TAG_TYPE_CMDLINE 1
  21. #define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
  22. #define MULTIBOOT_TAG_TYPE_MODULE 3
  23. #define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
  24. #define MULTIBOOT_TAG_TYPE_BOOTDEV 5
  25. #define MULTIBOOT_TAG_TYPE_MMAP 6
  26. #define MULTIBOOT_TAG_TYPE_VBE 7
  27. #define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
  28. #define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
  29. #define MULTIBOOT_TAG_TYPE_APM 10
  30. #define MULTIBOOT_TAG_TYPE_EFI32 11
  31. #define MULTIBOOT_TAG_TYPE_EFI64 12
  32. #define MULTIBOOT_TAG_TYPE_SMBIOS 13
  33. #define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
  34. #define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
  35. #define MULTIBOOT_TAG_TYPE_NETWORK 16
  36. #define MULTIBOOT_TAG_TYPE_EFI_MMAP 17
  37. #define MULTIBOOT_TAG_TYPE_EFI_BS 18
  38. #define MULTIBOOT_TAG_TYPE_EFI32_IH 19
  39. #define MULTIBOOT_TAG_TYPE_EFI64_IH 20
  40. #define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21
  41. #define MULTIBOOT_HEADER_TAG_END 0
  42. #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
  43. #define MULTIBOOT_HEADER_TAG_ADDRESS 2
  44. #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
  45. #define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
  46. #define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
  47. #define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
  48. #define MULTIBOOT_HEADER_TAG_EFI_BS 7
  49. #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
  50. #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
  51. #define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
  52. #define MULTIBOOT_ARCHITECTURE_I386 0
  53. #define MULTIBOOT_ARCHITECTURE_MIPS32 4
  54. #define MULTIBOOT_HEADER_TAG_OPTIONAL 1
  55. #define MULTIBOOT_LOAD_PREFERENCE_NONE 0
  56. #define MULTIBOOT_LOAD_PREFERENCE_LOW 1
  57. #define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
  58. #define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
  59. #define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
  60. // 直接用 -m64 编译出来的是 64 位代码,
  61. // 但是启动后的机器是 32 位的,相当于在 32 位机器上跑 64 位程序。
  62. // 得加一层跳转到 64 位的 -m32 代码,开启 long 模式后再跳转到以 -m64 编译的代码中
  63. // 对于 x86_64,需要在启动阶段进入长模式(IA32E),这意味着需要一个临时页表
  64. // See https://wiki.osdev.org/Creating_a_64-bit_kernel:
  65. // With a 32-bit bootstrap in your kernel
  66. // 这部分是从保护模式启动 long 模式的代码
  67. // 工作在 32bit
  68. // 声明这一段代码以 32 位模式编译
  69. .code32
  70. // multiboot2 文件头
  71. // 计算头长度
  72. .SET HEADER_LENGTH, multiboot_header_end - multiboot_header
  73. // 计算校验和
  74. .SET CHECKSUM, -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + HEADER_LENGTH)
  75. // 8 字节对齐
  76. .section .multiboot_header
  77. .align MULTIBOOT_HEADER_ALIGN
  78. // 声明所属段
  79. multiboot_header:
  80. // 魔数
  81. .long MULTIBOOT2_HEADER_MAGIC
  82. // 架构
  83. .long MULTIBOOT_ARCHITECTURE_I386
  84. // 头长度
  85. .long HEADER_LENGTH
  86. // 校验和
  87. .long CHECKSUM
  88. // 添加其它内容在此,详细信息见 Multiboot2 Specification version 2.0.pdf
  89. // 设置帧缓冲区
  90. .align 8
  91. framebuffer_tag_start:
  92. .short MULTIBOOT_HEADER_TAG_FRAMEBUFFER
  93. .short MULTIBOOT_HEADER_TAG_OPTIONAL
  94. .long framebuffer_tag_end - framebuffer_tag_start
  95. .long 1440
  96. .long 900
  97. .long 32
  98. framebuffer_tag_end:
  99. .align 8
  100. .short MULTIBOOT_HEADER_TAG_END
  101. // 结束标记
  102. .short 0
  103. .long 8
  104. multiboot_header_end:
  105. .section .bootstrap
  106. .global _start
  107. .type _start, @function
  108. # 在 multiboot2.cpp 中定义
  109. .extern _start64
  110. .extern boot_info_addr
  111. .extern multiboot2_magic
  112. ENTRY(_start)
  113. // 关中断
  114. cli
  115. // multiboot2_info 结构体指针
  116. mov %ebx, mb2_info
  117. //mov %ebx, %e8
  118. // 魔数
  119. mov %eax, mb2_magic
  120. //mov %eax, %e9
  121. / 从保护模式跳转到长模式
  122. // 1. 允许 PAE
  123. mov %cr4, %eax
  124. or $(1<<5), %eax
  125. mov %eax, %cr4
  126. // 2. 设置临时页表
  127. // 最高级
  128. mov $pml4, %eax
  129. mov $pdpt, %ebx
  130. or $0x3, %ebx
  131. mov %ebx, 0(%eax)
  132. // 次级
  133. mov $pdpt, %eax
  134. mov $pd, %ebx
  135. or $0x3, %ebx
  136. mov %ebx, 0(%eax)
  137. // 次低级
  138. mov $pd, %eax
  139. mov $pt, %ebx
  140. or $0x3, %ebx
  141. mov %ebx, 0(%eax)
  142. // 最低级
  143. // 循环 512 次,填满一页
  144. mov $512, %ecx
  145. mov $pt, %eax
  146. mov $0x3, %ebx
  147. .fill_pt:
  148. mov %ebx, 0(%eax)
  149. add $0x1000, %ebx
  150. add $8, %eax
  151. loop .fill_pt
  152. .global enter_head_from_ap_boot
  153. enter_head_from_ap_boot:
  154. // 填写 CR3
  155. mov $pml4, %eax
  156. mov %eax, %cr3
  157. // 3. 切换到 long 模式
  158. mov $0xC0000080, %ecx
  159. rdmsr
  160. or $(1<<8), %eax
  161. wrmsr
  162. // 4. 开启分页
  163. mov %cr0, %eax
  164. or $(1<<31), %eax
  165. mov %eax, %cr0
  166. // 5. 重新设置 GDT
  167. mov $gdt64_pointer, %eax
  168. lgdt 0(%eax)
  169. jmp $0x8, $ready_to_start_64
  170. hlt
  171. ret
  172. .code64
  173. .global ready_to_start_64
  174. ready_to_start_64:
  175. mov $0x10, %ax
  176. mov %ax, %ds
  177. mov %ax, %es
  178. mov %ax, %fs
  179. mov %ax, %ss
  180. mov $0x7e00, %esp
  181. //6. 跳转到start64
  182. movq switch_to_start64(%rip), %rax
  183. pushq $0x08 //段选择子
  184. pushq %rax
  185. lretq
  186. switch_to_start64:
  187. .quad _start64
  188. .code64
  189. is_from_ap:
  190. hlt
  191. .global _start64
  192. .type _start64, @function
  193. .extern Start_Kernel
  194. ENTRY(_start64)
  195. // 初始化寄存器
  196. mov $0x10, %ax
  197. mov %ax, %ds
  198. mov %ax, %es
  199. mov %ax, %fs
  200. mov %ax, %ss
  201. mov $0x7e00, %esp
  202. // === 加载GDTR ====
  203. lgdt GDT_POINTER(%rip) //这里我没搞明白rip相对寻址, 看了文档,大概是用来实现PIC的(position independent code)
  204. //lgdt $GDT_POINTER
  205. // === 加载IDTR ====
  206. lidt IDT_POINTER(%rip)
  207. //lidt $IDT_POINTER
  208. movq GDT_POINTER(%rip), %r12
  209. movq head_stack_start(%rip), %rsp
  210. // 分支,判断是否为apu
  211. movq $0x1b, %rcx // 根据IA32_APIC_BASE.BSP[8]标志位判断处理器是否为apu
  212. rdmsr
  213. bt $8, %rax
  214. jnc load_cr3
  215. // 2. 设置临时页表
  216. // 最高级
  217. mov $__PML4E, %eax
  218. mov $__PDPTE, %ebx
  219. or $0x3, %ebx
  220. mov %ebx, 0(%eax)
  221. mov %ebx, 256(%eax)
  222. // 次级
  223. mov $__PDPTE, %eax
  224. mov $__PDE, %ebx
  225. or $0x3, %ebx
  226. mov %ebx, 0(%eax)
  227. // ==== 加载CR3寄存器
  228. load_cr3:
  229. movq $__PML4E, %rax //设置页目录基地址
  230. movq %rax, %cr3
  231. movq switch_seg(%rip), %rax
  232. // 由于ljmp和lcall在GAS中不受支持,因此我们需要先伪造函数调用现场,通过lret的方式,给它跳转过去。才能更新cs寄存器
  233. // 实在是太妙了!Amazing!
  234. pushq $0x08 //段选择子
  235. pushq %rax
  236. lretq
  237. // 64位模式的代码
  238. switch_seg:
  239. .quad entry64
  240. entry64:
  241. movq $0x10, %rax
  242. movq %rax, %ds
  243. movq %rax, %es
  244. movq %rax, %gs
  245. movq %rax, %ss
  246. movq head_stack_start(%rip), %rsp //rsp的地址
  247. // 重新加载GDT和IDT,加载到高地址
  248. leaq GDT_Table(%rip), %r8
  249. leaq GDT_END(%rip), %r9
  250. subq %r8, %r9
  251. movq %r9, %r13 // GDT size
  252. leaq IDT_Table(%rip), %r8
  253. leaq IDT_END(%rip), %r9
  254. subq %r8, %r9
  255. movq %r9, %r12 // IDT size
  256. lgdt GDT_POINTER64(%rip)
  257. lidt IDT_POINTER64(%rip)
  258. // 分支,判断是否为apu
  259. movq $0x1b, %rcx // 根据IA32_APIC_BASE.BSP[8]标志位判断处理器是否为apu
  260. rdmsr
  261. bt $8, %rax
  262. jnc start_smp
  263. setup_IDT:
  264. // 该部分代码只在启动初期使用,后面的c文件中会重新设置IDT,
  265. leaq m_ignore_int(%rip), %rdx // 将ignore_int的地址暂时存到中段描述符的高8B
  266. movq $(0x08 << 16), %rax // 设置段选择子。由IDT结构和段选择子结构可知,本行设置段基地址为0x100000,TI=0,RPL=0
  267. movw %dx, %ax
  268. movq $ (0x8e00 << 32), %rcx // 设置Type=1110 P=1 DPL=00 0=0
  269. addq %rcx, %rax
  270. // 把ignore_int的地址填写到正确位置, rax存低8B, rdx存高8B
  271. movl %edx, %ecx
  272. shrl $16, %ecx // 去除低16位
  273. shlq $48, %rcx
  274. addq %rcx, %rax // 填写段内偏移31:16
  275. shrq $32, %rdx // (已经填写了32位,故右移32)
  276. leaq IDT_Table(%rip), %rdi // 获取中断描述符表的首地址,存储到rdi
  277. mov $256, %rcx // 初始化每个中断描述符
  278. repeat_set_idt:
  279. // ====== 循环,初始化总共256个中断描述符 ===
  280. movq %rax, (%rdi) // 保存低8B
  281. movq %rdx, 8(%rdi) // 保存高8B
  282. addq $0x10, %rdi // 转到下一个IDT表项
  283. dec %rcx
  284. jne repeat_set_idt
  285. SetUp_TSS64:
  286. // == 设置64位的任务状态段表 ===
  287. //rdx保存高8B, rax保存低8B
  288. leaq TSS64_Table(%rip), %rdx // 获取定义在process.c中的initial_tss[0]的地址
  289. movq $0xffff800000000000, %r8
  290. addq %r8, %rdx
  291. xorq %rax, %rax
  292. xorq %rcx, %rcx
  293. // 设置TSS描述符的47:40位为1000 1001
  294. movq $0x89, %rax
  295. shlq $40, %rax
  296. // 设置段基地址31:24
  297. movl %edx, %ecx
  298. shrl $24, %ecx
  299. shlq $56, %rcx
  300. addq %rcx, %rax
  301. xorq %rcx, %rcx
  302. // 设置段基地址23:00
  303. movl %edx, %ecx
  304. andl $0xffffff, %ecx // 清空ecx的中有效值的高8位(也就是上面已经赋值了的)
  305. shlq $16, %rcx
  306. addq %rcx, %rax
  307. addq $103, %rax // 设置段长度
  308. leaq GDT_Table(%rip), %rdi
  309. movq %rax, 80(%rdi) // 把低八B存储到GDT第10项
  310. shrq $32, %rdx
  311. movq %rdx, 88(%rdi) // 高8B存到GDT第11项
  312. // 装载任务状态段寄存器(已改为在main.c中使用load_TR宏进行装载)
  313. // mov $0x50, %ax // 设置起始地址为80
  314. // ltr %ax
  315. //now enable SSE and the like
  316. movq %cr0, %rax
  317. and $0xFFFB, %ax //clear coprocessor emulation CR0.EM
  318. or $0x2, %ax //set coprocessor monitoring CR0.MP
  319. movq %rax, %cr0
  320. movq %cr4, %rax
  321. or $(3 << 9), %ax //set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
  322. movq %rax, %cr4
  323. movq go_to_kernel(%rip), %rax /* movq address */
  324. pushq $0x08
  325. pushq %rax
  326. movq mb2_info, %r15
  327. movq mb2_magic, %r14
  328. lretq
  329. go_to_kernel:
  330. .quad Start_Kernel
  331. start_smp:
  332. //now enable SSE and the like
  333. movq %cr0, %rax
  334. and $0xFFFB, %ax //clear coprocessor emulation CR0.EM
  335. or $0x2, %ax //set coprocessor monitoring CR0.MP
  336. movq %rax, %cr0
  337. movq %cr4, %rax
  338. or $(3 << 9), %ax //set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
  339. movq %rax, %cr4
  340. movq go_to_smp_kernel(%rip), %rax /* movq address */
  341. pushq $0x08
  342. pushq %rax
  343. /*
  344. // 重新加载GDT和IDT,加载到高地址
  345. leaq GDT_Table(%rip), %r8
  346. leaq GDT_END(%rip), %r9
  347. subq %r8, %r9
  348. movq %r9, %r13 // GDT size
  349. leaq IDT_Table(%rip), %r8
  350. leaq IDT_END(%rip), %r9
  351. subq %r8, %r9
  352. movq %r9, %r12 // IDT size
  353. lgdt GDT_POINTER64(%rip)
  354. lidt IDT_POINTER64(%rip)
  355. */
  356. lretq
  357. go_to_smp_kernel:
  358. .quad smp_ap_start
  359. // ==== 异常/中断处理模块 ignore int: 忽略中断
  360. // (该部分代码只在启动初期使用,后面的c文件中会重新设置IDT,从而重设ignore_int的中断入点)
  361. m_ignore_int:
  362. // 切换到c语言的ignore_int
  363. movq go_to_ignore_int(%rip), %rax
  364. pushq $0x08
  365. pushq %rax
  366. lretq
  367. go_to_ignore_int:
  368. .quad ignore_int_handler
  369. ENTRY(head_stack_start)
  370. .quad initial_proc_union + 32768
  371. // 初始化页表
  372. .align 0x1000 //设置为4k对齐
  373. //.org 0x1000 //设置页表位置为内核执行头程序的0x1000处
  374. __PML4E:
  375. .quad 0x103007 // 用户访问,可读写,已存在, 地址在31~12位
  376. .fill 255,8,0
  377. .quad 0x103003
  378. .fill 255,8,0
  379. .org 0x2000
  380. __PDPTE:
  381. .quad 0x104003 // 用户访问,可读写,已存在
  382. .fill 511,8,0
  383. .org 0x3000
  384. __PDE:
  385. .quad 0x000083 // 用户访问,可读写,已存在
  386. .quad 0x200083
  387. .quad 0x400083
  388. .quad 0x600083
  389. .quad 0x800083
  390. .quad 0xa00083
  391. .quad 0xc00083
  392. .quad 0xe00083
  393. .quad 0x1000083
  394. .quad 0x1200083
  395. .quad 0x1400083
  396. .quad 0x1600083
  397. .quad 0x1800083
  398. .quad 0x1a00083
  399. .quad 0x1c00083
  400. .quad 0x1e00083
  401. .quad 0x2000083
  402. .quad 0x2200083
  403. .quad 0x2400083
  404. .quad 0x2600083
  405. .quad 0x2800083
  406. .quad 0x2a00083
  407. .quad 0x2c00083
  408. .quad 0x2e00083
  409. .quad 0x3000083
  410. .quad 0x3200083
  411. .quad 0x3400083
  412. .quad 0x3600083
  413. .quad 0xe0000083 /*虚拟地址0x 3000000 初始情况下,帧缓冲区映射到这里*/
  414. .quad 0xe0200083
  415. .quad 0xe0400083
  416. .quad 0xe0600083 /*0x1000000*/
  417. .quad 0xe0800083
  418. .quad 0xe0a00083
  419. .quad 0xe0c00083
  420. .quad 0xe0e00083
  421. .quad 0xe1000083
  422. .quad 0xe1200083
  423. .quad 0xe1400083
  424. .quad 0xe1600083
  425. .quad 0xe1800083
  426. .quad 0xe1a00083
  427. .quad 0xe1c00083
  428. .quad 0xe1e00083
  429. .fill 468,8,0
  430. // GDT表
  431. .align 16
  432. .global GDT_Table // 使得GDT可以被外部程序引用或者访问
  433. GDT_Table:
  434. .quad 0x0000000000000000 // 0 空描述符 0x00
  435. .quad 0x0020980000000000 // 1 内核64位代码段描述符 0x08
  436. .quad 0x0000920000000000 // 2 内核64位数据段描述符 0x10
  437. .quad 0x0000000000000000 // 3 用户32位代码段描述符 0x18
  438. .quad 0x0000000000000000 // 4 用户32位数据段描述符 0x20
  439. .quad 0x0020f80000000000 // 5 用户64位代码段描述符 0x28
  440. .quad 0x0000f20000000000 // 6 用户64位数据段描述符 0x30
  441. .quad 0x00cf9a000000ffff // 7 内核32位代码段描述符 0x38
  442. .quad 0x00cf92000000ffff // 8 内核32位数据段描述符 0x40
  443. .fill 100, 8, 0 // 10-11 TSS(跳过了第9段) 重复十次填充8字节的空间,赋值为0 长模式下,每个TSS长度为128bit
  444. GDT_END:
  445. .global GDT_POINTER
  446. GDT_POINTER:
  447. GDT_LIMIT: .word GDT_END - GDT_Table - 1 // GDT的大小
  448. GDT_BASE: .quad GDT_Table
  449. .global GDT_POINTER64
  450. GDT_POINTER64:
  451. GDT_LIMIT64: .word GDT_END - GDT_Table - 1 // GDT的大小
  452. GDT_BASE64: .quad GDT_Table + 0xffff800000000000
  453. // IDT 表
  454. .global IDT_Table
  455. IDT_Table:
  456. .fill 512, 8, 0 // 设置512*8字节的IDT表的空间
  457. IDT_END:
  458. .global IDT_POINTER
  459. IDT_POINTER:
  460. IDT_LIMIT: .word IDT_END - IDT_Table - 1
  461. IDT_BASE: .quad IDT_Table
  462. .global IDT_POINTER64
  463. IDT_POINTER64:
  464. IDT_LIMIT64: .word IDT_END - IDT_Table - 1
  465. IDT_BASE64: .quad IDT_Table + 0xffff800000000000
  466. // 64位的TSS表
  467. .global TSS64_Table
  468. TSS64_Table:
  469. .fill 13, 8, 0
  470. TSS64_END:
  471. .section .bootstrap.data
  472. mb2_magic: .quad 0
  473. mb2_info: .quad 0
  474. .code32
  475. // 临时页表 4KB/页
  476. .align 0x1000
  477. .global pml4
  478. pml4:
  479. .skip 0x1000
  480. pdpt:
  481. .skip 0x1000
  482. pd:
  483. .skip 0x1000
  484. pt:
  485. .skip 0x1000
  486. // 临时 GDT
  487. .align 16
  488. gdt64:
  489. null_desc:
  490. .short 0xFFFF
  491. .short 0
  492. .byte 0
  493. .byte 0
  494. .byte 0
  495. .byte 0
  496. code_desc:
  497. .short 0
  498. .short 0
  499. .byte 0
  500. .byte 0x9A
  501. .byte 0x20
  502. .byte 0
  503. data_desc:
  504. .short 0
  505. .short 0
  506. .byte 0
  507. .byte 0x92
  508. .byte 0
  509. .byte 0
  510. user_code_desc:
  511. .short 0
  512. .short 0
  513. .byte 0
  514. .byte 0xFA
  515. .byte 0x20
  516. .byte 0
  517. user_data_desc:
  518. .short 0
  519. .short 0
  520. .byte 0
  521. .byte 0xF2
  522. .byte 0
  523. .byte 0
  524. gdt64_pointer:
  525. .short gdt64_pointer-gdt64-1
  526. .quad gdt64
  527. gdt64_pointer64:
  528. .short gdt64_pointer-gdt64-1
  529. .quad gdt64