1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Push struct cpu_info */
.macro push_cpu_info index=$0
push \index /* index */
push $0 /* *cpu */
.endm
/* Push struct per_cpu_segment_data */
.macro push_per_cpu_segment_data cpu_info_pointer=%esp
push \cpu_info_pointer /* *cpu_info */
.endm
/*
* Sets the base address in the segment descriptor array.
*
* A segment descriptor has the following structure:
* struct {
* uint16_t segment_limit_0_15;
* uint16_t base_address_0_15;
* uint8_t base_address_16_23;
* uint8_t attrs[2];
* uint8_t base_address_24_31;
* };
*
* @desc_array: Address of the descriptor table
* @base: Address to set in the descriptor
* @desc_index: Index of the descriptor in the table. Defaults to 0. Must be a
* register if specified.
*
* Clobbers %eax, %ebx.
*/
.macro set_segment_descriptor_base desc_array:req, base:req, desc_index
mov \base, %eax
mov \desc_array, %ebx
.ifb \desc_index
movw %ax, 2(%ebx)
shr $16, %eax
movb %al, 4(%ebx)
shr $8, %eax
movb %al, 7(%ebx)
.else
movw %ax, 2(%ebx, \desc_index, 8)
shr $16, %eax
movb %al, 4(%ebx, \desc_index, 8)
shr $8, %eax
movb %al, 7(%ebx, \desc_index, 8)
.endif
.endm
|