Subversion Repositories Kolibri OS

Rev

Rev 8150 | Rev 8284 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8150 Rev 8206
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2020. All rights reserved.      ;;
3
;; Copyright (C) KolibriOS team 2020. All rights reserved.      ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;; Version 2, or (at your option) any later version.            ;;
5
;; Version 2, or (at your option) any later version.            ;;
6
;;                                                              ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
8
 
9
format pe64 efi
9
format pe64 efi
10
entry main
10
entry main
11
 
11
 
12
section '.text' code executable readable
12
section '.text' code executable readable
13
 
13
 
14
include '../../struct.inc'
14
include '../../struct.inc'
15
include '../../macros.inc'
15
include '../../macros.inc'
16
include '../../const.inc'
16
include '../../const.inc'
17
 
17
 
18
purge DQ
18
purge DQ
19
include 'uefi64.inc'
19
include 'uefi64.inc'
20
 
20
 
21
MEMORY_MAP_SIZE = 0x4000
21
MEMORY_MAP_SIZE = 0x10000
22
GOP_BUFFER_SIZE = 0x100
22
GOP_BUFFER_SIZE = 0x100
23
LIP_BUFFER_SIZE = 0x100
23
LIP_BUFFER_SIZE = 0x100
24
FILE_BUFFER_SIZE = 0x1000
24
FILE_BUFFER_SIZE = 0x1000
25
 
25
 
26
KERNEL_BASE  =  0x10000
26
KERNEL_BASE  =  0x10000
27
RAMDISK_BASE = 0x100000
27
RAMDISK_BASE = 0x100000
28
 
28
 
29
CODE_32_SELECTOR = 8
29
CODE_32_SELECTOR = 8
30
DATA_32_SELECTOR = 16
30
DATA_32_SELECTOR = 16
31
CODE_64_SELECTOR = 24
31
CODE_64_SELECTOR = 24
32
 
32
 
33
; linux/arch/x86/include/uapi/asm/e820.h
33
; linux/arch/x86/include/uapi/asm/e820.h
34
E820_RAM       = 1
34
E820_RAM       = 1
35
E820_RESERVED  = 2
35
E820_RESERVED  = 2
36
E820_ACPI      = 3
36
E820_ACPI      = 3
37
E820_NVS       = 4
37
E820_NVS       = 4
38
E820_UNUSABLE  = 5
38
E820_UNUSABLE  = 5
39
E820_PMEM      = 7
39
E820_PMEM      = 7
40
 
40
 
41
load_file:
41
load_file:
42
virtual at rsp+8
42
virtual at rsp+8
43
  .root   dq ?
43
  .root   dq ?
44
  .name   dq ?
44
  .name   dq ?
45
  .buffer dq ?
45
  .buffer dq ?
46
  .size   dq ?
46
  .size   dq ?
47
  .fatal  dq ?
47
  .fatal  dq ?
48
end virtual
48
end virtual
49
 
-
 
50
        eficall [.root], EFI_FILE_PROTOCOL.Open, [.root], file_handle, \
49
        eficall [.root], EFI_FILE_PROTOCOL.Open, [.root], file_handle, \
51
                [.name], EFI_FILE_MODE_READ, 0
50
                [.name], EFI_FILE_MODE_READ, 0
52
        cmp     rax, EFI_SUCCESS
51
        test    eax, eax
53
        jz      @f
52
        jz      @f
54
        xor     eax, eax
53
        xor     eax, eax
55
        cmp     [.fatal], 1
54
        cmp     [.fatal], 1
56
        jnz     .done
55
        jnz     .done
57
        mov     rbx, [efi_table]
56
        mov     rbx, [efi_table]
58
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
57
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
59
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
58
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
60
                msg_error_open_file
59
                msg_error_open_file
61
        mov     rbx, [efi_table]
60
        mov     rbx, [efi_table]
62
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
61
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
63
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
62
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
64
                [.name]
63
                [.name]
65
        jmp     $
64
        jmp     $
66
@@:
65
@@:
67
 
66
 
68
        lea     rax, [.size]
67
        lea     rax, [.size]
69
        eficall [file_handle], EFI_FILE_PROTOCOL.Read, [file_handle], rax, \
68
        eficall [file_handle], EFI_FILE_PROTOCOL.Read, [file_handle], rax, \
70
                [.buffer]
69
                [.buffer]
71
        eficall [file_handle], EFI_FILE_PROTOCOL.Close, [file_handle]
70
        eficall [file_handle], EFI_FILE_PROTOCOL.Close, [file_handle]
72
        mov     rax, [.size]
71
        mov     rax, [.size]
73
.done:
72
.done:
-
 
73
        push    rax
-
 
74
        call    clearbuf
-
 
75
        mov     rdi, msg
-
 
76
        call    num2dec
-
 
77
        push    rbx
-
 
78
        mov     rbx, [efi_table]
-
 
79
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
80
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
81
                msg_file_size
-
 
82
        pop     rbx
-
 
83
        push    rbx
-
 
84
        mov     rbx, [efi_table]
-
 
85
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
86
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
-
 
87
        pop     rbx
-
 
88
        pop     rax
74
        ret     8*5
89
        ret     8*5
75
 
90
 
76
skip_whitespace:
91
skip_whitespace:
77
.next_char:
92
.next_char:
78
        cmp     byte[rsi], 0
93
        cmp     byte[rsi], 0
79
        jz      .done
94
        jz      .done
80
        cmp     byte[rsi], 0x20 ; ' '
95
        cmp     byte[rsi], 0x20 ; ' '
81
        jz      .whitespace
96
        jz      .whitespace
82
        cmp     byte[rsi], 9    ; '\t'
97
        cmp     byte[rsi], 9    ; '\t'
83
        jz      .whitespace
98
        jz      .whitespace
84
        jmp     .done
99
        jmp     .done
85
.whitespace:
100
.whitespace:
86
        inc     rsi
101
        inc     rsi
87
        jmp     .next_char
102
        jmp     .next_char
88
.done:
103
.done:
89
        ret
104
        ret
90
 
105
 
91
skip_until_newline:
106
skip_until_newline:
92
.next_char:
107
.next_char:
93
        cmp     byte[rsi], 0
108
        cmp     byte[rsi], 0
94
        jz      .done
109
        jz      .done
95
        cmp     byte[rsi], 0xd  ; '\r'
110
        cmp     byte[rsi], 0xd  ; '\r'
96
        jz      .done
111
        jz      .done
97
        cmp     byte[rsi], 0xa  ; '\n'
112
        cmp     byte[rsi], 0xa  ; '\n'
98
        jz      .done
113
        jz      .done
99
        inc     rsi
114
        inc     rsi
100
        jmp     .next_char
115
        jmp     .next_char
101
.done:
116
.done:
102
        ret
117
        ret
103
 
118
 
104
skip_newline:
119
skip_newline:
105
.next_char:
120
.next_char:
106
        cmp     byte[rsi], 0xd  ; '\r'
121
        cmp     byte[rsi], 0xd  ; '\r'
107
        jz      .newline
122
        jz      .newline
108
        cmp     byte[rsi], 0xa  ; '\n'
123
        cmp     byte[rsi], 0xa  ; '\n'
109
        jz      .newline
124
        jz      .newline
110
        jmp     .done
125
        jmp     .done
111
.newline:
126
.newline:
112
        inc     rsi
127
        inc     rsi
113
        jmp     .next_char
128
        jmp     .next_char
114
.done:
129
.done:
115
        ret
130
        ret
116
 
131
 
117
skip_line:
132
skip_line:
118
        call    skip_until_newline
133
        call    skip_until_newline
119
        call    skip_newline
134
        call    skip_newline
120
        ret
135
        ret
121
 
136
 
122
dec2bin:
137
dec2bin:
123
        mov     edx, 0
138
        mov     edx, 0
124
.next_char:
139
.next_char:
125
        movzx   eax, byte[rsi]
140
        movzx   eax, byte[rsi]
126
        test    eax, eax
141
        test    eax, eax
127
        jz      .done
142
        jz      .done
128
        sub     eax, '0'
143
        sub     eax, '0'
129
        jb      .done
144
        jb      .done
130
        cmp     eax, 9
145
        cmp     eax, 9
131
        ja      .done
146
        ja      .done
132
        inc     rsi
147
        inc     rsi
133
        imul    edx, 10
148
        imul    edx, 10
134
        add     edx, eax
149
        add     edx, eax
135
        jmp     .next_char
150
        jmp     .next_char
136
.done:
151
.done:
137
        mov     eax, edx
152
        mov     eax, edx
138
        ret
153
        ret
139
 
154
 
140
parse_option:
155
parse_option:
141
        mov     rbx, config_options-3*8
156
        mov     rbx, config_options-3*8
142
.try_next_option:
157
.try_next_option:
143
        add     rbx, 3*8
158
        add     rbx, 3*8
144
        mov     rdi, rsi
159
        mov     rdi, rsi
145
        mov     rdx, [rbx]      ; option name
160
        mov     rdx, [rbx]      ; option name
146
        test    rdx, rdx
161
        test    rdx, rdx
147
        jz      .done
162
        jz      .done
148
.next_char:
163
.next_char:
149
        cmp     byte[rdx], 0
164
        cmp     byte[rdx], 0
150
        jnz     @f
165
        jnz     @f
151
        cmp     byte[rdi], '='
166
        cmp     byte[rdi], '='
152
        jz      .opt_name_ok
167
        jz      .opt_name_ok
153
@@:
168
@@:
154
        cmp     byte[rdi], 0
169
        cmp     byte[rdi], 0
155
        jz      .done
170
        jz      .done
156
        movzx   eax, byte[rdi]
171
        movzx   eax, byte[rdi]
157
        cmp     [rdx], al
172
        cmp     [rdx], al
158
        jnz     .try_next_option
173
        jnz     .try_next_option
159
        inc     rdi
174
        inc     rdi
160
        inc     rdx
175
        inc     rdx
161
        jmp     .next_char
176
        jmp     .next_char
162
.opt_name_ok:
177
.opt_name_ok:
163
        inc     rdi
178
        inc     rdi
164
        mov     rsi, rdi
179
        mov     rsi, rdi
165
        call    qword[rbx+8]
180
        call    qword[rbx+8]
166
.done:
181
.done:
167
        ret
182
        ret
168
 
183
 
169
parse_line:
184
parse_line:
170
.next_line:
185
.next_line:
171
        cmp     byte[rsi], 0
186
        cmp     byte[rsi], 0
172
        jz      .done
187
        jz      .done
173
        cmp     byte[rsi], 0xd  ; '\r'
