Subversion Repositories Kolibri OS

Rev

Rev 8092 | Rev 8206 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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