Subversion Repositories Kolibri OS

Rev

Rev 862 | Rev 864 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 862 Rev 863
Line 56... Line 56...
56
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
57
 
57
 
Line 58... Line 58...
58
include 'macros.inc'
58
include 'macros.inc'
Line 59... Line 59...
59
 
59
 
Line 60... Line 60...
60
$Revision: 862 $
60
$Revision: 863 $
Line 61... Line 61...
61
 
61
 
Line 127... Line 127...
127
public _rd_fat_end
127
public _rd_fat_end
128
public _rd_root
128
public _rd_root
129
public _rd_root_end
129
public _rd_root_end
130
 
130
 
Line -... Line 131...
-
 
131
 
-
 
132
extrn __edata
-
 
133
 
131
extrn _16bit_start
134
extrn _16bit_start
132
extrn _16bit_end
135
extrn _16bit_end
Line 133... Line 136...
133
 
136
 
-
 
137
extrn _enter_bootscreen
Line 134... Line 138...
134
extrn _enter_bootscreen
138
extrn _poweroff
135
 
139
 
Line 136... Line 140...
136
extrn _init
140
extrn _init
Line 211... Line 215...
211
           xor eax, eax
215
           xor eax, eax
212
           mov [cpu_caps], eax
216
           mov [cpu_caps], eax
213
           mov [cpu_caps+4], eax
217
           mov [cpu_caps+4], eax
214
 
218
 
Line 215... Line -...
215
           pushfd
-
 
216
           pop eax
-
 
217
           mov ecx, eax
-
 
218
           xor eax, 0x40000
-
 
219
           push eax
-
 
220
           popfd
-
 
221
           pushfd
-
 
222
           pop eax
-
 
223
           xor eax, ecx
-
 
224
           mov [cpu_type], CPU_386
-
 
225
           jz .end_cpuid
-
 
226
           push ecx
-
 
227
           popfd
-
 
228
 
-
 
229
           mov [cpu_type], CPU_486
-
 
230
           mov eax, ecx
-
 
231
           xor eax, 0x200000
-
 
232
           push eax
-
 
233
           popfd
-
 
234
           pushfd
-
 
235
           pop eax
-
 
236
           xor eax, ecx
-
 
237
           je .end_cpuid
-
 
238
           mov [cpu_id], 1
-
 
239
 
-
 
240
           xor eax, eax
219
           xor eax, eax
241
           cpuid
220
           cpuid
Line 242... Line 221...
242
 
221
 
243
           mov [cpu_vendor], ebx
222
           mov [cpu_vendor], ebx
Line 297... Line 276...
297
           ret
276
           ret
298
endp
277
endp
299
 
278
 
Line 300... Line 279...
300
align 4
279
align 4
-
 
280
_copy_pg_balloc  dd 0
-
 
281
 
-
 
282
 
301
_high_code:
283
_high_code:
Line 302... Line 284...
302
 
284
 
303
	   mov ax,os_stack
285
	   mov ax,os_stack
304
           mov dx,app_data
286
           mov dx,app_data
Line 329... Line 311...
329
 
311
 
Line 330... Line 312...
330
           call test_cpu
312
           call test_cpu
331
           call _init
313
           call _init
Line -... Line 314...
-
 
314
 
-
 
315
           mov eax, [_pg_balloc]
-
 
316
           mov [_copy_pg_balloc], eax
332
 
317
 
333
	   mov [tss._ss0], os_stack
318
	   mov [tss._ss0], os_stack
334
           mov [tss._esp0], __os_stack
319
           mov [tss._esp0], __os_stack
335
           mov [tss._esp], __os_stack
320
           mov [tss._esp], __os_stack
336
	   mov [tss._cs],os_code
321
	   mov [tss._cs],os_code
Line 349... Line 334...
349
 
334
 
Line 350... Line 335...
350
	   mov	ax,tss0
335
	   mov	ax,tss0
351
	   ltr	ax
336
	   ltr	ax
Line -... Line 337...
-
 
337
 
-
 
338
__core_restart:
352
 
339
 
353
           mov ecx, 1280*1024
340
           mov ecx, 1280*1024
354
           fastcall _balloc
341
           fastcall _balloc
Line 355... Line 342...
355
           mov [_display_data], eax
342
           mov [_display_data], eax
Line 5169... Line 5156...
5169
	   pop	eax
5156
	   pop	eax
5170
	   call sys_cd_audio
5157
	   call sys_cd_audio
5171
 
5158
 
Line 5172... Line 5159...
5172
yes_shutdown_param:
5159
yes_shutdown_param:
-
 
5160
 
5173
	   cli
5161
	   cli
Line 5174... Line -...
5174
 
-
 
5175
	   mov	eax, kernel_file ; load kernel.mnt to 0x7000:0
-
 
5176
	   push 12
-
 
5177
	   pop	esi
-
 
5178
	   xor	ebx,ebx
-
 
5179
	   or	ecx,-1
-
 
5180
	   mov	edx, OS_BASE+0x70000
-
 
5181
	   call fileread
-
 
5182
 
-
 
5183
   ;        mov  esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0
5162
 
5184
   ;        mov  edi,OS_BASE+0x40000
-
 
5185
   ;        mov  ecx,1000
5163
           cmp byte [BOOT_VAR+0x9030], 3
Line -... Line 5164...
-
 
5164
           je _sys_reboot
-
 
5165
 
-
 
5166
           cmp byte [BOOT_VAR+0x9030], 4
-
 
5167
           je _sys_restart
5186
   ;        rep  movsb
5168
 
5187
 
5169
           cld
5188
           mov  esi, BOOT_VAR    ; restore 0x0 - 0xffff
5170
           mov  esi, BOOT_VAR    ; restore 0x0 - 0xffff
5189
           mov  edi, OS_BASE
-
 
5190
           mov  ecx,0x10000/4
5171
           mov  edi, OS_BASE
Line -... Line 5172...
-
 
5172
           mov  ecx,0x10000/4
-
 
5173
           rep movsd
5191
           cld
5174
 
-
 
5175
           mov esi, _16bit_start + OS_BASE
-
 
5176
           mov ecx, _16bit_end
Line 5192... Line 5177...
5192
           rep movsd
5177
           shr ecx, 2
5193
 
-
 
5194
	   call restorefatchain
-
 
5195
 
-
 
5196
	   mov al, 0xFF
-
 
5197
	   out 0x21, al
5178
           mov edi, _16BIT_BASE + OS_BASE
5198
	   out 0xA1, al
5179
           rep movsd
Line 5199... Line -...
5199
 
-
 
5200
if 1
-
 
5201
       ;    mov  word [OS_BASE+0x467+0],pr_mode_exit
5180
 
5202
       ;    mov  word [OS_BASE+0x467+2],0x1000
-
 
Line 5203... Line -...
5203
 
-
 
5204
	   mov	al,0x0F
-
 
Line 5205... Line 5181...
5205
	   out	0x70,al
5181
           mov dword [_sys_pdbr],   PG_LARGE+PG_SW
Line 5206... Line 5182...
5206
	   mov	al,0x05
5182
           mov eax, _sys_pdbr + (0x100000000-OS_BASE)
5207
	   out	0x71,al
5183
           mov cr3, eax
-
 
5184
 
5208
 
5185
           jmp far 0x60:_poweroff;
5209
	   mov	al,0xFE
5186
 
5210
	   out	0x64,al
5187
 
5211
 
5188
_sys_restart:
5212
	   hlt
5189
 
5213
 
5190
           mov ax,os_stack
5214
else
5191
           mov dx,app_data
5215
	cmp	byte [OS_BASE + 0x9030], 2
-
 
5216
	jnz	no_acpi_power_off
5192
	   mov ss,ax
5217
 
-
 
5218
; scan for RSDP
5193
           mov esp, __os_stack
5219
; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA).
-
 
5220
	movzx	eax, word [OS_BASE + 0x40E]
-
 
5221
	shl	eax, 4
-
 
5222
	jz	@f
5194
 
5223
	mov	ecx, 1024/16
-
 
5224
	call	scan_rsdp
-
 
5225
	jnc	.rsdp_found
5195
           mov ds, dx
5226
@@:
-
 
5227
; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh.
5196
           mov es, dx
5228
	mov	eax, 0xE0000
5197
           mov fs, dx
5229
	mov	ecx, 0x2000
5198
           mov gs, dx
5230
	call	scan_rsdp
-
 
5231
	jc	no_acpi_power_off
-
 
5232
.rsdp_found:
-
 
5233
	mov	esi, [eax+16]	; esi contains physical address of the RSDT
-
 
5234
	mov	ebp, [ipc_tmp]
-
 
5235
	stdcall map_page, ebp, esi, PG_MAP
-
 
5236
	lea	eax, [esi+1000h]
-
 
5237
	lea	edx, [ebp+1000h]
-
 
5238
	stdcall map_page, edx, eax, PG_MAP
-
 
5239
	and	esi, 0xFFF
-
 
5240
	add	esi, ebp
-
 
5241
	cmp	dword [esi], 'RSDT'
5199
 
5242
	jnz	no_acpi_power_off
-
 
5243
	mov	ecx, [esi+4]
-
 
5244
	sub	ecx, 24h
-
 
5245
	jbe	no_acpi_power_off
-
 
5246
	shr	ecx, 2
-
 
5247
	add	esi, 24h
5200
           call restorefatchain
5248
.scan_fadt:
-
 
5249
	lodsd
-
 
5250
	mov	ebx, eax
-
 
5251
	lea	eax, [ebp+2000h]
-
 
5252
	stdcall map_page, eax, ebx, PG_MAP
-
 
5253
	lea	eax, [ebp+3000h]
-
 
5254
	add	ebx, 0x1000
-
 
5255
	stdcall map_page, eax, ebx, PG_MAP
5201
 
5256
	and	ebx, 0xFFF
-
 
5257
	lea	ebx, [ebx+ebp+2000h]
-
 
5258
	cmp	dword [ebx], 'FACP'
-
 
5259
	jz	.fadt_found
-
 
5260
	loop	.scan_fadt
-
 
5261
	jmp	no_acpi_power_off
-
 
5262
.fadt_found:
5202
           cld
5263
; ebx is linear address of FADT
-
 
5264
	mov	edx, [ebx+48]
-
 
5265
	test	edx, edx
-
 
5266
	jz	.nosmi
-
 
5267
	mov	al, [ebx+52]
5203
           mov  esi, BOOT_VAR    ; restore 0x0 - 0xffff
5268
	out	dx, al
-
 
5269
	mov	edx, [ebx+64]
-
 
5270
@@:
-
 
5271
	in	ax, dx
-
 
5272
	test	al, 1
5204
           mov  edi, OS_BASE
5273
	jz	@b
5205
           mov  ecx,0x10000/4
5274
.nosmi:
-
 
5275
	mov	edx, [ebx+64]
-
 
5276
	in	ax, dx
-
 
5277
	and	ax, 203h
-
 
5278
	or	ax, 3C00h
-
 
5279
	out	dx, ax
-
 
5280
	mov	edx, [ebx+68]
-
 
Line -... Line 5206...
-
 
5206
           rep movsd
-
 
5207
 
-
 
5208
           mov eax, [_copy_pg_balloc]
-
 
5209
           mov [_pg_balloc], eax
-
 
5210
 
-
 
5211
           mov dword [_sys_pdbr],   PG_LARGE+PG_SW
-
 
5212
           mov eax, _sys_pdbr + (0x100000000-OS_BASE)
Line -... Line 5213...
-
 
5213
           mov cr3, eax
-
 
5214
 
-
 
5215
           mov ecx, LAST_PAGE
-
 
5216
           mov edi, cur_saved_data
5281
	test	edx, edx
5217
           sub edi, OS_BASE
5282
	jz	@f
5218
           sub ecx, edi
5283
	in	ax, dx
5219
           shr ecx, 2
Line 5284... Line 5220...
5284
	and	ax, 203h
5220
           xor eax, eax
5285
	or	ax, 3C00h
5221
           rep stosd
5286
	out	dx, ax
5222
 
5287
@@:
5223
           call test_cpu
Line 5301... Line 5237...
5301
	   out	0x64,al
5237
	   out	0x64,al
5302
 
5238
 
Line 5303... Line 5239...
5303
	   hlt
5239
	   hlt
Line 5304... Line -...
5304
 
-
 
5305
scan_rsdp:
-
 
5306
	add	eax, OS_BASE
-
 
5307
.s:
-
 
5308
	cmp	dword [eax], 'RSD '
-
 
5309
	jnz	.n
-
 
5310
	cmp	dword [eax+4], 'PTR '
-
 
5311
	jnz	.n
-
 
5312
	xor	edx, edx
-
 
5313
	xor	esi, esi
-
 
5314
@@:
-
 
5315
	add	dl, [eax+esi]
-
 
5316
	inc	esi
-
 
5317
	cmp	esi, 20
-
 
5318
	jnz	@b
-
 
5319
	test	dl, dl
-
 
5320
	jz	.ok
-
 
5321
.n:
-
 
5322
	add	eax, 10h
-
 
5323
	loop	.s
-
 
5324
	stc
-
 
5325
.ok:
-
 
5326
	ret
-
 
5327
end if
-
 
5328
 
5240
 
Line 5329... Line 5241...
5329
include "data32.inc"
5241
include "data32.inc"
Line 5330... Line 5242...
5330
 
5242