188
        cmp     byte[rsi], 0xd  ; '\r'
174
        jz      .skip
189
        jz      .skip
175
        cmp     byte[rsi], 0xa  ; '\n'
190
        cmp     byte[rsi], 0xa  ; '\n'
176
        jz      .skip
191
        jz      .skip
177
        cmp     byte[rsi], '#'
192
        cmp     byte[rsi], '#'
178
        jz      .skip
193
        jz      .skip
179
        call    parse_option
194
        call    parse_option
180
        call    skip_line
195
        call    skip_line
181
        jmp     .next_line
196
        jmp     .next_line
182
.skip:
197
.skip:
183
        call    skip_line
198
        call    skip_line
184
        jmp     .next_line
199
        jmp     .next_line
185
.done:
200
.done:
186
        ret
201
        ret
187
 
202
 
188
cfg_opt_func_resolution:
203
cfg_opt_func_resolution:
189
        call    dec2bin
204
        call    dec2bin
190
        xor     edx, edx
205
        xor     edx, edx
191
        mov     [rdx+BOOT_LO.x_res], ax
206
        mov     [rdx+BOOT_LO.x_res], ax
192
        cmp     byte[rsi], 'x'
207
        cmp     byte[rsi], 'x'
193
        jz      @f
208
        jz      @f
194
        cmp     byte[rsi], '*'
209
        cmp     byte[rsi], '*'
195
        jz      @f
210
        jz      @f
196
        jmp     .done
211
        jmp     .done
197
@@:
212
@@:
198
        inc     rsi
213
        inc     rsi
199
        call    dec2bin
214
        call    dec2bin
200
        xor     edx, edx
215
        xor     edx, edx
201
        mov     [rdx+BOOT_LO.y_res], ax
216
        mov     [rdx+BOOT_LO.y_res], ax
202
        mov     [cfg_opt_used_resolution], 1
217
        mov     [cfg_opt_used_resolution], 1
203
.done:
218
.done:
204
        ret
219
        ret
205
 
220
 
206
cfg_opt_func_acpi:
221
cfg_opt_func_acpi:
207
        call    dec2bin
222
        call    dec2bin
208
        mov     [cfg_opt_used_acpi], 1
223
        mov     [cfg_opt_used_acpi], 1
209
        mov     [cfg_opt_value_acpi], al
224
        mov     [cfg_opt_value_acpi], al
210
        ret
225
        ret
211
 
226
 
212
cfg_opt_func_debug_print:
227
cfg_opt_func_debug_print:
213
        call    dec2bin
228
        call    dec2bin
214
        mov     [cfg_opt_used_debug_print], 1
229
        mov     [cfg_opt_used_debug_print], 1
215
        mov     [cfg_opt_value_debug_print], al
230
        mov     [cfg_opt_value_debug_print], al
216
        ret
231
        ret
217
 
232
 
218
cfg_opt_func_launcher_start:
233
cfg_opt_func_launcher_start:
219
        call    dec2bin
234
        call    dec2bin
220
        mov     [cfg_opt_used_launcher_start], 1
235
        mov     [cfg_opt_used_launcher_start], 1
221
        mov     [cfg_opt_value_launcher_start], al
236
        mov     [cfg_opt_value_launcher_start], al
222
        ret
237
        ret
223
 
238
 
224
cfg_opt_func_mtrr:
239
cfg_opt_func_mtrr:
225
        call    dec2bin
240
        call    dec2bin
226
        mov     [cfg_opt_used_mtrr], 1
241
        mov     [cfg_opt_used_mtrr], 1
227
        mov     [cfg_opt_value_mtrr], al
242
        mov     [cfg_opt_value_mtrr], al
228
        ret
243
        ret
229
 
244
 
230
cfg_opt_func_ask_params:
245
cfg_opt_func_ask_params:
231
        call    dec2bin
246
        call    dec2bin
232
        mov     [cfg_opt_used_ask_params], 1
247
        mov     [cfg_opt_used_ask_params], 1
233
        mov     [cfg_opt_value_ask_params], al
248
        mov     [cfg_opt_value_ask_params], al
234
        ret
249
        ret
235
 
250
 
236
cfg_opt_func_imgfrom:
251
cfg_opt_func_imgfrom:
237
        call    dec2bin
252
        call    dec2bin
238
        mov     [cfg_opt_used_imgfrom], 1
253
        mov     [cfg_opt_used_imgfrom], 1
239
        mov     [cfg_opt_value_imgfrom], al
254
        mov     [cfg_opt_value_imgfrom], al
240
        ret
255
        ret
241
 
256
 
242
cfg_opt_func_syspath:
257
cfg_opt_func_syspath:
243
        mov     rdi, cfg_opt_value_syspath
258
        mov     rdi, cfg_opt_value_syspath
244
.next_char:
259
.next_char:
245
        movzx   eax, byte[rsi]
260
        movzx   eax, byte[rsi]
246
        cmp     al, 0xd ; \r
261
        cmp     al, 0xd ; \r
247
        jz      .done
262
        jz      .done
248
        cmp     al, 0xa ; \n
263
        cmp     al, 0xa ; \n
249
        jz      .done
264
        jz      .done
250
        inc     rsi
265
        inc     rsi
251
        stosb
266
        stosb
252
        jmp     .next_char
267
        jmp     .next_char
253
.done:
268
.done:
254
        mov     byte[rdi], 0
269
        mov     byte[rdi], 0
255
        ret
270
        ret
256
 
271
 
257
parse_config:
272
parse_config:
258
virtual at rsp+8
273
virtual at rsp+8
259
  .buffer      dq ?
274
  .buffer      dq ?
260
end virtual
275
end virtual
261
;        mov     rsi, [.buffer]
276
;        mov     rsi, [.buffer]
-
 
277
        push    rbx
-
 
278
        mov     rbx, [efi_table]
-
 
279
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
280
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
281
                msg_parsing_config
-
 
282
        pop     rbx
262
        mov     rsi, KERNEL_BASE
283
        mov     rsi, KERNEL_BASE
263
.next_line:
284
.next_line:
264
        call    parse_line
285
        call    parse_line
265
        cmp     byte[rsi], 0
286
        cmp     byte[rsi], 0
266
        jnz     .next_line
287
        jnz     .next_line
267
        ret     1*8
288
        ret     1*8
268
 
289
 
269
read_options_from_config:
290
read_options_from_config:
270
        mov     rbx, [efi_table]
291
        mov     rbx, [efi_table]
271
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
292
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
272
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [efi_handle], lipuuid, \
293
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [efi_handle], lipuuid, \
273
                lip_interface
294
                lip_interface
274
        cmp     eax, EFI_SUCCESS
295
        test    eax, eax
275
        jnz     .error
296
        jz      @f
-
 
297
        push    rbx
-
 
298
        mov     rbx, [efi_table]
-
 
299
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
300
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
301
                msg_error_efi_lip_handle
-
 
302
        pop     rbx
-
 
303
        jmp     $
-
 
304
@@:
276
        mov     rax, [lip_interface]
305
        mov     rax, [lip_interface]
277
 
306
 
278
        mov     rbx, [efi_table]
307
        mov     rbx, [efi_table]
279
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
308
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
280
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, \
309
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, \
281
                [rax+EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle], sfspguid, \
310
                [rax+EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle], sfspguid, \
282
                sfsp_interface
311
                sfsp_interface
-
 
312
        test    eax, eax
-
 
313
        jz      @f
-
 
314
        push    rbx
283
        cmp     rax, EFI_SUCCESS
315
        mov     rbx, [efi_table]
-
 
316
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
317
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
318
                msg_error_lip_dev_sfsp
284
        jnz     .error
319
        pop     rbx
-
 
320
        jmp     $
285
 
321
@@:
286
        eficall [sfsp_interface], EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume, \
322
        eficall [sfsp_interface], EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume, \
287
                [sfsp_interface], esp_root
323
                [sfsp_interface], esp_root
-
 
324
        test    eax, eax
-
 
325
        jz      @f
-
 
326
        push    rbx
288
        cmp     rax, EFI_SUCCESS
327
        mov     rbx, [efi_table]
-
 
328
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
329
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
330
                msg_error_sfsp_openvolume
289
        jnz     .error
331
        pop     rbx
-
 
332
        jmp     $
290
 
333
@@:
291
        push    0 ; not fatal, i.e. it's ok to not find this file
334
        push    0 ; not fatal, i.e. it's ok to not find this file
292
        push    FILE_BUFFER_SIZE
335
        push    FILE_BUFFER_SIZE
293
        push    KERNEL_BASE
336
        push    KERNEL_BASE
294
        push    file_name
337
;        push    file_name
-
 
338
        mov     rax, file_name
-
 
339
        push    rax
295
        push    [esp_root]
340
        push    [esp_root]
296
        call    load_file
341
        call    load_file
297
 
342
 
298
        test    eax, eax
343
        test    eax, eax
299
        jz      @f
344
        jz      @f
300
        push    KERNEL_BASE
345
        push    KERNEL_BASE
301
        call    parse_config
346
        call    parse_config
302
@@:
347
@@:
303
 
348
 
304
.error:
349
.error:
305
        ret
350
        ret
306
 
351
 
307
print_vmode:
352
print_vmode:
308
        push    rax rbx rcx rdx rsi rdi
353
        push    rax rbx rcx rdx rsi rdi
309
        mov     rbx, rcx
354
        mov     rbx, rcx
310
        call    clearbuf
355
        call    clearbuf
311
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
356
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
312
        mov     rdi, msg
357
        mov     rdi, msg
313
        call    num2dec
358
        call    num2dec
314
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
359
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
315
        mov     rdi, msg+8*2
360
        mov     rdi, msg+8*2
316
        call    num2dec
361
        call    num2dec
317
 
362
 
318
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat]
363
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat]
319
        mov     rdi, msg+16*2
364
        mov     rdi, msg+16*2
320
        call    num2dec
365
        call    num2dec
321
 
366
 
322
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine]
367
        mov     eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine]
323
        mov     rdi, msg+24*2
368
        mov     rdi, msg+24*2
324
        call    num2dec
369
        call    num2dec
325
        mov     rbx, [efi_table]
370
        mov     rbx, [efi_table]
326
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
371
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
327
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
372
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
328
        pop     rdi rsi rdx rcx rbx rax
373
        pop     rdi rsi rdx rcx rbx rax
329
        ret
374
        ret
330
 
375
 
331
find_vmode_index_by_resolution:
376
find_vmode_index_by_resolution:
332
        mov     [cfg_opt_used_resolution], 1
377
        mov     [cfg_opt_used_resolution], 1
