Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e8d23b8
[sub] fixed url submodule
CodeAnarchist Feb 2, 2026
2aa4448
[netpkt] palloc in netpkt, minor fixes
CodeAnarchist Feb 6, 2026
fb2a1cf
[ALLOC,WIP] refactor
CodeAnarchist Feb 13, 2026
0f2afcc
[WIP ALLOC] misc, mm, fixed net memory leak
CodeAnarchist Feb 15, 2026
448fe67
[PROC]fix wx perms, enable user processes
CodeAnarchist Feb 17, 2026
9f6dbfc
Merge remote-tracking branch 'upstream/main' into mem
CodeAnarchist Feb 17, 2026
235bd1a
[ALLOC] asid, finalizing the merge
CodeAnarchist Feb 19, 2026
de459ae
[mmu] add global asid, vma, various fixes
CodeAnarchist Feb 21, 2026
77dc3d8
[mem] fix high-half exception vectors
CodeAnarchist Feb 22, 2026
93dc84d
[mem] brk and page fault
CodeAnarchist Feb 23, 2026
3306fc2
[alloc] vma-demand palloc/pfree
CodeAnarchist Feb 24, 2026
b52e442
[mem] make paddr_t explicit
CodeAnarchist Feb 26, 2026
8cdccc9
[mmu] no phys as pointer
CodeAnarchist Feb 26, 2026
86904c3
[mem wip] high half ker, TTBR0/TTBR1 split (not booting)
CodeAnarchist Mar 1, 2026
1699782
[mem] boot, kva/pa split
CodeAnarchist Mar 1, 2026
bb34ddf
[mem] rasp
CodeAnarchist Mar 5, 2026
426926c
[mem] uaccess, VMA
CodeAnarchist Mar 7, 2026
ba0a702
[mem/drivers] minor fixes
CodeAnarchist Mar 7, 2026
3b624fb
[mem/proc] unify mm ownership, user memory paths
CodeAnarchist Mar 8, 2026
dcbd8e2
[mem] finalize uaccess and TTBR0 isolation
CodeAnarchist Mar 10, 2026
219632f
[test]test
CodeAnarchist Mar 10, 2026
251a20a
[misc]fix stress test issues in filesystem, process and IO paths
CodeAnarchist Mar 15, 2026
f230b98
[misc] git requests and testing
CodeAnarchist Mar 17, 2026
d583063
[misc]removed brk heap in favor of full anon, cleaned up structs
CodeAnarchist Mar 19, 2026
1493941
[sched] fix scheduler crash, refactored to dynamic types
CodeAnarchist Mar 21, 2026
b7deedd
sub
CodeAnarchist Mar 21, 2026
d909dc3
[misc]fixed scheduler, fixed panic debugging, merged shared
CodeAnarchist Mar 27, 2026
1e01f69
Merge remote-tracking branch 'upstream/main' into mem
CodeAnarchist Mar 28, 2026
c2f5e88
merge
CodeAnarchist Mar 28, 2026
1073555
[misc] git reqs, minor fixes
CodeAnarchist Apr 2, 2026
8b81ae6
[misc] removed errno
CodeAnarchist Apr 4, 2026
4dfbee3
[proc] fix lifecycle handling and add clean user exit path
CodeAnarchist Apr 5, 2026
5617265
[link]use common user linker
CodeAnarchist Apr 5, 2026
8e4e6d6
[sched] idle
CodeAnarchist Apr 6, 2026
75dc054
[launch]added shared user exit trampoline, removed crt0 and _start
CodeAnarchist Apr 6, 2026
7937cf0
Merge remote-tracking branch 'upstream/main' into mem
CodeAnarchist Apr 8, 2026
9e73d0e
[merge] minor fixes
CodeAnarchist Apr 8, 2026
414605d
[common] -Werror
CodeAnarchist Apr 8, 2026
aa06147
[misc] warns
CodeAnarchist Apr 8, 2026
c81771d
[linker] user linker
CodeAnarchist Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "shared"]
path = shared
url = https://github.com/differrari/redlib
url = https://github.com/differrari/redlib.git
2 changes: 1 addition & 1 deletion bin/BinMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ../../common.mk
CPPFLAGS := -I. -I../../shared
CFLAGS := $(CFLAGS_BASE) $(CPPFLAGS)
CXXFLAGS := $(CXXFLAGS_BASE) $(CPPFLAGS)
LDFLAGS := -T $(shell ls *.ld)
LDFLAGS := -emain

