core: remove bozo typedef for types

This commit is contained in:
2025-02-07 12:35:32 +01:00
parent 70739744ac
commit 3b798e5daa
55 changed files with 59841 additions and 1789 deletions

View File

@ -13,8 +13,8 @@
#define PIT_COUNT (65535 / 2)
#define DELAY (1000 / (PIT_FREQUENCY / PIT_COUNT))
static u32 sleep_counter;
static u32 scheduler_counter;
static uint32_t sleep_counter;
static uint32_t scheduler_counter;
static void clock_handler(struct registers *regs);
@ -44,7 +44,7 @@ static void clock_handler(struct registers *regs)
sleep_counter--;
}
void sleep(u64 delay)
void sleep(uint64_t delay)
{
sleep_counter = delay / DELAY;
while (sleep_counter)

View File

@ -3,17 +3,17 @@
struct vbe_interface display;
void put_pixel(u32 color, u32 x, u32 y)
void put_pixel(uint32_t color, uint32_t x, uint32_t y)
{
// divide by 4 because display.buff is in 32bit instead of 8bit
const u32 coords = x + y * display.pitch / 4;
const uint32_t coords = x + y * display.pitch / 4;
display.buff[coords] = color;
}
void draw_icon(u32 pos_x, u32 pos_y, struct icon *img)
void draw_icon(uint32_t pos_x, uint32_t pos_y, struct icon *img)
{
for (u32 y = 0; y < img->height; y++) {
for (u32 x = 0; x < img->width; x++) {
for (uint32_t y = 0; y < img->height; y++) {
for (uint32_t x = 0; x < img->width; x++) {
put_pixel(img->pixels[y * img->width + x], pos_x + x,
pos_y + y);
}

View File

@ -3,14 +3,14 @@
#include "gdt.h"
#include "kprintf.h"
extern void set_gdt(u32 gdt_ptr);
extern void set_gdt(uint32_t gdt_ptr);
struct tss TSS;
u8 gdt_entries[GDT_SIZE * 8];
uint8_t gdt_entries[GDT_SIZE * 8];
struct gdt_descriptor gdtr;
static void set_gdt_entry_value(u8 *target, u32 base, u32 limit,
u8 access, u8 granularity)
static void set_gdt_entry_value(uint8_t *target, uint32_t base, uint32_t limit,
uint8_t access, uint8_t granularity)
{
if (limit > 0xFFFFF) {
kprintf(KERN_ERR
@ -38,7 +38,7 @@ static void set_gdt_entry_value(u8 *target, u32 base, u32 limit,
void init_gdt(void)
{
gdtr.size = 8 * GDT_SIZE - 1;
gdtr.base = (u32)&gdt_entries[0];
gdtr.base = (uint32_t)&gdt_entries[0];
set_gdt_entry_value(gdt_entries + 0x00, 0, 0, 0, 0); // Null segment
@ -92,8 +92,8 @@ void init_gdt(void)
GDT_ACCESS_A_ACCESSED,
GDT_FLAG_32BIT_MODE | GDT_FLAG_PAGE_MODE); // User stack
// TSS
set_gdt_entry_value(gdt_entries + GDT_OFFSET_TSS, (u32)&TSS,
set_gdt_entry_value(gdt_entries + GDT_OFFSET_TSS, (uint32_t)&TSS,
sizeof(struct tss) - 1, 0x89, 0);
set_gdt(((u32)&gdtr));
set_gdt(((uint32_t)&gdtr));
}

View File

@ -33,7 +33,7 @@ static isr_t interrupt_handlers[16];
void isr_handler(struct registers *regs)
{
u8 i = 0;
uint8_t i = 0;
while (i < ARRAY_SIZE(faults)) {
if (i == regs->int_no)
kpanic("interrupt: %s\n", faults[i]);

View File

@ -21,27 +21,27 @@ static struct idt_descriptor idtr;
void load_idt(struct idt_descriptor *idtr);
void idt_set_descriptor(u8 index, void *isr, u8 flags)
void idt_set_descriptor(uint8_t index, void *isr, uint8_t flags)
{
struct idt_entry *descriptor = &idt_entries[index];
descriptor->isr_low = (u32)isr & 0xFFFF;
descriptor->isr_low = (uint32_t)isr & 0xFFFF;
descriptor->kernel_cs = GDT_OFFSET_KERNEL_CODE;
descriptor->attributes = flags;
descriptor->isr_high = (u32)isr >> 16;
descriptor->isr_high = (uint32_t)isr >> 16;
descriptor->reserved = 0;
}
void init_idt(void)
{
idtr.offset = (uintptr_t)&idt_entries[0];
idtr.size = (u16)sizeof(struct idt_entry) * IDT_SIZE - 1;
idtr.size = (uint16_t)sizeof(struct idt_entry) * IDT_SIZE - 1;
u8 i;
uint8_t i;
for (i = 0; i < 32; i++)
idt_set_descriptor(i, isr_stub_table[i], 0x8E);
pic_remap(0x20, 0x28);
for (u8 j = 0; j < 16; j++)
for (uint8_t j = 0; j < 16; j++)
idt_set_descriptor(i + j, irq_stub_table[j], 0x8E);
load_idt(&idtr);
__asm__ volatile("sti");

View File

@ -1,9 +1,9 @@
#include "types.h"
#include <cpuid.h>
#include <stdbool.h>
#include <stdint.h>
const u32 CPUID_FLAG_MSR = 1 << 5;
const uint32_t CPUID_FLAG_MSR = 1 << 5;
bool cpu_has_msr()
{
@ -12,12 +12,12 @@ bool cpu_has_msr()
return edx & CPUID_FLAG_MSR;
}
void cpu_get_msr(u32 msr, u32 *lo, u32 *hi)
void cpu_get_msr(uint32_t msr, uint32_t *lo, uint32_t *hi)
{
asm volatile("rdmsr" : "=a"(*lo), "=d"(*hi) : "c"(msr));
}
void cpu_set_msr(u32 msr, u32 lo, u32 hi)
void cpu_set_msr(uint32_t msr, uint32_t lo, uint32_t hi)
{
asm volatile("wrmsr" : : "a"(lo), "d"(hi), "c"(msr));
}

View File

@ -24,7 +24,7 @@
void pic_remap(int offset_master, int offset_slave)
{
u8 a1, a2;
uint8_t a1, a2;
a1 = inb(PIC1_DATA); // save masks
a2 = inb(PIC2_DATA);
@ -56,7 +56,7 @@ void pic_remap(int offset_master, int offset_slave)
outb(PIC2_DATA, a2);
}
void pic_send_eoi(u8 irq)
void pic_send_eoi(uint8_t irq)
{
if (irq >= 8)
outb(PIC2_COMMAND, PIC_EOI);

View File

@ -43,7 +43,7 @@ static void owo(void)
static void awa(void)
{
u32 pid = fork();
uint32_t pid = fork();
PRINT_INT(pid);
if (pid < 0)
kprintf("camille il a une grosse bite (18cm)\n");
@ -52,7 +52,7 @@ static void awa(void)
wait();
}
void kernel_main(multiboot_info_t *mbd, u32 magic)
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
{
terminal_initialize();
init_gdt();

View File

@ -7,7 +7,7 @@
#include "string.h"
#include "terminal.h"
extern u32 page_table1[1024];
extern uint32_t page_table1[1024];
extern const char *faults[];
__attribute__((noreturn)) void kpanic(const char *format, ...)
@ -20,7 +20,7 @@ __attribute__((noreturn)) void kpanic(const char *format, ...)
kvprintf(format, &va);
va_end(va);
u32 faulting_address;
uint32_t faulting_address;
__asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address));
kprintf("fault at address: %p\n", faulting_address);
/* for (int i = 16; i < 32; i++) */

View File

@ -5,7 +5,7 @@
#include <stdarg.h>
#include <stdint.h>
int print_int_base(i64 number, const char *prefix, const char *base);
int print_int_base(int64_t number, const char *prefix, const char *base);
static int get_level(const char *str)
{
@ -20,19 +20,19 @@ static int print_flag(char flag, va_list *ap)
case '%':
return terminal_putchar('%');
case 'i':
return print_int_base(va_arg(*ap, i32), NULL, BASE_DECA);
return print_int_base(va_arg(*ap, int32_t), NULL, BASE_DECA);
case 'd':
return print_int_base(va_arg(*ap, i32), NULL, BASE_DECA);
return print_int_base(va_arg(*ap, int32_t), NULL, BASE_DECA);
case 'c':
return terminal_putchar(va_arg(*ap, int));
case 's':
return terminal_writestring(va_arg(*ap, char *));
case 'p':
return print_int_base(va_arg(*ap, u32), "0x", BASE_HEXA);
return print_int_base(va_arg(*ap, uint32_t), "0x", BASE_HEXA);
case 'x':
return print_int_base(va_arg(*ap, i32), "0x", BASE_HEXA);
return print_int_base(va_arg(*ap, int32_t), "0x", BASE_HEXA);
case 'u':
return print_int_base(va_arg(*ap, u32), NULL, BASE_DECA);
return print_int_base(va_arg(*ap, uint32_t), NULL, BASE_DECA);
}
return 0;
}

View File

@ -3,11 +3,11 @@
#include "string.h"
#include "terminal.h"
int print_int_base(i64 number, const char *prefix, const char *base)
int print_int_base(int64_t number, const char *prefix, const char *base)
{
const int base_size = strlen(base);
u64 div = 1;
u32 tmp;
uint64_t div = 1;
uint32_t tmp;
int rv = 0;
if (prefix)

View File

@ -34,7 +34,7 @@ int free_frame(void *frame_ptr)
frame_ptr >= it->addr + it->total_frames * PAGE_SIZE))
it = it->next;
u32 index = ((frame_ptr - it->addr) / PAGE_SIZE);
uint32_t index = ((frame_ptr - it->addr) / PAGE_SIZE);
SET_FRAME(it->frame_table, index, 0);
if (it->first_free_frame > index)
it->first_free_frame = index;

View File

@ -1,22 +1,22 @@
#include "debug.h"
#include "kprintf.h"
#include "memory.h"
void init_page_table(u32 page_table[1024], u16 start)
void init_page_table(uint32_t page_table[1024], uint16_t start)
{
for (u16 i = start; i < 1024; i++)
for (uint16_t i = start; i < 1024; i++)
page_table[i] = (i << 12) | 0x03;
}
i16 add_page_table(u16 pd_index)
int16_t add_page_table(uint16_t pd_index)
{
void *frame = alloc_frame();
if (!frame)
return -1;
page_table_default[PT_START + pd_index] =
((u32)frame & PAGE_MASK) | 0x03;
u32 *page_table =
(u32 *)GET_PAGE_ADDR(0, PT_START + pd_index);
((uint32_t)frame & PAGE_MASK) | 0x03;
uint32_t *page_table =
(uint32_t *)GET_PAGE_ADDR(0, PT_START + pd_index);
init_page_table(page_table, 0);
page_directory[pd_index] = ((u32)frame & PAGE_MASK) | 0x03;
page_directory[pd_index] = ((uint32_t)frame & PAGE_MASK) | 0x03;
return 0;
}

View File

@ -8,7 +8,7 @@
void show_valloc_mem(void)
{
char *const zones_name[3] = {"TINY", "SMALL", "LARGE"};
u32 total_size = 0;
uint32_t total_size = 0;
for (block_type_t type = 0; type < 3; ++type) {
int count = 0;
@ -23,7 +23,7 @@ void show_valloc_mem(void)
/* i++; */
/* if (i < 10) */
kprintf("%p - %p : %u bytes\n", block_it->ptr,
(u32)block_it->ptr +
(uint32_t)block_it->ptr +
block_it->sub_size + sizeof(Block),
block_it->sub_size);
total_size += block_it->sub_size;
@ -39,7 +39,7 @@ void show_valloc_mem(void)
for (Block *block_it = zone_it->free; block_it != NULL;
block_it = block_it->next_free) {
kprintf("%p - %p : %u bytes\n", block_it->ptr,
(u32)block_it->ptr +
(uint32_t)block_it->ptr +
block_it->sub_size + sizeof(Block),
block_it->sub_size);
}

View File

@ -98,7 +98,7 @@ void vfree(void *ptr)
{
if (ptr == NULL)
return;
Block *to_free = (Block *)((u32)ptr - sizeof(Block));
Block *to_free = (Block *)((uint32_t)ptr - sizeof(Block));
Block *to_merge = NULL;
to_free->in_use = false;
remove_used(to_free);

View File

@ -8,7 +8,7 @@
* Find first available (not in_use) block
* in a zone matching the size we need
*/
static Block *find_block(Zone *head, u32 size)
static Block *find_block(Zone *head, uint32_t size)
{
for (Zone *zone_it = head; zone_it != NULL; zone_it = zone_it->next) {
for (Block *block_it = zone_it->free; block_it != NULL;
@ -46,17 +46,17 @@ static Block *find_block(Zone *head, u32 size)
* We can see that it now has its own metadata and available
* data and it points towards [6]
*/
static void frag_block(Zone *zone, Block *old_block, u32 size)
static void frag_block(Zone *zone, Block *old_block, uint32_t size)
{
Block *new_block = (Block *)align_mem((u32)old_block + size);
Block *new_block = (Block *)align_mem((uint32_t)old_block + size);
assert(new_block <
(Block *)((u32)zone + get_zone_size(zone->type)));
(Block *)((uint32_t)zone + get_zone_size(zone->type)));
// Newly created block metadata
new_block->size = old_block->size - align_mem(size);
new_block->sub_size = new_block->size;
new_block->in_use = false;
new_block->ptr = (void *)((u32)new_block + sizeof(Block));
new_block->ptr = (void *)((uint32_t)new_block + sizeof(Block));
new_block->zone = zone;
new_block->prev = old_block;
@ -120,7 +120,7 @@ static void save_block(Zone *head, Block *block, Zone *zone)
*
* ptr: returns the aligned pointer of the block (after the metadata)
*/
void *vmalloc(u32 size)
void *vmalloc(uint32_t size)
{
void *ptr = NULL;
@ -136,7 +136,7 @@ void *vmalloc(u32 size)
// Find an available block in a zone of type "type"
Block *available = find_block(head, size);
if (available == NULL) {
u32 full_size;
uint32_t full_size;
if (type == LARGE)
full_size = size + sizeof(Block) + sizeof(Zone);
else

View File

@ -4,7 +4,7 @@
// Prototype for kfree and vmalloc
void kfree(void *ptr);
void *vmalloc(u32 size);
void *vmalloc(uint32_t size);
/*
* ptr: block to resize (undefined behavior if invalid)
@ -18,12 +18,12 @@ void *vmalloc(u32 size);
*
* ptr: returns the aligned pointer of the vreallocated block
*/
void *vrealloc(void *ptr, u32 size)
void *vrealloc(void *ptr, uint32_t size)
{
void *new_ptr = NULL;
if (ptr == NULL)
return NULL;
Block *block = (Block *)((u32)ptr - sizeof(Block));
Block *block = (Block *)((uint32_t)ptr - sizeof(Block));
if (block->size >= size) {
block->sub_size = size;
return (ptr);

View File

@ -1,9 +1,9 @@
#include "alloc.h"
#include <stdint.h>
u32 vsize(void *ptr)
uint32_t vsize(void *ptr)
{
Block *meta_data = (Block *)((u32)ptr - sizeof(Block));
Block *meta_data = (Block *)((uint32_t)ptr - sizeof(Block));
return meta_data->sub_size;
}

View File

@ -9,21 +9,21 @@
#include "utils.h"
#include "vbe.h"
u32 multiboot_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
u32 vbe_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
uint32_t multiboot_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
uint32_t vbe_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
multiboot_memory_map_t *mmap_addr;
multiboot_u32 mmap_length;
multiboot_uint32_t mmap_length;
static void init_mmap(multiboot_info_t *mbd_virt, size_t *pt_index)
{
// Index mbd->mmap_addr pointers
u32 i = 0;
uint32_t i = 0;
for (; i < mbd_virt->mmap_length; i++)
multiboot_page_table[i + *pt_index] =
((mbd_virt->mmap_addr + i * PAGE_SIZE) & PAGE_MASK) |
INIT_FLAGS;
mmap_addr = (multiboot_memory_map_t *)(GET_PAGE_ADDR(1023, *pt_index) +
(u32)mbd_virt->mmap_addr %
(uint32_t)mbd_virt->mmap_addr %
PAGE_SIZE);
mmap_length = mbd_virt->mmap_length / sizeof(multiboot_memory_map_t);
*pt_index += i;
@ -31,15 +31,15 @@ static void init_mmap(multiboot_info_t *mbd_virt, size_t *pt_index)
static void init_vbe(multiboot_info_t *mbd_virt)
{
const u32 framebuffer_size =
const uint32_t framebuffer_size =
mbd_virt->framebuffer_height * mbd_virt->framebuffer_pitch;
for (u32 i = 0; i < CEIL(framebuffer_size, PAGE_SIZE); i++) {
for (uint32_t i = 0; i < CEIL(framebuffer_size, PAGE_SIZE); i++) {
vbe_page_table[i % 1024] =
((mbd_virt->framebuffer_addr + i * PAGE_SIZE) & PAGE_MASK) |
INIT_FLAGS;
}
page_directory[800] = ((u32)vbe_page_table - HEAP_END) | 0x03;
display.buff = (u32 *)GET_PAGE_ADDR(800, 0) +
page_directory[800] = ((uint32_t)vbe_page_table - HEAP_END) | 0x03;
display.buff = (uint32_t *)GET_PAGE_ADDR(800, 0) +
(mbd_virt->framebuffer_addr % PAGE_SIZE);
display.height = mbd_virt->framebuffer_height;
display.width = mbd_virt->framebuffer_width;
@ -47,24 +47,24 @@ static void init_vbe(multiboot_info_t *mbd_virt)
display.bpp = mbd_virt->framebuffer_bpp;
}
void init_multiboot(multiboot_info_t *mbd, u32 magic)
void init_multiboot(multiboot_info_t *mbd, uint32_t magic)
{
if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
kpanic("invalid magic number! (git good skill issue)");
init_page_table(multiboot_page_table, 0);
page_directory[1023] =
((u32)multiboot_page_table - HEAP_END) | 0x03;
((uint32_t)multiboot_page_table - HEAP_END) | 0x03;
size_t pt_index = CEIL(
(u32)mbd % PAGE_SIZE + sizeof(multiboot_info_t), PAGE_SIZE);
(uint32_t)mbd % PAGE_SIZE + sizeof(multiboot_info_t), PAGE_SIZE);
// Index multiboot_info_t struct
for (u32 i = 0; i < pt_index; i++)
for (uint32_t i = 0; i < pt_index; i++)
multiboot_page_table[i] =
(((u32)mbd + PAGE_SIZE * i) & PAGE_MASK) | INIT_FLAGS;
(((uint32_t)mbd + PAGE_SIZE * i) & PAGE_MASK) | INIT_FLAGS;
multiboot_info_t *mbd_virt =
(multiboot_info_t *)(GET_PAGE_ADDR(1023, 0) +
(u32)mbd % PAGE_SIZE);
(uint32_t)mbd % PAGE_SIZE);
init_mmap(mbd_virt, &pt_index);
init_vbe(mbd_virt);
}

View File

@ -1,9 +1,8 @@
#include "interrupts.h"
#include "kprintf.h"
#include "task.h"
#include "types.h"
u16 fork(void)
uint16_t fork(void)
{
current_task->status = FORKED;
scheduler();
@ -24,4 +23,4 @@ void kfork(struct task *daddy)
daddy->status = RUN;
child->status = RUN;
toris();
}
}

View File

@ -12,8 +12,9 @@ struct task *current_task;
void scheduler(void)
{
// ZOMBIE, THREAD, RUN, WAIT, SLEEP, STOPPED, FORKED
void (*func[])(struct task *) = {zombify_task, NULL, NULL, NULL,
NULL, remove_task, kfork};
void (*func[])(struct task *) = {
zombify_task, NULL, NULL, NULL, NULL, remove_task, kfork,
};
if (!current_task) // || current_task->next == current_task)
return;

View File

@ -1,7 +1,7 @@
#include "interrupts.h"
#include "task.h"
u16 wait(void)
uint16_t wait(void)
{
if (current_task->child == NULL)
return -1;
@ -10,7 +10,7 @@ u16 wait(void)
current_task->child->status = STOPPED;
else
current_task->status = WAIT;
u16 child_pid = current_task->child->pid;
uint16_t child_pid = current_task->child->pid;
toris();
scheduler();
return child_pid;

View File

@ -17,7 +17,7 @@
void reboot(void)
{
u8 tmp;
uint8_t tmp;
__asm__ volatile("cli"); /* disable all interrupts */
do {

View File

@ -4,7 +4,7 @@
#include "kprintf.h"
static u16 raw_read_register(u16 cmos_register)
static uint16_t raw_read_register(uint16_t cmos_register)
{
// selecting the register
outb(CMOS_ADDRESS, cmos_register);
@ -12,19 +12,19 @@ static u16 raw_read_register(u16 cmos_register)
return inb(CMOS_DATA);
}
static u8 update_is_in_progress(void)
static uint8_t update_is_in_progress(void)
{
return raw_read_register(REGISTER_A) & 0x80;
}
static u16 read_register(u16 cmos_register)
static uint16_t read_register(uint16_t cmos_register)
{
while (update_is_in_progress())
kprintf("%d\n", update_is_in_progress());
return raw_read_register(cmos_register);
}
u8 bcd_mode_to_bin(u8 value)
uint8_t bcd_mode_to_bin(uint8_t value)
{
return (value & 0x0F) + ((value / 16) * 10);
}
@ -32,7 +32,7 @@ u8 bcd_mode_to_bin(u8 value)
struct rtc_date get_date(void)
{
struct rtc_date rv = {};
u8 century;
uint8_t century;
rv.second = read_register(SECOND_REGISTER);
rv.minute = read_register(MINUTE_REGISTER);

View File

@ -6,7 +6,7 @@
void color_cmd(char *arg)
{
u8 tmp_color;
uint8_t tmp_color;
static const char *colors[] = {
"BLACK", "BLUE", "GREEN", "CYAN",
"RED", "MAGENTA", "BROWN", "LIGHT_GREY",

View File

@ -8,7 +8,7 @@ struct key_event terminal_getkey(void)
{
static bool caps_mode = false;
struct key_event ev = {0};
u8 scan_code;
uint8_t scan_code;
scan_code = inb(KEYBOARD_PORT);
if (scan_code == 0x3A || scan_code == 0x58) {

View File

@ -42,18 +42,18 @@ void terminal_remove_last_char(void)
screen->column = VGA_WIDTH - 1;
screen->row--;
}
u32 pos_x = (screen->column) * FONT_WIDTH;
u32 pos_y = screen->row * FONT_HEIGHT;
uint32_t pos_x = (screen->column) * FONT_WIDTH;
uint32_t pos_y = screen->row * FONT_HEIGHT;
struct font node = get_font_node(
screen->buffer[screen->row * VGA_WIDTH + screen->column]);
screen->buffer[screen->row * VGA_WIDTH + screen->column] = '\0';
for (u32 y = 0; y < node.height; y++) {
for (u32 x = 0; x < node.width; x++) {
for (uint32_t y = 0; y < node.height; y++) {
for (uint32_t x = 0; x < node.width; x++) {
// Current bg is taking too much memory
// so we do a black bg for now
/* struct icon *bg = screen->background; */
/* u32 pixel = 0; */
/* uint32_t pixel = 0; */
/* if (bg->width > pos_x + x && bg->height > pos_y + y)
*/
/* pixel = bg->pixels[(pos_y + y) * bg->width + */
@ -74,38 +74,38 @@ void terminal_set_screen(int pos)
/* kprintf(PROMPT); */
}
void terminal_set_bg_color(u32 bg_color)
void terminal_set_bg_color(uint32_t bg_color)
{
screen->bg_color = bg_color;
}
void terminal_set_fg_color(u32 fg_color)
void terminal_set_fg_color(uint32_t fg_color)
{
screen->fg_color = screen->fg_color;
}
void terminal_set_color(u32 fg_color, u32 bg_color)
void terminal_set_color(uint32_t fg_color, uint32_t bg_color)
{
screen->fg_color = fg_color;
screen->bg_color = bg_color;
}
void terminal_set_default_fg_color(u32 fg_color)
void terminal_set_default_fg_color(uint32_t fg_color)
{
screen->default_color = fg_color;
}
u32 terminal_get_default_color(void)
uint32_t terminal_get_default_color(void)
{
return screen->default_color;
}
u8 terminal_get_char(int x, int y)
uint8_t terminal_get_char(int x, int y)
{
return screen->buffer[y * VGA_WIDTH + x];
}
void terminal_putentryat(struct font node, u32 fg_color, u32 bg_color,
void terminal_putentryat(struct font node, uint32_t fg_color, uint32_t bg_color,
size_t x, size_t y)
{
char *glyph = node.bitmap;
@ -128,8 +128,8 @@ static void terminal_scroll(void)
screen->row--;
memset(display.buff, 0, display.height * display.pitch);
for (size_t i = 0; i < VGA_WIDTH * (VGA_HEIGHT - 1); i++) {
const u32 x = (i % VGA_WIDTH) * FONT_WIDTH;
const u32 y = (i / VGA_WIDTH) * FONT_HEIGHT;
const uint32_t x = (i % VGA_WIDTH) * FONT_WIDTH;
const uint32_t y = (i / VGA_WIDTH) * FONT_HEIGHT;
screen->buffer[i] = screen->buffer[i + VGA_WIDTH];
terminal_putentryat(get_font_node(screen->buffer[i]),
screen->fg_color, screen->bg_color, x, y);
@ -143,7 +143,7 @@ static void terminal_new_line(void)
terminal_scroll();
}
void terminal_change_default_color(u32 color)
void terminal_change_default_color(uint32_t color)
{
// TODO
/* terminal_set_color(color); */
@ -151,7 +151,7 @@ void terminal_change_default_color(u32 color)
/* for (size_t x = 0; x < VGA_WIDTH; x++) { */
/* const size_t index = y * VGA_WIDTH + x;
*/
/* u8 entry_color =
/* uint8_t entry_color =
* get_entry_color(TERM_BUF[index]);
*/
/* TERM_BUF[index] = vga_entry( */
@ -170,7 +170,7 @@ void terminal_change_default_color(u32 color)
/* screen->color = color; */
}
void terminal_change_default_fg_color(u32 fg_color)
void terminal_change_default_fg_color(uint32_t fg_color)
{
terminal_set_fg_color(fg_color);
/* terminal_change_default_color(screen->fg_color); */
@ -228,7 +228,7 @@ int terminal_writestring(const char *data)
void update_cursor(void)
{
/* u16 pos = screen->row * VGA_WIDTH +
/* uint16_t pos = screen->row * VGA_WIDTH +
* screen->column; */
/* outb(0x3D4, 0x0F); */