333
        mov     [cfg_opt_value_vmode], 0
378
        mov     [cfg_opt_value_vmode], 0
334
.next_mode:
379
.next_mode:
335
        movzx   eax, [cfg_opt_value_vmode]
380
        movzx   eax, [cfg_opt_value_vmode]
336
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \
381
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \
337
                [gop_interface], rax, gop_info_size, gop_info
382
                [gop_interface], rax, gop_info_size, gop_info
338
        cmp     rax, EFI_SUCCESS
383
        cmp     rax, EFI_SUCCESS
339
        jnz     .error
384
        jnz     .error
340
        mov     rcx, [gop_info]
385
        mov     rcx, [gop_info]
341
        call    print_vmode
386
        call    print_vmode
342
        ; PixelBlueGreenRedReserved8BitPerColor
387
        ; PixelBlueGreenRedReserved8BitPerColor
343
        cmp     [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1
388
        cmp     [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1
344
        jnz     .skip_mode
389
        jnz     .skip_mode
345
        xor     edx, edx
390
        xor     edx, edx
346
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
391
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
347
        cmp     ax, [rdx+BOOT_LO.x_res]
392
        cmp     ax, [rdx+BOOT_LO.x_res]
348
        jnz     .skip_mode
393
        jnz     .skip_mode
349
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
394
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
350
        cmp     ax, [rdx+BOOT_LO.y_res]
395
        cmp     ax, [rdx+BOOT_LO.y_res]
351
        jnz     .skip_mode
396
        jnz     .skip_mode
352
        jmp     .done
397
        jmp     .done
353
.skip_mode:
398
.skip_mode:
354
        inc     [cfg_opt_value_vmode]
399
        inc     [cfg_opt_value_vmode]
355
        movzx   eax, [cfg_opt_value_vmode]
400
        movzx   eax, [cfg_opt_value_vmode]
356
        mov     rcx, [gop_interface]
401
        mov     rcx, [gop_interface]
357
        mov     rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
402
        mov     rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
358
        cmp     eax, 8;[rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode]
403
        cmp     eax, 8;[rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode]
359
        jnz     .next_mode
404
        jnz     .next_mode
360
        mov     [cfg_opt_used_resolution], 0
405
        mov     [cfg_opt_used_resolution], 0
361
        mov     [cfg_opt_value_ask_params], 1
406
        mov     [cfg_opt_value_ask_params], 1
362
 
407
 
363
        mov     rbx, [efi_table]
408
        mov     rbx, [efi_table]
364
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
409
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
365
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
410
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
366
                msg_error_no_such_vmode
411
                msg_error_no_such_vmode
367
        mov     rbx, [efi_table]
412
        mov     rbx, [efi_table]
368
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
413
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
369
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error
414
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
415
                msg_error
370
        jmp     $
416
        jmp     $
371
.error:
417
.error:
372
.done:
418
.done:
373
        ret
419
        ret
374
 
420
 
375
ask_for_params:
421
ask_for_params:
376
        ret
422
        ret
377
        mov     rbx, [efi_table]
423
        mov     rbx, [efi_table]
378
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
424
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
379
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [rax], gopuuid, \
425
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [rax], gopuuid, \
380
                msg_ask_for_params
426
                msg_ask_for_params
381
        jmp     $
427
        jmp     $
382
 
428
 
383
        xor     ebx, ebx
429
        xor     ebx, ebx
384
.next_mode:
430
.next_mode:
385
        call    clearbuf
431
        call    clearbuf
386
        mov     eax, ebx
432
        mov     eax, ebx
387
        lea     rdi, [msg]
433
        lea     rdi, [msg]
388
        call    num2dec
434
        call    num2dec
389
 
435
 
390
        push    rbx
436
        push    rbx
391
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \
437
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \
392
                [gop_interface], rbx, gop_info_size, gop_info
438
                [gop_interface], rbx, gop_info_size, gop_info
393
        cmp     rax, EFI_SUCCESS
439
        cmp     rax, EFI_SUCCESS
394
        jnz     .error
440
        jnz     .error
395
        mov     rcx, [gop_info]
441
        mov     rcx, [gop_info]
396
        ; PixelBlueGreenRedReserved8BitPerColor
442
        ; PixelBlueGreenRedReserved8BitPerColor
397
        cmp     [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1
443
        cmp     [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1
398
        jnz     .skip
444
        jnz     .skip
399
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
445
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
400
        lea     rdi, [msg+4*2]
446
        lea     rdi, [msg+4*2]
401
        call    num2dec
447
        call    num2dec
402
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
448
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
403
        lea     rdi, [msg+9*2]
449
        lea     rdi, [msg+9*2]
404
        call    num2dec
450
        call    num2dec
405
;        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine]
451
;        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine]
406
;        lea     rdi, [msg+14*2]
452
;        lea     rdi, [msg+14*2]
407
;        call    num2dec
453
;        call    num2dec
408
.skip:
454
.skip:
409
        mov     rbx, [efi_table]
455
        mov     rbx, [efi_table]
410
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
456
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
411
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
457
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
412
        cmp     rax, EFI_SUCCESS
458
        cmp     rax, EFI_SUCCESS
413
        jnz     .error
459
        jnz     .error
414
 
460
 
415
        pop     rbx
461
        pop     rbx
416
        inc     rbx
462
        inc     rbx
417
        mov     rcx, [gop_interface]
463
        mov     rcx, [gop_interface]
418
        mov     rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
464
        mov     rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
419
        cmp     ebx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode]
465
        cmp     ebx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode]
420
        jnz     .next_mode
466
        jnz     .next_mode
421
 
467
 
422
 
468
 
423
        mov     rbx, [efi_table]
469
        mov     rbx, [efi_table]
424
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConIn]
470
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConIn]
425
        eficall rbx, SIMPLE_INPUT_INTERFACE.Reset, rbx, 1
471
        eficall rbx, SIMPLE_INPUT_INTERFACE.Reset, rbx, 1
426
        cmp     rax, EFI_SUCCESS
472
        cmp     rax, EFI_SUCCESS
427
        jnz     .error
473
        jnz     .error
428
        xor     ecx, ecx
474
        xor     ecx, ecx
429
    @@:
475
    @@:
430
        push    rcx
476
        push    rcx
431
        mov     rbx, [efi_table]
477
        mov     rbx, [efi_table]
432
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConIn]
478
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConIn]
433
        eficall rbx, SIMPLE_INPUT_INTERFACE.ReadKeyStroke, rbx, msg
479
        eficall rbx, SIMPLE_INPUT_INTERFACE.ReadKeyStroke, rbx, msg
434
        pop     rcx
480
        pop     rcx
435
        mov     rdx, EFI_DEVICE_ERROR
481
        mov     rdx, EFI_DEVICE_ERROR
436
        cmp     rax, rdx
482
        cmp     rax, rdx
437
        jz      .error
483
        jz      .error
438
        mov     rdx, EFI_NOT_READY
484
        mov     rdx, EFI_NOT_READY
439
        cmp     rax, rdx
485
        cmp     rax, rdx
440
        jz      @b
486
        jz      @b
441
;        cmp     rax, EFI_SUCCESS
487
;        cmp     rax, EFI_SUCCESS
442
        movzx   eax, word[msg+2]
488
        movzx   eax, word[msg+2]
443
;jmp .key_done
489
;jmp .key_done
444
        cmp     al, 0x0D
490
        cmp     al, 0x0D
445
        jz      .key_done
491
        jz      .key_done
446
        imul    ecx, 10
492
        imul    ecx, 10
447
        sub     eax, '0'
493
        sub     eax, '0'
448
        add     ecx, eax
494
        add     ecx, eax
449
        jmp     @b
495
        jmp     @b
450
.key_done:
496
.key_done:
451
        mov     [cfg_opt_value_vmode], cl
497
        mov     [cfg_opt_value_vmode], cl
452
.error:
498
.error:
453
.done:
499
.done:
454
        ret
500
        ret
455
 
501
 
456
main:
502
main:
457
        mov     [efi_handle], rcx
503
        mov     [efi_handle], rcx
458
        mov     [efi_table], rdx
504
        mov     [efi_table], rdx
459
 
505
 
460
        mov     rbx, [efi_table]
506
        mov     rbx, [efi_table]
461
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
507
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
462
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset, rbx, 1
508
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset, rbx, 1
463
        test    eax, eax
509
        test    eax, eax
464
        jz      @f
510
        jz      @f
465
        jmp     $       ; what can I do here?
511
        jmp     $       ; what can I do here?
466
@@:
512
@@:
467
        mov     rbx, [efi_table]
513
        mov     rbx, [efi_table]
468
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
514
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
469
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
515
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
470
                msg_u4k_loaded
516
                msg_u4k_loaded
471
 
517
 
472
        mov     rbx, [efi_table]
518
        mov     rbx, [efi_table]
473
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
519
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
474
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
520
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
475
                msg_read_options
521
                msg_read_options
476
        call    read_options_from_config
522
        call    read_options_from_config
477
 
523
 
478
        ; read kernel file
524
        ; read kernel file
479
        mov     rbx, [efi_table]
525
        mov     rbx, [efi_table]
480
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
526
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
481
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
527
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
482
                msg_load_kernel
528
                msg_load_kernel
483
        push    1
529
        push    1
484
        push    -1
530
        push    -1
485
        push    KERNEL_BASE
531
        push    KERNEL_BASE
486
        push    kernel_name
532
;        push    kernel_name
-
 
533
        mov     rax, kernel_name
-
 
534
        push    rax
487
        push    [esp_root]
535
        push    [esp_root]
488
        call    load_file
536
        call    load_file
489
 
537
 
490
        ; read ramdisk image
538
        ; read ramdisk image
491
        mov     rbx, [efi_table]
539
        mov     rbx, [efi_table]
492
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
540
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
493
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
541
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
494
                msg_load_ramdisk
542
                msg_load_ramdisk
495
        push    1
543
        push    1
496
        push    -1
544
        push    -1
497
        push    RAMDISK_BASE
545
        push    RAMDISK_BASE
498
        push    ramdisk_name
546
;        push    ramdisk_name
-
 
547
        mov     rax, ramdisk_name
-
 
548
        push    rax
499
        push    [esp_root]
549
        push    [esp_root]
500
        call    load_file
550
        call    load_file
501
 
551
 
502
        ; alloc buffer for devices.dat
552
        ; alloc buffer for devices.dat
503
        mov     rbx, [efi_table]
553
        mov     rbx, [efi_table]
504
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
554
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
505
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
555
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
506
                msg_alloc_devicesdat
556
                msg_alloc_devicesdat
