summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpplover0 <osdev555@yandex.com>2025-12-23 15:52:49 +0300
committercpplover0 <osdev555@yandex.com>2025-12-23 15:52:49 +0300
commit0443bf3c06c75fcbbd4c86f5f0c06393f9fa2012 (patch)
tree2740ce1c6b711a0327841df4aa2d7baf6143dfdb
parent04f0a1ff9942f796088ccb85578236e8ea5f7eff (diff)
i dont remember what i did
-rw-r--r--build-pkg.sh3
-rw-r--r--kernel/src/arch/x86_64/interrupts/panic.cpp15
-rw-r--r--kernel/src/arch/x86_64/scheduling.cpp15
-rw-r--r--kernel/src/arch/x86_64/syscalls/file.cpp4
-rw-r--r--kernel/src/arch/x86_64/syscalls/process.cpp4
-rw-r--r--kernel/src/arch/x86_64/syscalls/syscalls.cpp2
-rw-r--r--kernel/src/generic/mm/pmm.cpp3
-rw-r--r--kernel/src/generic/vfs/tmpfs.cpp7
-rw-r--r--readme.md5
-rw-r--r--strip-all.sh3
-rw-r--r--tools/initbase/etc/X11/i3rc1
-rw-r--r--tools/initbase/etc/X11/twmrc6
-rw-r--r--tools/initbase/etc/X11/xinitrc3
-rw-r--r--tools/initbase/etc/locale.conf1
-rw-r--r--tools/pkg/3/pthread_test/main.c133
-rw-r--r--tools/pkg/5/orangex/main.sh35
-rw-r--r--tools/toolchain-build.sh2
17 files changed, 93 insertions, 149 deletions
diff --git a/build-pkg.sh b/build-pkg.sh
index 211c1a0..8b43a5d 100644
--- a/build-pkg.sh
+++ b/build-pkg.sh
@@ -7,7 +7,8 @@ export PKG_CONFIG_SYSROOT_DIR="$sysroot_path"
export PKG_CONFIG_PATH="$sysroot_path/usr/lib/pkgconfig:$sysroot_path/usr/share/pkgconfig:$sysroot_path/usr/local/lib/pkgconfig:$sysroot_path/usr/local/share/pkgconfig:$HOME/opt/cross/orange/lib/pkgconfig:$HOME/opt/cross/orange/share/pkgconfig"
INITRDDIR=""$(realpath initrd)""
-export CFLAGS="-fPIC -Wno-error -O2 -Wno-incompatible-pointer-types"
+export CFLAGS="-fPIC -Wno-error -O0 -Wno-incompatible-pointer-types -fno-omit-frame-pointer -ggdb3 -fno-inline-functions-called-once -fno-optimize-sibling-calls -fno-omit-frame-pointer"
+export CXXFLAGS="$CFLAGS"
cd tools/pkg/$1
sh pkg.sh "$INITRDDIR"
diff --git a/kernel/src/arch/x86_64/interrupts/panic.cpp b/kernel/src/arch/x86_64/interrupts/panic.cpp
index 2e1acae..4d5f79e 100644
--- a/kernel/src/arch/x86_64/interrupts/panic.cpp
+++ b/kernel/src/arch/x86_64/interrupts/panic.cpp
@@ -33,7 +33,7 @@ void panic(int_frame_t* ctx, const char* msg) {
}
arch::x86_64::process_t* proc = arch::x86_64::cpu::data()->temp.proc;
- if(proc && 0) {
+ if(proc && 1) {
uint64_t cr2;
asm volatile("mov %%cr2, %0" : "=r"(cr2) : : "memory");
@@ -90,7 +90,7 @@ void panic(int_frame_t* ctx, const char* msg) {
// }
// }
- Log::SerialDisplay(LEVEL_MESSAGE_FAIL,"process %d fired cpu exception with vec %d, rip 0x%p (offset 0x%p), cr2 0x%p, error code 0x%p, lastsys %d, rdx 0x%p\n",proc->id,ctx->vec,ctx->rip,ctx->rip - 0x41400000,cr2,ctx->err_code,proc->sys,ctx->rdx);
+ Log::SerialDisplay(LEVEL_MESSAGE_FAIL,"process %d fired cpu exception with vec %d, rip 0x%p (offset 0x%p), cr2 0x%p, error code 0x%p, lastsys %d, rdx 0x%p rbp 0x%p\n",proc->id,ctx->vec,ctx->rip,ctx->rip - 0x41400000,cr2,ctx->err_code,proc->sys,ctx->rdx,ctx->rbp);
vmm_obj_t* current = (vmm_obj_t*)proc->vmm_start;
@@ -105,6 +105,17 @@ void panic(int_frame_t* ctx, const char* msg) {
}
+ stackframe_t* rbp = (stackframe_t*)ctx->rbp;
+
+ memory::paging::enablepaging(ctx->cr3);
+ Log::SerialDisplay(LEVEL_MESSAGE_INFO,"[0] - 0x%016llX (current rip)\n",ctx->rip);
+ for (int i = 1; i < 25 && rbp; ++i) {
+ std::uint64_t ret_addr = rbp->rip;
+ Log::SerialDisplay(LEVEL_MESSAGE_INFO,"[%d] - 0x%016llX\n", i, ret_addr);
+ rbp = (stackframe_t*)rbp->rbp;
+ }
+ memory::paging::enablekernel();
+
arch::x86_64::scheduling::kill(proc);
schedulingSchedule(0);
}
diff --git a/kernel/src/arch/x86_64/scheduling.cpp b/kernel/src/arch/x86_64/scheduling.cpp
index f9b38b8..791a97b 100644
--- a/kernel/src/arch/x86_64/scheduling.cpp
+++ b/kernel/src/arch/x86_64/scheduling.cpp
@@ -410,14 +410,8 @@ void arch::x86_64::scheduling::futexwake(process_t* proc, int* lock) {
futex_lock.lock();
while(proc0) {
if((proc0->parent_id == proc->id || proc->parent_id == proc0->id)) {
- if(!proc0->futex) {
- proc0->futex = (std::uint64_t)lock; // now when proc doing wait() it can check and just ignore it
- } else {
- proc0->futex = 0;
- proc0->futex_lock.unlock();
- }
-
- //DEBUG(proc->is_debug,"Process which we can wakeup is %d",proc0->id);
+ proc0->futex = 0;
+ proc0->futex_lock.unlock();
}
proc0 = proc0->next;
}
@@ -428,11 +422,10 @@ void arch::x86_64::scheduling::futexwait(process_t* proc, int* lock, int val, in
futex_lock.lock();
int lock_val = *lock;
- if(lock_val == val && proc->futex == 0) {
+ if(lock_val == val) {
proc->futex_lock.lock();
proc->futex = (std::uint64_t)original_lock;
- } else if(proc->futex == (std::uint64_t)lock)
- proc->futex = 0;
+ }
futex_lock.unlock();
}
diff --git a/kernel/src/arch/x86_64/syscalls/file.cpp b/kernel/src/arch/x86_64/syscalls/file.cpp
index a25bf61..c1a1500 100644
--- a/kernel/src/arch/x86_64/syscalls/file.cpp
+++ b/kernel/src/arch/x86_64/syscalls/file.cpp
@@ -48,7 +48,7 @@ syscall_ret_t sys_openat(int dirfd, const char* path, int flags, int_frame_t* ct
memset(result,0,2048);
vfs::resolve_path(kpath,first_path,result,1,0);
- //DEBUG(1,"Trying to open %s from proc %d",result,proc->id);
+ DEBUG(0,"Trying to open %s from proc %d",result,proc->id);
if(result[0] == '\0') {
result[0] = '/';
@@ -245,6 +245,8 @@ syscall_ret_t sys_close(int fd) {
else if(fd < 3 && !fd_s)
return {0,0,0}; // ignoring
+ DEBUG(0,"Closing %s\n",fd_s->path);
+
if(fd_s->can_be_closed)
return {0,EBADF,0};
diff --git a/kernel/src/arch/x86_64/syscalls/process.cpp b/kernel/src/arch/x86_64/syscalls/process.cpp
index 016398d..d5c638b 100644
--- a/kernel/src/arch/x86_64/syscalls/process.cpp
+++ b/kernel/src/arch/x86_64/syscalls/process.cpp
@@ -42,7 +42,7 @@ syscall_ret_t sys_libc_log(const char* msg) {
char buffer[2048];
memset(buffer,0,2048);
copy_in_userspace_string(proc,buffer,(void*)msg,2048);
- DEBUG(0,"%s from proc %d",buffer,proc->id);
+ DEBUG(proc->is_debug,"%s from proc %d",buffer,proc->id);
return {0,0,0};
}
@@ -600,6 +600,8 @@ syscall_ret_t sys_clone(std::uint64_t stack, std::uint64_t rip, int c, int_frame
new_proc->ctx.rax = 0;
new_proc->ctx.rdx = 0;
+
+ //new_proc->fs_base = proc->fs_base;
new_proc->ctx.rsp = stack;
new_proc->ctx.rip = rip;
diff --git a/kernel/src/arch/x86_64/syscalls/syscalls.cpp b/kernel/src/arch/x86_64/syscalls/syscalls.cpp
index 398c9d4..aba44b8 100644
--- a/kernel/src/arch/x86_64/syscalls/syscalls.cpp
+++ b/kernel/src/arch/x86_64/syscalls/syscalls.cpp
@@ -105,7 +105,7 @@ extern "C" void syscall_handler_c(int_frame_t* ctx) {
arch::x86_64::cpu::data()->last_sys = ctx->rax;
- DEBUG(0,"sys %d from %d",ctx->rax,proc->id);
+ DEBUG(0,"sys %d from %d rip 0x%p",ctx->rax,proc->id,ctx->rip);
syscall_ret_t (*sys)(std::uint64_t D, std::uint64_t S, std::uint64_t d, int_frame_t* frame) = (syscall_ret_t (*)(std::uint64_t, std::uint64_t, std::uint64_t, int_frame_t*))item->syscall_func;
diff --git a/kernel/src/generic/mm/pmm.cpp b/kernel/src/generic/mm/pmm.cpp
index eeb072c..ada77fd 100644
--- a/kernel/src/generic/mm/pmm.cpp
+++ b/kernel/src/generic/mm/pmm.cpp
@@ -346,7 +346,10 @@ std::int64_t memory::freelist::alloc() {
}
}
std::uint64_t freelist_mem = freelist_page;
+
freelist_page = *((std::uint64_t*)Other::toVirt(freelist_mem));
+
+ memset(Other::toVirt(freelist_mem),0,4096);
return freelist_mem;
}
diff --git a/kernel/src/generic/vfs/tmpfs.cpp b/kernel/src/generic/vfs/tmpfs.cpp
index 48fd087..aec20e9 100644
--- a/kernel/src/generic/vfs/tmpfs.cpp
+++ b/kernel/src/generic/vfs/tmpfs.cpp
@@ -311,6 +311,13 @@ again:
}
vfs::tmpfs_node_t* next = (vfs::tmpfs_node_t*)(((std::uint64_t*)node->content)[fd->offset]);
+
+ if(next == 0) { // null pointer fix
+ out->d_reclen = 0;
+ memset(out->d_name,0,sizeof(out->d_name));
+ return 0;
+ }
+
memset(out->d_name,0,sizeof(out->d_name));
memcpy(out->d_name,__tmpfs__find_name(next->name),strlen(__tmpfs__find_name(next->name)));
out->d_reclen = sizeof(vfs::dirent_t);
diff --git a/readme.md b/readme.md
index 8e298cb..d24a8dd 100644
--- a/readme.md
+++ b/readme.md
@@ -50,6 +50,11 @@ Dependencies
cmake meson (1.4.2) ninja gcc (13.3.0) libgmp3-dev libmpfr-dev libmpc-dev libglib2.0-dev-bin python3.13 python3.13-dev python3.13-venv python3.13-distutils gettext gperf rsync flex bison make nasm bash
```
+Host python dependencies
+```
+mako pyyaml
+```
+
Also if you have custom python version you need to pass environment variable because python requires newest version
```
BUILDPYTHON=--with-build-python=python3.13 sh tar-initrd.sh
diff --git a/strip-all.sh b/strip-all.sh
index 912a437..9266428 100644
--- a/strip-all.sh
+++ b/strip-all.sh
@@ -17,4 +17,5 @@ if [ ! "$(which x86_64-orange-mlibc-gcc)" ]; then
exit 1
fi
-find initrd/usr/lib initrd/usr/bin -type f -print0 | xargs -0 -I{} x86_64-orange-mlibc-strip --strip-all {} \ No newline at end of file
+find initrd/usr/lib initrd/usr/bin -type f -print0 | xargs -0 -I{} x86_64-orange-mlibc-strip --strip-all {}
+sh build-pkg.sh 0/mlibc \ No newline at end of file
diff --git a/tools/initbase/etc/X11/i3rc b/tools/initbase/etc/X11/i3rc
new file mode 100644
index 0000000..705250c
--- /dev/null
+++ b/tools/initbase/etc/X11/i3rc
@@ -0,0 +1 @@
+exec i3 \ No newline at end of file
diff --git a/tools/initbase/etc/X11/twmrc b/tools/initbase/etc/X11/twmrc
new file mode 100644
index 0000000..268e9c3
--- /dev/null
+++ b/tools/initbase/etc/X11/twmrc
@@ -0,0 +1,6 @@
+
+xwallpaper --zoom /etc/twmbg.png &
+st &
+
+twm -f /root/.twmrc &
+exit \ No newline at end of file
diff --git a/tools/initbase/etc/X11/xinitrc b/tools/initbase/etc/X11/xinitrc
deleted file mode 100644
index 8a6646a..0000000
--- a/tools/initbase/etc/X11/xinitrc
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-i3 \ No newline at end of file
diff --git a/tools/initbase/etc/locale.conf b/tools/initbase/etc/locale.conf
new file mode 100644
index 0000000..a002108
--- /dev/null
+++ b/tools/initbase/etc/locale.conf
@@ -0,0 +1 @@
+LANG=en_US \ No newline at end of file
diff --git a/tools/pkg/3/pthread_test/main.c b/tools/pkg/3/pthread_test/main.c
index 3b01ce3..12632f3 100644
--- a/tools/pkg/3/pthread_test/main.c
+++ b/tools/pkg/3/pthread_test/main.c
@@ -1,131 +1,14 @@
#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <poll.h>
-
-#define SOCKET_PATH "/tmp/test_unix_socket"
-#define THREADS 10
-
-void* client_thread(void* arg) {
- (void)arg;
- int sock = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sock < 0) {
- perror("client socket");
- return NULL;
- }
-
- struct sockaddr_un serv_addr;
- memset(&serv_addr, 0, sizeof(serv_addr));
- serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, SOCKET_PATH, sizeof(serv_addr.sun_path) - 1);
-
- while (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
- usleep(100000);
- }
-
- int one = 1;
- while (1) {
- ssize_t n = write(sock, &one, sizeof(one));
- if (n != sizeof(one)) {
- perror("client write");
- break;
- }
-
- }
-
- close(sock);
- return NULL;
-}
+#include <locale.h>
+#include <langinfo.h>
int main() {
+ // Устанавливаем локаль по умолчанию
+ setlocale(LC_ALL, "");
- unlink(SOCKET_PATH);
-
- int listen_fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (listen_fd < 0) {
- perror("socket");
- exit(1);
- }
-
- struct sockaddr_un addr;
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, SOCKET_PATH, sizeof(addr.sun_path) - 1);
-
- if (bind(listen_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
- perror("bind");
- exit(1);
- }
-
- if (listen(listen_fd, THREADS) < 0) {
- perror("listen");
- exit(1);
- }
-
- pthread_t clients[THREADS];
- for (int i = 0; i < THREADS; i++) {
- if (pthread_create(&clients[i], NULL, client_thread, NULL) != 0) {
- perror("pthread_create");
- exit(1);
- }
- }
-
- int client_fds[THREADS];
- for (int i = 0; i < THREADS; i++) {
- client_fds[i] = accept(listen_fd, NULL, NULL);
- if (client_fds[i] < 0) {
- perror("accept");
- exit(1);
- }
- printf("Accepted client %d\n", i);
- }
-
- struct pollfd pfds[THREADS];
- for (int i = 0; i < THREADS; i++) {
- pfds[i].fd = client_fds[i];
- pfds[i].events = POLLIN;
- }
-
- while (1) {
- int ret = poll(pfds, THREADS, -1);
- if (ret < 0) {
- perror("poll");
- break;
- }
-
- for (int i = 0; i < THREADS; i++) {
- if (pfds[i].revents & POLLIN) {
- int val;
- ssize_t n = read(pfds[i].fd, &val, sizeof(val));
- if (n == 0) {
- printf("Client %d disconnected\n", i);
- close(pfds[i].fd);
- pfds[i].fd = -1;
- } else if (n == sizeof(val)) {
- if (val != 1) {
- printf("bug got %d from client %d\n", val, i);
- } else {
- printf("good value from client %d\n",i);
- }
- } else {
- perror("read");
- }
- }
- }
- }
-
- for (int i = 0; i < THREADS; i++) {
- if (pfds[i].fd != -1)
- close(pfds[i].fd);
- }
- close(listen_fd);
- unlink(SOCKET_PATH);
+ // Пытаемся получить информацию о правилах сортировки (COLLATION)
+ // В POSIX это не предусмотрено напрямую, так что используем другие значения
+ printf("Hi: %s\n", nl_langinfo(CODESET));
return 0;
-}
+} \ No newline at end of file
diff --git a/tools/pkg/5/orangex/main.sh b/tools/pkg/5/orangex/main.sh
index 3adaa85..ba58124 100644
--- a/tools/pkg/5/orangex/main.sh
+++ b/tools/pkg/5/orangex/main.sh
@@ -1,4 +1,33 @@
-stty -echo
-xinit /etc/X11/xinitrc > /dev/null 2> /dev/null
-stty +echo \ No newline at end of file
+while true; do
+
+ stty echo
+
+ echo "Select program to start:"
+ echo "1) i3wm"
+ echo "2) twm"
+ echo "3) bash"
+ read -p "Select number: " choice
+
+ stty -echo
+
+ case "$choice" in
+ 1)
+ xinit /etc/X11/i3rc > /dev/null 2> /dev/null
+ ;;
+ 2)
+ xinit /etc/X11/twmrc > /dev/null 2> /dev/null
+ ;;
+ 3)
+ stty echo
+ bash
+ ;;
+ *)
+ echo "Wrong choice !"
+ echo ""
+ ;;
+ esac
+
+ stty echo
+
+done
diff --git a/tools/toolchain-build.sh b/tools/toolchain-build.sh
index 3345e13..9ed855e 100644
--- a/tools/toolchain-build.sh
+++ b/tools/toolchain-build.sh
@@ -67,6 +67,8 @@ automake
cd ../../gcc-15.1.0/libstdc++-v3
autoconf
autotools_recursive_regen
+cd ../libgcc
+autotools_recursive_regen
cd ../../
cd gcc-15.1.0