aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt18
-rw-r--r--src/kernel/fs/elf.c2
-rw-r--r--src/kernel/fs/elf.h2
-rw-r--r--src/kernel/fs/ext2.c2
-rw-r--r--src/kernel/fs/ext2.h2
-rw-r--r--src/kernel/graphics/vesa.c14
-rw-r--r--src/kernel/graphics/vesa.h4
-rw-r--r--src/kernel/kernel.c4
-rw-r--r--src/kernel/syscall/actions/sys_exec.c2
-rw-r--r--src/kernel/syscall/actions/sys_getch.c2
-rw-r--r--src/kernel/syscall/actions/sys_pointers.c18
-rw-r--r--src/kernel/syscall/syscall.c5
-rw-r--r--src/kernel/syscall/syscall.h4
-rw-r--r--src/kernel/tasks/process.c3
-rw-r--r--src/kernel/tasks/process.h2
-rw-r--r--src/userspace/libc/math.h2
-rw-r--r--src/userspace/libc/stdarg.h2
-rw-r--r--src/userspace/libc/stdbool.h2
-rw-r--r--src/userspace/libc/stddef.h2
-rw-r--r--src/userspace/libc/stdint.h6
-rw-r--r--src/userspace/libc/stdio.h2
-rw-r--r--src/userspace/libc/stdlib.h2
-rw-r--r--src/userspace/libc/syscall.c2
-rw-r--r--src/userspace/libc/syscall.h4
-rw-r--r--src/userspace/libgui/gui.h22
-rw-r--r--src/userspace/libgui/init.c10
-rw-r--r--src/userspace/programs/init.c4
-rw-r--r--src/userspace/programs/sh.c2
28 files changed, 106 insertions, 40 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d77fb54..2ffab93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,7 @@ file(GLOB_RECURSE kernel_sources src/kernel/*.c src/kernel/*.asm)
file(GLOB_RECURSE resources_sources src/resources/*.c)
file(GLOB_RECURSE user_sources src/userspace/programs/*.c)
file(GLOB_RECURSE user_libc_sources src/userspace/libc/*.c)
+file(GLOB_RECURSE user_libgui_sources src/userspace/libgui/*.c)
# KERNEL
add_executable(kernel ${kernel_sources})
@@ -52,14 +53,21 @@ add_custom_command(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
-# USERSPACE
-add_library(userspace_lib ${user_libc_sources})
-target_include_directories(userspace_lib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libc/")
+# USERSPACE LIBC
+add_library(userspace_libc ${user_libc_sources})
+target_include_directories(userspace_libc PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libc/")
+
+# USERSPACE LIBGUI
+add_library(userspace_libgui ${user_libgui_sources})
+target_link_libraries(userspace_libgui userspace_libc)
+target_include_directories(userspace_libgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libc/" "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libgui/")
+
+# USERSPACE PROGRAMS
foreach(loop_file ${user_sources})
get_filename_component(testname ${loop_file} NAME_WE)
add_executable(${testname} ${loop_file})
target_compile_options(${testname} PRIVATE "-nostdinc")
- target_include_directories(${testname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libc/")
- target_link_libraries(${testname} userspace_lib "-T ${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/linker.ld")
+ target_include_directories(${testname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libc/" "${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/libgui/")
+ target_link_libraries(${testname} userspace_libc userspace_libgui "-T ${CMAKE_CURRENT_SOURCE_DIR}/src/userspace/linker.ld")
set_target_properties(${testname} PROPERTIES OUTPUT_NAME "${CMAKE_CURRENT_SOURCE_DIR}/build/user/${testname}")
endforeach(loop_file ${user_sources})
diff --git a/src/kernel/fs/elf.c b/src/kernel/fs/elf.c
index a4c78ba..37cc606 100644
--- a/src/kernel/fs/elf.c
+++ b/src/kernel/fs/elf.c
@@ -71,4 +71,4 @@ struct process *elf_load(char *path)
paging_switch_directory(paging_root_directory);
return proc;
-}
+} \ No newline at end of file
diff --git a/src/kernel/fs/elf.h b/src/kernel/fs/elf.h
index 0fe435b..8c7d38a 100644
--- a/src/kernel/fs/elf.h
+++ b/src/kernel/fs/elf.h
@@ -76,4 +76,4 @@ struct elf_program_header {
int is_elf(struct elf_header *header);
struct process *elf_load(char *path);
-#endif
+#endif \ No newline at end of file
diff --git a/src/kernel/fs/ext2.c b/src/kernel/fs/ext2.c
index 4e4f617..5fb0158 100644
--- a/src/kernel/fs/ext2.c
+++ b/src/kernel/fs/ext2.c
@@ -251,4 +251,4 @@ uint8_t *read_file(char *path)
warn("File not found");
return NULL;
}
-}
+} \ No newline at end of file
diff --git a/src/kernel/fs/ext2.h b/src/kernel/fs/ext2.h
index 7fbe493..88515a3 100644
--- a/src/kernel/fs/ext2.h
+++ b/src/kernel/fs/ext2.h
@@ -139,4 +139,4 @@ uint32_t ext2_look_up_path(char *path);
uint8_t *read_file(char *path);
-#endif
+#endif \ No newline at end of file
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index 898a0f3..30cda3a 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -187,9 +187,7 @@ void set_optimal_resolution()
uint32_t fb_size = vbe_width * vbe_height * vbe_bpl;
/* cursor_buffer = kmalloc(fb_size); */
for (uint32_t z = 0; z < fb_size; z += PAGE_S) {
- paging_map(paging_root_directory, (uint32_t)fb + z, (uint32_t)fb + z);
- /* paging_map(paging_root_directory, (uint32_t)cursor_buffer + z, */
- /* (uint32_t)cursor_buffer + z); */
+ paging_map_user(paging_root_directory, (uint32_t)fb + z, (uint32_t)fb + z);
}
if (vbe_height > 1440)
@@ -198,11 +196,11 @@ void set_optimal_resolution()
vesa_set_font(24);
else
vesa_set_font(16);
- vesa_set_color(default_text_color);
- vesa_clear();
+ //vesa_set_color(default_text_color);
+ //vesa_clear();
- vesa_set_color(vesa_blue);
- vesa_set_color(default_text_color);
+ //vesa_set_color(vesa_blue);
+ //vesa_set_color(default_text_color);
info("Successfully switched to video mode!");
@@ -253,7 +251,7 @@ void vesa_convert_color(uint32_t *color_array, uint32_t color)
void vesa_set_pixel(uint16_t x, uint16_t y, const uint32_t color[3])
{
- unsigned pos = (unsigned int)(x * vbe_bpl + y * vbe_pitch);
+ uint8_t pos = (uint8_t)(x * vbe_bpl + y * vbe_pitch);
char *draw = (char *)&fb[pos];
draw[pos] = (char)color[2];
draw[pos + 1] = (char)color[1];
diff --git a/src/kernel/graphics/vesa.h b/src/kernel/graphics/vesa.h
index c45be19..50bf85c 100644
--- a/src/kernel/graphics/vesa.h
+++ b/src/kernel/graphics/vesa.h
@@ -251,8 +251,8 @@ int vbe_bpl;
/**
* The framebuffer interface
*/
-unsigned char *fb;
+uint8_t *fb;
-unsigned char *cursor_buffer;
+uint8_t *cursor_buffer;
#endif \ No newline at end of file
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index 8056055..ffde014 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -64,11 +64,11 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address, uint32_t esp)
load_binaries();
set_optimal_resolution();
- printf("Content of /etc/test: %s", read_file("/etc/test"));
+ log("Content of /etc/test: %s", read_file("/etc/test"));
syscalls_install();
kexec("/bin/init");
halt_loop();
// asm ("div %0" :: "r"(0)); // Exception testing x/0
-}
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_exec.c b/src/kernel/syscall/actions/sys_exec.c
index dc1e9c6..000d185 100644
--- a/src/kernel/syscall/actions/sys_exec.c
+++ b/src/kernel/syscall/actions/sys_exec.c
@@ -4,4 +4,4 @@
uint32_t sys_exec(char *path)
{
return uexec(path);
-}
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_getch.c b/src/kernel/syscall/actions/sys_getch.c
index 91ccda7..3ce1f8c 100644
--- a/src/kernel/syscall/actions/sys_getch.c
+++ b/src/kernel/syscall/actions/sys_getch.c
@@ -8,4 +8,4 @@ uint32_t sys_getch()
uint32_t key = getch();
cli();
return key;
-}
+} \ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_pointers.c b/src/kernel/syscall/actions/sys_pointers.c
new file mode 100644
index 0000000..1a2d8f7
--- /dev/null
+++ b/src/kernel/syscall/actions/sys_pointers.c
@@ -0,0 +1,18 @@
+#include <stdint.h>
+#include <kernel/graphics/vesa.h>
+#include <kernel/fs/load.h>
+#include <kernel/memory/alloc.h>
+
+struct pointers {
+ uint8_t *fb;
+ struct font *font;
+};
+
+uint32_t sys_pointers()
+{
+ struct pointers *pointers = kmalloc(sizeof(struct pointers));
+ pointers->fb = fb;
+ pointers->font = font;
+
+ return pointers;
+} \ No newline at end of file
diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c
index d0b2b96..af59499 100644
--- a/src/kernel/syscall/syscall.c
+++ b/src/kernel/syscall/syscall.c
@@ -12,7 +12,8 @@ uint32_t (*syscalls[])() = { [0] = (uint32_t(*)())halt_loop, // DEBUG!
[2] = (uint32_t(*)())sys_putch,
[3] = sys_getch,
[4] = sys_malloc,
- [5] = sys_free };
+ [5] = sys_free,
+ [6] = sys_pointers };
void syscall_handler(struct regs *r)
{
@@ -36,4 +37,4 @@ void syscall_handler(struct regs *r)
void syscalls_install()
{
isr_install_handler(0x80, syscall_handler);
-}
+} \ No newline at end of file
diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h
index 5c21d58..b0a15c4 100644
--- a/src/kernel/syscall/syscall.h
+++ b/src/kernel/syscall/syscall.h
@@ -17,4 +17,6 @@ uint32_t sys_malloc(uint32_t count);
uint32_t sys_free(uint32_t ptr);
-#endif
+uint32_t sys_pointers();
+
+#endif \ No newline at end of file
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index a4c525a..d45ab50 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -217,6 +217,7 @@ uint32_t kexec(char *path)
proc->stdout = NULL;
proc->stderr = NULL;
process_init(proc);
+ return 0;
}
uint32_t uexec(char *path)
@@ -235,4 +236,4 @@ uint32_t uexec(char *path)
proc->gid = current_proc->pid;
process_spawn(proc);
return 0;
-}
+} \ No newline at end of file
diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h
index 5230ea4..b138f60 100644
--- a/src/kernel/tasks/process.h
+++ b/src/kernel/tasks/process.h
@@ -74,4 +74,4 @@ extern uint32_t stack_hold;
#define WAIT_ERROR (-1)
#define WAIT_OKAY 0
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/math.h b/src/userspace/libc/math.h
index 2683535..a2010c9 100644
--- a/src/userspace/libc/math.h
+++ b/src/userspace/libc/math.h
@@ -17,4 +17,4 @@
// Minimum, maximum, difference
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/stdarg.h b/src/userspace/libc/stdarg.h
index 41583f9..9442742 100644
--- a/src/userspace/libc/stdarg.h
+++ b/src/userspace/libc/stdarg.h
@@ -3,4 +3,4 @@
// va_{list,start,arg,end,copy}
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/stdbool.h b/src/userspace/libc/stdbool.h
index b445c80..337ca9b 100644
--- a/src/userspace/libc/stdbool.h
+++ b/src/userspace/libc/stdbool.h
@@ -8,4 +8,4 @@
#define TRUE 1
#define FALSE 0
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/stddef.h b/src/userspace/libc/stddef.h
index 531cee3..09dc508 100644
--- a/src/userspace/libc/stddef.h
+++ b/src/userspace/libc/stddef.h
@@ -5,4 +5,4 @@
#define NULL ((void *)0)
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/stdint.h b/src/userspace/libc/stdint.h
index be28300..63f29f4 100644
--- a/src/userspace/libc/stdint.h
+++ b/src/userspace/libc/stdint.h
@@ -12,7 +12,7 @@ typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;
-typedef signed long s64;
-typedef unsigned long u64;
+typedef signed long long s64;
+typedef unsigned long long u64;
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/stdio.h b/src/userspace/libc/stdio.h
index 03dfd1a..13ab933 100644
--- a/src/userspace/libc/stdio.h
+++ b/src/userspace/libc/stdio.h
@@ -5,4 +5,4 @@
// Character input/output
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/stdlib.h b/src/userspace/libc/stdlib.h
index ab6bff4..dfc97e8 100644
--- a/src/userspace/libc/stdlib.h
+++ b/src/userspace/libc/stdlib.h
@@ -7,4 +7,4 @@
// Memory management
-#endif
+#endif \ No newline at end of file
diff --git a/src/userspace/libc/syscall.c b/src/userspace/libc/syscall.c
index 42786d4..9194eef 100644
--- a/src/userspace/libc/syscall.c
+++ b/src/userspace/libc/syscall.c
@@ -14,3 +14,5 @@ DEFN_SYSCALL0(getch, 3);
DEFN_SYSCALL1(malloc, 4, u32);
DEFN_SYSCALL1(free, 5, u32);
+
+DEFN_SYSCALL0(pointers, 6); \ No newline at end of file
diff --git a/src/userspace/libc/syscall.h b/src/userspace/libc/syscall.h
index 394118c..90ebee5 100644
--- a/src/userspace/libc/syscall.h
+++ b/src/userspace/libc/syscall.h
@@ -80,4 +80,6 @@ DECL_SYSCALL1(malloc, u32);
DECL_SYSCALL1(free, u32);
-#endif
+DECL_SYSCALL0(pointers);
+
+#endif \ No newline at end of file
diff --git a/src/userspace/libgui/gui.h b/src/userspace/libgui/gui.h
new file mode 100644
index 0000000..b056dea
--- /dev/null
+++ b/src/userspace/libgui/gui.h
@@ -0,0 +1,22 @@
+#ifndef MELVIX_GUI_H
+#define MELVIX_GUI_H
+
+#include <stdint.h>
+
+struct font {
+ u16 font_32[758][32];
+ u16 font_24[758][24];
+ u8 font_16[758][16];
+ u16 cursor[19];
+};
+
+struct pointers {
+ u8 *fb;
+ struct font *font;
+};
+
+struct pointers *pointers;
+
+void gui_init();
+
+#endif \ No newline at end of file
diff --git a/src/userspace/libgui/init.c b/src/userspace/libgui/init.c
new file mode 100644
index 0000000..dfc42eb
--- /dev/null
+++ b/src/userspace/libgui/init.c
@@ -0,0 +1,10 @@
+#include <stdint.h>
+#include <syscall.h>
+#include <gui.h>
+
+struct pointers *pointers;
+
+void gui_init()
+{
+ pointers = syscall_pointers();
+} \ No newline at end of file
diff --git a/src/userspace/programs/init.c b/src/userspace/programs/init.c
index 3011530..91564c0 100644
--- a/src/userspace/programs/init.c
+++ b/src/userspace/programs/init.c
@@ -1,9 +1,11 @@
#include <syscall.h>
+#include <gui.h>
void main()
{
+ gui_init();
syscall_exec("/bin/sh");
while (1) {
};
-}
+} \ No newline at end of file
diff --git a/src/userspace/programs/sh.c b/src/userspace/programs/sh.c
index f477d6e..6dcb206 100644
--- a/src/userspace/programs/sh.c
+++ b/src/userspace/programs/sh.c
@@ -11,4 +11,4 @@ void main()
}
syscall_halt();
-}
+} \ No newline at end of file