507
        mov     rbx, [efi_table]
557
        mov     rbx, [efi_table]
508
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
558
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
509
        eficall rbx, EFI_BOOT_SERVICES.AllocatePages, \
559
        eficall rbx, EFI_BOOT_SERVICES.AllocatePages, \
510
                EFI_ALLOCATE_MAX_ADDRESS, EFI_RESERVED_MEMORY_TYPE, 1, \
560
                EFI_ALLOCATE_MAX_ADDRESS, EFI_RESERVED_MEMORY_TYPE, 1, \
511
                devicesdat_data
561
                devicesdat_data
512
        cmp     eax, EFI_SUCCESS
562
        cmp     eax, EFI_SUCCESS
513
        jnz     .error
563
        jnz     .error
514
 
564
 
515
        ; read devices.dat
565
        ; read devices.dat
516
        mov     rbx, [efi_table]
566
        mov     rbx, [efi_table]
517
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
567
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
518
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
568
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
519
                msg_load_devicesdat
569
                msg_load_devicesdat
520
 
570
 
521
        push    0 ; not fatal
571
        push    0 ; not fatal
522
        push    [devicesdat_size]
572
        push    [devicesdat_size]
523
        push    [devicesdat_data]
573
        push    [devicesdat_data]
524
        push    devicesdat_name
574
;        push    devicesdat_name
-
 
575
        mov     rax, devicesdat_name
-
 
576
        push    rax
525
        push    [esp_root]
577
        push    [esp_root]
526
        call    load_file
578
        call    load_file
527
        mov     [devicesdat_size], rax
579
        mov     [devicesdat_size], rax
528
 
580
 
529
        mov     rbx, [efi_table]
581
        mov     rbx, [efi_table]
530
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
582
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
531
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
583
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
532
                msg_locate_gop_handlers
584
                msg_locate_gop_handlers
533
 
585
 
534
        mov     rbx, [efi_table]
586
        mov     rbx, [efi_table]
535
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
587
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
536
        eficall rbx, EFI_BOOT_SERVICES.LocateHandle, \
588
        eficall rbx, EFI_BOOT_SERVICES.LocateHandle, \
537
                EFI_LOCATE_SEARCH_TYPE.ByProtocol, gopuuid, 0, \
589
                EFI_LOCATE_SEARCH_TYPE.ByProtocol, gopuuid, 0, \
538
                gop_buffer_size, gop_buffer
590
                gop_buffer_size, gop_buffer
539
        mov     [status], rax
591
        mov     [status], rax
540
 
592
 
541
        mov     rbx, [efi_table]
593
        mov     rbx, [efi_table]
542
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
594
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
543
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
595
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
544
                msg_gop_buffer_size
596
                msg_gop_buffer_size
545
        call    clearbuf
597
        call    clearbuf
546
        mov     rax, [gop_buffer_size]
598
        mov     rax, [gop_buffer_size]
547
        mov     rdi, msg
599
        mov     rdi, msg
548
        call    num2hex
600
        call    num2hex
549
        mov     rbx, [efi_table]
601
        mov     rbx, [efi_table]
550
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
602
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
551
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
603
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
552
 
604
 
553
        mov     rax, [status]
605
        mov     rax, [status]
554
        test    eax, eax
606
        test    eax, eax
555
        jz      @f
607
        jz      @f
556
        call    clearbuf
608
        call    clearbuf
557
        mov     rdi, msg
609
        mov     rdi, msg
558
        call    num2hex
610
        call    num2hex
559
        mov     rbx, [efi_table]
611
        mov     rbx, [efi_table]
560
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
612
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
561
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error
613
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
614
                msg_error
562
        mov     rbx, [efi_table]
615
        mov     rbx, [efi_table]
563
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
616
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
564
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
617
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
565
        jmp     $
618
        jmp     $
566
@@:
619
@@:
567
 
620
 
568
        mov     rbx, [efi_table]
621
        mov     rbx, [efi_table]
569
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
622
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
570
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
623
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
571
                msg_look_for_gop_handler
624
                msg_look_for_gop_handler
572
 
625
 
573
        mov     rbx, gop_buffer
626
        mov     rbx, gop_buffer
574
.next_gop_handle:
627
.next_gop_handle:
575
        mov     rax, rbx
628
        mov     rax, rbx
576
        sub     rax, gop_buffer
629
        mov     rcx, gop_buffer
-
 
630
        sub     rax, rcx
577
        cmp     rax, [gop_buffer_size]
631
        cmp     rax, [gop_buffer_size]
578
        jb      @f
632
        jb      @f
579
        push    rbx
633
        push    rbx
580
        mov     rbx, [efi_table]
634
        mov     rbx, [efi_table]
581
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
635
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
582
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
636
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
583
                msg_error_out_of_handlers
637
                msg_error_out_of_handlers
584
        pop     rbx
638
        pop     rbx
585
        push    rbx
639
        push    rbx
586
        mov     rbx, [efi_table]
640
        mov     rbx, [efi_table]
587
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
641
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
588
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error
642
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error
589
        pop     rbx
643
        pop     rbx
590
        jmp     $
644
        jmp     $
591
@@:
645
@@:
592
        push    rbx
646
        push    rbx
593
        mov     rbx, [efi_table]
647
        mov     rbx, [efi_table]
594
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
648
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
595
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
649
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
596
                msg_query_handler
650
                msg_query_handler
597
        pop     rbx
651
        pop     rbx
598
 
652
 
599
        mov     rax, rbx
653
        mov     rax, rbx
600
        push    rbx
654
        push    rbx
601
        mov     rbx, [efi_table]
655
        mov     rbx, [efi_table]
602
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
656
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
603
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [rax], gopuuid, \
657
        eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [rax], gopuuid, \
604
                gop_interface
658
                gop_interface
605
        pop     rbx
659
        pop     rbx
606
;mov rax, 0x8000_0000_0000_0003
660
;mov rax, 0x8000_0000_0000_0003
607
        test    eax, eax
661
        test    eax, eax
608
        jz      @f
662
        jz      @f
609
        call    clearbuf
663
        call    clearbuf
610
        mov     rdi, msg
664
        mov     rdi, msg
611
        call    num2hex
665
        call    num2hex
612
        push    rbx
666
        push    rbx
613
        mov     rbx, [efi_table]
667
        mov     rbx, [efi_table]
614
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
668
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
615
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
669
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
616
        pop     rbx
670
        pop     rbx
617
 
671
 
618
        add     rbx, 8
672
        add     rbx, 8
619
        jmp     .next_gop_handle
673
        jmp     .next_gop_handle
620
@@:
674
@@:
621
 
-
 
622
        push    rbx
-
 
623
        mov     rbx, [efi_table]
-
 
624
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
625
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
626
                msg_look_for_rsdp
-
 
627
        pop     rbx
-
 
628
 
-
 
629
        mov     rbx, [efi_table]
-
 
630
        mov     rdi, [rbx+EFI_SYSTEM_TABLE.ConfigurationTable]
-
 
631
        mov     rcx, [rbx+EFI_SYSTEM_TABLE.NumberOfTableEntries]
-
 
632
        mov     rax, 0x11d3e4f18868e871
-
 
633
        mov     rdx, 0x81883cc7800022bc
-
 
634
.next_table:
-
 
635
        dec     ecx
-
 
636
        js      .all_tables_done
-
 
637
        cmp     [rdi+0], rax
-
 
638
        jnz     .not_acpi20
-
 
639
        cmp     [rdi+8], rdx
-
 
640
        jnz     .not_acpi20
-
 
641
        mov     rax, [rdi+16]
-
 
642
        mov     rdx, BOOT_LO.acpi_rsdp
-
 
643
        mov     [rdx], eax
-
 
644
        jmp     .all_tables_done
-
 
645
.not_acpi20:
675
 
646
        add     rdi, 24
-
 
647
        jmp     .next_table
-
 
648
.all_tables_done:
676
        call    find_rsdp
649
 
677
 
650
        mov     rbx, [efi_table]
678
        mov     rbx, [efi_table]
651
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
679
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
652
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
680
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
653
                msg_acpi_tables_done
681
                msg_acpi_tables_done
654
 
682
 
655
        cmp     [cfg_opt_used_resolution], 0
683
        cmp     [cfg_opt_used_resolution], 0
656
        jz      .not_used_resolution
684
        jz      .not_used_resolution
657
        mov     rbx, [efi_table]
685
        mov     rbx, [efi_table]
658
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
686
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
659
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
687
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
660
                msg_opt_resolution
688
                msg_opt_resolution
661
        call    clearbuf
689
        call    clearbuf
662
        xor     edx, edx
690
        xor     edx, edx
663
        movzx   eax, [rdx+BOOT_LO.x_res]
691
        movzx   eax, [rdx+BOOT_LO.x_res]
664
        mov     rdi, msg
692
        mov     rdi, msg
665
        call    num2dec
693
        call    num2dec
666
        xor     edx, edx
694
        xor     edx, edx
667
        movzx   eax, [rdx+BOOT_LO.y_res]
695
        movzx   eax, [rdx+BOOT_LO.y_res]
668
        mov     rdi, msg+8*2
696
        mov     rdi, msg+8*2
669
        call    num2dec
697
        call    num2dec
670
        mov     rbx, [efi_table]
698
        mov     rbx, [efi_table]
671
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
699
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
672
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
700
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
673
        call    find_vmode_index_by_resolution
701
        call    find_vmode_index_by_resolution
674
.not_used_resolution:
702
.not_used_resolution:
675
        cmp     [cfg_opt_used_debug_print], 0
703
        cmp     [cfg_opt_used_debug_print], 0
676
        jz      .not_used_debug_print
704
        jz      .not_used_debug_print
677
        movzx   eax, [cfg_opt_value_debug_print]
705
        movzx   eax, [cfg_opt_value_debug_print]
678
        xor     edx, edx
706
        xor     edx, edx
679
        mov     [rdx+BOOT_LO.debug_print], al
707
        mov     [rdx+BOOT_LO.debug_print], al
680
.not_used_debug_print:
708
.not_used_debug_print:
681
 
709
 
682
        cmp     [cfg_opt_value_ask_params], 0
710
        cmp     [cfg_opt_value_ask_params], 0
683
        jz      @f
711
        jz      @f
684
        call    ask_for_params
712
        call    ask_for_params
685
@@:
713
@@:
-
 
714
 
-
 
715
;        call    calc_memmap
-
 
716
;        call    dump_memmap
686
 
717
 
687
        movzx   ecx, [cfg_opt_value_vmode]
718
        movzx   ecx, [cfg_opt_value_vmode]
