Subversion Repositories Kolibri OS

Rev

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

Rev 1196 Rev 1198
Line 59... Line 59...
59
$Revision: 1025 $
59
$Revision: 1025 $
Line 60... Line 60...
60
 
60
 
Line -... Line 61...
-
 
61
 
61
 
62
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
Line 62... Line 63...
62
USE_COM_IRQ equ 1      ;make irq 3 and irq 4 available for PCI devices
63
 
63
 
64
; Enabling the next line will enable serial output console
64
debug_com_base equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used, comment this line out to disable
65
;debug_com_base  equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
Line 235... Line 236...
235
 
236
 
236
	   xor esi, esi
237
           xor esi, esi
237
	   mov	 edi,0x2F0000
238
           mov   edi,0x2F0000
238
	   mov	 ecx,0x10000 / 4
239
           mov   ecx,0x10000 / 4
239
	   rep	 movsd
240
           rep   movsd
240
	   xor edi, edi
241
           mov   edi,0x1000
241
	   mov	 ecx,0x10000 / 4
242
           mov   ecx,0xf000 / 4
Line 242... Line 243...
242
	   rep	 stosd
243
           rep   stosd
243
 
244
 
Line 451... Line 452...
451
.noSYSCALL:
452
.noSYSCALL:
452
; -----------------------------------------
453
; -----------------------------------------
Line 453... Line 454...
453
 
454
 
Line 454... Line 455...
454
; LOAD IDT
455
; LOAD IDT
455
 
456
 
Line 456... Line 457...
456
	   call build_interrupt_table
457
           call build_interrupt_table ;lidt is executed
457
	   lidt [idtreg]
458
          ;lidt [idtreg]
458
 
459
 
Line 546... Line 547...
546
	xor  eax,eax
547
        xor  eax,eax
547
	inc  eax
548
        inc  eax
548
	mov   [BgrDrawMode],eax
549
        mov   [BgrDrawMode],eax
549
	mov   [BgrDataWidth],eax
550
        mov   [BgrDataWidth],eax
550
	mov   [BgrDataHeight],eax
551
        mov   [BgrDataHeight],eax
551
	mov    [mem_BACKGROUND],4095
552
        mov    [mem_BACKGROUND], 4
552
	stdcall kernel_alloc, [mem_BACKGROUND]
-
 
553
	mov [img_background], eax
553
        mov [img_background], static_background_data
Line 554... Line 554...
554
 
554
 
