Subversion Repositories Kolibri OS

Rev

Rev 2014 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2014 Rev 2047
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 2014 $
8
$Revision: 2047 $
9
 
9
 
Line 335... Line 335...
335
	   ret
335
	   ret
336
endp
336
endp
Line 337... Line 337...
337
 
337
 
338
align 4
338
align 4
339
proc init_LFB
339
proc init_LFB
Line 340... Line 340...
340
	   call init_mtrr
340
	   stdcall set_mtrr, [LFBAddress],[LFBSize],MEM_WC
341
 
341
 
342
	   mov edx, LFB_BASE
342
	   mov edx, LFB_BASE
343
	   mov esi, [LFBAddress]
343
	   mov esi, [LFBAddress]
Line 362... Line 362...
362
	   ret
362
	   ret
363
endp
363
endp
Line 364... Line 364...
364
 
364
 
365
align 4
365
align 4
366
init_userDMA:
366
init_userDMA:
367
	   stdcall alloc_pages, 4096	; 16M <<<<<<<<<<+++++++++++++++++++++++++++++++++
-
 
368
	   add eax, 0x007FFFF0		; terrible mess, sorry ...
-
 
-
 
367
	   stdcall set_mtrr, [UserDMAaddr], USER_DMA_SIZE, MEM_UC   ; <<<<<<<<<<+++++++++++++++++++++++++++++++++
369
	   and eax, 0xFF800000		; align at 8M boundary
368
 
370
	   mov [UserDMAaddr], eax
369
	   mov	eax, [UserDMAaddr]	; phys. addr, 8M-aligned
371
	   or  eax, PG_LARGE + PG_UW + PG_NOCACHE
370
	   or  eax, PG_GLOBAL+PG_LARGE + PG_UW + PG_NOCACHE
372
	   mov ebx, sys_pgdir + (USER_DMA_BUFFER shr 20)
371
	   mov ebx, sys_pgdir + (USER_DMA_BUFFER shr 20)
373
	   mov [ebx], eax
372
	   mov [ebx], eax
374
	   add ebx, 4
373
	   add ebx, 4
375
	   add eax, 0x00400000
374
	   add eax, 0x00400000
-
 
375
	   mov [ebx], eax
376
	   mov [ebx], eax
376
 
377
	   mov eax, cr3       ;flush TLB
377
	   mov eax, cr3       ;flush TLB
378
	   mov cr3, eax
378
	   mov cr3, eax
Line 379... Line 379...
379
	   ret
379
	   ret
Line 1247... Line 1247...
1247
	   ret
1247
	   ret
1248
endp
1248
endp
Line 1249... Line 1249...
1249
 
1249
 
1250
 
-
 
1251
align 4
-
 
1252
proc init_mtrr
-
 
1253
 
-
 
1254
	   cmp [BOOT_VAR+0x901c],byte 2
-
 
1255
	   je  .exit
-
 
1256
 
-
 
1257
	   bt [cpu_caps], CAPS_MTRR
-
 
1258
	   jnc .exit
-
 
1259
 
-
 
1260
	   mov eax, cr0
-
 
1261
	   or eax, 0x60000000	;disable caching
-
 
1262
	   mov cr0, eax
-
 
1263
	   wbinvd		;invalidate cache
-
 
1264
 
-
 
1265
	   mov ecx, 0x2FF
-
 
1266
	   rdmsr		;
-
 
1267
; has BIOS already initialized MTRRs?
-
 
1268
	   test ah, 8
-
 
1269
	   jnz .skip_init
-
 
1270
; rarely needed, so mainly placeholder
-
 
1271
; main memory - cached
-
 
1272
	   push eax
-
 
1273
 
-
 
1274
	   mov eax, [MEM_AMOUNT]
-
 
1275
; round eax up to next power of 2
-
 
1276
	   dec eax
-
 
1277
	   bsr ecx, eax
-
 
1278
	   mov ebx, 2
-
 
1279
	   shl ebx, cl
-
 
1280
	   dec ebx
-
 
1281
; base of memory range = 0, type of memory range = MEM_WB
-
 
1282
	   xor edx, edx
-
 
1283
	   mov eax, MEM_WB
-
 
1284
	   mov ecx, 0x200
-
 
1285
	   wrmsr
-
 
1286
; mask of memory range = 0xFFFFFFFFF - (size - 1), ebx = size - 1
-
 
1287
	   mov eax, 0xFFFFFFFF
-
 
1288
	   mov edx, 0x0000000F
-
 
1289
	   sub eax, ebx
-
 
1290
	   sbb edx, 0
-
 
1291
	   or eax, 0x800
-
 
1292
	   inc ecx
-
 
1293
	   wrmsr
-
 
1294
; clear unused MTRRs
-
 
1295
	   xor eax, eax
-
 
1296
	   xor edx, edx
-
 
1297
@@:
-
 
1298
	   wrmsr
-
 
1299
	   inc ecx
-
 
1300
	   cmp ecx, 0x210
-
 
1301
	   jb @b
-
 
1302
; enable MTRRs
-
 
1303
	   pop eax
-
 
1304
	   or ah, 8
-
 
1305
	   and al, 0xF0 ; default memtype = UC
-
 
1306
	   mov ecx, 0x2FF
-
 
1307
	   wrmsr
-
 
1308
.skip_init:
-
 
1309
	   stdcall set_mtrr, [LFBAddress],[LFBSize],MEM_WC
-
 
1310
 
-
 
1311
	   wbinvd		;again invalidate
-
 
1312
 
-
 
1313
	   mov eax, cr0
-
 
1314
	   and eax, not 0x60000000
-
 
1315
	   mov cr0, eax 	; enable caching
-
 
1316
.exit:
-
 
1317
	   ret
-
 
1318
endp
-
 
1319
 
1250
 
1320
align 4
1251
align 4
1321
proc set_mtrr stdcall, base:dword,size:dword,mem_type:dword
1252
proc set_mtrr stdcall, base:dword,size:dword,mem_type:dword
1322
; find unused register
1253
; find unused register
1323
	   mov ecx, 0x201
1254
	   mov ecx, 0x201
Line 1335... Line 1266...
1335
	   jb @b
1266
	   jb @b
1336
; no free registers, ignore the call
1267
; no free registers, ignore the call
1337
.ret:
1268
.ret:
1338
	   ret
1269
	   ret
1339
.found:
1270
.found:
-
 
1271
	   mov eax, cr0
-
 
1272
	   or eax, 0x60000000	;disable caching
-
 
1273
	   mov cr0, eax
1340
; found, write values
1274
	   wbinvd		;invalidate cache
-
 
1275
 
1341
	   xor edx, edx
1276
	   xor edx, edx
1342
	   mov eax, [base]
1277
	   mov eax, [base]
1343
	   or eax, [mem_type]
1278
	   or eax, [mem_type]
1344
	   wrmsr
1279
	   wrmsr
Line 1350... Line 1285...
1350
	   sub eax, ebx
1285
	   sub eax, ebx
1351
	   sbb edx, 0
1286
	   sbb edx, 0
1352
	   or eax, 0x800
1287
	   or eax, 0x800
1353
	   inc ecx
1288
	   inc ecx
1354
	   wrmsr
1289
	   wrmsr
-
 
1290
 
-
 
1291
	   wbinvd		;again invalidate
-
 
1292
	   mov eax, cr0
-
 
1293
	   and eax, not 0x60000000
-
 
1294
	   mov cr0, eax 	; enable caching
-
 
1295
 
1355
	   ret
1296
	   ret
1356
endp
1297
endp
Line 1357... Line 1298...
1357
 
1298
 
1358
align 4
1299
align 4