Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
0670465
[CONSOLE] fixed newline issue
Aug 3, 2025
f66bac7
[AUDIO] made sound shorter
Aug 3, 2025
3d6fd94
[CONSOLE] made continuous buffer for prints
Aug 3, 2025
cd6b1d2
[FS, MEM] Kernel always uses the same stack, fs has global fd_ids
Aug 3, 2025
46ad5e2
[CONSOLE] fixing console crash
Aug 3, 2025
212ded0
[AUDIO] disabling audio buzz
Aug 4, 2025
da829a9
[CONSOLE, WIP] re-enabling terminal by shortcut
Aug 4, 2025
204f6fc
[CONSOLE, WIP] showing latest logs in console (wrong offset)
Aug 4, 2025
355aa7b
[CONSOLE] refresh after newlines in put_string
Aug 4, 2025
77c98f1
[CONSOLE] created new instance of the console
Aug 4, 2025
65613cf
[GPU] removed unused font import from gpu
Aug 4, 2025
7101b7a
[CONSOLE] added input to terminal
Aug 4, 2025
94f1c46
[CONSOLE] fixed weird log buffer crash
Aug 4, 2025
2edc845
[CONSOLE] no I didn't :(
Aug 4, 2025
ae9d7cf
[CONSOLE] handling double keys (99% accuracy)
Aug 4, 2025
974357f
Merge branch 'main' into console
Aug 5, 2025
61a592e
[CONSOLE] fixed va_list alignment issue crash
Aug 5, 2025
35379d2
[CONSOLE] fixed alignment in putf
Aug 6, 2025
93f2c39
[CONSOLE] added cursor to console, separated input into terminal class
Aug 6, 2025
b94b2e8
[PROJ] fixed minor formatting
Aug 6, 2025
fd96c69
[CONSOLE] added backspace as a simple input
Aug 6, 2025
c43331b
Merge branch 'main' into console
Aug 7, 2025
09c785a
Merge branch 'main' into console
Aug 7, 2025
95c3841
Merge branch 'main' into console
Aug 8, 2025
72985f9
Merge branch 'console' of github.com:differrari/RedactedOS into console
Aug 8, 2025
98259c0
[INPUT] fixed keys
Aug 8, 2025
1f55ca4
[CONSOLE] removed ring buffer in console
Aug 8, 2025
565f7a1
[CONSOLE, TMP] added cat command (temporarily in terminal)
Aug 8, 2025
48be0b2
[FS] keeping track of file size
Aug 8, 2025
1f07562
[CONSOLE] added non-stantard text colors
Aug 8, 2025
f19d7d9
[CONSOLE] limiting color to 24 bit
Aug 8, 2025
045f223
[CONSOLE] removed unused function
Aug 8, 2025
e96711e
Merge branch 'main' into console
Aug 9, 2025
e634636
Merge branch 'main' into console
Aug 9, 2025
b17898c
merge main into console
Aug 9, 2025
0fc4df7
[STRING] parse integer
Aug 9, 2025
3a304f4
[PROJ] restoring linux-compatible rundebug script
Aug 9, 2025
cd9d764
[FS] introducting cursor to file descriptor
Aug 9, 2025
4b36908
[FS] removing some logs from modules
Aug 9, 2025
a85ed9e
[FS,FAIL] trying to write to console as file (seems like nested sysca…
Aug 9, 2025
9076d09
[CONSOLE, TMP] fixing printf issue by using the file functions outsid…
Aug 9, 2025
fe5bcda
[LINK] removed redundant kcoreprocesses section
Aug 9, 2025
b23834b
[PROC, CONSOLE] output file reading
Aug 9, 2025
693d899
[CONSOLE] implemented cat
Aug 10, 2025
f449598
[PROC] added arguments to processes (used by cat) and properly exitin…
Aug 10, 2025
5486788
[CAT] added usage and error messages to cat
Aug 10, 2025
8cb9e8a
[PROC] added exit codes
Aug 10, 2025
a702bc0
Use GCC dependency generation in Makefiles
codebrainz Aug 10, 2025
f33d27f
Use ARCH make variable in dump target
codebrainz Aug 10, 2025
939a999
Use building make variable RM (for `rm -f`)
codebrainz Aug 10, 2025
ff4bffd
Merge pull request #22 from codebrainz/make-deps
differrari Aug 10, 2025
25b9325
[CONSOLE] load commands from bin
Aug 10, 2025
e832de3
Split C and C++ compilers and flags
codebrainz Aug 10, 2025
4070d03
Implement "silent" Make rules by default
codebrainz Aug 10, 2025
af5c969
Use instead of repeating targets
codebrainz Aug 10, 2025
d66a325
Extract common variables into common.mk
codebrainz Aug 10, 2025
1e91708
Merge pull request #23 from codebrainz/make-cleanups
differrari Aug 10, 2025
16a98b8
[GRAPH] added explicit screen resolutions
Aug 10, 2025
045dcb1
Removing some hardcoded values
Aug 11, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dump
.cache/*
compile_commands.json
.clangd
*.d
39 changes: 12 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
ARCH ?= aarch64-none-elf
CC := $(ARCH)-gcc
LD := $(ARCH)-ld
AR := $(ARCH)-ar
OBJCOPY := $(ARCH)-objcopy

CFLAGS_BASE ?= -g -O0 -nostdlib -ffreestanding \
-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables \
-Wall -Wextra -Wno-unused-parameter -Wno-address-of-packed-member -mcpu=cortex-a72
CONLY_FLAGS_BASE ?= -std=c17
LDFLAGS_BASE ?=

LOAD_ADDR ?= 0x41000000
XHCI_CTX_SIZE ?= 32
QEMU ?= true
MODE ?= virt

export ARCH CC LD AR OBJCOPY CFLAGS_BASE CONLY_FLAGS_BASE LDFLAGS_BASE LOAD_ADDR XHCI_CTX_SIZE QEMU
include common.mk

OS := $(shell uname)
FS_DIRS := fs/redos/user
Expand All @@ -42,13 +25,13 @@ kernel:
$(MAKE) -C kernel LOAD_ADDR=$(LOAD_ADDR) XHCI_CTX_SIZE=$(XHCI_CTX_SIZE) QEMU=$(QEMU)

clean:
$(MAKE) -C shared clean
$(MAKE) -C user clean
$(MAKE) -C kernel clean
$(MAKE) -C shared $@
$(MAKE) -C user $@
$(MAKE) -C kernel $@
@echo "removing fs dirs"
rm -rf $(FS_DIRS)
$(RM) -r $(FS_DIRS)
@echo "removing images"
rm -f kernel.img kernel.elf disk.img dump
$(RM) kernel.img kernel.elf disk.img dump

raspi:
$(MAKE) LOAD_ADDR=0x80000 XHCI_CTX_SIZE=64 QEMU=true all
Expand All @@ -63,11 +46,11 @@ run:
debug:
$(MAKE) $(MODE)
./rundebug MODE=$(MODE) $(ARGS)

dump:
$(OBJCOPY) -O binary kernel.elf kernel.img
aarch64-none-elf-objdump -D kernel.elf > dump
$(ARCH)-objdump -D kernel.elf > dump

install:
$(MAKE) clean
$(MAKE) LOAD_ADDR=0x80000 XHCI_CTX_SIZE=64 QEMU=false all
Expand All @@ -89,4 +72,6 @@ help:
make debug build and run with debugger\n\
make dump disassemble kernel.elf\n\
make install create raspi kernel and mount it on a bootable partition\n\
make prepare-fs create directories for the filesystem\n\n"
make prepare-fs create directories for the filesystem\n\n"\
\n\
Use 'make V=1' for verbose build output.
34 changes: 34 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARCH ?= aarch64-none-elf
CC := $(ARCH)-gcc
CXX := $(ARCH)-g++
LD := $(ARCH)-ld
AR := $(ARCH)-ar
OBJCOPY := $(ARCH)-objcopy

COMMON_FLAGS ?= -ffreestanding -nostdlib -fno-exceptions -fno-unwind-tables \
-fno-asynchronous-unwind-tables -g -O0 -Wall -Wextra \
-Wno-unused-parameter -Wno-address-of-packed-member \
-mcpu=cortex-a72

CFLAGS_BASE ?= $(COMMON_FLAGS) -std=c17
CXXFLAGS_BASE ?= $(COMMON_FLAGS) -fno-rtti
LDFLAGS_BASE ?=

LOAD_ADDR ?= 0x41000000
XHCI_CTX_SIZE ?= 32
QEMU ?= true
MODE ?= virt

ifeq ($(V), 1)
VAR = $(AR)
VAS = $(CC)
VCC = $(CC)
VCXX = $(CXX)
VLD = $(LD)
else
VAR = @echo " [AR] $@" && $(AR)
VAS = @echo " [AS] $@" && $(CC)
VCC = @echo " [CC] $@" && $(CC)
VCXX = @echo " [CXX] $@" && $(CXX)
VLD = @echo " [LD] $@" && $(LD)
endif
27 changes: 19 additions & 8 deletions kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
#kernel
# toolchain (inherited from top-level)

CFLAGS := $(CFLAGS_BASE) -I. -I../shared -I../user -DXHCI_CTX_SIZE=$(XHCI_CTX_SIZE)
include ../common.mk

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

ifeq ($(QEMU),true)
CFLAGS += -DQEMU
CPPFLAGS += -DQEMU
endif

LDFLAGS := $(LDFLAGS_BASE) -T $(shell ls *.ld) --defsym=LOAD_ADDR=$(LOAD_ADDR)
CFLAGS := $(CFLAGS_BASE) $(CPPFLAGS)
CXXFLAGS := $(CXXFLAGS_BASE) $(CPPFLAGS)
LDFLAGS := $(LDFLAGS_BASE) -T $(shell ls *.ld) --defsym=LOAD_ADDR=$(LOAD_ADDR)

CLEAN_OBJS := $(shell find . -name '*.o')
CLEAN_DEPS := $(shell find . -name '*.d')
C_SRC := $(shell find . -name '*.c')
ASM_SRC := $(shell find . -name '*.S')
CPP_SRC := $(shell find . -name '*.cpp')
OBJ := $(C_SRC:.c=.o) $(ASM_SRC:.S=.o) $(CPP_SRC:.cpp=.o)
OBJL := $(filter-out ./boot.o,$(OBJ))
DEP := $(C_SRC:.c=.d) $(ASM_SRC:.S=.d) $(CPP_SRC:.cpp=.d)

ELF := ../kernel.elf
TARGET := ../kernel.img

all: $(TARGET)

$(TARGET): ../shared/libshared.a $(OBJ)
$(LD) $(LDFLAGS) -o $(ELF) $(OBJL) ../shared/libshared.a
$(VLD) $(LDFLAGS) -o $(ELF) $(OBJL) ../shared/libshared.a
$(OBJCOPY) -O binary $(ELF) $@

%.o: %.S
$(CC) $(CFLAGS) -c $< -o $@
$(VAS) $(CFLAGS) -c $< -o $@

%.o: %.c
$(CC) $(CFLAGS) $(CONLY_FLAGS_BASE) -c $< -o $@
$(VCC) $(CFLAGS) -c -MMD -MP $< -o $@

%.o: %.cpp
$(CC) $(CFLAGS) -fno-rtti -c $< -o $@
$(VCXX) $(CXXFLAGS) -c -MMD -MP $< -o $@

clean:
rm -f $(CLEAN_OBJS) $(ELF) $(TARGET)
$(RM) $(CLEAN_OBJS) $(CLEAN_DEPS) $(ELF) $(TARGET)

-include $(DEP)
5 changes: 3 additions & 2 deletions kernel/audio/virtio_audio_pci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ bool VirtioAudioDriver::config_streams(uint32_t streams){
kprintf("[VIRTIO_AUDIO error] Failed to configure stream %i",stream);
}

#if false
if (stream_info[stream].direction == VIRTIO_SND_D_OUTPUT){
kprintf("Playing from stream %i",stream);
select_queue(&audio_dev, TRANSMIT_QUEUE);

for (uint16_t i = 0; i < 100; i++){
for (uint16_t i = 0; i < 10; i++){
size_t total_size = sizeof(virtio_snd_pcm_status) + sizeof(virtio_snd_pcm_xfer) + TOTAL_BUF_SIZE;
uintptr_t full_buffer = (uintptr_t)kalloc(audio_dev.memory_page, total_size, ALIGN_4KB, true, true);
virtio_snd_pcm_xfer *header = (virtio_snd_pcm_xfer*)full_buffer;
Expand All @@ -218,8 +219,8 @@ bool VirtioAudioDriver::config_streams(uint32_t streams){

select_queue(&audio_dev, CONTROL_QUEUE);
}
#endif
}

return true;
}

Expand Down
52 changes: 52 additions & 0 deletions kernel/bin/bin_mod.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "bin_mod.h"
#include "cat.h"
#include "kernel_processes/kprocess_loader.h"

#define N_ARR(arr) (sizeof(arr)/sizeof((arr)[0]))

bool init_bin(){
return true;
}

typedef struct open_bin_ref {
char *name;
int (*func)(int argc, char* argv[]);
} open_bin_ref;

open_bin_ref available_cmds[] = {
{ "cat", run_cat }
};

process_t* exec(const char* prog_name, int argc, const char* argv[]){
for (uint32_t i = 0; i < N_ARR(available_cmds); i++){
if (strcmp(available_cmds[i].name, prog_name, false) == 0){
return create_kernel_process(available_cmds[i].name, available_cmds[i].func, argc, argv);
}
}
return 0;
}

FS_RESULT open_bin(){
return FS_RESULT_DRIVER_ERROR;
}

size_t read_bin(){
return 0;
}

sizedptr list_bin(const char *path){
return (sizedptr){0,0};
}

driver_module bin_module = (driver_module){
.name = "bin",
.mount = "/bin",
.version = VERSION_NUM(0, 1, 0, 1),
.init = init_bin,
.fini = 0,
.open = 0,
.read = read_bin,
.write = 0,
.seek = 0,
.readdir = list_bin,
};
16 changes: 16 additions & 0 deletions kernel/bin/bin_mod.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "dev/driver_base.h"
#include "process/process.h"

#ifdef __cplusplus
extern "C" {
#endif

process_t* exec(const char* prog_name, int argc, const char* argv[]);

#ifdef __cplusplus
}
#endif

extern driver_module bin_module;
36 changes: 36 additions & 0 deletions kernel/bin/cat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "cat.h"
#include "kernel_processes/kprocess_loader.h"
#include "filesystem/filesystem.h"
#include "process/scheduler.h"
#include "syscalls/syscalls.h"
#include "console/kio.h"

int run_cat(int argc, char* argv[]){
uint16_t pid = get_current_proc_pid();
string s = string_format("/proc/%i/out",pid);
file fd2;
open_file(s.data, &fd2);
if (argc != 2){
string err_msg = string_l("Usage cat <path> <size>");
write_file(&fd2, err_msg.data, err_msg.length);
free(err_msg.data, err_msg.mem_length);
return 2;
}
const char* path = argv[0];
size_t size = parse_int_u64(argv[1], UINT32_MAX);
file fd;
open_file(path, &fd);
if (fd.size == 0){
string err_msg = string_format("Couldn't find file %s", argv[0]);
write_file(&fd2, err_msg.data, err_msg.length);
free(err_msg.data, err_msg.mem_length);
return 1;
}
if (size == 0) size = fd.size;
char* buf = (char*)malloc(size);
read_file(&fd, buf, size);

write_file(&fd2, buf, size);
free(s.data, s.mem_length);
return 0;
}
13 changes: 13 additions & 0 deletions kernel/bin/cat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "process/process.h"

#ifdef __cplusplus
extern "C" {
#endif

int run_cat(int argc, char* argv[]);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion kernel/boot.S
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ el2_entry:
eret

stack_setup:
ldr x1, =stack_top
ldr x1, =ksp
mov sp, x1

mov x29, xzr
Expand Down
36 changes: 36 additions & 0 deletions kernel/console/kconsole/console.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "kconsole.hpp"
#include "kconsole.h"
#include "graph/graphics.h"
#include "input/input_dispatch.h"
#include "kernel_processes/windows/windows.h"
#include "terminal.hpp"

KernelConsole kconsole;

Expand All @@ -15,4 +18,37 @@ extern "C" void kconsole_puts(const char *s) {

extern "C" void kconsole_clear() {
kconsole.clear();
}

extern "C" int toggle_visual(int argc, char* argv[]){
keypress kp = {
.modifier = KEY_MOD_LALT,
.rsvd = 0,
.keys = {0x13},
};
uint16_t shortcut = sys_subscribe_shortcut_current(kp);
bool active = false;
Terminal *terminal = new Terminal();
terminal->initialize();
while (1){
if (sys_shortcut_triggered_current(shortcut)){
active = !active;
if (active){
pause_window_draw();
sys_focus_current();
terminal->refresh();
} else {
resume_window_draw();
terminal->clear();
}
}
if (active){
terminal->update();
}
}
return 1;
}

process_t* start_terminal(){
return create_kernel_process("terminal",toggle_visual, 0, 0);
}
Loading