git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AcessNative - Fixing Fixing Fixing
[tpg/acess2.git]
/
Kernel
/
arch
/
x86_64
/
proc.c
diff --git
a/Kernel/arch/x86_64/proc.c
b/Kernel/arch/x86_64/proc.c
index
1d1513b
..
99fa7e6
100644
(file)
--- a/
Kernel/arch/x86_64/proc.c
+++ b/
Kernel/arch/x86_64/proc.c
@@
-5,6
+5,7
@@
#include <acess.h>
#include <proc.h>
#include <threads.h>
#include <acess.h>
#include <proc.h>
#include <threads.h>
+#include <threads_int.h>
#include <desctab.h>
#include <mm_virt.h>
#include <errno.h>
#include <desctab.h>
#include <mm_virt.h>
#include <errno.h>
@@
-42,9
+43,7
@@
extern int giNextTID;
extern int giTotalTickets;
extern int giNumActiveThreads;
extern tThread gThreadZero;
extern int giTotalTickets;
extern int giNumActiveThreads;
extern tThread gThreadZero;
-//extern tThread *Threads_GetNextToRun(int CPU);
extern void Threads_Dump(void);
extern void Threads_Dump(void);
-extern tThread *Threads_CloneTCB(Uint *Err, Uint Flags);
extern void Proc_ReturnToUser(void);
extern int GetCPUNum(void);
extern void Proc_ReturnToUser(void);
extern int GetCPUNum(void);
@@
-54,12
+53,17
@@
void ArchThreads_Init(void);
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
#endif
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
#endif
-
void
Proc_Start(void);
-
tThread
*Proc_GetCurThread(void);
+
//void
Proc_Start(void);
+
//tThread
*Proc_GetCurThread(void);
void Proc_ChangeStack(void);
void Proc_ChangeStack(void);
- int Proc_Clone(Uint *Err, Uint Flags);
+// int Proc_Clone(Uint *Err, Uint Flags);
+// int Proc_SpawnWorker(void);
+Uint Proc_MakeUserStack(void);
+void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
+ int Proc_Demote(Uint *Err, int Dest, tRegs *Regs);
void Proc_CallFaultHandler(tThread *Thread);
void Proc_CallFaultHandler(tThread *Thread);
+void Proc_DumpThreadCPUState(tThread *Thread);
void Proc_Scheduler(int CPU);
// === GLOBALS ===
void Proc_Scheduler(int CPU);
// === GLOBALS ===
@@
-304,7
+308,10
@@
void ArchThreads_Init(void)
outb(0x40, (TIMER_DIVISOR>>8)&0xFF); // High Byte
// Create Per-Process Data Block
outb(0x40, (TIMER_DIVISOR>>8)&0xFF); // High Byte
// Create Per-Process Data Block
- MM_Allocate(MM_PPD_CFG);
+ if( !MM_Allocate(MM_PPD_CFG) )
+ {
+ Warning("Oh, hell, Unable to allocate PPD for Thread#0");
+ }
// Change Stacks
Proc_ChangeStack();
// Change Stacks
Proc_ChangeStack();
@@
-386,7
+393,7
@@
void Proc_Start(void)
if(Proc_Clone(0, 0) == 0)
{
gaCPUs[0].IdleThread = Proc_GetCurThread();
if(Proc_Clone(0, 0) == 0)
{
gaCPUs[0].IdleThread = Proc_GetCurThread();
- gaCPUs[0].IdleThread->ThreadName = "Idle Thread";
+ gaCPUs[0].IdleThread->ThreadName =
(char*)
"Idle Thread";
Threads_SetPriority( gaCPUs[0].IdleThread, -1 ); // Never called randomly
gaCPUs[0].IdleThread->Quantum = 1; // 1 slice quantum
for(;;) HALT(); // Just yeilds
Threads_SetPriority( gaCPUs[0].IdleThread, -1 ); // Never called randomly
gaCPUs[0].IdleThread->Quantum = 1; // 1 slice quantum
for(;;) HALT(); // Just yeilds
@@
-611,8
+618,17
@@
Uint Proc_MakeUserStack(void)
if(i != -1) return 0;
// Allocate Stack - Allocate incrementally to clean up MM_Dump output
if(i != -1) return 0;
// Allocate Stack - Allocate incrementally to clean up MM_Dump output
- for( i = 0; i < USER_STACK_SZ/4069; i++ )
- MM_Allocate( base + (i<<12) );
+ for( i = 0; i < USER_STACK_SZ/0x1000; i++ )
+ {
+ if( !MM_Allocate( base + (i<<12) ) )
+ {
+ // Error
+ Log_Error("Proc", "Unable to allocate user stack (%i pages requested)", USER_STACK_SZ/0x1000);
+ while( i -- )
+ MM_Deallocate( base + (i<<12) );
+ return 0;
+ }
+ }
return base + USER_STACK_SZ;
}
return base + USER_STACK_SZ;
}
@@
-724,6
+740,10
@@
void Proc_CallFaultHandler(tThread *Thread)
for(;;);
}
for(;;);
}
+void Proc_DumpThreadCPUState(tThread *Thread)
+{
+}
+
/**
* \fn void Proc_Scheduler(int CPU)
* \brief Swap current thread and clears dead threads
/**
* \fn void Proc_Scheduler(int CPU)
* \brief Swap current thread and clears dead threads
@@
-761,18
+781,22
@@
void Proc_Scheduler(int CPU)
// Error Check
if(thread == NULL) {
thread = gaCPUs[CPU].IdleThread;
// Error Check
if(thread == NULL) {
thread = gaCPUs[CPU].IdleThread;
- Warning("Hmm... Threads_GetNextToRun returned NULL, I don't think this should happen.\n");
+ //Warning("Hmm... Threads_GetNextToRun returned NULL, I don't think this should happen.\n");
+ //LogF("Zzzzz.\n");
return;
}
#if DEBUG_TRACE_SWITCH
return;
}
#if DEBUG_TRACE_SWITCH
- Log("Switching to task %i, CR3 = 0x%x, RIP = %p",
+ Log
F
("Switching to task %i, CR3 = 0x%x, RIP = %p",
thread->TID,
thread->MemState.CR3,
thread->SavedState.RIP
);
#endif
thread->TID,
thread->MemState.CR3,
thread->SavedState.RIP
);
#endif
+
+ if(CPU > MAX_CPUS)
+ LogF("CPU = %i", CPU);
// Set current thread
gaCPUs[CPU].Current = thread;
// Set current thread
gaCPUs[CPU].Current = thread;
UCC
git Repository :: git.ucc.asn.au