Subversion Repositories Kolibri OS

Rev

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

Rev 2434 Rev 2437
Line 67... Line 67...
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 68... Line 68...
68
 
68
 
69
include 'macros.inc'
69
include 'macros.inc'
Line 70... Line 70...
70
include 'struct.inc'
70
include 'struct.inc'
Line 71... Line 71...
71
 
71
 
Line 72... Line 72...
72
$Revision: 2434 $
72
$Revision: 2437 $
Line 159... Line 159...
159
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
159
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 160... Line 160...
160
 
160
 
Line -... Line 161...
-
 
161
 
-
 
162
; CR0 Flags - Protected mode and Paging
161
 
163
 
Line 162... Line 164...
162
; CR0 Flags - Protected mode and Paging
164
align 16
Line 163... Line 165...
163
 
165
 
Line 196... Line 198...
196
        or      eax, ecx
198
        or      eax, ecx
197
        and     eax, 10011111b *65536*256 + 0xffffff ; caching enabled
199
        and     eax, 10011111b *65536*256 + 0xffffff ; caching enabled
198
        mov     cr0, eax
200
        mov     cr0, eax
199
        jmp     pword os_code:B32       ; jmp to enable 32 bit mode
201
        jmp     pword os_code:B32       ; jmp to enable 32 bit mode
Line -... Line 202...
-
 
202
 
-
 
203
include "boot/shutdown.inc" ; shutdown or restart
-
 
204
 
-
 
205
include "data16.inc"
-
 
206
 
-
 
207
align 4096
-
 
208
__ap_start_16:
-
 
209
        cli
-
 
210
        lgdt    [cs:(tmp_gdt-__ap_start_16)]            ; Load GDT
-
 
211
        mov     eax, cr0                                ; protected mode
-
 
212
        or      eax, CR0_PE
-
 
213
        and     eax, 10011111b *65536*256 + 0xffffff    ; caching enabled
-
 
214
        mov     cr0, eax
-
 
215
        jmp     pword os_code:__ap_start_32             ; jmp to enable 32 bit mode
200
 
216
 
201
align 8
217
align 8
Line 202... Line 218...
202
tmp_gdt:
218
tmp_gdt:
203
 
219
 
Line 215... Line 231...
215
        dw     0x0000
231
        dw     0x0000
216
        db     0x00
232
        db     0x00
217
        dw     11011111b *256 +10010010b
233
        dw     11011111b *256 +10010010b
218
        db     0x00
234
        db     0x00
Line 219... Line -...
219
 
-
 
Line 220... Line 235...
220
include "data16.inc"
235
 
221
 
236
 
Line -... Line 237...
-
 
237
use32
-
 
238
org $+0x10000
-
 
239
 
-
 
240
align 16
-
 
241
__ap_start_32:
-
 
242
        mov     ax, os_stack       ; Selector for os
-
 
243
        mov     ds, ax
-
 
244
        mov     es, ax
-
 
245
        mov     fs, ax
-
 
246
        mov     gs, ax
-
 
247
        mov     ss, ax
-
 
248
 
-
 
249
        bt      [cpu_caps-OS_BASE], CAPS_PSE
-
 
250
        jnc     .no_PSE
-
 
251
 
-
 
252
        mov     ebx, cr4
-
 
253
        or      ebx, CR4_PSE
-
 
254
        mov     eax, PG_LARGE+PG_SW
-
 
255
        mov     cr4, ebx
-
 
256
.no_PSE:
-
 
257
        mov     eax, sys_pgdir-OS_BASE
-
 
258
        mov     cr3, eax
-
 
259
 
-
 
260
        mov     eax, cr0
-
 
261
        or      eax, CR0_PG+CR0_WP
-
 
262
        mov     cr0, eax
-
 
263
 
222
use32
264
        lgdt    [gdts]
223
org $+0x10000
265
        jmp     pword os_code:ap_entry
224
 
266
 
