// === IMPORTS ===\r
extern int Proc_Clone(Uint *Err, Uint Flags);\r
extern void Threads_SetName(char *Name);\r
+extern char *Threads_GetName(int ID);\r
extern Uint MM_ClearUser();\r
extern void Threads_Exit();\r
extern void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);\r
free(savedFile);\r
if(bases[0] == 0)\r
{\r
- Warning("Proc_Execve - Unable to load '%s'", File);\r
+ Warning("Proc_Execve - Unable to load '%s'", Threads_GetName(-1));\r
Threads_Exit();\r
for(;;);\r
}\r
// === PROTOTYPES ===
void Threads_Init();
void Threads_SetName(char *NewName);
+char *Threads_GetName(int ID);
void Threads_SetTickets(int Num);
int Threads_WaitTID(int TID, int *status);
tThread *Threads_GetThread(Uint TID);
strcpy(cur->ThreadName, NewName);
}
+/**
+ * \fn char *Threads_GetName(int ID)
+ * \brief Gets a thread's name
+ */
+char *Threads_GetName(int ID)
+{
+ if(ID == -1) {
+ return Proc_GetCurThread()->ThreadName;
+ }
+ return NULL;
+}
+
/**
* \fn void Threads_SetTickets(int Num)
* \brief Sets the 'priority' of a task
\r
// === GLOBALS ===\r
struct sFILE _iob[STDIO_MAX_STREAMS]; // IO Buffer\r
-struct sFILE *stdin = &_iob[0]; // Standard Input\r
-struct sFILE *stdout = &_iob[1]; // Standard Output\r
-struct sFILE *stderr = &_iob[2]; // Standard Error\r
+struct sFILE *stdin; // Standard Input\r
+struct sFILE *stdout; // Standard Output\r
+struct sFILE *stderr; // Standard Error\r
+///\note Initialised in SoMain\r
\r
// === CODE ===\r
/**\r
itoa(tmp, arg, 10, minSize, pad);\r
goto sprintf_puts;\r
// break;\r
+ case 'p': // Pointer\r
+ buf[pos++] = '*';\r
+ buf[pos++] = '0';\r
+ buf[pos++] = 'x';\r
case 'x':\r
itoa(tmp, arg, 16, minSize, pad);\r
goto sprintf_puts;\r
case 'u':\r
itoa(tmp, arg, 10, minSize, pad);\r
goto sprintf_puts;\r
+ case 'p': // Pointer\r
+ len += 3;\r
case 'x':\r
itoa(tmp, arg, 16, minSize, pad);\r
goto sprintf_puts;\r
*/\r
EXPORT int printf(const char *format, ...)\r
{\r
- #if 0\r
+ #if 1\r
int size;\r
char *buf;\r
va_list args;\r
\r
free(buf);\r
return size;\r
- #endif\r
+ \r
+ #else\r
\r
int ret;\r
va_list args;\r
ret = fprintfv(stdout, (char*)format, args);\r
va_end(args);\r
return ret;\r
+ #endif\r
}\r
\r
/**\r
\r
// Initialise Heap\r
if(_heap_start == NULL)\r
- {LOCAL void *sbrk(int delta);\r
+ {\r
_heap_start = sbrk(0);\r
_heap_end = _heap_start;\r
extendHeap(HEAP_INIT_SIZE);\r
}\r
\r
/**\r
- \fn LOCAL void *extendHeap(int bytes)\r
- \brief Create a new block at the end of the heap area\r
- \param bytes Integer - Size reqired\r
- \return Pointer to last free block\r
+ * \fn LOCAL void *extendHeap(int bytes)\r
+ * \brief Create a new block at the end of the heap area\r
+ * \param bytes Integer - Size reqired\r
+ * \return Pointer to last free block\r
*/\r
\r
LOCAL void *extendHeap(int bytes)\r
\r
extern char **_envp;\r
extern struct sFILE _iob[];\r
+extern struct sFILE *stdin;\r
+extern struct sFILE *stdout;\r
+extern struct sFILE *stderr;\r
\r
/**\r
* \fn int SoMain()\r
_envp = envp;\r
\r
// Init FileIO Pointers\r
- _iob[0].FD = 0; _iob[0].Flags = FILE_FLAG_MODE_READ;\r
- _iob[1].FD = 1; _iob[1].Flags = FILE_FLAG_MODE_WRITE;\r
- _iob[2].FD = 2; _iob[2].Flags = FILE_FLAG_MODE_WRITE;\r
+ stdin = &_iob[0];\r
+ stdin->FD = 0; stdin->Flags = FILE_FLAG_MODE_READ;\r
+ stdout = &_iob[1];\r
+ stdout->FD = 1; stdout->Flags = FILE_FLAG_MODE_WRITE;\r
+ stderr = &_iob[2];\r
+ stderr->FD = 2; stderr->Flags = FILE_FLAG_MODE_WRITE;\r
\r
return 1;\r
}\r