Skip to content

Commit a0e6f4e

Browse files
author
di
committed
[MOD] created kernel modules for (static) compilation of modules
1 parent 4b84992 commit a0e6f4e

16 files changed

Lines changed: 91 additions & 14 deletions

File tree

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ endif
1111

1212
.PHONY: all shared user kernel clean raspi virt run debug dump prepare-fs help install
1313

14-
all: kshared kernel shared user utils bins
14+
all: kshared modules kernel shared user utils bins
1515
@echo "Build complete."
1616
./createfs
1717

1818
kshared:
1919
$(MAKE) -C shared SH_FLAGS=-DKERNEL BUILD_DIR=./kbuild TARGET=klibshared.a
20+
21+
modules: kshared
22+
$(MAKE) -C modules
2023

2124
shared:
2225
$(MAKE) -C shared BUILD_DIR=./build
2326

2427
user: shared prepare-fs
2528
$(MAKE) -C user
2629

27-
kernel: kshared
30+
kernel: kshared modules
2831
$(MAKE) -C kernel LOAD_ADDR=$(LOAD_ADDR) XHCI_CTX_SIZE=$(XHCI_CTX_SIZE) QEMU=$(QEMU) TEST=$(TEST)
2932

3033
utils: shared prepare-fs
@@ -43,6 +46,7 @@ clean:
4346
$(MAKE) -C kernel $@
4447
$(MAKE) -C utils $@
4548
$(MAKE) -C bin $@
49+
$(MAKE) -C modules $@
4650
@echo "removing fs dirs"
4751
$(RM) -r $(FS_DIRS)
4852
@echo "removing images"

kernel/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ include ../common.mk
55

66
CPPFLAGS := -I. -I../shared -I../user -DXHCI_CTX_SIZE=$(XHCI_CTX_SIZE)
77

8+
MODULES := $(wildcard ../modules/*.a)
9+
810
ifeq ($(QEMU),true)
911
CPPFLAGS += -DQEMU
1012
endif
@@ -36,8 +38,8 @@ prepare:
3638
mkdir -p $(BUILD_DIR)
3739

3840
$(TARGET): ../shared/klibshared.a prepare $(OBJ)
39-
echo $(LDFLAGS)
40-
$(VLD) $(LDFLAGS) -o $(ELF) $(OBJL) ../shared/klibshared.a $(BUILD_DIR)/boot.o
41+
echo $(LIBMODULES)
42+
$(VLD) $(LDFLAGS) -o $(ELF) $(OBJL) ../shared/klibshared.a $(MODULES) $(BUILD_DIR)/boot.o
4143
$(OBJCOPY) -O binary $(ELF) $@
4244
cp $(ELF) ../fs/kernel.elf
4345

kernel/graph/graphics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ void gpu_setup_cursor(gpu_point initial_loc);
2929
void gpu_update_cursor(gpu_point new_loc, bool full);
3030
void gpu_set_cursor_pressed(bool pressed);
3131

32+
void gpu_create_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, draw_ctx *ctx);
33+
void gpu_resize_window(uint32_t width, uint32_t height, draw_ctx *win_ctx);
34+
3235
extern system_module graphics_module;
3336

3437
#ifdef __cplusplus

kernel/graph/tres.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "tres.h"
2-
#include "drivers/gpu_driver.hpp"
32
#include "std/memory.h"
43
#include "process/scheduler.h"
54
#include "filesystem/filesystem.h"
65
#include "syscalls/syscalls.h"
76
#include "kernel_processes/windows/launcher.h"
87
#include "console/kio.h"
98
#include "sysregs.h"
9+
#include "graphics.h"
1010
#include "ui/graphic_types.h"
1111

1212
clinkedlist_t *window_list;
@@ -23,11 +23,8 @@ typedef struct window_tab {
2323
uint16_t pid;
2424
} window_tab;
2525

26-
GPUDriver *main_gpu_driver;
27-
2826
void init_window_manager(uintptr_t gpu_driver){
2927
window_list = clinkedlist_create();
30-
main_gpu_driver = (GPUDriver*)gpu_driver;
3128
}
3229

3330
int find_window(void *node, void *key){
@@ -64,7 +61,7 @@ extern "C" void create_window(int32_t x, int32_t y, uint32_t width, uint32_t hei
6461
frame->x = x;
6562
frame->y = y;
6663
clinkedlist_push_front(window_list, PHYS_TO_VIRT_P(frame));
67-
main_gpu_driver->create_window(x,y, width, height, &frame->win_ctx);
64+
gpu_create_window(x,y, width, height, &frame->win_ctx);
6865
process_t *p = launch_launcher();
6966
p->win_id = frame->win_id;
7067
frame->pid = p->id;
@@ -76,7 +73,7 @@ void resize_window(uint32_t width, uint32_t height){
7673
clinkedlist_node_t *node = clinkedlist_find(window_list, PHYS_TO_VIRT_P(&p->win_id), (typeof(find_window)*)PHYS_TO_VIRT_P(find_window));
7774
if (node && node->data){
7875
window_frame* frame = (window_frame*)node->data;
79-
main_gpu_driver->resize_window(width, height, &frame->win_ctx);
76+
gpu_resize_window(width, height, &frame->win_ctx);
8077
frame->width = width;
8178
frame->height = height;
8279
dirty_windows = true;
@@ -104,7 +101,7 @@ void commit_frame(draw_ctx* frame_ctx, window_frame* frame){
104101
}
105102

106103
draw_ctx win_ctx = frame->win_ctx;
107-
draw_ctx *screen_ctx = main_gpu_driver->get_ctx();
104+
draw_ctx *screen_ctx = gpu_get_ctx();
108105

109106
int32_t sx = global_win_offset.x + frame->x;
110107
int32_t sy = global_win_offset.y + frame->y;

modules/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
include ../common.mk
2+
3+
SUBDIRS := $(wildcard */.)
4+
SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
5+
6+
all: $(SUBDIRS)
7+
8+
$(SUBDIRS):
9+
$(MAKE) -C $@
10+
11+
clean: $(SUBCLEAN)
12+
13+
$(SUBCLEAN): %.clean:
14+
$(MAKE) -C $* clean
15+
16+
clean: $(SUBCLEAN)
17+
18+
.PHONY: all $(SUBDIRS)