CLEAN_OBJS := $(shell find . -name '*.o')
CLEAN_DEPS := $(shell find . -name '*.d')
Expand Down
27 changes: 0 additions & 27 deletions bin/read/linker.ld

This file was deleted.

27 changes: 0 additions & 27 deletions bin/test/linker.ld

This file was deleted.

1 change: 1 addition & 0 deletions kernel/audio/OutputAudioDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ void OutputAudioDevice::populate(){
}

sizedptr OutputAudioDevice::request_buffer(){
*(uint32_t*)(buffer + write_ptr) = stream_id;
sizedptr ptr = (sizedptr){buffer + write_ptr + header_size, buf_size};
write_ptr += packet_size;
if (write_ptr + packet_size >= BUF_SIZE) write_ptr = 0;
Expand Down
122 changes: 44 additions & 78 deletions kernel/bin/bin_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include "syscalls/syscalls.h"
#include "console/kio.h"
#include "process/loading/elf_file.h"
#include "input/input_dispatch.h"
#include "std/memory.h"
#include "process/scheduler.h"
#include "sysregs.h"
#include "input/input_dispatch.h"

bool init_bin(){
return true;
Expand All @@ -29,90 +29,56 @@ open_bin_ref available_cmds[] = {
{ "monitor", monitor_procs },
};

process_t* load_proc(const char *full_name, const char *prog_name, int argc, const char *argv[]){
Comment thread
CodeAnarchist marked this conversation as resolved.
file fd = {};
if (!prog_name){
prog_name = full_name;
do {
const char *next = seek_to(prog_name, '/');
if (!*next) break;
prog_name = next;
} while (*prog_name);
}
string bundle = string_from_literal_length(full_name,prog_name-full_name-1);
FS_RESULT op = openf(full_name, &fd);
if (op != FS_RESULT_SUCCESS){
kprintf("Failed to open file %s",full_name);
return 0;
}
char *program = malloc(fd.size);
if (readf(&fd, program, fd.size) != fd.size){
kprintf("Failed to read file %s", full_name);
}
process_t *proc = load_elf_file(prog_name, bundle.data, program, fd.size);
proc->win_id = get_current_proc()->win_id;
closef(&fd);
if (!proc){
kprintf("Failed to create process for %s",prog_name);
}
proc->PROC_X0 = argc;
if (argc > 0){
uintptr_t start = (uintptr_t)argv[0];
uintptr_t end = (uintptr_t)argv;
size_t total = end-start;
size_t argvs = argc * sizeof(uintptr_t);
char *nargvals = (char*)(PHYS_TO_VIRT_P(proc->stack_phys)-total-argvs);
char *vnargvals = (char*)(proc->stack-total-argvs);
char** nargv = (char**)(PHYS_TO_VIRT_P(proc->stack_phys)-argvs);
uintptr_t strptr = 0;
for (int i = 0; i < argc; i++){
size_t strsize = strlen(argv[i]);
memcpy(nargvals + strptr, argv[i], strsize);
*(char*)(nargvals + strptr + strsize++) = 0;
nargv[i] = vnargvals + strptr;
strptr += strsize;
}
proc->priority = PROC_PRIORITY_FULL;
proc->PROC_X1 = (uintptr_t)proc->stack-argvs;
proc->sp -= total+argvs;
}
proc->state = READY;
sys_set_focus(proc->id);
return proc;
}
process_t* execute(const char* prog_name, int argc, const char* argv[], uint32_t mode){
if (!prog_name || !*prog_name) return 0;
if (mode != EXEC_MODE_KEEP_FOCUS) mode = EXEC_MODE_DEFAULT;

process_t *cur = get_current_proc();
uint16_t win_id = cur ? cur->win_id : 0;
bool transfer_focus = win_id && mode == EXEC_MODE_DEFAULT;

process_t* execute(const char* prog_name, int argc, const char* argv[]){
size_t listsize = 0x1000;
void *listptr = zalloc(listsize);
if (strcont(prog_name, "/")){
return load_proc(prog_name, 0, argc, argv);
}
if (list_directory_contents("/boot/redos/bin/", listptr, listsize, 0)){
char *full_name = strcat_new(prog_name, ".elf");
string_list *list = (string_list*)listptr;
char* reader = (char*)list->array;
for (uint32_t i = 0; i < list->count; i++){
char *f = reader;
if (*f){
if (strcmp_case(f, full_name,true) == 0){
string path = string_format("/boot/redos/bin/%s",full_name);
process_t *p = load_proc(path.data, full_name, argc, argv);
string_free(path);
release(full_name);
release(list);
return p;
}
while (*reader) reader++;
reader++;
}
const char *name = prog_name;
for (const char *p = prog_name; *p; p++) if (*p == '/') name = p + 1;

char proc_name[256] = {};
size_t i = 0;
while (name[i] && name[i] != '.' && i + 1 < sizeof(proc_name)){
proc_name[i] = name[i];
i++;
}

string bundle = string_from_literal_length(prog_name, name - prog_name - 1);
process_t *proc = load_elf_process_path(proc_name, bundle.data, prog_name, argc, argv);
release(bundle.data);
if (!proc) return 0;

if (win_id) proc->win_id = win_id;
if (transfer_focus) sys_set_focus(proc->id);
return proc;
}

char *full_name = (strend_case(prog_name, ".elf", true) == 0) ? string_from_literal(prog_name).data : strcat_new(prog_name, ".elf");
if (full_name) {
char pathbuf[1024] = {};
size_t pathlen = string_format_buf(pathbuf, sizeof(pathbuf), "/boot/redos/bin/%s",full_name);
process_t *proc = 0;
if (pathlen < sizeof(pathbuf) - 1) proc = load_elf_process_path(prog_name, 0, pathbuf, argc, argv);
release(full_name);
release(listptr);
if (proc) {
if (win_id) proc->win_id = win_id;
if (transfer_focus) sys_set_focus(proc->id);
return proc;
}
}

for (uint32_t i = 0; i < N_ARR(available_cmds); i++){
if (strcmp(available_cmds[i].name, prog_name) == 0){
return create_kernel_process(available_cmds[i].name, available_cmds[i].func, argc, argv);
process_t *proc = create_kernel_process(available_cmds[i].name, available_cmds[i].func, argc, argv);
if (!proc) return 0;
if (win_id) proc->win_id = win_id;
if (transfer_focus) sys_set_focus(proc->id);
return proc;
}
}
return 0;
Expand Down Expand Up @@ -142,4 +108,4 @@ system_module bin_module = (system_module){
.sread = 0,
.swrite = 0,
.readdir = 0,
};//TODO: with dfs, should be possible to map virts for hardcoded commands + physical map to /boot/redos/bin
};
2 changes: 1 addition & 1 deletion kernel/bin/bin_mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extern "C" {
#endif

process_t* execute(const char* prog_name, int argc, const char* argv[]);
process_t* execute(const char* prog_name, int argc, const char* argv[], uint32_t mode);

#ifdef __cplusplus
}
Expand Down
53 changes: 26 additions & 27 deletions kernel/bin/monitor_processes.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ui/draw/draw.h"
#include "std/string.h"
#include "theme/theme.h"
#include "memory/addr.h"
#include "math/math.h"
#include "syscalls/syscalls.h"
#include "memory/memory_types.h"
Expand All @@ -17,12 +18,12 @@ char* parse_proc_state(int state){
{
case STOPPED:
return "Stopped";

case READY:
return "Ready";
case RUNNING:
case BLOCKED:
return "Running";

case BLOCKED:
return "Blocked";
default:
return "Invalid";
}
Expand All @@ -40,16 +41,16 @@ uint64_t calc_heap(uintptr_t ptr){
char *procname;

void print_process_info(){
process_t *processes = get_all_processes();
for (int i = 0; i < MAX_PROCS; i++){
process_t *proc = &processes[i];
process_t *proc = get_all_processes();
while (proc){
if (proc->id != 0 && proc->state != STOPPED && (!procname || strcmp_case(procname,proc->name,true) == 0)){
print("Process [%i]: %s [pid = %i | status = %s]",i,(uintptr_t)proc->name,proc->id,(uintptr_t)parse_proc_state(proc->state));
print("Process %s [pid = %i | status = %s]",(uintptr_t)proc->name,proc->id,(uintptr_t)parse_proc_state(proc->state));
print("Stack: %x (%x). SP: %x",proc->stack, proc->stack_size, proc->sp);
print("Heap: %x (%x)",proc->heap, calc_heap(proc->heap_phys));
print("Heap: %x (%x)",proc->mm.mmap_bottom, calc_heap(proc->heap_phys));
print("Flags: %x", proc->spsr);
print("PC: %x",proc->pc);
}
proc = proc->process_next;
}
}

Expand All @@ -73,12 +74,11 @@ void draw_memory(char *name,int x, int y, int width, int full_height, int used,

string str = string_format("%s\n%x",(uintptr_t)name, used);
fb_draw_string(&ctx,str.data, stack_top.x, stack_top.y + height + 5, 2, system_theme.bg_color);
free_sized(str.data,str.mem_length);
string_free(str);
}

void draw_process_view(){
fb_clear(&ctx,system_theme.bg_color+0x112211);
process_t *processes = get_all_processes();
gpu_size screen_size = (gpu_size){ctx.width,ctx.height};
gpu_point screen_middle = {screen_size.width / 2, screen_size.height / 2};

Expand All @@ -89,26 +89,25 @@ void draw_process_view(){
if (ev.key == KEY_LEFT)
scroll_index = max(scroll_index - 1, 0);
if (ev.key == KEY_RIGHT)
scroll_index = min(scroll_index + 1,MAX_PROCS);
scroll_index++;
}

for (int i = 0; i < PROCS_PER_SCREEN; i++) {
int index = scroll_index;
int valid_count = 0;
uint16_t index = scroll_index+i;
uint16_t valid_count = 0;
process_t *proc = get_all_processes();

process_t *proc = NULL;
while (index < MAX_PROCS) {
proc = &processes[index];
while (proc) {
if (proc->id != 0 && proc->state != STOPPED) {
if (valid_count == i + scroll_index) {
if (valid_count == index) {
break;
}
valid_count++;
}
index++;
proc = proc->process_next;
}

if (proc == NULL || proc->id == 0 || valid_count < i || proc->state == STOPPED) break;
if (proc == NULL || proc->id == 0 || proc->state == STOPPED) break;

string name = string_from_literal((const char*)(uintptr_t)proc->name);
string state = string_from_literal(parse_proc_state(proc->state));
Expand All @@ -130,18 +129,18 @@ void draw_process_view(){

string pc = string_from_hex(proc->pc);
fb_draw_string(&ctx,pc.data, xo, pc_y, scale, system_theme.bg_color);
free_sized(pc.data, pc.mem_length);
string_free(pc);

draw_memory("Stack", xo, stack_y, stack_width, stack_height, proc->stack - proc->sp, proc->stack_size);
uint64_t heap = calc_heap(proc->heap_phys);
uint64_t heap_limit = ((heap + 0xFFF) & ~0xFFF);
draw_memory("Heap", xo + stack_width + 50, stack_y, stack_width, stack_height, heap, heap_limit);
draw_memory("Stack", xo, stack_y, stack_width, stack_height, proc->stack - proc->sp, proc->stack_size ? proc->stack_size : 1);
uint64_t heap = proc->mm.ttbr0 ? (proc->mm.rss_anon_pages * PAGE_SIZE) : calc_heap(proc->heap_phys);
uint64_t heap_limit = proc->mm.ttbr0 ? (uint64_t)(proc->mm.mmap_top - proc->mm.mmap_bottom) : ((heap + 0xFFF) & ~0xFFF);
draw_memory("Heap", xo + stack_width + 50, stack_y, stack_width, stack_height, heap, heap_limit ? heap_limit : PAGE_SIZE);

string flags = string_format("Flags: %x", proc->spsr);
fb_draw_string(&ctx, flags.data, xo, flags_y, scale, system_theme.bg_color);
free_sized(name.data, name.mem_length);
free_sized(state.data, state.mem_length);
free_sized(flags.data, flags.mem_length);
string_free(name);
string_free(state);
string_free(flags);

}
commit_draw_ctx(&ctx);
Expand Down
Loading
Loading