build.bat can create the image if missing, split the shell into native, posix and win32, clean up the build by moving executables into directories, the bootloader is no longer responsible to resolve drivers, fix ResolvePath, every process gets a copy of a module (dll), the child always inherits the cwd, fix function exports in posix, add unlink and exit to posix, add path translator to win32, first bugcheck.
This commit is contained in:
1 parent
0c7f461c6d
commit
f80e66ecde
38 files changed
+1620
-462
No files matched your search
+46
-11
@@ -2,20 +2,52 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Syscall stubs
|
||||
// ---------------------------------------------------------------------------
|
||||
extern uint32_t SysCreateProcess(const char* path, uint32_t* handleOut,
|
||||
const char* cmdline);
|
||||
extern uint32_t SysCloseHandle(uint32_t handle);
|
||||
extern void SysDebugPrint(const char* str);
|
||||
extern uint32_t SysWaitForProcess(uint32_t handle);
|
||||
extern void SysExitProcess(int code);
|
||||
extern void SysYield(void);
|
||||
#include <syscall.h>
|
||||
|
||||
#define STATUS_SUCCESS 0u
|
||||
|
||||
void itoa(int num, char* str) {
|
||||
int i = 0;
|
||||
int is_negative = 0;
|
||||
|
||||
// Handle 0 explicitly
|
||||
if (num == 0) {
|
||||
str[i++] = '0';
|
||||
str[i] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle negative numbers
|
||||
if (num < 0) {
|
||||
is_negative = 1;
|
||||
num = -num;
|
||||
}
|
||||
|
||||
// Process individual digits (result is in reverse)
|
||||
while (num != 0) {
|
||||
int rem = num % 10;
|
||||
str[i++] = rem + '0';
|
||||
num = num / 10;
|
||||
}
|
||||
|
||||
if (is_negative) {
|
||||
str[i++] = '-';
|
||||
}
|
||||
|
||||
str[i] = '\0'; // Null terminate
|
||||
|
||||
// Reverse the string
|
||||
int start = 0;
|
||||
int end = i - 1;
|
||||
while (start < end) {
|
||||
char temp = str[start];
|
||||
str[start] = str[end];
|
||||
str[end] = temp;
|
||||
start++;
|
||||
end--;
|
||||
}
|
||||
}
|
||||
|
||||
void _start(const char* args)
|
||||
{
|
||||
uint32_t h = 0;
|
||||
@@ -25,6 +57,9 @@ void _start(const char* args)
|
||||
s = SysCreateProcess(args, &h, NULL);
|
||||
if (s != STATUS_SUCCESS) {
|
||||
SysDebugPrint("[init] FATAL: failed to start!\n");
|
||||
char buffer[12];
|
||||
itoa(s, buffer);
|
||||
SysDebugPrint(buffer); SysDebugPrint("\n");
|
||||
SysExitProcess(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user