Updated userspace

This commit is contained in:
Alex
2022-12-24 09:18:45 +02:00
parent 0ce6433311
commit 40410cba41
25 changed files with 472 additions and 36 deletions

View File

@ -53,7 +53,7 @@ build: $(FILENAME)
mv $(FILENAME) ../../../out/system/$(FILENAME)
$(FILENAME): $(OBJ)
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -lssp -linit -o $@
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -lssp -linit -lsys -lgraph -o $@
%.o: %.c $(HEADERS)
$(info Compiling $<)

View File

@ -1,13 +1,24 @@
#include <stdlib.h>
#include <init.h>
#include <aux.h>
#include <syslib.h>
#include <sysbase.h>
#include <sysfile.h>
#include <init.h>
void PutCharToKernelConsole(char c)
{
__asm__ __volatile__("syscall"
:
: "a"(1), "D"(c), "S"(0)
: "rcx", "r11", "memory");
}
#define print(m, ...) init_log(m, ##__VA_ARGS__)
int main(int argc, char *argv[], char *envp[])
{
print("Hello World!\n");
for (int i = 0; i < 14; i++)
PutCharToKernelConsole("\nHello World!\n"[i]);
print("%p %p %p\n", (void *)(uint64_t)&argc, (void *)&argv, (void *)&envp);
print("I have %d arguments\n", argc);
for (int i = 0; i < argc; i++)
@ -30,5 +41,17 @@ int main(int argc, char *argv[], char *envp[])
for (auxv = (Elf64_auxv_t *)e; auxv->a_type != AT_NULL; auxv++)
print("auxv: %ld %#lx\n", auxv->a_type, auxv->a_un.a_val);
File *test = FileOpen("/Test.txt", FILE_READ);
if (test == NULL)
{
print("Failed to open file\n");
return 1;
}
char buf[1024];
uint64_t read = FileRead(test, (uint8_t *)buf, 1024);
print("Read %ld bytes from file\n", read);
print("File contents: %s\n", buf);
FileClose(test);
return 0;
}