blob: 825c23ccbd561865a9d9dff546bf9f4a19b31c3d [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi11f00792020-03-04 15:10:45 +01002
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -07003.code32
Kyösti Mälkki7522a8f2020-11-20 16:47:38 +02004
5.section .init, "ax", @progbits
6
7.section .init._gdt_, "ax", @progbits
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -07008
9 .globl gdt_init
10gdt_init:
11 lgdt %cs:gdtptr
12 ret
13
14.previous
15 .align 4
16.globl gdtptr
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -070017gdtptr:
18 .word gdt_end - gdt -1 /* compute the table limit */
19 .long gdt /* we know the offset */
Patrick Rudolph4e8dee52019-03-03 17:58:54 +010020
Patrick Rudolphadcf7822020-08-27 20:50:18 +020021#if ENV_X86_64
Patrick Rudolph8daa12f2018-12-26 15:12:32 +010022.code64
Kyösti Mälkki7522a8f2020-11-20 16:47:38 +020023.section .init._gdt64_, "ax", @progbits
Patrick Rudolph8daa12f2018-12-26 15:12:32 +010024 .globl gdt_init64
25gdt_init64:
Patrick Rudolph29ed4f52020-07-05 08:46:55 +020026 movabs $gdtptr64, %rax
27 lgdt (%rax)
Patrick Rudolph8daa12f2018-12-26 15:12:32 +010028 ret
29
30.previous
31 .align 4
32.globl gdtptr64
33gdtptr64:
34 .word gdt_end - gdt -1 /* compute the table limit */
35 .quad gdt /* we know the offset */
36#endif
37
Patrick Rudolph4e8dee52019-03-03 17:58:54 +010038 .align 4
39gdt:
40 /* selgdt 0, unused */
41 .word 0x0000, 0x0000 /* dummy */
42 .byte 0x00, 0x00, 0x00, 0x00
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -070043
44 /* selgdt 0x08, flat code segment */
45 .word 0xffff, 0x0000
46 .byte 0x00, 0x9b, 0xcf, 0x00 /* G=1 and 0x0f, So we get 4Gbytes
47 for limit */
48
49 /* selgdt 0x10,flat data segment */
50 .word 0xffff, 0x0000
51 .byte 0x00, 0x93, 0xcf, 0x00
52
53 /* selgdt 0x18, flat code segment (64-bit) */
54 .word 0xffff, 0x0000
55 .byte 0x00, 0x9b, 0xaf, 0x00
56
57gdt_end: