Subversion Repositories Kolibri OS

Rev

Rev 1952 | Rev 2047 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1952 Rev 2014
Line 56... Line 56...
56
;;
56
;;
57
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
57
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 58... Line 58...
58
 
58
 
Line 59... Line 59...
59
include 'macros.inc'
59
include 'macros.inc'
Line 60... Line 60...
60
 
60
 
Line 61... Line 61...
61
$Revision: 1952 $
61
$Revision: 2014 $
Line 217... Line 217...
217
	   bts [cpu_caps-OS_BASE], CAPS_TSC	;force use rdtsc
217
	   bts [cpu_caps-OS_BASE], CAPS_TSC	;force use rdtsc
Line 218... Line 218...
218
 
218
 
Line 219... Line 219...
219
	   call init_BIOS32	; (init.inc - to be removed later)
219
	   call init_BIOS32	; (init.inc - to be removed later)
-
 
220
 
220
 
221
; PCIe extended config space access
-
 
222
 
221
; PCIe extended config space access
223
	display '** Platform chosen (const.inc): '
-
 
224
if PLATFORM>PLATFORM_RS780
-
 
225
	call fusion_pcie_init	; (bus/HT.inc)
-
 
226
	display 'RS880/Fusion '
-
 
227
else
-
 
228
	call rs7xx_pcie_init	; (bus/HT.inc)
-
 
229
	display 'RS780 '
-
 
230
end if
Line 222... Line 231...
222
;           call rs7xx_pcie_init ; (bus/HT.inc)
231
	display 10,13
223
	   call fusion_pcie_init	; (bus/HT.inc)
232
 
224
 
233
 
Line 240... Line 249...
240
 
249
 
241
align 4
250
align 4
242
bios32_entry	dd ?
251
bios32_entry	dd ?
Line 243... Line 252...
243
tmp_page_tabs	dd ?
252
tmp_page_tabs	dd ?
244
 
253
 
245
use16
254
;use16
246
org $-0x10000
255
;org $-0x10000
-
 
256
;include "boot/shutdown.inc" ; shutdown or restart
247
include "boot/shutdown.inc" ; shutdown or restart
257
;org $+0x10000
Line 248... Line 258...
248
org $+0x10000
258
 
249
use32
259
use32
250
 
260
 
Line 570... Line 580...
570
 
580
 
571
;!!!!!!!!!!!!!!!!!!!!!!!
581
;!!!!!!!!!!!!!!!!!!!!!!!
572
include 'vmodeld.inc'
582
include 'vmodeld.inc'
Line 573... Line -...
573
;!!!!!!!!!!!!!!!!!!!!!!!
-
 
574
 
-
 
575
if 0
-
 
576
  mov ax,[OS_BASE+0x10000+bx_from_load]
-
 
577
  cmp ax,'r1'		; if using not ram disk, then load librares and parameters {SPraid.simba}
-
 
578
  je  no_lib_load
-
 
579
; LOADING LIBRARES
-
 
580
   stdcall dll.Load,@IMPORT		    ; loading librares for kernel (.obj files)
-
 
581
   call load_file_parse_table		    ; prepare file parse table
-
 
582
   call set_kernel_conf 		    ; configure devices and gui
-
 
Line 583... Line 583...
583
no_lib_load:
583
;!!!!!!!!!!!!!!!!!!!!!!!
Line 584... Line 584...
584
end if
584
 
585
 
585
 
Line 586... Line 586...
586
; LOAD FONTS I and II
586
; LOAD FONTS I and II
587
 
587
 
Line 588... Line 588...
588
	stdcall read_file, char, FONT_I, 0, 2304
588
	stdcall read_file, char, FONT_I, 0, 2304
589
	stdcall read_file, char2, FONT_II, 0, 2560
589
	stdcall read_file, char2, FONT_II, 0, 2560
590
 
590
 
Line 591... Line 591...
591
	mov   esi,boot_fonts
591
;        mov   esi,boot_fonts
592
	call  boot_log
592
;        call  boot_log
593
 
593
 
594
; PRINT AMOUNT OF MEMORY
594
; PRINT AMOUNT OF MEMORY
Line 608... Line 608...
608
 
608
 
Line 609... Line 609...
609
; BUILD SCHEDULER
609
; BUILD SCHEDULER
Line 610... Line 610...
610
 
610
 
611
	call   build_scheduler ; sys32.inc
611
	call   build_scheduler ; sys32.inc
Line 612... Line 612...
612
 
612
 
Line 613... Line 613...
613
	mov    esi,boot_devices
613
;        mov    esi,boot_devices
Line 622... Line 622...
622
	call  boot_log
622
	call  boot_log
623
	call  set_window_defaults
623
	call  set_window_defaults
Line 624... Line 624...
624
 
624
 
Line 625... Line 625...
625
; SET BACKGROUND DEFAULTS
625
; SET BACKGROUND DEFAULTS
626
 
626
 
627
	mov   esi,boot_bgr
627
;        mov   esi,boot_bgr
628
	call  boot_log
628
;        call  boot_log
Line 629... Line 629...
629
	call  init_background	;
629
	call  init_background	;
Line 630... Line 630...
630
	call  calculatebackground
630
	call  calculatebackground
631
 
631
 
Line 632... Line 632...
632
; SET UP OS TASK
632
; SET UP OS TASK
633
 
633
 
634
	mov  esi,boot_setostask
634
;        mov  esi,boot_setostask
635
	call boot_log
635
;        call boot_log
Line 681... Line 681...
681
	mov [SLOT_BASE+APPDATA.cursor+256],eax
681
	mov [SLOT_BASE+APPDATA.cursor+256],eax
Line 682... Line 682...
682
 
682
 
Line 683... Line 683...
683
 
683
 
684
  ; READ TSC / SECOND
684
  ; READ TSC / SECOND
685
 
685
 
686
	mov   esi,boot_tsc
686
;        mov   esi,boot_tsc
687
	call  boot_log
687
;        call  boot_log
688
	cli
688
	cli
689
	rdtsc ;call  _rdtsc
689
	rdtsc ;call  _rdtsc
Line 722... Line 722...
722
; SET MOUSE
722
; SET MOUSE
Line 723... Line 723...
723
 
723
 
724
	;call   detect_devices
724
	;call   detect_devices
Line 725... Line 725...
725
	stdcall load_driver, szPS2MDriver
725
	stdcall load_driver, szPS2MDriver
726
 
726
 
727
	mov   esi,boot_setmouse
727
;        mov   esi,boot_setmouse
728
	call  boot_log
728
;        call  boot_log
729
;       call  setmouse
729
;       call  setmouse
Line 730... Line 730...
730
;     mov     [MOUSE_PICTURE],dword mousepointer
730
;     mov     [MOUSE_PICTURE],dword mousepointer
Line 752... Line 752...
752
	   stdcall map_page,tss._io_map_1,\
752
	   stdcall map_page,tss._io_map_1,\
753
		   [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
753
		   [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
Line 754... Line 754...
754
 
754
 
755
 
755
 
756
	call init_userDMA	; <<<<<<<<< ============== core/memory.inc =================
756
	call init_userDMA	; <<<<<<<<< ============== core/memory.inc =================
Line 757... Line 757...
757
	mov	esi, boot_uDMA_ok
757
;        mov     esi, boot_uDMA_ok
758
	call	boot_log
758
;        call    boot_log
Line 759... Line 759...
759
 
759
 
Line 777... Line 777...
777
 
777
 
778
;        cmp   eax,2                  ; continue if a process has been loaded
778
;        cmp   eax,2                  ; continue if a process has been loaded
779
	sub   eax,2
779
	sub   eax,2
Line 780... Line 780...
780
	jz    first_app_found
780
	jz    first_app_found
781
 
781
 
Line 782... Line 782...
782
	mov	esi, boot_failed
782
;        mov     esi, boot_failed
783
	call	boot_log
783
;        call    boot_log
Line 784... Line 784...
784
 
784
 
Line 823... Line 823...
823
 
823
 
Line 824... Line 824...
824
 
824
 
825
 
825
 
826
; START MULTITASKING
826
; START MULTITASKING
827
 
827
 
828
if preboot_blogesc
828
;if preboot_blogesc
829
	mov	esi, boot_tasking
829
;        mov     esi, boot_tasking
830
	call	boot_log
830
;        call    boot_log
Line 831... Line 831...
831
.bll1:	in	al, 0x60	; wait for ESC key press
831
;.bll1:  in      al, 0x60        ; wait for ESC key press
Line 832... Line 832...
832
	cmp	al, 129
832
;        cmp     al, 129
Line 4466... Line 4466...
4466
	   call stop_all_services
4466
	   call stop_all_services
Line 4467... Line 4467...
4467
 
4467
 
4468
yes_shutdown_param:
4468
yes_shutdown_param:
Line 4469... Line -...
4469
	   cli
-
 
4470
 
-
 
4471
	   mov	eax, kernel_file ; load kernel.mnt to 0x7000:0
-
 
4472
	   push 12
-
 
4473
	   pop	esi
-
 
4474
	   xor	ebx,ebx
-
 
4475
	   or	ecx,-1
-
 
4476
	   mov	edx, OS_BASE+0x70000
-
 
4477
	   call fileread
-
 
4478
 
-
 
4479
	   mov	esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0
-
 
4480
	   mov	edi,OS_BASE+0x40000
-
 
4481
	   mov	ecx,1000
-
 
4482
	   rep	movsb
-
 
4483
 
-
 
4484
	   mov	esi,OS_BASE+0x2F0000	; restore 0x0 - 0xffff
-
 
4485
	   mov	edi, OS_BASE
-
 
4486
	   mov	ecx,0x10000/4
-
 
4487
	   cld
-
 
4488
	   rep movsd
-
 
Line 4489... Line 4469...
4489
 
4469
	   cli
4490
	   call restorefatchain
4470
 
4491
 
4471
 
Line -... Line 4472...
-
 
4472
	   mov al, 0xFF
-
 
4473
	   out 0x21, al 	;IntrCntrl1Reg2
4492
	   mov al, 0xFF
4474
	   out 0xA1, al 	;IntrCntrl2Reg2
4493
	   out 0x21, al
-
 
4494
	   out 0xA1, al
-
 
4495
 
-
 
4496
if 0
-
 
4497
	   mov	word [OS_BASE+0x467+0],pr_mode_exit
-
 
4498
	   mov	word [OS_BASE+0x467+2],0x1000
-
 
4499
 
-
 
4500
	   mov	al,0x0F
-
 
4501
	   out	0x70,al
-
 
4502
	   mov	al,0x05
-
 
4503
	   out	0x71,al
-
 
4504
 
-
 
4505
	   mov	al,0xFE
-
 
4506
	   out	0x64,al
-
 
4507
 
-
 
4508
	   hlt
-
 
4509
	   jmp $-1
-
 
4510
 
-
 
4511
else
-
 
4512
	cmp	byte [OS_BASE + 0x9030], 2
-
 
4513
	jnz	no_acpi_power_off
-
 
4514
 
-
 
4515
; scan for RSDP
-
 
4516
; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA).
-
 
4517
	movzx	eax, word [OS_BASE + 0x40E]
-
 
4518
	shl	eax, 4
-
 
4519
	jz	@f
-
 
4520
	mov	ecx, 1024/16
-
 
4521
	call	scan_rsdp
-
 
4522
	jnc	.rsdp_found
-
 
4523
@@:
-
 
4524
; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh.
-
 
4525
	mov	eax, 0xE0000
-
 
4526
	mov	ecx, 0x2000
-
 
4527
	call	scan_rsdp
4475
 
4528
	jc	no_acpi_power_off
-
 
4529
.rsdp_found:
-
 
4530
	mov	esi, [eax+16]	; esi contains physical address of the RSDT
-
 
4531
	mov	ebp, [ipc_tmp]
-
 
4532
	stdcall map_page, ebp, esi, PG_MAP
-
 
4533
	lea	eax, [esi+1000h]
-
 
4534
	lea	edx, [ebp+1000h]
-
 
4535
	stdcall map_page, edx, eax, PG_MAP
-
 
4536
	and	esi, 0xFFF
-
 
4537
	add	esi, ebp
-
 
4538
	cmp	dword [esi], 'RSDT'
-
 
4539
	jnz	no_acpi_power_off
-
 
4540
	mov	ecx, [esi+4]
-
 
4541
	sub	ecx, 24h
-
 
4542
	jbe	no_acpi_power_off
-
 
4543
	shr	ecx, 2
4476
	cmp	byte [BOOT_VAR + 0x9030], 2
4544
	add	esi, 24h
-
 
4545
.scan_fadt:
-
 
4546
	lodsd
-
 
4547
	mov	ebx, eax
-
 
4548
	lea	eax, [ebp+2000h]
-
 
4549
	stdcall map_page, eax, ebx, PG_MAP
-
 
4550
	lea	eax, [ebp+3000h]
-
 
4551
	add	ebx, 0x1000
-
 
4552
	stdcall map_page, eax, ebx, PG_MAP
-
 
4553
	and	ebx, 0xFFF
-
 
4554
	lea	ebx, [ebx+ebp+2000h]
-
 
4555
	cmp	dword [ebx], 'FACP'
-
 
4556
	jz	.fadt_found
-
 
4557
	loop	.scan_fadt
-
 
4558
	jmp	no_acpi_power_off
-
 
4559
.fadt_found:
-
 
4560
; ebx is linear address of FADT
-
 
4561
	mov	edi, [ebx+40] ; physical address of the DSDT
-
 
4562
	lea	eax, [ebp+4000h]
-
 
4563
	stdcall map_page, eax, edi, PG_MAP
-
 
4564
	lea	eax, [ebp+5000h]
-
 
4565
	lea	esi, [edi+0x1000]
-
 
4566
	stdcall map_page, eax, esi, PG_MAP
-
 
4567
	and	esi, 0xFFF
-
 
4568
	sub	edi, esi
-
 
4569
	cmp	dword [esi+ebp+4000h], 'DSDT'
-
 
4570
	jnz	no_acpi_power_off
-
 
4571
	mov	eax, [esi+ebp+4004h] ; DSDT length
-
 
4572
	sub	eax, 36+4
-
 
4573
	jbe	no_acpi_power_off
-
 
4574
	add	esi, 36
-
 
4575
.scan_dsdt:
-
 
4576
	cmp	dword [esi+ebp+4000h], '_S5_'
-
 
4577
	jnz	.scan_dsdt_cont
-
 
4578
	cmp	byte [esi+ebp+4000h+4], 12h ; DefPackage opcode
-
 
4579
	jnz	.scan_dsdt_cont
-
 
4580
	mov	dl, [esi+ebp+4000h+6]
-
 
4581
	cmp	dl, 4 ; _S5_ package must contain 4 bytes
-
 
4582
		      ; ...in theory; in practice, VirtualBox has 2 bytes
-
 
4583
	ja	.scan_dsdt_cont
-
 
4584
	cmp	dl, 1
-
 
4585
	jb	.scan_dsdt_cont
-
 
4586
	lea	esi, [esi+ebp+4000h+7]
-
 
4587
	xor	ecx, ecx
-
 
4588
	cmp	byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx
-
 
4589
	jz	@f
-
 
4590
	cmp	byte [esi], 0xA
-
 
4591
	jnz	no_acpi_power_off
-
 
4592
	inc	esi
-
 
4593
	mov	cl, [esi]
-
 
4594
@@:
-
 
4595
	inc	esi
-
 
4596
	cmp	dl, 2
-
 
4597
	jb	@f
-
 
4598
	cmp	byte [esi], 0
-
 
4599
	jz	@f
-
 
4600
	cmp	byte [esi], 0xA
-
 
4601
	jnz	no_acpi_power_off
-
 
4602
	inc	esi
-
 
4603
	mov	ch, [esi]
4477
	jnz	pm_restart
4604
@@:
-
 
4605
	jmp	do_acpi_power_off
-
 
4606
.scan_dsdt_cont:
-
 
4607
	inc	esi
-
 
4608
	cmp	esi, 0x1000
-
 
4609
	jb	@f
-
 
4610
	sub	esi, 0x1000
-
 
4611
	add	edi, 0x1000
-
 
4612
	push	eax
-
 
4613
	lea	eax, [ebp+4000h]
-
 
4614
	stdcall map_page, eax, edi, PG_MAP
-
 
4615
	push	PG_MAP
-
 
4616
	lea	eax, [edi+1000h]
-
 
4617
	push	eax
-
 
4618
	lea	eax, [ebp+5000h]
-
 
4619
	push	eax
-
 
4620
	stdcall map_page
-
 
4621
	pop	eax
-
 
4622
@@:
-
 
4623
	dec	eax
4478
if 0
4624
	jnz	.scan_dsdt
-
 
4625
	jmp	no_acpi_power_off
-
 
4626
do_acpi_power_off:
-
 
4627
	mov	edx, [ebx+48]
4479
	mov	al, SB_PM_CTRL_BLK
4628
	test	edx, edx
-
 
4629
	jz	.nosmi
4480
	mov	ah, al
4630
	mov	al, [ebx+52]
4481
	inc	ah
4631
	out	dx, al
4482
	mov	dx, 0x0CD6
4632
	mov	edx, [ebx+64]
4483
	out	dx, al
4633
@@:
-
 
4634
	in	ax, dx
4484
	inc	dl
4635
	test	al, 1
4485
	in	al, dx
4636
	jz	@b
4486
	mov	cl, al
4637
.nosmi:
-
 
4638
	and	cx, 0x0707
4487
	dec	dl
4639
	shl	cx, 2
-
 
4640
	or	cx, 0x2020
4488
	mov	al, ah
4641
	mov	edx, [ebx+64]
4489
	out	dx, al
4642
	in	ax, dx
4490
	inc	dl
4643
	and	ax, 203h
-
 
4644
	or	ah, cl
-
 
4645
	out	dx, ax
-
 
4646
	mov	edx, [ebx+68]
4491
	in	al, dx
4647
	test	edx, edx
-
 
4648
	jz	@f
4492
	mov	ch, al
4649
	in	ax, dx
4493
end if
4650
	and	ax, 203h
4494
	mov	dx, 0x0804	;cx
Line 4651... Line 4495...
4651
	or	ah, ch
4495
	mov	ax, 0x03400
4652
	out	dx, ax
-
 
4653
@@:
-
 
Line 4654... Line 4496...
4654
	jmp	$
4496
	out	dx, ax
4655
 
4497
; THE END...
4656
 
4498
	jmp	$	; just to be absolutely sure
4657
no_acpi_power_off:
4499
 
Line 4658... Line 4500...
4658
	   mov	word [OS_BASE+0x467+0],pr_mode_exit
4500
 
-
 
4501
pm_restart:
4659
	   mov	word [OS_BASE+0x467+2],0x1000
4502
 
Line 4660... Line 4503...
4660
 
4503
	   mov	al,0x0F
4661
	   mov	al,0x0F
4504
	   out	0x70,al 	; NmiEnable
Line 4662... Line -...
4662
	   out	0x70,al
-
 
4663
	   mov	al,0x05
-
 
4664
	   out	0x71,al
-
 
4665
 
-
 
4666
	   mov	al,0xFE
-
 
4667
	   out	0x64,al
-
 
4668
 
-
 
4669
	   hlt
-
 
4670
	   jmp $-1
-
 
4671
 
-
 
4672
scan_rsdp:
-
 
4673
	add	eax, OS_BASE
-
 
4674
.s:
-
 
4675
	cmp	dword [eax], 'RSD '
-
 
4676
	jnz	.n
-
 
4677
	cmp	dword [eax+4], 'PTR '
-
 
4678
	jnz	.n
-
 
4679
	xor	edx, edx
-
 
4680
	xor	esi, esi
-
 
4681
@@:
-
 
4682
	add	dl, [eax+esi]
-
 
4683
	inc	esi
-
 
4684
	cmp	esi, 20
-
 
Line 4685... Line 4505...
4685
	jnz	@b
4505
	   mov	al,0x05
Line 4686... Line 4506...
4686
	test	dl, dl
4506
	   out	0x71,al 	; RtcData