688
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode, \
719
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode, \
689
                [gop_interface], rcx
720
                [gop_interface], rcx
690
        test    eax, eax
721
        test    eax, eax
691
        jz      @f
722
        jz      @f
692
        call    clearbuf
723
        call    clearbuf
693
        mov     rdi, msg
724
        mov     rdi, msg
694
        call    num2hex
725
        call    num2hex
695
        mov     rbx, [efi_table]
726
        mov     rbx, [efi_table]
696
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
727
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
697
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
728
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
698
        mov     rbx, [efi_table]
729
        mov     rbx, [efi_table]
699
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
730
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
700
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error
731
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
732
                msg_error
701
        jmp     $
733
        jmp     $
702
@@:
734
@@:
703
 
735
 
704
        mov     rcx, [gop_interface]
736
        mov     rcx, [gop_interface]
705
        mov     rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
737
        mov     rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
706
        mov     rdi, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferBase]
738
        mov     rdi, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferBase]
707
        mov     [fb_base], rdi
739
        mov     [fb_base], rdi
708
 
-
 
709
 
740
 
710
        mov     ebx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.Mode]
741
        mov     ebx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.Mode]
711
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \
742
        eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \
712
                [gop_interface], rbx, gop_info_size, gop_info
743
                [gop_interface], rbx, gop_info_size, gop_info
713
        cmp     rax, EFI_SUCCESS
744
        test    eax, eax
-
 
745
        jz      @f
714
        jnz     .error
746
        jmp     .error
-
 
747
@@:
715
        mov     rcx, [gop_info]
748
        mov     rcx, [gop_info]
716
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
749
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution]
717
        xor     rdx, rdx
750
        xor     rdx, rdx
718
        mov     [rdx+BOOT_LO.x_res], ax
751
        mov     [rdx+BOOT_LO.x_res], ax
719
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
752
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution]
720
        mov     [rdx+BOOT_LO.y_res], ax
753
        mov     [rdx+BOOT_LO.y_res], ax
721
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine]
754
        mov     eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine]
722
        shl     eax, 2
755
        shl     eax, 2
723
        mov     [rdx+BOOT_LO.pitch], ax
756
        mov     [rdx+BOOT_LO.pitch], ax
724
 
757
 
725
        mov     byte[rdx+BOOT_LO.pci_data+0], 1    ; PCI access mechanism
758
        mov     byte[rdx+BOOT_LO.pci_data+0], 1    ; PCI access mechanism
726
        mov     byte[rdx+BOOT_LO.pci_data+1], 8    ; last bus, don't know how to count them
759
        mov     byte[rdx+BOOT_LO.pci_data+1], 8    ; last bus, don't know how to count them
727
        mov     byte[rdx+BOOT_LO.pci_data+2], 0x10 ; PCI version
760
        mov     byte[rdx+BOOT_LO.pci_data+2], 0x10 ; PCI version
728
        mov     byte[rdx+BOOT_LO.pci_data+3], 0x02
761
        mov     byte[rdx+BOOT_LO.pci_data+3], 0x02
729
        mov     dword[rdx+BOOT_LO.pci_data+4], 0xe3
762
        mov     dword[rdx+BOOT_LO.pci_data+4], 0xe3
730
 
-
 
731
 
-
 
732
        mov     rbx, [efi_table]
-
 
733
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
-
 
734
        eficall rbx, EFI_BOOT_SERVICES.AllocatePages, EFI_ALLOCATE_ANY_PAGES, \
-
 
735
                EFI_RESERVED_MEMORY_TYPE, MEMORY_MAP_SIZE/0x1000, memory_map
-
 
736
        cmp     eax, EFI_SUCCESS
-
 
737
        jnz     .error
-
 
738
 
-
 
739
        mov     rbx, [efi_table]
-
 
740
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
-
 
741
        eficall rbx, EFI_BOOT_SERVICES.GetMemoryMap, memory_map_size, \
-
 
742
                [memory_map], memory_map_key, descriptor_size, descriptor_ver
-
 
743
        cmp     eax, EFI_SUCCESS
-
 
744
        jnz     .error
-
 
745
 
-
 
746
        mov     rdi, BOOT_LO.memmap_block_cnt
-
 
747
        mov     dword[rdi], 0
-
 
748
        mov     rdi, BOOT_LO.memmap_blocks
-
 
749
        mov     rax, [memory_map_size]
-
 
750
        xor     edx, edx
-
 
751
        mov     rcx, [descriptor_size]
-
 
752
        div     ecx
-
 
753
        mov     ecx, eax
-
 
754
        mov     rsi, [memory_map]
-
 
755
.next_descr:
-
 
756
        call    add_uefi_memmap
-
 
757
        add     rsi, [descriptor_size]
-
 
758
        add     rdi, sizeof.e820entry
-
 
759
        dec     ecx
-
 
760
        test    ecx, ecx
-
 
761
        jnz     .next_descr
-
 
762
 
763
 
763
        ; kernel
764
        ; kernel
764
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
765
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
765
;                450000/0x1000, EFI_ALLOCATE_ADDRESS
766
;                450000/0x1000, EFI_ALLOCATE_ADDRESS
766
 
767
 
767
        ; ramdisk
768
        ; ramdisk
768
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
769
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
769
;                2880*512/0x1000, EFI_ALLOCATE_ADDRESS
770
;                2880*512/0x1000, EFI_ALLOCATE_ADDRESS
-
 
771
 
-
 
772
        call    calc_memmap
770
 
773
 
771
        mov     rbx, [efi_table]
774
        mov     rbx, [efi_table]
772
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
775
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
773
        eficall rbx, EFI_BOOT_SERVICES.ExitBootServices, [efi_handle], \
776
        eficall rbx, EFI_BOOT_SERVICES.ExitBootServices, [efi_handle], \
774
                [memory_map_key]
777
                [memory_map_key]
775
        cmp     eax, EFI_SUCCESS
-
 
776
        jnz     .error
778
        call    halt_on_error
777
 
-
 
778
 
779
 
779
        cli
780
        cli
780
 
781
 
781
        xor     edx, edx
782
        xor     edx, edx
782
        xor     esi, esi
783
        xor     esi, esi
783
        mov     [esi+BOOT_LO.bpp], 32
784
        mov     [esi+BOOT_LO.bpp], 32
784
        mov     [esi+BOOT_LO.vesa_mode], dx
785
        mov     [esi+BOOT_LO.vesa_mode], dx
785
        mov     [esi+BOOT_LO.bank_switch], edx
786
        mov     [esi+BOOT_LO.bank_switch], edx
786
        mov     rdi, [fb_base]
787
        mov     rdi, [fb_base]
787
        mov     [esi+BOOT_LO.lfb], edi
788
        mov     [esi+BOOT_LO.lfb], edi
788
 
789
 
789
        movzx   eax, [cfg_opt_value_mtrr]
790
        movzx   eax, [cfg_opt_value_mtrr]
790
        mov     [esi+BOOT_LO.mtrr], al
791
        mov     [esi+BOOT_LO.mtrr], al
791
 
792
 
792
        movzx   eax, [cfg_opt_value_launcher_start]
793
        movzx   eax, [cfg_opt_value_launcher_start]
793
        mov     [esi+BOOT_LO.launcher_start], al
794
        mov     [esi+BOOT_LO.launcher_start], al
794
 
795
 
795
        movzx   eax, [cfg_opt_value_debug_print]
796
        movzx   eax, [cfg_opt_value_debug_print]
796
        mov     [esi+BOOT_LO.debug_print], al
797
        mov     [esi+BOOT_LO.debug_print], al
797
 
798
 
798
        mov     [esi+BOOT_LO.dma], dl
799
        mov     [esi+BOOT_LO.dma], dl
799
;        mov     qword[esi+BOOT_LO.pci_data], 0
800
;        mov     qword[esi+BOOT_LO.pci_data], 0
800
        mov     [esi+BOOT_LO.apm_entry], edx
801
        mov     [esi+BOOT_LO.apm_entry], edx
801
        mov     [esi+BOOT_LO.apm_version], dx
802
        mov     [esi+BOOT_LO.apm_version], dx
802
        mov     [esi+BOOT_LO.apm_flags], dx
803
        mov     [esi+BOOT_LO.apm_flags], dx
803
        mov     [esi+BOOT_LO.apm_code_32], dx
804
        mov     [esi+BOOT_LO.apm_code_32], dx
804
        mov     [esi+BOOT_LO.apm_code_16], dx
805
        mov     [esi+BOOT_LO.apm_code_16], dx
805
        mov     [esi+BOOT_LO.apm_data_16], dx
806
        mov     [esi+BOOT_LO.apm_data_16], dx
806
        mov     [esi+BOOT_LO.bios_hd_cnt], dl
807
        mov     [esi+BOOT_LO.bios_hd_cnt], dl
807
 
808
 
808
        movzx   eax, [cfg_opt_value_imgfrom]
809
        movzx   eax, [cfg_opt_value_imgfrom]
809
        mov     [esi+BOOT_LO.rd_load_from], al
810
        mov     [esi+BOOT_LO.rd_load_from], al
810
 
811
 
811
        mov     eax, dword[devicesdat_size]
812
        mov     eax, dword[devicesdat_size]
812
        mov     [rdx+BOOT_LO.devicesdat_size], eax
813
        mov     [rdx+BOOT_LO.devicesdat_size], eax
813
        mov     eax, dword[devicesdat_data]
814
        mov     eax, dword[devicesdat_data]
814
        mov     [rdx+BOOT_LO.devicesdat_data], eax
815
        mov     [rdx+BOOT_LO.devicesdat_data], eax
815
 
816
 
816
        mov     rsi, cfg_opt_value_syspath
817
        mov     rsi, cfg_opt_value_syspath
817
        mov     rdi, BOOT_LO.syspath
818
        mov     rdi, BOOT_LO.syspath
818
        mov     ecx, 0x17
819
        mov     ecx, 0x17
819
        rep movsb
820
        rep movsb
820
 
821
 
821
        lgdt    [cs:GDTR]
822
        lgdt    [cs:GDTR]
822
 
823
 
823
        mov     ax, DATA_32_SELECTOR
824
        mov     ax, DATA_32_SELECTOR
824
        mov     ds, ax
825
        mov     ds, ax
825
        mov     es, ax
826
        mov     es, ax
826
        mov     fs, ax
827
        mov     fs, ax
827
        mov     gs, ax
828
        mov     gs, ax
828
        mov     ss, ax
829
        mov     ss, ax
829
 
830
 
830
        push    CODE_32_SELECTOR
831
        push    CODE_32_SELECTOR
