aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarvin Borner2020-04-28 23:33:34 +0200
committerMarvin Borner2020-04-28 23:33:34 +0200
commit34c752f6fe4f71169172f1b3e46b1eddf69eba6e (patch)
treec9acf3f6cac1791861d3506c4fe6f2c1dfedeae5 /src
parent5f8b5ce7efb7738eaebad43f9648975788ae19ff (diff)
Added support for multiple user applications
Diffstat (limited to 'src')
-rw-r--r--src/bootloader/grub.cfg2
-rw-r--r--src/kernel/acpi/acpi.c1
-rw-r--r--src/kernel/graphics/vesa.c2
-rw-r--r--src/kernel/kernel.c8
-rw-r--r--src/kernel/lib/memory.c1
-rw-r--r--src/kernel/multiboot.c3
-rw-r--r--src/kernel/syscall.c20
-rw-r--r--src/kernel/syscall.h87
-rw-r--r--src/kernel/syscall/syscall.c2
-rw-r--r--src/userspace/libc/syscall.h12
-rw-r--r--src/userspace/linker.ld2
-rw-r--r--src/userspace/programs/init.c6
12 files changed, 21 insertions, 125 deletions
diff --git a/src/bootloader/grub.cfg b/src/bootloader/grub.cfg
index 75d4934..cdd19b4 100644
--- a/src/bootloader/grub.cfg
+++ b/src/bootloader/grub.cfg
@@ -1,6 +1,6 @@
set timeout=0
set default=0
menuentry "Melvix" {
- multiboot2 /boot/kernel.bin
+ multiboot2 /boot/kernel.bin foo bar
boot
} \ No newline at end of file
diff --git a/src/kernel/acpi/acpi.c b/src/kernel/acpi/acpi.c
index 865435f..3e07171 100644
--- a/src/kernel/acpi/acpi.c
+++ b/src/kernel/acpi/acpi.c
@@ -35,6 +35,7 @@ void acpi_init(struct rsdp *rsdp)
hpet = (struct hpet *)kmalloc(sizeof(struct hpet));
madt = (struct madt *)kmalloc(sizeof(struct madt));
+ // TODO: Fix ACPI table discovering (HPET & MADT missing)
if (strncmp(rsdp->signature, "RSD PTR ", 8) == 0) {
memcpy(rsdt, rsdp->rsdt_address, sizeof(struct rsdt) + 32);
debug("Found RSDT");
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index 43b0799..898a0f3 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -122,6 +122,8 @@ void set_optimal_resolution()
if (mode_info->width > vbe_width ||
(mode_info->width == vbe_width && (mode_info->bpp >> 3) > vbe_bpl)) {
// if (mode_info->bpp == 32) { // Force specific bpp for debugging
+ debug("Found mode: %dx%dx%d", mode_info->width, mode_info->height,
+ mode_info->bpp);
highest = *mode;
vbe_width = mode_info->width;
vbe_height = mode_info->height;
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index 3efe193..90b967f 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -44,9 +44,8 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address, uint32_t esp)
isrs_install();
irq_install();
+ // multiboot_parse(multiboot_address); // TODO: Why does this break graphics?
paging_install();
- log("0x%x", multiboot_address); // TODO: Fix multiboot table mmap
- multiboot_parse(multiboot_address);
// Install drivers
cli();
@@ -65,10 +64,10 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address, uint32_t esp)
load_binaries();
set_optimal_resolution();
- printf("%s", read_file("/etc/test"));
+ printf("Content of /etc/test: %s", read_file("/etc/test"));
syscalls_install();
- struct process *proc = elf_load("/bin/sh");
+ struct process *proc = elf_load("/bin/init");
if (proc) {
proc->stdin = NULL;
proc->stdout = NULL;
@@ -76,7 +75,6 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address, uint32_t esp)
process_init(proc);
}
- log("Okidoko!");
halt_loop();
// asm ("div %0" :: "r"(0)); // Exception testing x/0
} \ No newline at end of file
diff --git a/src/kernel/lib/memory.c b/src/kernel/lib/memory.c
index 30f75f9..819a70f 100644
--- a/src/kernel/lib/memory.c
+++ b/src/kernel/lib/memory.c
@@ -58,6 +58,7 @@ uint32_t memory_get_free()
void memory_print()
{
if (meminfo != NULL) {
+ // TODO: Fix multiboot mem lower/upper
info("Mem lower: 0x%x", meminfo->mem_lower);
info("Mem upper: 0x%x", meminfo->mem_upper);
}
diff --git a/src/kernel/multiboot.c b/src/kernel/multiboot.c
index 086e628..e922ee7 100644
--- a/src/kernel/multiboot.c
+++ b/src/kernel/multiboot.c
@@ -15,7 +15,8 @@ void multiboot_parse(uint32_t multiboot_address)
tag = (struct multiboot_tag *)((multiboot_uint8_t *)tag + ((tag->size + 7) & ~7))) {
switch (tag->type) {
case MULTIBOOT_TAG_TYPE_CMDLINE:
- debug("Got cmdline");
+ // TODO: Add cmdline config support
+ debug("Got cmdline: %s", ((struct multiboot_tag_string *)tag)->string);
break;
case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
debug("Got bootloader name: %s",
diff --git a/src/kernel/syscall.c b/src/kernel/syscall.c
deleted file mode 100644
index 68750e1..0000000
--- a/src/kernel/syscall.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <kernel/syscall.h>
-
-/**
- * DEFINITIONS
- */
-DEFN_SYSCALL0(halt, 0);
-
-DEFN_SYSCALL1(write, 1, const char *);
-
-DEFN_SYSCALL1(read, 2, const char *);
-
-DEFN_SYSCALL1(writec, 3, char);
-
-DEFN_SYSCALL0(readc, 4);
-
-DEFN_SYSCALL0(get_pointers, 5);
-
-DEFN_SYSCALL1(alloc, 6, uint32_t);
-
-DEFN_SYSCALL1(free, 7, uint32_t); \ No newline at end of file
diff --git a/src/kernel/syscall.h b/src/kernel/syscall.h
deleted file mode 100644
index 9f5bdb0..0000000
--- a/src/kernel/syscall.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef MELVIX_SYSCALL_H
-#define MELVIX_SYSCALL_H
-
-#include <stdint.h>
-
-#define DECL_SYSCALL0(fn) int syscall_##fn();
-#define DECL_SYSCALL1(fn, p1) int syscall_##fn(p1);
-#define DECL_SYSCALL2(fn, p1, p2) int syscall_##fn(p1, p2);
-#define DECL_SYSCALL3(fn, p1, p2, p3) int syscall_##fn(p1, p2, p3);
-#define DECL_SYSCALL4(fn, p1, p2, p3, p4) int syscall_##fn(p1, p2, p3, p4);
-#define DECL_SYSCALL5(fn, p1, p2, p3, p4, p5) int syscall_##fn(p1, p2, p3, p4, p5);
-
-#define DEFN_SYSCALL0(fn, num) \
- int syscall_##fn() \
- { \
- int a; \
- asm volatile("int $0x80" : "=a"(a) : "0"(num)); \
- return a; \
- }
-
-#define DEFN_SYSCALL1(fn, num, P1) \
- int syscall_##fn(P1 p1) \
- { \
- int a; \
- asm volatile("int $0x80" : "=a"(a) : "0"(num), "b"((int)p1)); \
- return a; \
- }
-
-#define DEFN_SYSCALL2(fn, num, P1, P2) \
- int syscall_##fn(P1 p1, P2 p2) \
- { \
- int a; \
- asm volatile("int $0x80" : "=a"(a) : "0"(num), "b"((int)p1), "c"((int)p2)); \
- return a; \
- }
-
-#define DEFN_SYSCALL3(fn, num, P1, P2, P3) \
- int syscall_##fn(P1 p1, P2 p2, P3 p3) \
- { \
- int a; \
- asm volatile("int $0x80" \
- : "=a"(a) \
- : "0"(num), "b"((int)p1), "c"((int)p2), "d"((int)p3)); \
- return a; \
- }
-
-#define DEFN_SYSCALL4(fn, num, P1, P2, P3, P4) \
- int syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4) \
- { \
- int a; \
- asm volatile("int $0x80" \
- : "=a"(a) \
- : "0"(num), "b"((int)p1), "c"((int)p2), "d"((int)p3), "S"((int)p4)); \
- return a; \
- }
-
-#define DEFN_SYSCALL5(fn, num) \
- int syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) \
- { \
- int a; \
- asm volatile("int $0x80" \
- : "=a"(a) \
- : "0"(num), "b"((int)p1), "c"((int)p2), "d"((int)p3), "S"((int)p4), \
- "D"((int)p5)); \
- return a; \
- }
-
-/**
- * DECLARATIONS
- */
-DECL_SYSCALL0(halt);
-
-DECL_SYSCALL1(write, const char *);
-
-DECL_SYSCALL1(read, const char *);
-
-DECL_SYSCALL1(writec, char);
-
-DECL_SYSCALL0(readc);
-
-DECL_SYSCALL0(get_pointers);
-
-DECL_SYSCALL1(alloc, uint32_t);
-
-DECL_SYSCALL1(free, uint32_t);
-
-#endif \ No newline at end of file
diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c
index a106f07..ca12118 100644
--- a/src/kernel/syscall/syscall.c
+++ b/src/kernel/syscall/syscall.c
@@ -8,7 +8,7 @@
typedef uint32_t (*syscall_func)(uint32_t, ...);
uint32_t (*syscalls[])() = { [0] = (uint32_t(*)())halt_loop, // DEBUG!
- [1] = sys_putch,
+ [1] = (uint32_t(*)())sys_putch,
[2] = sys_getch,
[3] = sys_malloc,
[4] = sys_free };
diff --git a/src/userspace/libc/syscall.h b/src/userspace/libc/syscall.h
index 9f5bdb0..61ffecc 100644
--- a/src/userspace/libc/syscall.h
+++ b/src/userspace/libc/syscall.h
@@ -70,17 +70,11 @@
*/
DECL_SYSCALL0(halt);
-DECL_SYSCALL1(write, const char *);
+DECL_SYSCALL1(putch, const char *);
-DECL_SYSCALL1(read, const char *);
+DECL_SYSCALL0(getch);
-DECL_SYSCALL1(writec, char);
-
-DECL_SYSCALL0(readc);
-
-DECL_SYSCALL0(get_pointers);
-
-DECL_SYSCALL1(alloc, uint32_t);
+DECL_SYSCALL1(malloc, uint32_t);
DECL_SYSCALL1(free, uint32_t);
diff --git a/src/userspace/linker.ld b/src/userspace/linker.ld
index 8ede485..69018c4 100644
--- a/src/userspace/linker.ld
+++ b/src/userspace/linker.ld
@@ -1,4 +1,4 @@
-ENTRY(_start)
+ENTRY(main)
SECTIONS
{
.text 0x40000000:
diff --git a/src/userspace/programs/init.c b/src/userspace/programs/init.c
new file mode 100644
index 0000000..bf3c7f4
--- /dev/null
+++ b/src/userspace/programs/init.c
@@ -0,0 +1,6 @@
+void main()
+{
+ // TODO: Exec shell
+ while (1) {
+ };
+} \ No newline at end of file