Skip to content

Commit

Permalink
Made so that frostedwm command need to run the window manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
pradosh-arduino committed Jan 27, 2025
1 parent 730795e commit a16bf7b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions source/includes/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ extern int64 fb_width;
*/
extern int64 fb_height;

extern int64* wm_addr;

/**
* @brief The main kernel function
* @attention main() to something else, make sure to change the linker script accordingly.
Expand Down
15 changes: 3 additions & 12 deletions source/kernel/C/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ int terminal_columns = 0;
int64 fb_width = 0;
int64 fb_height = 0;

int64* wm_addr;

int64* font_address = null;

/**
Expand Down Expand Up @@ -381,18 +383,7 @@ void main(void) {
// int* test3 = malloc(sizeof(int));
// int* test4 = malloc(sizeof(int));

void* file_addr = module_request.response->modules[0]->address;
elf_load_from_memory(file_addr);
fdlfcn_handle* handle = fdlopen(file_addr, FDL_IMMEDIATE);
int(*startfunction)(void);
startfunction = (int(*)(void))fdlsym(handle, "_start");
if (startfunction != NULL)
{
int result = startfunction();
printf("Result function: %d\n", result);
info("Successfully loaded function from .so file", __FILE__);
}
fdlclose(handle);
wm_addr = module_request.response->modules[0]->address;

int failed_attempts = 0;

Expand Down
21 changes: 20 additions & 1 deletion source/kernel/C/shell/sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <stdint.h>
#include <flanterm/flanterm.h>
#include <filesystems/fwrfs.h>

#include <fdlfcn.h>

void init_command_list(command_list* lst)
{
Expand Down Expand Up @@ -93,6 +93,23 @@ void welcome_message(){
display_time();
}

extern int64* wm_addr;

void start_window_manager(){
void* file_addr = wm_addr;
elf_load_from_memory(file_addr);
fdlfcn_handle* handle = fdlopen(file_addr, FDL_IMMEDIATE);
int(*startfunction)(void);
startfunction = (int(*)(void))fdlsym(handle, "_start");
if (startfunction != NULL)
{
int result = startfunction();
printf("Result function: %d\n", result);
info("Successfully loaded function from .so file", __FILE__);
}
fdlclose(handle);
}

extern struct flanterm_context* ft_ctx;

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

0 comments on commit a16bf7b

Please sign in to comment.