831
        lea     rax, [.next]
832
        lea     rax, [.next]
832
        push    rax
833
        push    rax
833
        retf
834
        retf
834
use32
835
use32
835
align 16
836
align 16
836
.next:
837
.next:
837
        mov     eax, cr0
838
        mov     eax, cr0
838
        and     eax, not CR0_PG
839
        and     eax, not CR0_PG
839
        mov     cr0, eax
840
        mov     cr0, eax
840
 
841
 
841
        mov     ecx, MSR_AMD_EFER
842
        mov     ecx, MSR_AMD_EFER
842
        rdmsr
843
        rdmsr
843
        btr     eax, 8                  ; LME
844
        btr     eax, 8                  ; LME
844
        wrmsr
845
        wrmsr
845
 
846
 
846
        mov     eax, cr4
847
        mov     eax, cr4
847
        and     eax, not CR4_PAE
848
        and     eax, not CR4_PAE
848
        mov     cr4, eax
849
        mov     cr4, eax
849
 
850
 
850
        push    KERNEL_BASE
851
        push    KERNEL_BASE
851
        retn
852
        retn
852
 
853
 
853
use64
854
use64
854
.error:
855
.error:
855
        mov     rbx, [efi_table]
856
        mov     rbx, [efi_table]
856
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
857
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
857
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
858
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
858
                msg_error
859
                msg_error
859
        jmp     $
860
        jmp     $
860
 
861
 
-
 
862
 
-
 
863
halt_on_error:
-
 
864
        push    rax rbx rcx rdx rsi rdi
-
 
865
        test    eax, eax
-
 
866
        jz      @f
-
 
867
        call    clearbuf
-
 
868
        mov     rdi, msg
-
 
869
        call    num2hex
-
 
870
        mov     rbx, [efi_table]
-
 
871
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
872
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
873
                msg_error
-
 
874
        mov     rbx, [efi_table]
-
 
875
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
876
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
-
 
877
        jmp     $
-
 
878
@@:
-
 
879
        pop     rdi rsi rdx rcx rbx rax
-
 
880
        ret
-
 
881
 
-
 
882
find_rsdp:
-
 
883
        push    rbx
-
 
884
        mov     rbx, [efi_table]
-
 
885
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
886
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
887
                msg_look_for_rsdp
-
 
888
        pop     rbx
-
 
889
 
-
 
890
        mov     rbx, [efi_table]
-
 
891
        mov     rdi, [rbx+EFI_SYSTEM_TABLE.ConfigurationTable]
-
 
892
        mov     rcx, [rbx+EFI_SYSTEM_TABLE.NumberOfTableEntries]
-
 
893
        mov     rax, 0x11d3e4f18868e871
-
 
894
        mov     rdx, 0x81883cc7800022bc
-
 
895
.next_table:
-
 
896
        dec     ecx
-
 
897
        js      .all_tables_done
-
 
898
        cmp     [rdi+0], rax
-
 
899
        jnz     .not_acpi20
-
 
900
        cmp     [rdi+8], rdx
-
 
901
        jnz     .not_acpi20
-
 
902
        mov     rax, [rdi+16]
-
 
903
        mov     rdx, BOOT_LO.acpi_rsdp
-
 
904
        mov     [rdx], eax
-
 
905
        jmp     .all_tables_done
-
 
906
.not_acpi20:
-
 
907
        add     rdi, 24
-
 
908
        jmp     .next_table
-
 
909
.all_tables_done:
-
 
910
        ret
-
 
911
 
-
 
912
calc_memmap:
-
 
913
        mov     rbx, [efi_table]
-
 
914
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
-
 
915
        eficall rbx, EFI_BOOT_SERVICES.AllocatePages, EFI_ALLOCATE_ANY_PAGES, \
-
 
916
                EFI_RESERVED_MEMORY_TYPE, MEMORY_MAP_SIZE/0x1000, memory_map
-
 
917
        call    halt_on_error
-
 
918
 
-
 
919
        mov     rbx, [efi_table]
-
 
920
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.BootServices]
-
 
921
        eficall rbx, EFI_BOOT_SERVICES.GetMemoryMap, memory_map_size, \
-
 
922
                [memory_map], memory_map_key, descriptor_size, descriptor_ver
-
 
923
        call    halt_on_error
-
 
924
 
-
 
925
        mov     rdi, BOOT_LO.memmap_block_cnt
-
 
926
        mov     dword[rdi], 0
-
 
927
        mov     rdi, BOOT_LO.memmap_blocks
-
 
928
        mov     rax, [memory_map_size]
-
 
929
        xor     edx, edx
-
 
930
        mov     rcx, [descriptor_size]
-
 
931
        div     ecx
-
 
932
        mov     ecx, eax
-
 
933
        cmp     ecx, MAX_MEMMAP_BLOCKS
-
 
934
        jbe     @f
-
 
935
        mov     ecx, MAX_MEMMAP_BLOCKS
-
 
936
@@:
-
 
937
        xor     eax, eax
-
 
938
        mov     [rax+BOOT_LO.memmap_block_cnt], 0
-
 
939
        mov     rsi, [memory_map]
-
 
940
.next_descr:
-
 
941
        call    add_uefi_memmap
-
 
942
        add     rsi, [descriptor_size]
-
 
943
        add     rdi, sizeof.e820entry
-
 
944
        dec     ecx
-
 
945
        jnz     .next_descr
-
 
946
        ret
-
 
947
 
-
 
948
dump_memmap:
-
 
949
        xor     eax, eax
-
 
950
        mov     rsi, BOOT_LO.memmap_blocks
-
 
951
        mov     ebx, [rax+BOOT_LO.memmap_block_cnt]
-
 
952
 
-
 
953
        call    clearbuf
-
 
954
        mov     eax, ebx
-
 
955
        mov     rdi, msg
-
 
956
        call    num2dec
-
 
957
        push    rbx
-
 
958
        mov     rbx, [efi_table]
-
 
959
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
960
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \
-
 
961
                msg_memmap
-
 
962
        pop     rbx
-
 
963
        push    rbx
-
 
964
        mov     rbx, [efi_table]
-
 
965
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
966
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
-
 
967
        pop     rbx
-
 
968
        call    clearbuf
-
 
969
.next_mapping:
-
 
970
        dec     ebx
-
 
971
        js      .done
-
 
972
        mov     rax, rsi
-
 
973
        mov     rcx, BOOT_LO.memmap_blocks
-
 
974
        sub     rax, rcx
-
 
975
        mov     ecx, sizeof.e820entry
-
 
976
        xor     edx, edx
-
 
977
        div     ecx
-
 
978
        mov     rdi, msg
-
 
979
        call    num2dec
-
 
980
        mov     rax, [rsi+e820entry.addr]
-
 
981
        mov     rdi, msg+4*2
-
 
982
        call    num2hex
-
 
983
        mov     rax, [rsi+e820entry.size]
-
 
984
        mov     rdi, msg+24*2
-
 
985
        call    num2hex
-
 
986
        push    rbx
-
 
987
        mov     rbx, [efi_table]
-
 
988
        mov     rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
-
 
989
        eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg
-
 
990
        pop     rbx
-
 
991
        add     rsi, sizeof.e820entry
-
 
992
        jmp     .next_mapping
-
 
993
.done:
-
 
994
        ret
-
 
995
 
861
 
996
 
862
; linux/arch/x86/platform/efi/efi.c
997
; linux/arch/x86/platform/efi/efi.c
863
; do_add_efi_memmap
998
; do_add_efi_memmap
864
add_uefi_memmap:
999
add_uefi_memmap:
865
        push    rax rbx rcx rdx rsi rdi
1000
        push    rax rbx rcx rdx rsi rdi
866
 
1001
 
867
        mov     r10d, [rsi+EFI_MEMORY_DESCRIPTOR.Type]
1002
        mov     r10d, [rsi+EFI_MEMORY_DESCRIPTOR.Type]
868
        mov     r11, [rsi+EFI_MEMORY_DESCRIPTOR.PhysicalStart]
1003
        mov     r11, [rsi+EFI_MEMORY_DESCRIPTOR.PhysicalStart]
869
        mov     r13, [rsi+EFI_MEMORY_DESCRIPTOR.NumberOfPages]
1004
        mov     r13, [rsi+EFI_MEMORY_DESCRIPTOR.NumberOfPages]
870
        mov     r14, [rsi+EFI_MEMORY_DESCRIPTOR.Attribute]
1005
        mov     r14, [rsi+EFI_MEMORY_DESCRIPTOR.Attribute]
871
 
1006
 
872
        mov     [rdi+e820entry.addr], r11
1007
        mov     [rdi+e820entry.addr], r11
873
        mov     rax, r13
1008
        mov     rax, r13
874
        shl     rax, 12
1009
        shl     rax, 12
875
        mov     [rdi+e820entry.size], rax
1010
        mov     [rdi+e820entry.size], rax
876
 
1011
 
877
 
1012
 
878
        cmp     r10d, EFI_LOADER_CODE
1013
        cmp     r10d, EFI_LOADER_CODE
879
        jz      .case0
1014
        jz      .case0
880
        cmp     r10d, EFI_LOADER_DATA
1015
        cmp     r10d, EFI_LOADER_DATA
881
        jz      .case0
1016
        jz      .case0
882
        cmp     r10d, EFI_BOOT_SERVICES_CODE
1017
        cmp     r10d, EFI_BOOT_SERVICES_CODE
883
        jz      .case0
1018
        jz      .case0
884
        cmp     r10d, EFI_BOOT_SERVICES_DATA
1019
        cmp     r10d, EFI_BOOT_SERVICES_DATA
885
        jz      .case0
1020
        jz      .case0
886
        cmp     r10d, EFI_CONVENTIONAL_MEMORY
1021
        cmp     r10d, EFI_CONVENTIONAL_MEMORY
887
        jz      .case0
1022
        jz      .case0
888
        cmp     r10d, EFI_ACPI_RECLAIM_MEMORY
1023
        cmp     r10d, EFI_ACPI_RECLAIM_MEMORY
889
        jz      .case1
1024
        jz      .case1
890
        cmp     r10d, EFI_ACPI_MEMORY_NVS
1025
        cmp     r10d, EFI_ACPI_MEMORY_NVS
891
        jz      .case2
1026
        jz      .case2
892
        cmp     r10d, EFI_UNUSABLE_MEMORY
1027
        cmp     r10d, EFI_UNUSABLE_MEMORY
893
        jz      .case3
1028
        jz      .case3
894
        cmp     r10d, EFI_PERSISTENT_MEMORY
1029
        cmp     r10d, EFI_PERSISTENT_MEMORY
