Subversion Repositories Kolibri OS

Rev

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

Rev 838 Rev 839
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2007. 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
$Revision: 838 $
-
 
9
 
-
 
10
 
-
 
Line 11... Line 8...
11
MEM_WB     equ 6               ;write-back memory
8
$Revision: 839 $
12
MEM_WC     equ 1               ;write combined memory
-
 
13
MEM_UC     equ 0               ;uncached memory
-
 
14
 
-
 
15
 
-
 
16
align 4
-
 
17
proc init_mem
-
 
18
 
-
 
19
           mov ecx, [0x2F0000 + 0x9100]
-
 
20
           mov esi, 0x2F0000 + 0x9104
-
 
21
           xor eax, eax
-
 
22
@@:
-
 
23
           cmp dword [esi+16], 1
-
 
24
           jne .next
-
 
25
           mov edx, [esi+8]
-
 
26
           cmp eax, [esi+8]
-
 
27
           ja .next
-
 
28
 
-
 
29
           mov eax, [esi+8]
-
 
30
.next:
-
 
31
           add esi, 20
-
 
32
           loop @B
-
 
33
 
-
 
34
           and eax, -4096
-
 
35
 
-
 
36
           mov [MEM_AMOUNT-OS_BASE], eax
-
 
37
           mov [pg_data.mem_amount-OS_BASE], eax
-
 
38
 
-
 
39
           shr eax, 12
-
 
40
           mov edx, eax
-
 
41
           mov [pg_data.pages_count-OS_BASE], eax
-
 
42
           shr eax, 3
-
 
43
           mov [pg_data.pagemap_size-OS_BASE], eax
-
 
44
 
-
 
45
           add eax, (sys_pgmap-OS_BASE)+4095
-
 
46
           and eax, not 4095
-
 
47
           mov [tmp_page_tabs], eax
-
 
48
 
-
 
49
           cmp edx, (OS_BASE/4096)
-
 
50
           jbe @F
-
 
51
           mov edx, (OS_BASE/4096)
-
 
52
           jmp .set
-
 
53
@@:
-
 
54
           cmp edx, (HEAP_MIN_SIZE/4096)
-
 
55
           jae .set
-
 
56
           mov edx, (HEAP_MIN_SIZE/4096)
-
 
57
.set:
-
 
58
           mov [pg_data.kernel_pages-OS_BASE], edx
-
 
59
           shr edx, 10
-
 
60
           mov [pg_data.kernel_tables-OS_BASE], edx
-
 
61
 
-
 
62
           xor eax, eax
-
 
63
           mov edi, sys_pgdir-OS_BASE
-
 
64
           mov ecx, 4096/4
-
 
65
           cld
-
 
66
           rep stosd
-
 
67
 
-
 
68
           mov edx, (sys_pgdir-OS_BASE)+ (OS_BASE shr 20)
-
 
69
           bt [cpu_caps-OS_BASE], CAPS_PSE
-
 
70
           jnc .no_PSE
-
 
71
 
-
 
72
           mov ebx, cr4
-
 
73
           or ebx, CR4_PSE
-
 
74
           mov eax, PG_LARGE+PG_SW
-
 
75
           mov cr4, ebx
-
 
76
           dec [pg_data.kernel_tables-OS_BASE]
-
 
77
 
-
 
78
           mov [edx], eax
-
 
79
           add eax, 0x00400000
-
 
80
           add edx, 4
-
 
81
 
-
 
82
           mov eax, 0x400000+PG_SW
-
 
83
           mov ecx, [tmp_page_tabs]
-
 
84
           sub ecx, 0x400000
-
 
85
           shr ecx, 12          ;ecx/=4096
-
 
86
           jmp .map_low
-
 
87
.no_PSE:
-
 
88
           mov eax, PG_SW
-
 
89
           mov ecx, [tmp_page_tabs]
-
 
90
           shr ecx, 12
-
 
91
.map_low:
-
 
92
           mov edi, [tmp_page_tabs]
-
 
93
@@:                                   ;
-
 
94
           stosd
-
 
95
           add eax, 0x1000
-
 
96
           dec ecx
-
 
97
           jnz @B
-
 
98
 
-
 
99
           mov ecx, [pg_data.kernel_tables-OS_BASE]
-
 
100
           shl ecx, 10
-
 
101
           xor eax, eax
-
 
102
           rep stosd
-
 
103
 
-
 
104
           mov ecx, [pg_data.kernel_tables-OS_BASE]
-
 
105
           mov eax, [tmp_page_tabs]
-
 
106
           or eax, PG_SW
-
 
107
           mov edi, edx
-
 
108
 
-
 
109
.map_kernel_tabs:
-
 
110
 
-
 
111
           stosd
-
 
112
           add eax, 0x1000
-
 
113
           dec ecx
-
 
114
           jnz .map_kernel_tabs
-
 
115
 
-
 
116
           mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE
-
 
117
 
-
 
118
           mov edi, (sys_pgdir-OS_BASE)
-
 
119
           lea esi, [edi+(OS_BASE shr 20)]
-
 
120
           movsd
-
 
121
           movsd
-
 
122
           ret
-
 
123
endp
-
 
124
 
-
 
125
align 4
-
 
126
proc init_page_map
-
 
127
 
-
 
128
           mov edi, sys_pgmap-OS_BASE
-
 
129
           mov ecx, [pg_data.pagemap_size-OS_BASE]
-
 
130
           shr ecx, 2
-
 
131
           or eax, -1
-
 
132
           cld
-
 
133
           rep stosd
-
 
134
 
-
 
135
           mov ecx, [tmp_page_tabs]
-
 
136
           mov edx, [pg_data.pages_count-OS_BASE]
-
 
137
           shr ecx, 12
-
 
138
           add ecx, [pg_data.kernel_tables-OS_BASE]
-
 
139
           sub edx, ecx
-
 
140
           mov [pg_data.pages_free-OS_BASE], edx
-
 
141
 
-
 
142
           mov edi, sys_pgmap-OS_BASE
-
 
143
           mov ebx, ecx
-
 
144
           shr ecx, 5
-
 
145
           xor eax, eax
-
 
146
           rep stosd
-
 
147
 
-
 
148
           not eax
-
 
149
           mov ecx, ebx
-
 
150
           and ecx, 31
-
 
151
           shl eax, cl
-
 
152
           mov [edi], eax
-
 
153
           add edi, OS_BASE
-
 
154
           mov [page_start-OS_BASE], edi;
-
 
155
 
-
 
156
           mov ebx, sys_pgmap
-
 
157
           add ebx, [pg_data.pagemap_size-OS_BASE]
-
 
158
           mov [page_end-OS_BASE], ebx
-
 
159
 
-
 
Line 160... Line 9...
160
           mov [pg_data.pg_mutex-OS_BASE], 0
9
 
161
           ret
10
 
162
endp
11
 
163
 
12