From: John Hodge Date: Sat, 15 May 2010 02:49:55 +0000 (+0800) Subject: Updates to CPU Determining and initialising fractal mappings X-Git-Tag: rel0.06~188 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1810e1d377b996679ae090bfe57d1b5321ce190f;p=tpg%2Facess2.git Updates to CPU Determining and initialising fractal mappings --- diff --git a/Kernel/arch/x86_64/include/desctab.h b/Kernel/arch/x86_64/include/desctab.h index de3996c6..ee9b20bf 100644 --- a/Kernel/arch/x86_64/include/desctab.h +++ b/Kernel/arch/x86_64/include/desctab.h @@ -52,6 +52,9 @@ typedef struct { Uint32 Rsvd3[2]; Uint16 Rsvd4; Uint16 IOMapBase; + + // Acess Specific Fields + Uint8 CPUNumber; // CPU Number } __attribute__ ((packed)) tTSS; #endif diff --git a/Kernel/arch/x86_64/include/mm_virt.h b/Kernel/arch/x86_64/include/mm_virt.h index 420db1b1..a5abc71a 100644 --- a/Kernel/arch/x86_64/include/mm_virt.h +++ b/Kernel/arch/x86_64/include/mm_virt.h @@ -25,7 +25,7 @@ * 9900 00000000 - 9A00 00000000 40 1 TiB Kernel VFS * A000 00000000 - B000 00000000 44 16 TiB Kernel Stacks * D000 00000000 - E000 00000000 44 16 TiB Hardware Mappings - * FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping + * FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping (PML4 510) * FE80 00000000 - FF00 00000000 39 512 GiB Temp Fractal Mapping */ diff --git a/Kernel/arch/x86_64/proc.c b/Kernel/arch/x86_64/proc.c index 038cc612..623de556 100644 --- a/Kernel/arch/x86_64/proc.c +++ b/Kernel/arch/x86_64/proc.c @@ -36,9 +36,10 @@ extern tThread *gActiveThreads; extern tThread *gSleepingThreads; extern tThread *gDeleteThreads; extern tThread *Threads_GetNextToRun(int CPU); -extern void Threads_Dump(); +extern void Threads_Dump(void); extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags); -extern void Proc_ReturnToUser(); +extern void Proc_ReturnToUser(void); +extern void GetCPUNum(void); // === PROTOTYPES === void ArchThreads_Init(); @@ -268,6 +269,7 @@ void ArchThreads_Init() #else pos = 0; #endif + gTSSs[pos].CPUNumber = pos; gTSSs[pos].RSP0 = 0; // Set properly by scheduler gGDT[6+pos*2].BaseLow = ((Uint)(&gTSSs[pos])) & 0xFFFF; gGDT[6+pos*2].BaseMid = ((Uint)(&gTSSs[pos])) >> 16; @@ -347,7 +349,8 @@ void Proc_Start() tThread *Proc_GetCurThread() { #if USE_MP - return gaCPUs[ gaAPIC_to_CPU[gpMP_LocalAPIC->ID.Val&0xFF] ].Current; + //return gaCPUs[ gaAPIC_to_CPU[gpMP_LocalAPIC->ID.Val&0xFF] ].Current; + return gaCPUs[ GetCPUNum() ].Current; #else return gCurrentThread; #endif diff --git a/Kernel/arch/x86_64/start32.asm b/Kernel/arch/x86_64/start32.asm index 1163b31a..577607aa 100644 --- a/Kernel/arch/x86_64/start32.asm +++ b/Kernel/arch/x86_64/start32.asm @@ -66,7 +66,9 @@ gInitialPML4: ; Covers 256 TiB (Full 48-bit Virtual Address Space) dd gInitialPDP - KERNEL_BASE + 3, 0 ; Identity Map Low 4Mb times 256-1 dq 0 dd gInitialPDP - KERNEL_BASE + 3, 0 ; Map Low 4Mb to kernel base - times 256-1 dq 0 + times 256-1-2 dq 0 + dd gInitialPML4 - KERNEL_BASE + 3, 0 ; Fractal Mapping + dq 0 gInitialPDP: ; Covers 512 GiB dd gInitialPD - KERNEL_BASE + 3, 0 diff --git a/Kernel/arch/x86_64/start64.asm b/Kernel/arch/x86_64/start64.asm index c1f1e58b..30fc9717 100644 --- a/Kernel/arch/x86_64/start64.asm +++ b/Kernel/arch/x86_64/start64.asm @@ -15,7 +15,15 @@ GetRIP: mov rax, [rsp] ret -KSTACK_USERSTATE_SIZE equ (4+8+1+5)*4 ; SRegs, GPRegs, CPU, IRET +[global GetCPUNum] +GetCPUNum: + str ax + mov gs, ax + xor rax, rax + mov al, [gs:104] ; End of TSS + ret + +KSTACK_USERSTATE_SIZE equ (16+1+5)*8 ; GPRegs, CPU, IRET [global Proc_ReturnToUser] [extern Proc_GetCurThread] Proc_ReturnToUser: @@ -38,7 +46,8 @@ Proc_ReturnToUser: mov rcx, [rax+KSTACK_USERSTATE_SIZE-3*8] mov rdx, [rbx+60] ; Get Signal Number mov [rcx-8], rdx - mov QWORD [rcx-16], User_Syscall_RetAndExit + mov rax, User_Syscall_RetAndExit + mov [rcx-16], rax sub rcx, 16 ; Restore Segment Registers