895
        jz      .case4
1030
        jz      .case4
896
        jmp     .default
1031
        jmp     .default
897
 
1032
 
898
.case0:
1033
.case0:
899
        test    r14, EFI_MEMORY_WB
1034
        test    r14, EFI_MEMORY_WB
900
        jz      @f
1035
        jz      @f
901
        mov     eax, E820_RAM
1036
        mov     eax, E820_RAM
902
        jmp     .done
1037
        jmp     .done
903
    @@:
1038
    @@:
904
        mov     eax, E820_RESERVED
1039
        mov     eax, E820_RESERVED
905
        jmp     .done
1040
        jmp     .done
906
.case1:
1041
.case1:
907
        mov     eax, E820_ACPI
1042
        mov     eax, E820_ACPI
908
        jmp     .done
1043
        jmp     .done
909
.case2:
1044
.case2:
910
        mov     eax, E820_NVS
1045
        mov     eax, E820_NVS
911
        jmp     .done
1046
        jmp     .done
912
.case3:
1047
.case3:
913
        mov     eax, E820_UNUSABLE
1048
        mov     eax, E820_UNUSABLE
914
        jmp     .done
1049
        jmp     .done
915
.case4:
1050
.case4:
916
        mov     eax, E820_PMEM
1051
        mov     eax, E820_PMEM
917
        jmp     .done
1052
        jmp     .done
918
.default:
1053
.default:
919
        mov     eax, E820_RESERVED
1054
        mov     eax, E820_RESERVED
920
        jmp     .done
1055
        jmp     .done
921
 
1056
 
922
.done:
1057
.done:
923
        mov     [rdi+e820entry.type], eax
1058
        mov     [rdi+e820entry.type], eax
924
 
1059
 
925
        mov     rax, BOOT_LO.memmap_block_cnt
1060
        mov     rax, BOOT_LO.memmap_block_cnt
926
        inc     word[rax]
1061
        inc     word[rax]
927
 
1062
 
928
        pop     rdi rsi rdx rcx rbx rax
1063
        pop     rdi rsi rdx rcx rbx rax
929
        ret
1064
        ret
930
 
1065
 
931
 
1066
 
932
num2dec:
1067
num2dec:
933
        push    rax rbx rcx rdx rsi rdi
1068
        push    rax rbx rcx rdx rsi rdi
934
 
1069
 
935
        xor     ecx, ecx
1070
        xor     ecx, ecx
936
        mov     ebx, 10
1071
        mov     ebx, 10
937
.next_digit:
1072
.next_digit:
938
        xor     edx, edx
1073
        xor     edx, edx
939
        div     ebx
1074
        div     ebx
940
        push    rdx
1075
        push    rdx
941
        inc     ecx
1076
        inc     ecx
942
        test    eax, eax
1077
        test    eax, eax
943
        jnz     .next_digit
1078
        jnz     .next_digit
944
 
1079
 
945
.next_char:
1080
.next_char:
946
        pop     rax
1081
        pop     rax
947
        add     eax, '0'
1082
        add     eax, '0'
948
        stosw
1083
        stosw
949
        loop    .next_char
1084
        loop    .next_char
950
 
1085
 
951
        pop     rdi rsi rdx rcx rbx rax
1086
        pop     rdi rsi rdx rcx rbx rax
952
        ret
1087
        ret
953
 
1088
 
954
 
1089
 
955
num2hex:
1090
num2hex:
956
        push    rax rbx rcx rdx rsi rdi
1091
        push    rax rbx rcx rdx rsi rdi
957
 
1092
 
958
        xchg    rdx, rax
1093
        xchg    rdx, rax
959
        mov     ecx, 16
1094
        mov     ecx, 16
960
.next_tetra:
1095
.next_tetra:
961
        rol     rdx, 4
1096
        rol     rdx, 4
962
        movzx   eax, dl
1097
        movzx   eax, dl
963
        and     eax, 0x0f
1098
        and     eax, 0x0f
964
        movzx   eax, byte[hex+eax]
1099
        movzx   eax, byte[hex+eax]
965
        stosw
1100
        stosw
966
        loop    .next_tetra
1101
        loop    .next_tetra
967
 
1102
 
968
        pop     rdi rsi rdx rcx rbx rax
1103
        pop     rdi rsi rdx rcx rbx rax
969
        ret
1104
        ret
970
 
1105
 
971
hex db '0123456789ABCDEF'
1106
hex db '0123456789ABCDEF'
972
 
1107
 
973
clearbuf:
1108
clearbuf:
974
        push    rax rbx rcx rdx rsi rdi
1109
        push    rax rbx rcx rdx rsi rdi
975
        mov     eax, 0x0020
1110
        mov     eax, 0x0020
976
        mov     ecx, 79
1111
        mov     ecx, 79
977
        mov     rdi, msg
1112
        mov     rdi, msg
978
        rep stosw
1113
        rep stosw
979
        pop     rdi rsi rdx rcx rbx rax
1114
        pop     rdi rsi rdx rcx rbx rax
980
        ret
1115
        ret
981
 
1116
 
982
section '.data' data readable writeable
1117
section '.data' data readable writeable
983
efi_handle  dq 0
1118
efi_handle  dq 0
984
efi_table   dq 0
1119
efi_table   dq 0
985
uefi_rsptmp dq 0
1120
uefi_rsptmp dq 0
986
 
1121
 
987
GDTR:
1122
GDTR:
988
        dw 4*8-1
1123
        dw 4*8-1
989
        dq GDT
1124
        dq GDT
990
GDT:
1125
GDT:
991
        dw 0, 0, 0, 0
1126
        dw 0, 0, 0, 0
992
        dw 0FFFFh,0,9A00h,0CFh          ; 32-bit code
1127
        dw 0FFFFh,0,9A00h,0CFh          ; 32-bit code
993
        dw 0FFFFh,0,9200h,0CFh          ; flat data
1128
        dw 0FFFFh,0,9200h,0CFh          ; flat data
994
        dw 0FFFFh,0,9A00h,0AFh          ; 64-bit code
1129
        dw 0FFFFh,0,9A00h,0AFh          ; 64-bit code
995
 
1130
 
996
 
1131
 
997
fb_base         dq 0
1132
fb_base         dq 0
998
 
1133
 
999
gopuuid         db EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
1134
gopuuid         db EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
1000
gop_buffer_size dq GOP_BUFFER_SIZE
1135
gop_buffer_size dq GOP_BUFFER_SIZE
1001
gop_handle      dq 0
1136
gop_handle      dq 0
1002
gop_interface   dq 0
1137
gop_interface   dq 0
1003
gop_info_size   dq 0
1138
gop_info_size   dq 0
1004
gop_info        dq 0
1139
gop_info        dq 0
1005
 
1140
 
1006
lipuuid         db EFI_LOADED_IMAGE_PROTOCOL_GUID
1141
lipuuid         db EFI_LOADED_IMAGE_PROTOCOL_GUID
1007
lip_buffer_size dq LIP_BUFFER_SIZE
1142
lip_buffer_size dq LIP_BUFFER_SIZE
1008
lip_handle      dq 0
1143
lip_handle      dq 0
1009
lip_interface   dq 0
1144
lip_interface   dq 0
1010
 
1145
 
1011
sfspguid        db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
1146
sfspguid        db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
1012
sfsp_interface  dq 0
1147
sfsp_interface  dq 0
1013
 
1148
 
1014
esp_root        dq ?
1149
esp_root        dq ?
1015
file_handle     dq ?
1150
file_handle     dq ?
1016
file_name       du '\EFI\KOLIBRIOS\KOLIBRI.INI',0
1151
file_name       du '\EFI\KOLIBRIOS\KOLIBRI.INI',0
1017
kernel_name     du '\EFI\KOLIBRIOS\KOLIBRI.KRN',0
1152
kernel_name     du '\EFI\KOLIBRIOS\KOLIBRI.KRN',0
1018
ramdisk_name    du '\EFI\KOLIBRIOS\KOLIBRI.IMG',0
1153
ramdisk_name    du '\EFI\KOLIBRIOS\KOLIBRI.IMG',0
1019
devicesdat_name du '\EFI\KOLIBRIOS\DEVICES.DAT',0
1154
devicesdat_name du '\EFI\KOLIBRIOS\DEVICES.DAT',0
1020
file_buffer_size dq FILE_BUFFER_SIZE-1  ; leave the last byte for \0
1155
file_buffer_size dq FILE_BUFFER_SIZE-1  ; leave the last byte for \0
1021
 
1156
 
1022
config_options  dq cfg_opt_name_resolution, cfg_opt_func_resolution, \
1157
config_options  dq cfg_opt_name_resolution, cfg_opt_func_resolution, \
1023
                   cfg_opt_cmnt_resolution, \
1158
                   cfg_opt_cmnt_resolution, \
1024
                   cfg_opt_name_acpi,  cfg_opt_func_acpi, cfg_opt_cmnt_acpi, \
1159
                   cfg_opt_name_acpi,  cfg_opt_func_acpi, cfg_opt_cmnt_acpi, \
1025
                   cfg_opt_name_debug_print, cfg_opt_func_debug_print, \
1160
                   cfg_opt_name_debug_print, cfg_opt_func_debug_print, \
1026
                   cfg_opt_cmnt_debug_print, \
1161
                   cfg_opt_cmnt_debug_print, \
1027
                   cfg_opt_name_launcher_start, cfg_opt_func_launcher_start, \
1162
                   cfg_opt_name_launcher_start, cfg_opt_func_launcher_start, \
1028
                   cfg_opt_cmnt_launcher_start, \
1163
                   cfg_opt_cmnt_launcher_start, \
1029
                   cfg_opt_name_mtrr,  cfg_opt_func_mtrr, cfg_opt_cmnt_mtrr, \
1164
                   cfg_opt_name_mtrr,  cfg_opt_func_mtrr, cfg_opt_cmnt_mtrr, \
1030
                   cfg_opt_name_ask_params,  cfg_opt_func_ask_params, \
1165
                   cfg_opt_name_ask_params,  cfg_opt_func_ask_params, \
1031
                   cfg_opt_cmnt_ask_params, \
1166
                   cfg_opt_cmnt_ask_params, \
1032
                   cfg_opt_name_imgfrom, cfg_opt_func_imgfrom, \
1167
                   cfg_opt_name_imgfrom, cfg_opt_func_imgfrom, \
1033
                   cfg_opt_cmnt_imgfrom, \
1168
                   cfg_opt_cmnt_imgfrom, \
1034
                   cfg_opt_name_syspath, cfg_opt_func_syspath, \
