diff options
author | Marvin Borner | 2020-08-16 15:35:43 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-16 15:35:43 +0200 |
commit | 36e36fae364dec02999f58edbe997780d901b674 (patch) | |
tree | 8b06909e475ef84201ca2ef9375880249b1d5e68 | |
parent | c4a0bc2571162ad83fc51eb823f1c535336041bf (diff) |
Added WM and exec parameters
-rw-r--r-- | apps/Makefile | 2 | ||||
-rw-r--r-- | apps/a.c | 12 | ||||
-rw-r--r-- | apps/b.c | 12 | ||||
-rw-r--r-- | apps/init.c | 12 | ||||
-rw-r--r-- | apps/wm.c | 26 | ||||
-rw-r--r-- | kernel/features/proc.c | 2 | ||||
-rw-r--r-- | kernel/features/syscall.c | 4 | ||||
-rw-r--r-- | libc/inc/sys.h | 9 | ||||
-rw-r--r-- | libc/sys.c | 15 | ||||
-rw-r--r-- | libgui/gui.c | 26 | ||||
-rw-r--r-- | libgui/inc/gui.h | 2 |
11 files changed, 56 insertions, 66 deletions
diff --git a/apps/Makefile b/apps/Makefile index 8f9408e..390d181 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -1,6 +1,6 @@ # MIT License, Copyright (c) 2020 Marvin Borner -COBJS = a.o b.o init.o +COBJS = init.o wm.o CC = ../cross/opt/bin/i686-elf-gcc LD = ../cross/opt/bin/i686-elf-ld OC = ../cross/opt/bin/i686-elf-objcopy diff --git a/apps/a.c b/apps/a.c deleted file mode 100644 index b49e7f9..0000000 --- a/apps/a.c +++ /dev/null @@ -1,12 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#include <def.h> -#include <print.h> - -void main() -{ - print("\nA loaded.\n"); - while (1) { - print("A"); - } -} diff --git a/apps/b.c b/apps/b.c deleted file mode 100644 index 504a5fd..0000000 --- a/apps/b.c +++ /dev/null @@ -1,12 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner - -#include <def.h> -#include <print.h> - -void main() -{ - print("\nB loaded.\n"); - while (1) { - print("B"); - } -} diff --git a/apps/init.c b/apps/init.c index 89d446b..de87798 100644 --- a/apps/init.c +++ b/apps/init.c @@ -11,14 +11,8 @@ void main(struct vbe *vbe) { print("Init loaded.\n"); - printf("VBE: %dx%d\n", vbe->width, vbe->height); + int a = exec("/wm", vbe); - const u32 color[3] = { 0, 0, 0 }; - vesa_fill(vbe, color); - gui_init("/font/spleen-16x32.psfu"); - gui_term_write(vbe, "hallo"); - - /* exec("/a"); */ - /* exec("/b"); */ - exit(); + if (a) + exit(); } diff --git a/apps/wm.c b/apps/wm.c new file mode 100644 index 0000000..b9cae91 --- /dev/null +++ b/apps/wm.c @@ -0,0 +1,26 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#include <cpu.h> +#include <def.h> +#include <gui.h> +#include <print.h> +#include <sys.h> +#include <vesa.h> + +void main(char **argv) +{ + struct vbe *vbe = (struct vbe *)argv[0]; + + print("WM loaded.\n"); + printf("VBE: %dx%d\n", vbe->width, vbe->height); + + const u32 color[3] = { 0xff, 0xff, 0 }; + const u32 text[3] = { 0, 0, 0 }; + vesa_fill(vbe, color); + gui_init("/font/spleen-16x32.psfu"); + gui_write(vbe, 50, 50, text, "hallo"); + + while (1) { + }; + exit(); +} diff --git a/kernel/features/proc.c b/kernel/features/proc.c index f59ff32..f6e1fe6 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -49,7 +49,7 @@ void scheduler(struct regs *regs) regs->cs = GDT_USER_CODE_OFFSET; regs->eflags = EFLAGS_ALWAYS | EFLAGS_INTERRUPTS; } - printf("%d", current->pid); + /* printf("%d", current->pid); */ } void proc_print() diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index b486deb..e6bcb83 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -39,6 +39,10 @@ void syscall_handler(struct regs *r) case SYS_EXEC: { char *path = (char *)r->ebx; struct proc *proc = proc_make(); + ((u32 *)proc->regs.esp)[0] = r->ecx; + ((u32 *)proc->regs.esp)[1] = r->edx; + ((u32 *)proc->regs.esp)[2] = r->esi; + ((u32 *)proc->regs.esp)[3] = r->edi; r->eax = bin_load(path, proc); break; } diff --git a/libc/inc/sys.h b/libc/inc/sys.h index d95b760..0914bc4 100644 --- a/libc/inc/sys.h +++ b/libc/inc/sys.h @@ -14,6 +14,7 @@ int sys2(enum sys num, int d1, int d2); int sys3(enum sys num, int d1, int d2, int d3); int sys4(enum sys num, int d1, int d2, int d3, int d4); int sys5(enum sys num, int d1, int d2, int d3, int d4, int d5); +int sysv(enum sys num, ...); /** * Wrappers @@ -22,10 +23,12 @@ int sys5(enum sys num, int d1, int d2, int d3, int d4, int d5); #define loop() sys0(SYS_LOOP) #define read(path) (void *)sys1(SYS_READ, (int)path) #define write(path, buf) sys2(SYS_WRITE, (int)path, buf) -#define exec(path) sys1(SYS_EXEC, (int)path) +#define exec(path, ...) sysv(SYS_EXEC, (int)path, ##__VA_ARGS__) #define exit() \ - sys0(SYS_EXIT); \ - while (1) { \ + { \ + sys0(SYS_EXIT); \ + while (1) { \ + } \ } #endif @@ -1,6 +1,7 @@ // MIT License, Copyright (c) 2020 Marvin Borner // Syscall implementation +#include <arg.h> #include <sys.h> /** @@ -55,3 +56,17 @@ int sys5(enum sys num, int d1, int d2, int d3, int d4, int d5) "D"((int)d5)); return a; } + +#include <print.h> +int sysv(enum sys num, ...) +{ + va_list ap; + int args[5]; + + va_start(ap, num); + for (int i = 0; i < 5; i++) + args[i] = va_arg(ap, int); + va_end(ap); + + return sys5(num, args[0], args[1], args[2], args[3], args[4]); +} diff --git a/libgui/gui.c b/libgui/gui.c index 460cf07..e42e0f6 100644 --- a/libgui/gui.c +++ b/libgui/gui.c @@ -38,32 +38,6 @@ void gui_write(struct vbe *vbe, int x, int y, const u32 c[3], char *text) } } -// Abstraction -int x, y = 0; -const u32 c[3] = { 0xff, 0xff, 0xff }; -void gui_term_write_char(struct vbe *vbe, char ch) -{ - if (x + font->width > vbe->width) { - x = 0; - y += font->height; - } - - if (ch >= ' ' && ch <= '~') { - gui_write_char(vbe, x, y, c, ch); - x += font->width; - } else if (ch == '\n') { - x = 0; - y += font->height; - } -} - -void gui_term_write(struct vbe *vbe, char *text) -{ - for (u32 i = 0; i < strlen(text); i++) { - gui_term_write_char(vbe, text[i]); - } -} - void gui_init(char *font_path) { font = psf_parse(read(font_path)); diff --git a/libgui/inc/gui.h b/libgui/inc/gui.h index 52fe805..c646fab 100644 --- a/libgui/inc/gui.h +++ b/libgui/inc/gui.h @@ -16,8 +16,6 @@ struct font { }; void gui_write(struct vbe *vbe, int x, int y, const u32 c[3], char *text); -void gui_term_write_char(struct vbe *vbe, char ch); -void gui_term_write(struct vbe *vbe, char *text); void gui_init(char *font_path); #endif |