225
align 4
267
align 4
226
B32:
268
B32:
Line 267... Line 309...
267
        call    init_mem
309
        call    init_mem
268
        call    init_page_map
310
        call    init_page_map
Line 269... Line 311...
269
 
311
 
Line -... Line 312...
-
 
312
; ENABLE PAGING
-
 
313
 
270
; ENABLE PAGING
314
        xchg bx, bx
271
 
315
 
Line 272... Line 316...
272
        mov     eax, sys_pgdir-OS_BASE
316
        mov     eax, sys_pgdir-OS_BASE
273
        mov     cr3, eax
317
        mov     cr3, eax
Line 281... Line 325...
281
 
325
 
282
align 4
326
align 4
283
bios32_entry    dd ?
327
bios32_entry    dd ?
Line 284... Line -...
284
tmp_page_tabs   dd ?
-
 
285
 
-
 
286
use16
-
 
287
org $-0x10000
-
 
288
include "boot/shutdown.inc" ; shutdown or restart
-
 
Line 289... Line 328...
289
org $+0x10000
328
tmp_page_tabs   dd ?
290
use32
329
 
291
 
330
 
Line 292... Line 331...
292
__DEBUG__ fix 1
331
__DEBUG__ fix 1
Line -... Line 332...
-
 
332
__DEBUG_LEVEL__ fix 1
-
 
333
include 'init.inc'
-
 
334
 
-
 
335
org OS_BASE+$
-
 
336
 
-
 
337
ap_entry:
-
 
338
        bt      [cpu_caps], CAPS_PGE
-
 
339
        jnc     @F
-
 
340
 
-
 
341
        mov     ebx, cr4
-
 
342
        or      ebx, CR4_PGE
-
 
343
        mov     cr4, ebx
-
 
344
@@:
-
 
345
.1:
-
 
346
        mov ebx, LFB_BASE
-
 
347
        mov edx, 128
-
 
348
.2:
-
 
349
        mov ecx, 128
-
 
350
        mov edi, ebx
-
 
351
        mov eax, [_display.width]
-
 
352
        lea ebx, [ebx+eax*4]
-
 
353
        mov eax, 0xFF808080
-
 
354
        rep stosd
-
 
355
        dec edx
-
 
356
        jnz .2
293
__DEBUG_LEVEL__ fix 1
357
        jmp .1
294
include 'init.inc'
358
 
295
 
359
        hlt
296
org OS_BASE+$
360
        jmp ap_entry
297
 
361
 
Line 315... Line 379...
315
 
379
 
316
        mov     ebx, cr4
380
        mov     ebx, cr4
317
        or      ebx, CR4_PGE
381
        or      ebx, CR4_PGE
318
        mov     cr4, ebx
382
        mov     cr4, ebx
319
@@:
383
@@:
320
        xor     eax, eax
384
;        xor     eax, eax
321
        mov     dword [sys_pgdir], eax
385
;        mov     dword [sys_pgdir], eax
Line 322... Line 386...
322
        mov     dword [sys_pgdir+4], eax
386
;        mov     dword [sys_pgdir+4], eax
323
 
387
 
Line 324... Line 388...
324
        mov     eax, cr3
388
;        mov     eax, cr3
325
        mov     cr3, eax          ; flush TLB
389
;        mov     cr3, eax          ; flush TLB
Line 326... Line 390...
326
 
390
 
Line 617... Line 681...
617
        call    PIT_init
681
        call    PIT_init
Line 618... Line 682...
618
 
682
 
619
; Try to Initialize APIC
683
; Try to Initialize APIC
Line -... Line 684...
-
 
684
        call    APIC_init
-
 
685
 
620
        call    APIC_init
686
        call    LAPIC_init
621
 
687
 
622
; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15)
688
; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15)
623
; they are used: when partitions are scanned, hd_read relies on timer
689
; they are used: when partitions are scanned, hd_read relies on timer
624
        call    unmask_timer
690
        call    unmask_timer