Исправление всех предупреждений

This commit is contained in:
Aren Elchinyan 2023-10-31 19:06:56 +03:00
parent 2a05297bc3
commit ef5e8cc0ab
9 changed files with 62 additions and 23 deletions

View File

@ -17,6 +17,8 @@ void cpu_init( );
void gdt_init( ); void gdt_init( );
void idt_init( ); void idt_init( );
void idt_set_int(uint8_t vector, void *int_handler); void idt_set_int(uint8_t vector, void *int_handler);
uint64_t arch_get_tick_b( );
uint64_t arch_get_tick_l( );
uint64_t arch_get_tick( ); uint64_t arch_get_tick( );
static inline void outb(uint16_t port, uint8_t val) { static inline void outb(uint16_t port, uint8_t val) {

View File

@ -19,10 +19,12 @@
void mem_dump_memory( ); void mem_dump_memory( );
void mem_init( ); void mem_init( );
void *mem_alloc(size_t size); void *mem_alloc(size_t size);
void mem_add_block(void *addr, size_t size);
void mem_free(void *addr); void mem_free(void *addr);
void *mem_realloc(void *addr, size_t size); void *mem_realloc(void *addr, size_t size);
void *mem_frame_alloc(uint64_t wanted_frames); void *mem_frame_alloc(uint64_t wanted_frames);
void mem_frame_free(void *ptr, uint64_t frames); void mem_frame_free(void *ptr, uint64_t frames);
void *mem_frame_calloc(uint64_t frames); void *mem_frame_calloc(uint64_t frames);
void mem_merge_all_blocks( );
#endif // mem.h #endif // mem.h

View File

@ -10,6 +10,12 @@
#ifndef MOD_H #ifndef MOD_H
#define MOD_H #define MOD_H
// Максимальное количество модулей 16. Позже перепишем на динамический массив,
// сейчас для прототипа это не так важно
#define MOD_MAX 16
void mod_init( ); void mod_init( );
void mod_list_show( );
void mod_find(char *name);
#endif // mod.h #endif // mod.h

View File

@ -13,6 +13,11 @@
#include <stdint.h> #include <stdint.h>
typedef struct { typedef struct {
uint32_t *address;
uint64_t width;
uint64_t height;
uint64_t pitch;
uint16_t bpp;
int reserved; int reserved;
} framebuffer_t; } framebuffer_t;
@ -28,8 +33,9 @@ typedef struct {
typedef struct { typedef struct {
char *name; char *name;
char *message; char *message;
int err_code; uint64_t type;
uint64_t func_count; int64_t err_code;
uint64_t module_id;
} module_info_t; } module_info_t;
typedef struct { typedef struct {

View File

@ -35,9 +35,7 @@
static inline void pause( ) { static inline void pause( ) {
for (uint64_t i = 0; i < 1024; i++) { for (uint64_t i = 0; i < 1024; i++) {
for (uint64_t j = 0; j < 1024; j++) { for (uint64_t j = 0; j < 4; j++) { asm volatile("pause"); }
for (uint64_t q = 0; q < 8; q++) { asm volatile("pause"); }
}
} }
} }

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 1 #define VERSION_MINOR 1
#define VERSION_BUILD 366 #define VERSION_BUILD 426

View File

@ -13,7 +13,6 @@
#include <tool.h> #include <tool.h>
static bool acpi_msrs_support = false; static bool acpi_msrs_support = false;
static bool mmx_support = false;
static void cpuid(uint32_t leaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, static void cpuid(uint32_t leaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx,
uint32_t *edx) { uint32_t *edx) {
@ -26,7 +25,8 @@ static void msr_get(uint32_t msr, uint32_t *lo, uint32_t *hi) {
asm volatile("rdmsr" : "=a"(*lo), "=d"(*hi) : "c"(msr)); asm volatile("rdmsr" : "=a"(*lo), "=d"(*hi) : "c"(msr));
} }
static void msr_set(uint32_t msr, uint32_t lo, uint32_t hi) { static void __attribute__((unused))
msr_set(uint32_t msr, uint32_t lo, uint32_t hi) {
asm volatile("wrmsr" : : "a"(lo), "d"(hi), "c"(msr)); asm volatile("wrmsr" : : "a"(lo), "d"(hi), "c"(msr));
} }
@ -92,6 +92,13 @@ static void brandname( ) {
if (manufacturer[0] == 0x68747541) { do_amd( ); } if (manufacturer[0] == 0x68747541) { do_amd( ); }
} }
void cpu_idle( ) {
if (acpi_msrs_support) {
LOG("Температура: %d (в QEMU/KVM всегда 0)\n",
get_cpu_temperature_intel( ));
}
}
void cpu_init( ) { void cpu_init( ) {
uint32_t eax, ebx, ecx, edx; uint32_t eax, ebx, ecx, edx;
cpuid(1, &eax, &ebx, &ecx, &edx); cpuid(1, &eax, &ebx, &ecx, &edx);

View File

@ -70,6 +70,7 @@ void exception_handler(struct frame state) {
state.rbp, state.rsp, state.r8, state.r9, state.r10, state.r11, state.rbp, state.rsp, state.r8, state.r9, state.r10, state.r11,
state.r12, state.r13, state.r14, state.r15, state.rip, state.rflags, state.r12, state.r13, state.r14, state.r15, state.rip, state.rflags,
state.cs, state.ss, state.err, state.int_number); state.cs, state.ss, state.err, state.int_number);
LOG("stack_top = %x\n", stack_top);
asm volatile("cli; hlt"); asm volatile("cli; hlt");
} }
@ -90,11 +91,14 @@ static void idt_load( ) {
asm volatile("lidt %0" : : "m"(*ptr)); asm volatile("lidt %0" : : "m"(*ptr));
} }
void idt_set_int(uint8_t vector, void *int_handler) {} void idt_set_int(uint8_t vector, void *int_handler) {
idt_desc_setup(&IDT[vector], KERNEL_CS, (uintptr_t)int_handler,
IDT_INTERRUPT_FLAGS);
idt_load( );
}
void idt_init( ) { void idt_init( ) {
asm volatile("sti"); asm volatile("sti");
fb_printf("Настройка прерываний...\n");
for (int i = 0; i != IDT_EXCEPTIONS; ++i) { for (int i = 0; i != IDT_EXCEPTIONS; ++i) {
const uintptr_t handler = (uintptr_t)isr_stubs[i]; const uintptr_t handler = (uintptr_t)isr_stubs[i];

View File

@ -8,30 +8,44 @@
#include <stdint.h> #include <stdint.h>
#include <sys.h> #include <sys.h>
module_info_t *current_module;
void sys_init( ) {} void sys_init( ) {}
framebuffer_t *sys_alloc_framebuffer( ) { framebuffer_t *sys_alloc_framebuffer( ) {
return (framebuffer_t *)0; return (framebuffer_t *)0;
} }
void sys_free_framebuffer(framebuffer_t *frame) {} void sys_free_framebuffer(framebuffer_t *frame) {
frame->reserved = 0;
}
void sys_exit(int code) {} void sys_exit(int code) {
current_module->err_code = code;
}
int sys_get_error( ) { int sys_get_error( ) {
return 0; return current_module->err_code;
} }
sys_info_t *sys_get_info( ) {} sys_info_t *sys_get_info( ) {
return &(sys_info_t){ .reserved = 0 };
module_info_t *sys_get_module(uid_t module_id) {}
uid_t sys_new_thread(func_t func) {}
int sys_delete_thread(uid_t thread_id) {
return 0;
} }
time_t sys_get_time( ) {} module_info_t *sys_get_module(uint64_t module_id) {
return (module_info_t *)module_id;
}
void sys_set_alarm(time_t time, func_t func) {} uint64_t sys_new_thread(uint64_t func) {
return func;
}
int sys_delete_thread(uint64_t thread_id) {
return thread_id;
}
time_t sys_get_time( ) {
return (time_t){ .year = 2023, .month = 10, .day = 31, .second = 1 };
}
// void sys_set_alarm(time_t time, func_t func) {}