Line 555... Line 555...
555
	mov	[SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE
555
        mov     [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE
Line 672... Line 672...
672
	mov  esi,boot_setostask
672
        mov  esi,boot_setostask
673
	call boot_log
673
        call boot_log
Line 674... Line 674...
674
 
674
 
675
	xor  eax, eax
675
        xor  eax, eax
676
	mov  dword [SLOT_BASE+APPDATA.fpu_state], fpu_data
676
        mov  dword [SLOT_BASE+APPDATA.fpu_state], fpu_data
677
	mov  dword [SLOT_BASE+APPDATA.fpu_handler], eax
677
        mov  dword [SLOT_BASE+APPDATA.exc_handler], eax
Line 678... Line 678...
678
	mov  dword [SLOT_BASE+APPDATA.sse_handler], eax
678
        mov  dword [SLOT_BASE+APPDATA.except_mask], eax
Line 679... Line 679...
679
 
679
 
680
	; name for OS/IDLE process
680
        ; name for OS/IDLE process
Line 694... Line 694...
694
	mov esi, fpu_data
694
        mov esi, fpu_data
695
	mov ecx, 512/4
695
        mov ecx, 512/4
696
	cld
696
        cld
697
	rep movsd
697
        rep movsd
Line 698... Line 698...
698
 
698
 
699
	mov dword [SLOT_BASE+256+APPDATA.fpu_handler], eax
699
        mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax
Line 700... Line 700...
700
	mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax
700
        mov dword [SLOT_BASE+256+APPDATA.except_mask], eax
701
 
701
 
702
	mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET
702
        mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET
Line 722... Line 722...
722
  ; READ TSC / SECOND
722
  ; READ TSC / SECOND
Line 723... Line 723...
723
 
723
 
724
	mov   esi,boot_tsc
724
        mov   esi,boot_tsc
725
	call  boot_log
725
        call  boot_log
726
	cli
726
        cli
727
	call  _rdtsc
727
        rdtsc ;call  _rdtsc
728
	mov   ecx,eax
728
        mov   ecx,eax
729
	mov   esi,250		    ; wait 1/4 a second
729
        mov   esi,250               ; wait 1/4 a second
730
	call  delay_ms
730
        call  delay_ms
731
	call  _rdtsc
731
        rdtsc ;call  _rdtsc
732
	sti
732
        sti
733
	sub   eax,ecx
733
        sub   eax,ecx
734
	shl   eax,2
734
        shl   eax,2
735
	mov   [CPU_FREQ],eax	      ; save tsc / sec
735
        mov   [CPU_FREQ],eax          ; save tsc / sec
736
	mov ebx, 1000000
736
;       mov ebx, 1000000
-
 
737
;       div ebx
-
 
738
; ¢®®¡é¥-â® ¯à®¨§¢®¤¨â¥«ì­®áâì ¢ ¤ ­­®¬ ª®­ªà¥â­®¬ ¬¥áâ¥
-
 
739
; ᮢ¥à襭­® ­¥ªà¨â¨ç­ , ­® çâ®¡ë § âª­ãâì «î¡¨â¥«¥©
-
 
740
; ®¯â¨¬¨§¨àãîé¨å ª®¬¯¨«ïâ®à®¢ Ÿ‚“...
-
 
741
        mov     edx, 2251799814
-
 
742
        mul     edx
737
	div ebx
743
        shr     edx, 19
-
 
744
        mov [stall_mcs], edx
-
 
745
; PRINT CPU FREQUENCY
-
 
746
        mov     esi, boot_cpufreq
-
 
747
        call    boot_log
-
 
748
 
-
 
749
        mov     ebx, edx
-
 
750
        movzx   ecx, word [boot_y]
-
 
751
        add     ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is '
-
 
752
        mov     edx, 0xFFFFFF
-
 
753
        mov     edi, 1
-
 
754
        mov     eax, 0x00040000
Line 738... Line 755...
738
	mov [stall_mcs], eax
755
        call    display_number_force
Line 739... Line 756...
739
 
756
 
Line 740... Line 757...
740
; SET VARIABLES
757
; SET VARIABLES
Line 741... Line 758...
741
 
758
 
742
	call  set_variables
759
        call  set_variables
743
 
760
 
Line 744... Line 761...
744
; SET MOUSE
761
; SET MOUSE
745
 
762
 
746
	;call   detect_devices
763
        ;call   detect_devices
Line 787... Line 804...
787
	   stdcall map_page,tss._io_map_0,\
804
           stdcall map_page,tss._io_map_0,\
788
		   (tss._io_map_0-OS_BASE), PG_MAP
805
                   (tss._io_map_0-OS_BASE), PG_MAP
789
	   stdcall map_page,tss._io_map_1,\
806
           stdcall map_page,tss._io_map_1,\
790
		   (tss._io_map_1-OS_BASE), PG_MAP
807
                   (tss._io_map_1-OS_BASE), PG_MAP
Line 791... Line -...
791
 
-
 
792
  mov ax,[OS_BASE+0x10000+bx_from_load]
-
 
Line 793... Line 808...
793
 
808
 
794
 
809
 
Line 795... Line 810...
795
; LOAD FIRST APPLICATION
810
; LOAD FIRST APPLICATION
Line 987... Line 1002...
987
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1002
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
988
;                                                                    ;
1003
;                                                                    ;
989
;                      MAIN OS LOOP END                              ;
1004
;                      MAIN OS LOOP END                              ;
990
;                                                                    ;
1005
;                                                                    ;
991
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1006
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
992
 
1007
align 4
993
checkidle:
1008
checkidle:
994
	pushad
1009
        pushad
995
 
-
 
996
	cmp  [check_idle_semaphore],0
-
 
997
	jne  no_idle_state
-
 
998
 
-
 
999
	call change_task
1010
        call    change_task
1000
	mov  eax,[idlemem]
-
 
1001
	mov  ebx,[timer_ticks] ;[0xfdf0]
-
 
1002
	cmp  eax,ebx
-
 
1003
	jnz  idle_exit
1011
        jmp     idle_loop_entry
1004
	call _rdtsc
-
 
1005
	mov  ecx,eax
-
 
1006
      idle_loop:
1012
  idle_loop:
-
 
1013
        cmp     eax,[idlemem]     ; eax == [timer_ticks]
-
 
1014
        jne     idle_exit
-
 
1015
        rdtsc   ;call _rdtsc
-
 
1016
        mov     ecx,eax
1007
	hlt
1017
        hlt
1008
	cmp  [check_idle_semaphore],0
-
 
1009
	jne  idle_loop_exit
-
 
1010
	mov  eax,[timer_ticks] ;[0xfdf0]
-
 
1011
	cmp  ebx,eax
-
 
1012
	jz   idle_loop
-
 
1013
      idle_loop_exit:
1018
        rdtsc   ;call _rdtsc
1014
	mov  [idlemem],eax
-
 
1015
	call _rdtsc
-
 
1016
	sub  eax,ecx
1019
        sub     eax,ecx
1017
	mov  ebx,[idleuse]
-
 
1018
	add  ebx,eax
-
 
1019
	mov  [idleuse],ebx
1020
        add     [idleuse],eax
1020
 
-
 
1021
	popad
-
 
1022
	ret
-
 
1023
 
-
 
1024
      idle_exit:
1021
  idle_loop_entry:
1025
 
-
 
1026
	mov  ebx,[timer_ticks] ;[0xfdf0]
1022
        mov     eax,[timer_ticks] ; eax =  [timer_ticks]
1027
	mov  [idlemem],ebx
1023
        cmp     [check_idle_semaphore],0
1028
	call change_task
-
 
1029
 
-
 
1030
	popad
-
 
1031
	ret
-
 
1032
 
-
 
1033
      no_idle_state:
1024
        je      idle_loop
1034
 
-
 
1035
	dec  [check_idle_semaphore]
1025
        dec     [check_idle_semaphore]
1036
 
-
 
1037
	mov  ebx,[timer_ticks] ;[0xfdf0]
-
 
1038
	mov  [idlemem],ebx
1026
  idle_exit:
1039
	call change_task
1027
        mov     [idlemem],eax     ; eax == [timer_ticks]
1040
 
-
 
1041
	popad
1028
        popad
1042
	ret
1029
        ret
Line 1043... Line 1030...
1043
 
1030
 
1044
uglobal
1031
uglobal
Line 1144... Line 1131...
1144
	pop   eax
1131
        pop   eax
Line 1145... Line 1132...
1145
 
1132
 
Line 1146... Line 1133...
1146
	mov   [BTN_ADDR],dword BUTTON_INFO    ; address of button list
1133
	mov   [BTN_ADDR],dword BUTTON_INFO    ; address of button list
1147
 
-
 
1148
     ;!! IP 04.02.2005:
1134
 
Line 1149... Line 1135...
1149
	mov   [next_usage_update], 100
1135
     ;!! IP 04.02.2005:
Line 1150... Line 1136...
1150
	mov   byte [DONT_SWITCH], 0 ; change task if possible
1136
        mov   byte [DONT_SWITCH], 0 ; change task if possible
Line 1304... Line 1290...
1304
     mov   ebx,16
1290
     mov   ebx,16
1305
   d_hexnum:
1291
   d_hexnum:
1306
     xor   edx,edx
1292
     xor   edx,edx
1307
     call  division_64_bits
1293
     call  division_64_bits
1308
     div   ebx
1294
     div   ebx
-
 
1295
   hexletters = __fdo_hexdigits
1309
     add   edx,hexletters
1296
     add   edx,hexletters
1310
     mov   dl,[edx]
1297
     mov   dl,[edx]
1311
     mov   [edi],dl
1298
     mov   [edi],dl
1312
     dec   edi
1299
     dec   edi
1313
     loop  d_hexnum
1300
     loop  d_hexnum
Line 2259... Line 2246...
2259
.yes_floppy_save:
2246
.yes_floppy_save:
2260
	ret
2247
        ret
Line 2261... Line 2248...
2261
 
2248
 
2262
uglobal
2249
uglobal
2263
;  bgrchanged  dd  0x0
2250
;  bgrchanged  dd  0x0
2264
bgrlock db 0
2251
align 4
-
 
2252
bgrlockpid dd 0
2265
bgrlockpid dd 0
2253
bgrlock db 0
Line 2266... Line 2254...
2266
endg
2254
endg
Line 2267... Line 2255...
2267
 
2255
 
Line 2272... Line 2260...
2272
    cmp   ecx,0
2260
    cmp   ecx,0
2273
    je	  sbgrr
2261
    je    sbgrr
2274
    cmp   edx,0
2262
    cmp   edx,0
2275
    je	  sbgrr
2263
    je    sbgrr
2276
@@:
2264
@@:
2277
	mov	al, 1
2265
;;Maxis use atomic bts for mutexes  4.4.2009
2278
	xchg	[bgrlock], al
2266
        bts     dword [bgrlock], 0
2279
	test	al, al
2267
        jnc     @f
2280
	jz	@f
-
 
2281
	call	change_task
2268
        call    change_task
2282
	jmp	@b
2269
        jmp     @b
2283
@@:
2270
@@:
2284
    mov   [BgrDataWidth],ecx
2271
    mov   [BgrDataWidth],ecx
2285
    mov   [BgrDataHeight],edx
2272
    mov   [BgrDataHeight],edx
2286
;    mov   [bgrchanged],1
2273
;    mov   [bgrchanged],1
Line 2287... Line 2274...
2287
 
2274
 
2288
    pushad
2275
    pushad
2289
; return memory for old background
2276
; return memory for old background
-
 
2277
        mov     eax, [img_background]
-
 
2278
        cmp     eax, static_background_data
-
 
2279
        jz      @f
-
 
2280
        stdcall kernel_free, eax
2290
    stdcall kernel_free, [img_background]
2281
@@:
2291
; calculate RAW size
2282
; calculate RAW size
2292
    xor  eax,eax
2283
    xor  eax,eax
2293
    inc  eax
2284
    inc  eax
2294
    cmp  [BgrDataWidth],eax
2285
    cmp  [BgrDataWidth],eax
Line 2304... Line 2295...
2304
    lea  eax,[eax*3]
2295
    lea  eax,[eax*3]
2305
    mov  [mem_BACKGROUND],eax
2296
    mov  [mem_BACKGROUND],eax
2306
; get memory for new background
2297
; get memory for new background
2307
    stdcall kernel_alloc, eax
2298
    stdcall kernel_alloc, eax
2308
    test eax, eax
2299
    test eax, eax
2309
    jz .exit_mem
2300
    jz .memfailed
2310
    mov [img_background], eax
2301
    mov [img_background], eax
-
 
2302
    jmp .exit
-
 
2303
.memfailed:
-
 
2304
; revert to static monotone data
-
 
2305
        mov     [img_background], static_background_data
-
 
2306
        xor     eax, eax
-
 
2307
        inc     eax
-
 
2308
        mov     [BgrDataWidth], eax
-
 
2309
        mov     [BgrDataHeight], eax
-
 
2310
        mov     [mem_BACKGROUND], 4
2311
.exit_mem:
2311
.exit:
2312
    popad
2312
    popad
2313
	mov	[bgrlock], 0
2313
        mov     [bgrlock], 0
Line 2314... Line 2314...
2314
 
2314
 
2315
  sbgrr:
2315
  sbgrr:
Line 2318... Line 2318...
2318
nosb1:
2318
nosb1:
Line 2319... Line 2319...
2319
 
2319
 
2320
    cmp   ebx,2 			   ; SET PIXEL
2320
    cmp   ebx,2                            ; SET PIXEL
Line -... Line 2321...
-
 
2321
    jnz   nosb2
-
 
2322
 
-
 
2323
    mov   eax, [img_background]
-
 
2324
    test  ecx, ecx
-
 
2325
    jz    @f
-
 
2326
    cmp   eax, static_background_data
2321
    jnz   nosb2
2327
    jz    .ret
2322
 
2328
@@:
2323
    mov ebx, [mem_BACKGROUND]
2329
    mov ebx, [mem_BACKGROUND]
2324
    add ebx, 4095
2330
    add ebx, 4095
2325
    and ebx, -4096
2331
    and ebx, -4096
2326
    sub ebx, 4
2332
    sub ebx, 4
Line 2327... Line -...
2327
    cmp   ecx, ebx
-
 
2328
    ja	 @F
2333
    cmp   ecx, ebx
2329
 
2334
    ja   .ret
2330
    mov   eax,[img_background]
2335
 
2331
    mov   ebx,[eax+ecx]
2336
    mov   ebx,[eax+ecx]
2332
    and   ebx,0xFF000000 ;255*256*256*256
2337
    and   ebx,0xFF000000 ;255*256*256*256
2333
    and   edx,0x00FFFFFF ;255*256*256+255*256+255
2338
    and   edx,0x00FFFFFF ;255*256*256+255*256+255
2334
    add   edx,ebx
2339
    add   edx,ebx
2335
    mov   [eax+ecx],edx
2340
    mov   [eax+ecx],edx
Line 2336... Line 2341...
2336
@@:
2341
.ret:
2337
    ret
2342
    ret
Line 2361... Line 2366...
2361
    ret
2366
    ret
2362
  nosb4:
2367
  nosb4:
Line 2363... Line 2368...
2363
 
2368
 
2364
    cmp   ebx,5 			   ; BLOCK MOVE TO BGR
2369
    cmp   ebx,5                            ; BLOCK MOVE TO BGR
-
 
2370
    jnz   nosb5
-
 
2371
    cmp   [img_background], static_background_data
-
 
2372
    jnz   @f
-
 
2373
    test  edx, edx
-
 
2374
    jnz   .fin
-
 
2375
    cmp   esi, 4
-
 
2376
    ja    .fin
2365
    jnz   nosb5
2377
  @@:
2366
  ; bughere
2378
  ; bughere
2367
    mov   eax, ecx
2379
    mov   eax, ecx
2368
    mov   ebx, edx
2380
    mov   ebx, edx
2369
    add   ebx, [img_background]   ;IMG_BACKGROUND
2381
    add   ebx, [img_background]   ;IMG_BACKGROUND
Line 2373... Line 2385...
2373
    ret
2385
    ret
2374
  nosb5:
2386
  nosb5:
Line 2375... Line 2387...
2375
 
2387
 
2376
	cmp	ebx, 6
2388
        cmp     ebx, 6
-
 
2389
        jnz     nosb6
2377
	jnz	nosb6
2390
;;Maxis use atomic bts for mutex 4.4.2009
2378
@@:
-
 
2379
	mov	al, 1
2391
@@:
2380
	xchg	[bgrlock], al
2392
        bts     dword [bgrlock], 0
2381
	test	al, al
-
 
2382
	jz	@f
2393
        jnc     @f
2383
	call	change_task
2394
        call    change_task
2384
	jmp	@b
2395
        jmp     @b
2385
@@:
2396
@@:
2386
	mov	eax, [CURRENT_TASK]
2397
        mov     eax, [CURRENT_TASK]
-
 
2398
        mov     [bgrlockpid], eax
-
 
2399
        cmp     [img_background], static_background_data
2387
	mov	[bgrlockpid], eax
2400
        jz      .nomem
2388
	stdcall user_alloc, [mem_BACKGROUND]
2401
        stdcall user_alloc, [mem_BACKGROUND]
2389
	mov	[esp+32], eax
2402
        mov     [esp+32], eax
2390
	test	eax, eax
2403
        test    eax, eax
2391
	jz	.nomem
2404
        jz      .nomem
Line 2483... Line 2496...
2483
nogb1:
2496
nogb1:
Line 2484... Line 2497...
2484
 
2497
 
2485
    cmp   eax,2 				 ; PIXEL
2498
    cmp   eax,2                                  ; PIXEL
Line -... Line 2499...
-
 
2499
    jnz   nogb2
-
 
2500
 
-
 
2501
        mov     eax, [img_background]
-
 
2502
        test    ebx, ebx
-
 
2503
        jz      @f
-
 
2504
        cmp     eax, static_background_data
2486
    jnz   nogb2
2505
        jz      .ret
2487
 
2506
@@:
2488
    mov ecx, [mem_BACKGROUND]
2507
    mov ecx, [mem_BACKGROUND]
2489
    add ecx, 4095
2508
    add ecx, 4095
2490
    and ecx, -4096
2509
    and ecx, -4096
2491
    sub ecx, 4
2510
    sub ecx, 4
Line 2492... Line -...
2492
    cmp ebx, ecx
-
 
2493
    ja	@F
2511
    cmp ebx, ecx
Line 2494... Line 2512...
2494
 
2512
    ja  .ret
2495
    mov   eax,[img_background]
2513
 
2496
    mov   eax,[ebx+eax]
2514
    mov   eax,[ebx+eax]
2497
 
2515
 
2498
    and   eax, 0xFFFFFF
2516
    and   eax, 0xFFFFFF
Line 2499... Line 2517...
2499
    mov   [esp+36],eax
2517
    mov   [esp+36],eax
2500
@@:
2518
.ret:
Line 3081... Line 3099...
3081
    mov   [edi+WDATA.box.left],ebx
3099
    mov   [edi+WDATA.box.left],ebx
3082
    mov   [edi+WDATA.box.top],ecx
3100
    mov   [edi+WDATA.box.top],ecx
Line 3083... Line 3101...
3083
 
3101
 
Line 3084... Line -...
3084
    call  check_window_position
-
 
3085
 
-
 
3086
    call  set_window_clientbox
3102
    call  check_window_position
3087
 
3103
 
Line 3088... Line 3104...
3088
    push  ecx esi edi		    ; save for window fullscreen/resize
3104
    push  ecx esi edi               ; save for window fullscreen/resize
3089
    ;mov   esi,edi
3105
    ;mov   esi,edi
Line 3131... Line 3147...
3131
 
3147
 
3132
    mov   [KEY_COUNT],byte 0	       ; empty keyboard buffer
3148
    mov   [KEY_COUNT],byte 0           ; empty keyboard buffer
Line 3133... Line 3149...
3133
    mov   [BTN_COUNT],byte 0	       ; empty button buffer
3149
    mov   [BTN_COUNT],byte 0           ; empty button buffer
-
 
3150
 
-
 
3151
  newd:
3134
 
3152
    call  set_window_clientbox
3135
  newd:
3153
 
Line 3136... Line 3154...
3136
    mov   [edi+WDATA.fl_redraw],byte 0	 ; no redraw
3154
    mov   [edi+WDATA.fl_redraw],byte 0   ; no redraw
Line 3647... Line 3665...
3647
 
3665
 
Line 3648... Line 3666...
3648
	 ret
3666
         ret
Line 3649... Line -...
3649
 
-
 
3650
calculatebackground:   ; background
-
 
3651
 
-
 
3652
	; all black
-
 
3653
 
-
 
3654
	mov   edi, [img_background]  ;IMG_BACKGROUND                 ; set background to black
-
 
3655
	xor   eax, eax
-
 
3656
	mov   ecx, 1023    ;0x0fff00 / 4
-
 
3657
	cld
3667
 
3658
	rep   stosd
3668
calculatebackground:   ; background
3659
 
3669
 
3660
	mov   edi,display_data		    ; set os to use all pixels
3670
        mov   edi,display_data              ; set os to use all pixels
Line 3703... Line 3713...
3703
	ret
3713
        ret
Line 3704... Line 3714...
3704
 
3714
 
3705
 
3715
 
-
 
3716
set_app_param:
3706
set_app_param:
3717
        mov     edi, [TASK_BASE]
-
 
3718
        mov     eax, [edi + TASKDATA.event_mask]
3707
	mov	edi, [TASK_BASE]
3719
        mov     [edi + TASKDATA.event_mask], ebx
Line 3708... Line 3720...
3708
	mov	[edi + TASKDATA.event_mask], ebx
3720
        mov     [esp+32], eax
Line 4646... Line 4658...
4646
 
4658
 
Line 4647... Line 4659...
4647
     cli
4659
     cli
Line 4648... Line 4660...
4648
 
4660
 
4649
     ret
4661
     ret
4650
 
4662
 
4651
 
4663
if used _rdtsc
4652
_rdtsc:
4664
_rdtsc:
4653
     bt [cpu_caps], CAPS_TSC
4665
     bt [cpu_caps], CAPS_TSC
4654
     jnc ret_rdtsc
4666
     jnc ret_rdtsc
4655
     rdtsc
4667
     rdtsc
4656
     ret
4668
     ret
4657
   ret_rdtsc:
4669
   ret_rdtsc:
-
 
4670
     mov   edx,0xffffffff
Line 4658... Line 4671...
4658
     mov   edx,0xffffffff
4671
     mov   eax,0xffffffff
Line 4659... Line 4672...
4659
     mov   eax,0xffffffff
4672
     ret
Line 5348... Line 5361...
5348
apm_vf	      dd    0
5361
apm_vf        dd    0
5349
align 4
5362
align 4
5350
sys_apm:
5363
sys_apm:
5351
    cmp    word [apm_vf], 0    ; Check APM BIOS enable
5364
    cmp    word [apm_vf], 0    ; Check APM BIOS enable
5352
    jne    @f
5365
    jne    @f
5353
    or	  [esp + 56], byte 1	; error
5366
    or     [esp + 48], byte 1    ; error
5354
    mov    [esp + 36], dword 8	  ; 32-bit protected-mode interface not supported
5367
    mov    [esp + 36], dword 8    ; 32-bit protected-mode interface not supported
5355
    ret
5368
    ret
Line 5356... Line 5369...
5356
 
5369
 
5357
@@:
5370
@@:
5358
    xchg    eax, ecx
5371
    xchg    eax, ecx
Line 5359... Line 5372...
5359
    xchg    ebx, ecx
5372
    xchg    ebx, ecx
5360
 
5373
 
5361
    cmp    al, 3
5374
    cmp    al, 3
5362
    ja	  @f
5375
    ja    @f
5363
    and    [esp + 56], byte 0xfe    ; emulate func 0..3 as func 0
5376
    and    [esp + 48], byte 0xfe    ; emulate func 0..3 as func 0
5364
    mov    eax, [apm_vf]
5377
    mov    eax, [apm_vf]
5365
    mov    [esp + 36], eax
5378
    mov    [esp + 36], eax
5366
    shr    eax, 16
5379
    shr    eax, 16
Line 5388... Line 5401...
5388
    mov    [esp + 24], ebx
5401
    mov    [esp + 24], ebx
5389
    mov    [esp + 28], edx
5402
    mov    [esp + 28], edx
5390
    mov    [esp + 32], ecx
5403
    mov    [esp + 32], ecx
5391
    mov    [esp + 36], eax
5404
    mov    [esp + 36], eax
5392
    setc    al
5405
    setc   al
5393
    and    [esp + 56], byte 0xfe
5406
    and    [esp + 48], byte 0xfe
5394
    or	  [esp + 56], al
5407
    or     [esp + 48], al
Line 5395... Line 5408...
5395
 
5408
 
5396
 
5409
 
Line 5441... Line 5454...
5441
 
5454
 
5442
	   mov al, 0xFF
5455
           mov al, 0xFF
5443
	   out 0x21, al
5456
           out 0x21, al
Line 5444... Line 5457...
5444
	   out 0xA1, al
5457
           out 0xA1, al
5445
 
5458
 
5446
if 1
5459
if 0
Line 5447... Line 5460...
5447
	   mov	word [OS_BASE+0x467+0],pr_mode_exit
5460
           mov  word [OS_BASE+0x467+0],pr_mode_exit
5448
	   mov	word [OS_BASE+0x467+2],0x1000
5461
           mov  word [OS_BASE+0x467+2],0x1000
Line 5454... Line 5467...
5454
 
5467
 
5455
	   mov	al,0xFE
5468
           mov  al,0xFE
Line 5456... Line 5469...
5456
	   out	0x64,al
5469
           out  0x64,al
-
 
5470
 
Line 5457... Line 5471...
5457
 
5471
           hlt
5458
	   hlt
5472
           jmp $-1
5459
 
5473
 
Line 5505... Line 5519...
5505
	jz	.fadt_found
5519
        jz      .fadt_found
5506
	loop	.scan_fadt
5520
        loop    .scan_fadt
5507
	jmp	no_acpi_power_off
5521
        jmp     no_acpi_power_off
5508
.fadt_found:
5522
.fadt_found:
5509
; ebx is linear address of FADT
5523
; ebx is linear address of FADT
-
 
5524
        mov     edi, [ebx+40] ; physical address of the DSDT
-
 
5525
        lea     eax, [ebp+4000h]
-
 
5526
        stdcall map_page, eax, edi, PG_MAP
-
 
5527
        lea     eax, [ebp+5000h]
-
 
5528
        lea     esi, [edi+0x1000]
-
 
5529
        stdcall map_page, eax, esi, PG_MAP
-
 
5530
        and     esi, 0xFFF
-
 
5531
        sub     edi, esi
-
 
5532
        cmp     dword [esi+ebp+4000h], 'DSDT'
-
 
5533
        jnz     no_acpi_power_off
-
 
5534
        mov     eax, [esi+ebp+4004h] ; DSDT length
-
 
5535
        sub     eax, 36+4
-
 
5536
        jbe     no_acpi_power_off
-
 
5537
        add     esi, 36
-
 
5538
.scan_dsdt:
-
 
5539
        cmp     dword [esi+ebp+4000h], '_S5_'
-
 
5540
        jnz     .scan_dsdt_cont
-
 
5541
        cmp     byte [esi+ebp+4000h+4], 12h ; DefPackage opcode
-
 
5542
        jnz     .scan_dsdt_cont
-
 
5543
        mov     dl, [esi+ebp+4000h+6]
-
 
5544
        cmp     dl, 4 ; _S5_ package must contain 4 bytes
-
 
5545
                      ; ...in theory; in practice, VirtualBox has 2 bytes
-
 
5546
        ja      .scan_dsdt_cont
-
 
5547
        cmp     dl, 1
-
 
5548
        jb      .scan_dsdt_cont
-
 
5549
        lea     esi, [esi+ebp+4000h+7]
-
 
5550
        xor     ecx, ecx
-
 
5551
        cmp     byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx
-
 
5552
        jz      @f
-
 
5553
        cmp     byte [esi], 0xA
-
 
5554
        jnz     no_acpi_power_off
-
 
5555
        inc     esi
-
 
5556
        mov     cl, [esi]
-
 
5557
@@:
-
 
5558
        inc     esi
-
 
5559
        cmp     dl, 2
-
 
5560
        jb      @f
-
 
5561
        cmp     byte [esi], 0
-
 
5562
        jz      @f
-
 
5563
        cmp     byte [esi], 0xA
-
 
5564
        jnz     no_acpi_power_off
-
 
5565
        inc     esi
-
 
5566
        mov     ch, [esi]
-
 
5567
@@:
-
 
5568
        jmp     do_acpi_power_off
-
 
5569
.scan_dsdt_cont:
-
 
5570
        inc     esi
-
 
5571
        cmp     esi, 0x1000
-
 
5572
        jb      @f
-
 
5573
        sub     esi, 0x1000
-
 
5574
        add     edi, 0x1000
-
 
5575
        push    eax
-
 
5576
        lea     eax, [ebp+4000h]
-
 
5577
        stdcall map_page, eax, edi, PG_MAP
-
 
5578
        push    PG_MAP
-
 
5579
        lea     eax, [edi+1000h]
-
 
5580
        push    eax
-
 
5581
        lea     eax, [ebp+5000h]
-
 
5582
        push    eax
-
 
5583
        stdcall map_page
-
 
5584
        pop     eax
-
 
5585
@@:
-
 
5586
        dec     eax
-
 
5587
        jnz     .scan_dsdt
-
 
5588
        jmp     no_acpi_power_off
-
 
5589
do_acpi_power_off:
5510
	mov	edx, [ebx+48]
5590
        mov     edx, [ebx+48]
5511
	test	edx, edx
5591
        test    edx, edx
5512
	jz	.nosmi
5592
        jz      .nosmi
5513
	mov	al, [ebx+52]
5593
        mov     al, [ebx+52]
5514
	out	dx, al
5594
        out     dx, al
Line 5516... Line 5596...
5516
@@:
5596
@@:
5517
	in	ax, dx
5597
        in      ax, dx
5518
	test	al, 1
5598
        test    al, 1
5519
	jz	@b
5599
        jz      @b
5520
.nosmi:
5600
.nosmi:
-
 
5601
        and     cx, 0x0707
-
 
5602
        shl     cx, 2
-
 
5603
        or      cx, 0x2020
5521
	mov	edx, [ebx+64]
5604
        mov     edx, [ebx+64]
5522
	in	ax, dx
5605
        in      ax, dx
5523
	and	ax, 203h
5606
        and     ax, 203h
5524
	or	ax, 3C00h
5607
        or      ah, cl
5525
	out	dx, ax
5608
        out     dx, ax
5526
	mov	edx, [ebx+68]
5609
        mov     edx, [ebx+68]
5527
	test	edx, edx
5610
        test    edx, edx
5528
	jz	@f
5611
        jz      @f
5529
	in	ax, dx
5612
        in      ax, dx
5530
	and	ax, 203h
5613
        and     ax, 203h
5531
	or	ax, 3C00h
5614
        or      ah, ch
5532
	out	dx, ax
5615
        out     dx, ax
5533
@@:
5616
@@:
5534
	jmp	$
5617
        jmp     $
Line 5545... Line 5628...
5545
 
5628
 
5546
	   mov	al,0xFE
5629
           mov  al,0xFE
Line 5547... Line 5630...
5547
	   out	0x64,al
5630
           out  0x64,al
-
 
5631
 
Line 5548... Line 5632...
5548
 
5632
           hlt
5549
	   hlt
5633
           jmp $-1
5550
 
5634
 
5551
scan_rsdp:
5635
scan_rsdp:
Line 5576... Line 5660...
5576
 
5660
 
Line 5577... Line 5661...
5577
__REV__ = __REV
5661
__REV__ = __REV
5578
 
5662
 
5579
uglobals_size = $ - endofcode
-