Subversion Repositories Kolibri OS

Rev

Rev 9958 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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