Skip to content

Commit

Permalink
Небольшие исправления
Browse files Browse the repository at this point in the history
  • Loading branch information
0Nera committed Sep 16, 2024
1 parent 5858814 commit af1d9d8
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void arch_init( );
void task_init( );
void task_after_init( );
void task_switch( );
uint64_t task_new_thread(void (*func)(void *), char *name);
uint64_t task_new_thread(void (*func)(void *), char *name, void *arg);
void task_del_current( );
void task_del(uint64_t id);
void cpu_init( );
Expand Down
1 change: 1 addition & 0 deletions include/tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void tool_memcpy(void *dest, void *src, uint64_t n);
void *tool_memset(void *ptr, uint8_t n, uint64_t size);
uint64_t tool_strlen(const char *str);
void tool_strcpy(char *dest, char *src);
int tool_strcmp(const char *s1, const char *s2);
uint64_t tool_starts_with(const char *str, const char *prefix);
uint64_t tool_str_contains(const char *str, const char *substr);
void tool_format(void (*putc)(char c), const char *format_string, va_list args);
Expand Down
2 changes: 1 addition & 1 deletion include/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_BUILD 96
#define VERSION_BUILD 107
3 changes: 2 additions & 1 deletion kernel/cpu/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void task_switch( ) {
task_switch_asm(last, next);
}

uint64_t task_new_thread(void (*func)(void *), char *name) {
uint64_t task_new_thread(void (*func)(void *), char *name, void *arg) {
LOG("Выделение потока\n");

uint64_t cr3;
Expand All @@ -64,6 +64,7 @@ uint64_t task_new_thread(void (*func)(void *), char *name) {
stack[--stack_top] = (uint64_t)0;

new_task->rsp = (uint64_t)new_task->stack + sizeof(uint64_t) * stack_top;
new_task->rdi = (uint64_t)arg;
new_task->cpu_time = 500;
new_task->cpu_time_expired = new_task->cpu_time;
new_task->id = next_thread_id++;
Expand Down
10 changes: 5 additions & 5 deletions kernel/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <mod.h>
#include <stdint.h>

#include <tool.h>

elf64_header_t *elf64_get_header(void *data) {
return (elf64_header_t *)(data);
Expand Down Expand Up @@ -53,7 +53,7 @@ unsigned long elf64_hash(unsigned char *name) {
while (*name) {
h = (h << 4) + *name++;
// Проверка на overflow
if (g = h & 0xf0000000) h ^= g >> 24;
if (g = (h & 0xf0000000)) h ^= g >> 24;
// Ограничение хэша
h &= 0xffffffff;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ void import_test( ) {
}

void *elf_parse(elf64_header_t *head) {
elf64_section_header_t *symtab = NULL;
// elf64_section_header_t *symtab = NULL;

if (head->e_ident[0] != ELFMAG0 || head->e_ident[1] != ELFMAG1 || head->e_ident[2] != ELFMAG2 ||
head->e_ident[3] != ELFMAG3) {
Expand Down Expand Up @@ -123,8 +123,8 @@ void *elf_parse(elf64_header_t *head) {
// log_printf("%u\n", tool_strcmp(string_table + sym->st_name, "import_test"));
if (tool_strcmp(string_table + sym->st_name, "import_test") == 0) {
log_printf("0x%x\n", head + sym->st_value);
void (*imp)( ) = (void *)head + sym->st_value;
// imp = &import_test;
// void (*imp)( ) = (void *)head + sym->st_value;
// imp = &import_test;
}
break;
case STT_FUNC: log_printf("объект кода\n"); break;
Expand Down
1 change: 1 addition & 0 deletions modlib/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ typedef struct {
uint64_t (*new_thread)(void (*func)(void *), char *name);
void (*delete_thread)( );
time_t (*get_time)( );
module_info_t *ret;
} __attribute__((packed)) env_t;

#endif // types.h
4 changes: 2 additions & 2 deletions scripts/pbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def create_hdd(IMAGE_NAME):
os.system(f"sgdisk {IMAGE_NAME}.hdd -n 1:2048 -t 1:ef00")
os.system(f"./limine/limine bios-install {IMAGE_NAME}.hdd")
os.system(f"mformat -i {IMAGE_NAME}.hdd@@1M")
os.system(f"mmd -i {IMAGE_NAME}.hdd@@1M ::/mod ::/EFI ::/EFI/BOOT")
os.system(f"mmd -i {IMAGE_NAME}.hdd@@1M ::/EFI ::/EFI/BOOT")
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M kernel.elf configs/limine.cfg limine/limine-bios.sys ::/")
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M modules/bin/* ::/mod")
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M iso_root/mod/ ::/")
os.system(f"mcopy -i {IMAGE_NAME}.hdd@@1M limine/BOOTX64.EFI limine/BOOTIA32.EFI ::/EFI/BOOT")
os.system(f"./limine/limine bios-install {IMAGE_NAME}.hdd")

Expand Down

0 comments on commit af1d9d8

Please sign in to comment.