Cleanup init

This commit is contained in:
Alex 2023-04-23 22:18:14 +03:00
parent 1000a57531
commit faa781a9ca
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 10 additions and 16 deletions

View File

@ -54,7 +54,7 @@ build: $(FILENAME)
$(FILENAME): $(OBJ) $(FILENAME): $(OBJ)
$(info Linking $@) $(info Linking $@)
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -lssp -linit -lsys -lgraph -o $@ $(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -lssp -linit -o $@
%.o: %.c $(HEADERS) %.o: %.c $(HEADERS)
$(info Compiling $<) $(info Compiling $<)

View File

@ -1,21 +1,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <aux.h> #include <aux.h>
#include <sysbase.h>
#include <sysfile.h>
#include <init.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__) #define print(m, ...) init_log(m, ##__VA_ARGS__)
int main(int argc, char *argv[], char *envp[]) void test_args(int argc, char *argv[], char *envp[])
{ {
print("%p %p %p\n", (void *)(uint64_t)&argc, (void *)&argv, (void *)&envp); print("%p %p %p\n", (void *)(uint64_t)&argc, (void *)&argv, (void *)&envp);
print("I have %d arguments\n", argc); print("I have %d arguments\n", argc);
@ -38,8 +28,12 @@ int main(int argc, char *argv[], char *envp[])
for (auxv = (Elf64_auxv_t *)e; auxv->a_type != AT_NULL; auxv++) 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); print("auxv: %ld %#lx\n", auxv->a_type, auxv->a_un.a_val);
}
File *test = FileOpen("/Test.txt", FILE_READ); int main(int argc, char *argv[], char *envp[])
{
// test_args(argc, argv, envp);
FILE *test = fopen("/Test.txt", "r");
if (test == NULL) if (test == NULL)
{ {
print("Failed to open file\n"); print("Failed to open file\n");
@ -47,9 +41,9 @@ int main(int argc, char *argv[], char *envp[])
} }
char buf[1024]; char buf[1024];
uint64_t read = FileRead(test, 0, (uint8_t *)buf, 1024); int read = fread(buf, 1024, 1, test);
print("Read %ld bytes from file\n", read); print("Read %ld bytes from file\n", read);
print("File contents: %s\n", buf); print("File contents: %s\n", buf);
FileClose(test); fclose(test);
return 0; return 0;
} }