Skip to content

Commit a16bf7b

Browse files
Made so that frostedwm command need to run the window manager.
1 parent 730795e commit a16bf7b

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

source/includes/kernel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ extern int64 fb_width;
7373
*/
7474
extern int64 fb_height;
7575

76+
extern int64* wm_addr;
77+
7678
/**
7779
* @brief The main kernel function
7880
* @attention main() to something else, make sure to change the linker script accordingly.

source/kernel/C/kernel.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ int terminal_columns = 0;
1919
int64 fb_width = 0;
2020
int64 fb_height = 0;
2121

22+
int64* wm_addr;
23+
2224
int64* font_address = null;
2325

2426
/**
@@ -381,18 +383,7 @@ void main(void) {
381383
// int* test3 = malloc(sizeof(int));
382384
// int* test4 = malloc(sizeof(int));
383385

384-
void* file_addr = module_request.response->modules[0]->address;
385-
elf_load_from_memory(file_addr);
386-
fdlfcn_handle* handle = fdlopen(file_addr, FDL_IMMEDIATE);
387-
int(*startfunction)(void);
388-
startfunction = (int(*)(void))fdlsym(handle, "_start");
389-
if (startfunction != NULL)
390-
{
391-
int result = startfunction();
392-
printf("Result function: %d\n", result);
393-
info("Successfully loaded function from .so file", __FILE__);
394-
}
395-
fdlclose(handle);
386+
wm_addr = module_request.response->modules[0]->address;
396387

397388
int failed_attempts = 0;
398389

source/kernel/C/shell/sh.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <stdint.h>
2121
#include <flanterm/flanterm.h>
2222
#include <filesystems/fwrfs.h>
23-
23+
#include <fdlfcn.h>
2424

2525
void init_command_list(command_list* lst)
2626
{
@@ -93,6 +93,23 @@ void welcome_message(){
9393
display_time();
9494
}
9595

96+
extern int64* wm_addr;
97+
98+
void start_window_manager(){
99+
void* file_addr = wm_addr;
100+
elf_load_from_memory(file_addr);
101+
fdlfcn_handle* handle = fdlopen(file_addr, FDL_IMMEDIATE);
102+
int(*startfunction)(void);
103+
startfunction = (int(*)(void))fdlsym(handle, "_start");
104+
if (startfunction != NULL)
105+
{
106+
int result = startfunction();
107+
printf("Result function: %d\n", result);
108+
info("Successfully loaded function from .so file", __FILE__);
109+
}
110+
fdlclose(handle);
111+
}
112+
96113
extern struct flanterm_context* ft_ctx;
97114

98115
struct fwrfs* fs;
@@ -291,6 +308,8 @@ void execute(const char* buffer, int argc, char** argv)
291308
printf("touch: missing file operand");
292309
} else if (strcmp(buffer, "ls") == 0) {
293310
list_contents(fs);
311+
} else if (strncmp(buffer, "frostedwm", 9) == 0 || strcmp(buffer, "frostedwm") == 0) {
312+
start_window_manager();
294313
} else if (strncmp(buffer, "user ", 5) == 0 || strcmp(buffer, "user") == 0) {
295314
if(argv[1] != null)
296315
if((int)argv[1] == 1)

0 commit comments

Comments
 (0)