modules/graph/Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
include ../../common.mk
2+
3+
CPPFLAGS := -I. -I../../kernel -I../../shared
4+
CFLAGS := $(CFLAGS_BASE) $(CPPFLAGS)
5+
CXXFLAGS := $(CXXFLAGS_BASE) $(CPPFLAGS)
6+
7+
CLEAN_OBJS := $(shell find . -name "*.o")
8+
CLEAN_DEPS := $(shell find . -name "*.d")
9+
C_SRC := $(shell find . -name "*.c")
10+
CPP_SRC := $(shell find . -name "*.cpp")
11+
ASM_SRC := $(shell find . -name "*.S")
12+
OBJ := $(C_SRC:%.c=$(BUILD_DIR)/%.o) $(ASM_SRC:%.S=$(BUILD_DIR)/%.o) $(CPP_SRC:%.cpp=$(BUILD_DIR)/%.o)
13+
DEP := $(C_SRC:%.c=$(BUILD_DIR)/%.d) $(ASM_SRC:%.S=$(BUILD_DIR)/%.d) $(CPP_SRC:%.cpp=$(BUILD_DIR)/%.d)
14+
15+
TARGET := $(shell echo "../lib$(notdir $(CURDIR)).a")
16+
17+
.PHONY: all clean prepare
18+
19+
all: prepare $(TARGET)
20+
21+
prepare:
22+
mkdir -p $(BUILD_DIR)
23+
24+
$(TARGET): $(OBJ)
25+
@echo "Finishing build $(ARCH)"
26+
echo $(addprefix $(BUILD_DIR)/,$(notdir $(OBJ)))
27+
$(VAR) rcs $@ $(OBJ)
28+
29+
$(BUILD_DIR)/%.o: %.S
30+
@mkdir -p $(dir $@)
31+
$(VAS) $(CFLAGS) $(SH_FLAGS) -c $< -o $@
32+
33+
$(BUILD_DIR)/%.o: %.c
34+
@mkdir -p $(dir $@)
35+
$(VCC) $(CFLAGS) $(SH_FLAGS) -c -MMD -MP $< -o $@
36+
37+
$(BUILD_DIR)/%.o: %.cpp
38+
@mkdir -p $(dir $@)
39+
$(VCXX) $(CXXFLAGS) $(SH_FLAGS) -c -MMD -MP $< -o $@
40+
41+
clean:
42+
$(RM) $(CLEAN_OBJS) $(CLEAN_DEPS) $(TARGET)
43+
$(RM) -r $(BUILD_DIR)
44+
45+
-include $(DEP)
46+
File renamed without changes.
File renamed without changes.

kernel/graph/drivers/framebuffer_gpus/ramfb_driver/ramfb.cpp renamed to modules/graph/drivers/framebuffer_gpus/ramfb_driver/ramfb.cpp

File renamed without changes.

kernel/graph/drivers/framebuffer_gpus/ramfb_driver/ramfb.hpp renamed to modules/graph/drivers/framebuffer_gpus/ramfb_driver/ramfb.hpp

File renamed without changes.

0 commit comments

Comments
 (0)