Browse Source

fixed all warnings

master
Mathieu Serandour 1 year ago
parent
commit
9c9275f807
  1. 4
      kernel/Makefile
  2. 8
      kernel/acpi/acpi.c
  3. 2
      kernel/debug/panic.c
  4. 13
      kernel/drivers/hpet.c
  5. 2
      kernel/drivers/pcie.c
  6. 7
      kernel/entry.c
  7. 21
      kernel/int/apic.c
  8. 2
      kernel/int/idt.h
  9. 16
      kernel/memory/paging.c
  10. 8
      kernel/memory/vmap.h

4
kernel/Makefile

@ -44,6 +44,10 @@ $(KERNEL): $(OBJ)
#%.txt.o: ../resources/ascii/%.txt
# $(LD) -r -b binary -o $@ $<
kernel/memory/paging.o: INTERNALCFLAGS += -Wno-int-conversion
%.c.o: %.c
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@

8
kernel/acpi/acpi.c

@ -73,7 +73,7 @@ void read_acpi_tables(const void* rsdp_location) {
fadt_parsed = true;
break;
case HPET_SIGNATURE:
parse_hpet(table);
parse_hpet((const void*)table);
hpet_parsed = true;
break;
case PCIE_SIGNATURE:
@ -94,14 +94,14 @@ void read_acpi_tables(const void* rsdp_location) {
void map_acpi_mmios(void) {
// mmios to map: HPET, PCIE
// cache disable
map_pages(apic_config_base, APIC_VIRTUAL_ADDRESS, 1,
map_pages((uint64_t)apic_config_base, APIC_VIRTUAL_ADDRESS, 1,
PRESENT_ENTRY | PCD);
map_pages(hpet_config_space, HPET_VIRTUAL_ADDRESS, 1,
map_pages((uint64_t)hpet_config_space, HPET_VIRTUAL_ADDRESS, 1,
PRESENT_ENTRY | PCD);
}
static void parse_hpet(const struct HPET* table) {
hpet_config_space = table->address;
hpet_config_space = (void*)table->address;
}
static void parse_madt(const struct MADT* table) {

2
kernel/debug/panic.c

@ -10,7 +10,7 @@ int zero = 0;
extern uint64_t _rbp(void);
// always inline: make sure
static __attribute__((always_inline)) void stack_trace(void) {
static inline __attribute__((always_inline)) void stack_trace(void) {
void** ptr = (void**)_rbp();
kputs("backtrace:\n");

13
kernel/drivers/hpet.c

@ -48,19 +48,14 @@ static_assert(sizeof(struct HPET_MMIO) == 0x400);
static uint32_t hpet_period = 0;
void hpet_init(void) {
struct HPET_MMIO* const base = HPET_VIRTUAL_ADDRESS;
hpet_period = base->capabilities >> 32;
struct HPET_MMIO* const base = (void *)HPET_VIRTUAL_ADDRESS;
// enable HPET main timer
base->general_config |= 1;
hpet_period = base->capabilities >> 32;
}
void hpet_prepare_wait_ms(unsigned ms) {
struct HPET_MMIO* const base = HPET_VIRTUAL_ADDRESS;
struct HPET_MMIO* const base = (void *)HPET_VIRTUAL_ADDRESS;
hpet_period = base->capabilities >> 32;
@ -71,7 +66,7 @@ void hpet_prepare_wait_ms(unsigned ms) {
//t * 1000 / (T * 1e15) *
void hpet_wait() {
struct HPET_MMIO* const base = HPET_VIRTUAL_ADDRESS;
struct HPET_MMIO* const base = (void *)HPET_VIRTUAL_ADDRESS;
base->general_config |= 1;

2
kernel/drivers/pcie.c

@ -1,5 +1,5 @@
#include "pcie.h"
struct PCIE_Descriptor pcie_descriptor = {0, {0}};
struct PCIE_Descriptor pcie_descriptor = {0};

7
kernel/entry.c

@ -115,8 +115,8 @@ static void init_memory(const struct stivale2_struct_tag_memmap* memmap_tag,
// map MMIOs
map_pages(
early_virtual_to_physical(fbtag->framebuffer_addr),
0xffffffff00000000,
early_virtual_to_physical((void *)fbtag->framebuffer_addr),
MMIO_BEGIN,
(fbtag->framebuffer_height * fbtag->framebuffer_pitch+0x0fff) / 0x1000,
PRESENT_ENTRY
);
@ -162,8 +162,7 @@ void _start(struct stivale2_struct *stivale2_struct) {
// first initialize our terminal
//initVideo(fbtag, 0xc0000000);
initVideo(fbtag, 0xffffffff00000000);
initVideo(fbtag, (void *)MMIO_BEGIN);
init_gdt_table();
// we cannot use stivale2 terminal
// after loading our gdt

21
kernel/int/apic.c

@ -7,17 +7,13 @@
#include "../memory/vmap.h"
#include "../drivers/hpet.h"
volatile struct APICConfig* apic_config = APIC_VIRTUAL_ADDRESS;
static volatile struct APICConfig* apic_config = (void *)APIC_VIRTUAL_ADDRESS;
void set_rflags(uint64_t rf);
uint64_t get_rflags(void);
static uint64_t apic_timer_clock_count = 0;
uint64_t apic_timer_clock_count = 0;
char buffer[128] = {0};
__attribute__((interrupt)) void lapic_timer_handler(struct IFrame* frame) {
(void) frame;
++apic_timer_clock_count;
@ -43,9 +39,6 @@ inline uint64_t read(uint32_t m_address) {
return ((uint64_t) high << 32) | low;
}
#define PRINT(X) kprintf("%s = %lx\n", #X, X)
void apic_setup_clock(void) {
@ -58,10 +51,6 @@ void apic_setup_clock(void) {
assert(apic_config != NULL);
set_irq_handler(32, lapic_timer_handler);
pit_init();
// enable apic and set spurious int to 0xff
apic_config->spurious_interrupt_vector.reg = 0x100 | LAPIC_SPURIOUS_IRQ;
@ -76,18 +65,12 @@ void apic_setup_clock(void) {
hpet_wait();
// for(int i = 0; i < 10; i++)
// pit_wait(1); /// wait for 1 ms
//terminal_clear();
uint32_t t = (UINT32_MAX - apic_config->timer_current_count.reg);
apic_config->timer_initial_count.reg = t;
// irq on
// enable apic and set spurious int to 0xff
// unmask the IRQ, periodic mode, timer on irq 32
apic_config->LVT_timer.reg = 0x20020;

2
kernel/int/idt.h

@ -31,7 +31,7 @@ void _cli(void);
void _sti(void);
void setup_isr(void);
void setup_isrs(void);
#endif // IDT_H

16
kernel/memory/paging.c

@ -174,10 +174,10 @@ static void map_physical_memory(const struct stivale2_struct_tag_memmap* memmap)
continue;
uint64_t virtual_addr = translate_address(phys_addr);
void* virtual_addr = translate_address((void *)phys_addr);
map_pages(phys_addr, virtual_addr, size, PRESENT_ENTRY);
map_pages(phys_addr, (uint64_t)virtual_addr, size, PRESENT_ENTRY);
// use the allocator to allocate page tables
// to map its own data
}
@ -264,8 +264,8 @@ static int present_entry(void* entry) {
//function for debug purposes
static void print_struct(int level, void** table, uint64_t virt) {
uint64_t* addr = translate_address(table);
static inline void print_struct(int level, void** table, uint64_t virt) {
void** addr = translate_address(table);
//if(level > 1)
// return ;
@ -416,12 +416,12 @@ static void* alloc_page_table(void) {
static void* get_entry_or_allocate(void** restrict table, unsigned index) {
assert(index < 512);
uint64_t* virtual_addr_table = translate_address(table);
void** virtual_addr_table = translate_address(table);
void* entry = virtual_addr_table[index];
if(!present_entry(entry)) {
uint64_t e = create_table_entry(
void* e = create_table_entry(
alloc_page_table(),
PRESENT_ENTRY);
return virtual_addr_table[index] = e;
@ -451,7 +451,7 @@ void map_pages(uint64_t physical_addr,
while(count > 0 && pti < 512) {
// create a new entry
uint64_t e = create_table_entry((void*)physical_addr,flags);
void* e = create_table_entry((void*)physical_addr,flags);
void** entry_ptr = (void**)translate_address(pdentry) + pti;
@ -505,7 +505,7 @@ void alloc_pages(uint64_t virtual_addr_begin,
fill_page_table_allocator_buffer(16);
physalloc(size, virtual_addr_begin, callback);
physalloc(size, (void*)virtual_addr_begin, callback);
count -= size;
virtual_addr_begin += size * 0x1000;

8
kernel/memory/vmap.h

@ -68,9 +68,9 @@
*/
#define TRANSLATED_PHYSICAL_MEMORY_BEGIN 0xffff800000000000llu
#define MMIO_BEGIN 0xffffffff00000000llu
#define KERNEL_DATA_BEGIN 0xffffffff80000000llu
#define PAGE_TABLES_BEGIN 0xffffffffc0000000llu
#define MMIO_BEGIN 0xffffffff00000000llu
#define KERNEL_DATA_BEGIN 0xffffffff80000000llu
#define PAGE_TABLES_BEGIN 0xffffffffc0000000llu
// return non 0 value iif the given address
// resides in kernel memory
@ -108,6 +108,6 @@ static inline uint64_t early_virtual_to_physical(
// translate a physical memory address
// to access it where it is mapped
static void* translate_address(void* phys_addr) {
static inline void* translate_address(void* phys_addr) {
return (void*)((uint64_t)phys_addr | TRANSLATED_PHYSICAL_MEMORY_BEGIN);
}

Loading…
Cancel
Save