Uint32 Rsvd3[2];
Uint16 Rsvd4;
Uint16 IOMapBase;
+
+ // Acess Specific Fields
+ Uint8 CPUNumber; // CPU Number
} __attribute__ ((packed)) tTSS;
#endif
* 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
*/
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();
#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;
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
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
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:
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