1169
                   cfg_opt_name_syspath, cfg_opt_func_syspath, \
1035
                   cfg_opt_cmnt_syspath, \
1170
                   cfg_opt_cmnt_syspath, \
1036
                   0
1171
                   0
1037
 
1172
 
1038
cfg_opt_name_resolution     db "resolution",0
1173
cfg_opt_name_resolution     db "resolution",0
1039
cfg_opt_name_acpi           db "acpi",0
1174
cfg_opt_name_acpi           db "acpi",0
1040
cfg_opt_name_debug_print    db "debug_print",0
1175
cfg_opt_name_debug_print    db "debug_print",0
1041
cfg_opt_name_launcher_start db "launcher_start",0
1176
cfg_opt_name_launcher_start db "launcher_start",0
1042
cfg_opt_name_mtrr           db "mtrr",0
1177
cfg_opt_name_mtrr           db "mtrr",0
1043
cfg_opt_name_ask_params     db "ask_params",0
1178
cfg_opt_name_ask_params     db "ask_params",0
1044
cfg_opt_name_imgfrom        db "imgfrom",0
1179
cfg_opt_name_imgfrom        db "imgfrom",0
1045
cfg_opt_name_syspath        db "syspath",0
1180
cfg_opt_name_syspath        db "syspath",0
1046
 
1181
 
1047
cfg_opt_cmnt_resolution     db "# Graphic mode",0
1182
cfg_opt_cmnt_resolution     db "# Graphic mode",0
1048
cfg_opt_cmnt_acpi           db "# ACPI settings",0xa, \
1183
cfg_opt_cmnt_acpi           db "# ACPI settings",0xa, \
1049
                               "#   0: don't use",0xa, \
1184
                               "#   0: don't use",0xa, \
1050
                               "#   1: parse ACPI tables",0xa, \
1185
                               "#   1: parse ACPI tables",0xa, \
1051
                               "#   2: + call _PIC method",0xa, \
1186
                               "#   2: + call _PIC method",0xa, \
1052
                               "#   3: + get APIC interrupts",0xa,0
1187
                               "#   3: + get APIC interrupts",0xa,0
1053
cfg_opt_cmnt_debug_print    db "# Duplicate debug output to the screen",0
1188
cfg_opt_cmnt_debug_print    db "# Duplicate debug output to the screen",0
1054
cfg_opt_cmnt_launcher_start db "# Start LAUNCHER app after kernel is loaded",0
1189
cfg_opt_cmnt_launcher_start db "# Start LAUNCHER app after kernel is loaded",0
1055
cfg_opt_cmnt_mtrr           db "# Configure MTRR's",0
1190
cfg_opt_cmnt_mtrr           db "# Configure MTRR's",0
1056
cfg_opt_cmnt_ask_params     db "# Interrupt booting to ask the user for boot", \
1191
cfg_opt_cmnt_ask_params     db "# Interrupt booting to ask the user for boot", \
1057
                               " params",0
1192
                               " params",0
1058
cfg_opt_cmnt_imgfrom        db "# Where to load ramdisk image from",0
1193
cfg_opt_cmnt_imgfrom        db "# Where to load ramdisk image from",0
1059
cfg_opt_cmnt_syspath        db "# Path to /sys directory",0
1194
cfg_opt_cmnt_syspath        db "# Path to /sys directory",0
1060
 
1195
 
1061
cfg_opt_used_resolution     db 0
1196
cfg_opt_used_resolution     db 0
1062
cfg_opt_used_acpi           db 0
1197
cfg_opt_used_acpi           db 0
1063
cfg_opt_used_debug_print    db 0
1198
cfg_opt_used_debug_print    db 0
1064
cfg_opt_used_launcher_start db 0
1199
cfg_opt_used_launcher_start db 0
1065
cfg_opt_used_mtrr           db 0
1200
cfg_opt_used_mtrr           db 0
1066
cfg_opt_used_ask_params     db 0
1201
cfg_opt_used_ask_params     db 0
1067
cfg_opt_used_imgfrom        db 0
1202
cfg_opt_used_imgfrom        db 0
1068
cfg_opt_used_syspath        db 0
1203
cfg_opt_used_syspath        db 0
1069
 
1204
 
1070
cfg_opt_value_vmode          db 0
1205
cfg_opt_value_vmode          db 0
1071
cfg_opt_value_acpi           db 0
1206
cfg_opt_value_acpi           db 0
1072
cfg_opt_value_debug_print    db 0
1207
cfg_opt_value_debug_print    db 0
1073
cfg_opt_value_launcher_start db 1
1208
cfg_opt_value_launcher_start db 1
1074
cfg_opt_value_mtrr           db 0
1209
cfg_opt_value_mtrr           db 0
1075
cfg_opt_value_ask_params     db 0
1210
cfg_opt_value_ask_params     db 0
1076
cfg_opt_value_imgfrom        db RD_LOAD_FROM_MEMORY
1211
cfg_opt_value_imgfrom        db RD_LOAD_FROM_MEMORY
1077
cfg_opt_value_syspath        db "/RD/1",0
1212
cfg_opt_value_syspath        db "/RD/1",0
1078
                             rb 20
1213
                             rb 20
1079
 
1214
 
1080
memory_map_key  dq 0
1215
memory_map_key  dq 0
1081
descriptor_size dq 0
1216
descriptor_size dq 0
1082
descriptor_ver  dq 0
1217
descriptor_ver  dq 0
1083
memory_map_size dq MEMORY_MAP_SIZE
1218
memory_map_size dq MEMORY_MAP_SIZE
1084
 
1219
 
1085
msg_u4k_loaded            du "uefi64kos loaded",13,10,0
1220
msg_u4k_loaded            du "uefi64kos loaded",13,10,0
1086
msg_read_options          du "Read options from config file",13,10,0
1221
msg_read_options          du "Read options from config file",13,10,0
-
 
1222
msg_file_size             du "File size:",13,10,0
-
 
1223
msg_parsing_config        du "Parsing config file",13,10,0
1087
msg_load_kernel           du "Load kernel",13,10,0
1224
msg_load_kernel           du "Load kernel",13,10,0
1088
msg_load_ramdisk          du "Load ramdisk",13,10,0
1225
msg_load_ramdisk          du "Load ramdisk",13,10,0
1089
msg_load_devicesdat       du "Load DEVICES.DAT",13,10,0
1226
msg_load_devicesdat       du "Load DEVICES.DAT",13,10,0
1090
msg_alloc_devicesdat      du "Allocate memory for DEVICES.DAT",13,10,0
1227
msg_alloc_devicesdat      du "Allocate memory for DEVICES.DAT",13,10,0
1091
msg_locate_gop_handlers   du "Locate GOP handlers",13,10,0
1228
msg_locate_gop_handlers   du "Locate GOP handlers",13,10,0
1092
msg_look_for_gop_handler  du "Look for GOP handler",13,10,0
1229
msg_look_for_gop_handler  du "Look for GOP handler",13,10,0
1093
msg_query_handler         du "Query handler",13,10,0
1230
msg_query_handler         du "Query handler",13,10,0
1094
msg_query_vmode           du "Query vmode",13,10,0
1231
msg_query_vmode           du "Query vmode",13,10,0
1095
msg_vmode_found           du "Video mode found",13,10,0
1232
msg_vmode_found           du "Video mode found",13,10,0
1096
msg_look_for_rsdp         du "Look for RSDP",13,10,0
1233
msg_look_for_rsdp         du "Look for RSDP",13,10,0
1097
msg_rsdp_found            du "RSDP found",13,10,0
1234
msg_rsdp_found            du "RSDP found",13,10,0
1098
msg_acpi_tables_done      du "ACPI tables done",13,10,0
1235
msg_acpi_tables_done      du "ACPI tables done",13,10,0
1099
msg_ask_for_params        du "Ask for params",13,10,0
1236
msg_ask_for_params        du "Ask for params",13,10,0
1100
msg_set_graphic_mode      du "Set graphic mode",13,10,0
1237
msg_set_graphic_mode      du "Set graphic mode",13,10,0
1101
msg_success               du "Success!",13,10,0
1238
msg_success               du "Success!",13,10,0
1102
msg_gop_buffer_size       du "GOP buffer size",13,10,0
1239
msg_gop_buffer_size       du "GOP buffer size",13,10,0
1103
msg_opt_resolution        du "option resolution: ",0
1240
msg_opt_resolution        du "Option resolution: ",0
-
 
1241
msg_memmap                du "Memmap",13,10,0
1104
msg_error                 du "Error!",13,10,0
1242
msg_error                 du "Error!",13,10,0
-
 
1243
msg_error_efi_lip_handle  du "efi_handle can't handle LIP",13,10,0
-
 
1244
msg_error_lip_dev_sfsp    du "LIP device handle can't handle SFSP",13,10,0
-
 
1245
msg_error_sfsp_openvolume du "SFSP OpenVolume failed",13,10,0
1105
msg_error_no_such_vmode   du "No such vmode",13,10,0
1246
msg_error_no_such_vmode   du "No such vmode",13,10,0
1106
msg_error_out_of_handlers du "Out of handlers",13,10,0
1247
msg_error_out_of_handlers du "Out of handlers",13,10,0
1107
msg_error_open_file       du "Error: can't open file ",0
1248
msg_error_open_file       du "Error: can't open file ",0
-
 
1249
msg_error_exit_boot_services du "Error: Exit boot services",13,10,0
1108
msg                       du 79 dup " ",13,10,0
1250
msg                       du 79 dup " ",13,10,0
1109
 
1251
 
1110
efi_fs_info_id db EFI_FILE_SYSTEM_INFO_ID
1252
efi_fs_info_id db EFI_FILE_SYSTEM_INFO_ID
1111
efi_fs_info_size dq sizeof.EFI_FILE_SYSTEM_INFO
1253
efi_fs_info_size dq sizeof.EFI_FILE_SYSTEM_INFO
1112
efi_fs_info EFI_FILE_SYSTEM_INFO
1254
efi_fs_info EFI_FILE_SYSTEM_INFO
1113
 
1255
 
1114
memory_map      dq ?
1256
memory_map      dq ?
1115
gop_buffer      rq GOP_BUFFER_SIZE/8
1257
gop_buffer      rq GOP_BUFFER_SIZE/8
1116
devicesdat_data dq 0xffffffff
1258
devicesdat_data dq 0xffffffff
1117
devicesdat_size dq 0x1000
1259
devicesdat_size dq 0x1000
1118
status          dq ?
1260
status          dq ?
1119
 
1261
 
1120
section '.reloc' fixups data discardable
1262
section '.reloc' fixups data discardable