Небольшие исправления

This commit is contained in:
Aren Elchinyan 2024-01-22 21:46:36 +03:00
parent df965c2218
commit 883c977b28
8 changed files with 15 additions and 18 deletions

View File

@ -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;

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_BUILD 983
#define VERSION_BUILD 984

View File

@ -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( ) {

View File

@ -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( ); }
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;

1
run.sh
View File

@ -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