diff --git a/include/sys.h b/include/sys.h index 3dee2bf..b2dc9d9 100644 --- a/include/sys.h +++ b/include/sys.h @@ -42,9 +42,11 @@ typedef struct { } uid_t; typedef struct { - uint16_t year; + uint8_t year; uint8_t month; uint8_t day; + uint8_t hours; + uint8_t minutes; uint8_t second; } time_t; diff --git a/include/version.h b/include/version.h index 20594b2..58a9b0b 100644 --- a/include/version.h +++ b/include/version.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 1 -#define VERSION_BUILD 983 +#define VERSION_BUILD 984 diff --git a/kernel/cpu/task.c b/kernel/cpu/task.c index c194f06..eb98fdf 100644 --- a/kernel/cpu/task.c +++ b/kernel/cpu/task.c @@ -17,12 +17,12 @@ static task_t *kernel_task = NULL; task_t *current_task = NULL; uint32_t *test_buf = NULL; extern uint64_t full_init; +uint64_t task_f_init = 0; lock_t task_lock; void task_switch_asm(task_t *, task_t *); -void task_switch(struct frame *state) { - UNUSED(state); +void task_switch( ) { asm volatile("cli"); task_t *next = current_task->next; @@ -80,7 +80,7 @@ uint64_t task_new_thread(void (*func)(void *)) { void dummy( ) { LOG("\t\tПривет! Я поток: %u\n", current_task->id); - for (;;) { asm volatile("hlt"); } + for (;;) { task_switch( ); } } void task_init( ) { diff --git a/kernel/lock.c b/kernel/lock.c index dc18768..2156f0b 100644 --- a/kernel/lock.c +++ b/kernel/lock.c @@ -26,12 +26,14 @@ void lock_acquire(lock_t lock) { for (;;) { if (lock_swap(lock)) { break; } count++; - if (count > 1000000) { + if (count > 10000) { LOG("%s:%u блокировка зависла", lock.func, lock.line); assert(0); } asm volatile("pause"); + + if (task_f_init) { task_switch( ); } } } diff --git a/kernel/sys.c b/kernel/sys.c index 274b0a4..2ac029c 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -57,10 +57,6 @@ static int sys_delete_thread(uint64_t thread_id) { return thread_id; } -static time_t sys_get_time( ) { - return (time_t){ .year = 2023, .month = 10, .day = 31, .second = 1 }; -} - env_t *sys_install(env_t *module) { module->fb_printf = &log_printf; module->alloc_framebuffer = &sys_alloc_framebuffer; @@ -74,7 +70,7 @@ env_t *sys_install(env_t *module) { module->mod_list_get = &mod_list_get; module->new_thread = &sys_new_thread; module->delete_thread = &sys_delete_thread; - module->get_time = &sys_get_time; + module->get_time = &rtc_get_time; return module; } diff --git a/modlib/lib/build.sh b/modlib/lib/build.sh index 1fc2c67..d87c9b0 100755 --- a/modlib/lib/build.sh +++ b/modlib/lib/build.sh @@ -1,14 +1,8 @@ #/bin/sh - CC="gcc" AR="ar" ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -static -nostdlib " -if [ -d "../../sdk" ]; then - CC="../../sdk/bin/x86_64-elf-gcc" - AR="../../sdk/bin/x86_64-elf-ar" -fi - mkdir -p bin $CC $ARCH_FLAGS -I../../modlib -finput-charset=UTF-8 -fexec-charset=cp1251 -c system.c -o bin/system.o diff --git a/modlib/types.h b/modlib/types.h index 03d06c4..2e1ec54 100644 --- a/modlib/types.h +++ b/modlib/types.h @@ -56,9 +56,11 @@ typedef struct { } uid_t; typedef struct { - uint16_t year; + uint8_t year; uint8_t month; uint8_t day; + uint8_t hours; + uint8_t minutes; uint8_t second; } time_t; diff --git a/run.sh b/run.sh index dbeae54..46bc877 100755 --- a/run.sh +++ b/run.sh @@ -3,6 +3,7 @@ qemu-system-x86_64 -name "БМПОС" -cpu max -m 1G -smp 1 \ -serial file:serial.log \ -drive file=bmosp.hdd,if=none,id=sata_drive -device ahci \ -device virtio-blk-pci,drive=sata_drive --no-reboot \ + -rtc base=localtime,clock=host \ -net nic,model=pcnet # AMD PCnet Am79C970 #qemu-system-x86_64 -name "БМПОС" -cpu max -m 1G -smp 1 -hda bmosp.hdd --no-reboot #qemu-system-x86_64 -name "БМПОС" -cpu max -m 1G -smp 1 -cdrom bmosp.iso -boot d --no-reboot