X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fstart.asm;h=b6026de6b936ccbe97ba75dd6d8c53066b83ba91;hb=a20cfd571f504f5c7f2d29516442a12c200441d5;hp=8c7d9a64008e469209a3bd7b3a2b459476ba7780;hpb=9c61cf12758c0977ee1dc5791cba638fd3437ba6;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/start.asm b/Kernel/arch/x86/start.asm index 8c7d9a64..b6026de6 100644 --- a/Kernel/arch/x86/start.asm +++ b/Kernel/arch/x86/start.asm @@ -68,17 +68,23 @@ start: ; Start Paging mov ecx, gaInitPageDir - KERNEL_BASE mov cr3, ecx - mov ecx, cr0 - or ecx, 0x80010000 ; PG and WP + or ecx, 0x80010000 ; PG and WP mov cr0, ecx mov WORD [0xB8002], 0x0763 ; 'c' - mov WORD [0xB8004], 0x0765 ; 'e' - lea ecx, [.higherHalf] - jmp ecx -.higherHalf: + ; Set GDT + lgdt [gGDTPtr] + mov cx, 0x10 ; PL0 Data + mov ss, cx + mov ds, cx + mov es, cx + mov gs, cx + mov fs, cx + mov WORD [0xB8004], 0x0765 ; 'e' + jmp 0x08:.higher_half +.higher_half: mov WORD [0xB8006], 0x0773 ; 's' mov WORD [0xB8008], 0x0773 ; 's' @@ -99,8 +105,6 @@ start: ; Multiprocessing AP Startup Code (Must be within 0 - 0x10FFF0) ; %if USE_MP -[extern gGDT] -[extern gGDTPtr] [extern gIDTPtr] [extern gpMP_LocalAPIC] [extern giMP_TimerCount] @@ -108,6 +112,7 @@ start: [extern gaCPUs] [extern giNumInitingCPUs] [extern MM_NewKStack] +[extern Proc_InitialiseSSE] lGDTPtr: ; Local GDT Pointer dw 3*8-1 @@ -120,6 +125,7 @@ APWait: .hlt: ;hlt jmp .hlt +[extern Proc_Reschedule] [global APStartup] APStartup: ;xchg bx, bx ; MAGIC BREAK! @@ -160,11 +166,13 @@ APStartup: mov ebx, [ebp+0x20] ; Read ID shr ebx, 24 ;xchg bx, bx ; MAGIC BREAK - ; CL is now local APIC ID + ; BL is now local APIC ID mov cl, BYTE [gaAPIC_to_CPU+ebx] xor ebx, ebx mov bl, cl ; BL is now the CPU ID + mov dr1, ebx ; Save the CPU number to a debug register + ; Mark the CPU as up mov BYTE [gaCPUs+ebx*8+1], 1 ; Decrement the remaining CPU count dec DWORD [giNumInitingCPUs] @@ -179,8 +187,6 @@ APStartup: ; Set TSS lea ecx, [ebx*8+0x30] ltr cx - ; Save the CPU number to a debug register - mov dr1, ebx ;xchg bx, bx ; MAGIC_BREAK ; Enable Local APIC @@ -194,11 +200,15 @@ APStartup: mov DWORD [ebp+0x360], 0x000100D2 ; ##Enable LINT1 on IVT#0xD2 mov DWORD [ebp+0x370], 0x000100E1 ; ##Enable Error on IVT#0xE1 mov DWORD [ebp+0x0B0], 0 ; Send an EOI (just in case) + + ; Initialise SSE support + call Proc_InitialiseSSE ; CPU is now marked as initialised - sti - ;xchg bx, bx ; MAGIC BREAK + .hlt: + sti + call Proc_Reschedule hlt jmp .hlt %endif @@ -228,6 +238,25 @@ CallWithArgArray: pop ebp ret +[section .data] +; GDT +GDT_SIZE equ (1+2*2+1+MAX_CPUS)*8 +[global gGDT] +gGDT: + ; PL0 - Kernel + ; PL3 - User + dd 0x00000000, 0x00000000 ; 00 NULL Entry + dd 0x0000FFFF, 0x00CF9A00 ; 08 PL0 Code + dd 0x0000FFFF, 0x00CF9200 ; 10 PL0 Data + dd 0x0000FFFF, 0x00CFFA00 ; 18 PL3 Code + dd 0x0000FFFF, 0x00CFF200 ; 20 PL3 Data + dd 26*4-1, 0x00408900 ; 28 Double Fault TSS + times MAX_CPUS dd 26*4-1, 0x00408900 ; 30+ TSSes +[global gGDTPtr] +gGDTPtr: + dw GDT_SIZE-1 + dd gGDT + [section .initpd] [global gaInitPageDir] [global gaInitPageTable] @@ -252,4 +281,5 @@ ALIGN 4096 Kernel_Stack_Top: gInitAPStacks: times 32*MAX_CPUS dd 0 - + +; vim: ft=nasm ts=8