From 6928f36f6647d3bcd5e1e852b45b09b31e881c76 Mon Sep 17 00:00:00 2001 From: vanten-s Date: Tue, 13 Aug 2024 15:24:17 +0200 Subject: [PATCH] Fixed indentation --- arch/i686/gdt.c | 56 +++++++++++++------------- arch/i686/interrupts/pic.c | 48 +++++++++++----------- arch/i686/strlib.c | 8 ++-- arch/i686/tty.c | 82 +++++++++++++++++++------------------- include/kernel/gdt.h | 56 +++++++++++++------------- kernel/elf.c | 10 ++--- kernel/kernel.c | 4 +- 7 files changed, 132 insertions(+), 132 deletions(-) diff --git a/arch/i686/gdt.c b/arch/i686/gdt.c index f90c6cb..b3db1f0 100644 --- a/arch/i686/gdt.c +++ b/arch/i686/gdt.c @@ -18,34 +18,34 @@ struct GDT { } __attribute__((packed)); struct tss_entry_struct { - uint32_t prev_tss; // The previous TSS - with hardware task switching these form a kind of backward linked list. - uint32_t esp0; // The stack pointer to load when changing to kernel mode. - uint32_t ss0; // The stack segment to load when changing to kernel mode. - // Everything below here is unused. - uint32_t esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2. - uint32_t ss1; - uint32_t esp2; - uint32_t ss2; - uint32_t cr3; - uint32_t eip; - uint32_t eflags; - uint32_t eax; - uint32_t ecx; - uint32_t edx; - uint32_t ebx; - uint32_t esp; - uint32_t ebp; - uint32_t esi; - uint32_t edi; - uint32_t es; - uint32_t cs; - uint32_t ss; - uint32_t ds; - uint32_t fs; - uint32_t gs; - uint32_t ldt; - uint16_t trap; - uint16_t iomap_base; + uint32_t prev_tss; // The previous TSS - with hardware task switching these form a kind of backward linked list. + uint32_t esp0; // The stack pointer to load when changing to kernel mode. + uint32_t ss0; // The stack segment to load when changing to kernel mode. + // Everything below here is unused. + uint32_t esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2. + uint32_t ss1; + uint32_t esp2; + uint32_t ss2; + uint32_t cr3; + uint32_t eip; + uint32_t eflags; + uint32_t eax; + uint32_t ecx; + uint32_t edx; + uint32_t ebx; + uint32_t esp; + uint32_t ebp; + uint32_t esi; + uint32_t edi; + uint32_t es; + uint32_t cs; + uint32_t ss; + uint32_t ds; + uint32_t fs; + uint32_t gs; + uint32_t ldt; + uint16_t trap; + uint16_t iomap_base; } __attribute__((packed)); struct tss_entry_struct tss; diff --git a/arch/i686/interrupts/pic.c b/arch/i686/interrupts/pic.c index 8285d4a..a4e37f9 100644 --- a/arch/i686/interrupts/pic.c +++ b/arch/i686/interrupts/pic.c @@ -21,29 +21,29 @@ void init_pic() { uint8_t a1; - - a1 = inb(PIC1_DATA); // save masks - inb(PIC2_DATA); - - outb(PIC1_COMMAND, ICW1_INIT | ICW1_ICW4); // starts the initialization sequence (in cascade mode) - io_wait(); - outb(PIC2_COMMAND, ICW1_INIT | ICW1_ICW4); - io_wait(); - outb(PIC1_DATA, 0x20); // ICW2: Master PIC vector offset - io_wait(); - outb(PIC2_DATA, 0xFF); // ICW2: Slave PIC vector offset - io_wait(); - outb(PIC1_DATA, 4); // ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100) - io_wait(); - outb(PIC2_DATA, 2); // ICW3: tell Slave PIC its cascade identity (0000 0010) - io_wait(); - - outb(PIC1_DATA, ICW4_8086); // ICW4: have the PICs use 8086 mode (and not 8080 mode) - io_wait(); - outb(PIC2_DATA, ICW4_8086); - io_wait(); - - outb(PIC1_DATA, a1); // restore saved masks. - // outb(PIC2_DATA, a2); + + a1 = inb(PIC1_DATA); // save masks + inb(PIC2_DATA); + + outb(PIC1_COMMAND, ICW1_INIT | ICW1_ICW4); // starts the initialization sequence (in cascade mode) + io_wait(); + outb(PIC2_COMMAND, ICW1_INIT | ICW1_ICW4); + io_wait(); + outb(PIC1_DATA, 0x20); // ICW2: Master PIC vector offset + io_wait(); + outb(PIC2_DATA, 0xFF); // ICW2: Slave PIC vector offset + io_wait(); + outb(PIC1_DATA, 4); // ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100) + io_wait(); + outb(PIC2_DATA, 2); // ICW3: tell Slave PIC its cascade identity (0000 0010) + io_wait(); + + outb(PIC1_DATA, ICW4_8086); // ICW4: have the PICs use 8086 mode (and not 8080 mode) + io_wait(); + outb(PIC2_DATA, ICW4_8086); + io_wait(); + + outb(PIC1_DATA, a1); // restore saved masks. + // outb(PIC2_DATA, a2); outb(PIC2_DATA, 0xFF); } diff --git a/arch/i686/strlib.c b/arch/i686/strlib.c index 73c42c6..37a9e6e 100644 --- a/arch/i686/strlib.c +++ b/arch/i686/strlib.c @@ -2,10 +2,10 @@ size_t strlen(const char* str) { - size_t len = 0; - while (str[len]) - len++; - return len; + size_t len = 0; + while (str[len]) + len++; + return len; } char to_upper_char(char c) diff --git a/arch/i686/tty.c b/arch/i686/tty.c index 7ee69c0..8e87fc6 100644 --- a/arch/i686/tty.c +++ b/arch/i686/tty.c @@ -9,32 +9,32 @@ /* Hardware text mode color constants. */ enum vga_color { - VGA_COLOR_BLACK = 0, - VGA_COLOR_BLUE = 1, - VGA_COLOR_GREEN = 2, - VGA_COLOR_CYAN = 3, - VGA_COLOR_RED = 4, - VGA_COLOR_MAGENTA = 5, - VGA_COLOR_BROWN = 6, - VGA_COLOR_LIGHT_GREY = 7, - VGA_COLOR_DARK_GREY = 8, - VGA_COLOR_LIGHT_BLUE = 9, - VGA_COLOR_LIGHT_GREEN = 10, - VGA_COLOR_LIGHT_CYAN = 11, - VGA_COLOR_LIGHT_RED = 12, - VGA_COLOR_LIGHT_MAGENTA = 13, - VGA_COLOR_LIGHT_BROWN = 14, - VGA_COLOR_WHITE = 15, + VGA_COLOR_BLACK = 0, + VGA_COLOR_BLUE = 1, + VGA_COLOR_GREEN = 2, + VGA_COLOR_CYAN = 3, + VGA_COLOR_RED = 4, + VGA_COLOR_MAGENTA = 5, + VGA_COLOR_BROWN = 6, + VGA_COLOR_LIGHT_GREY = 7, + VGA_COLOR_DARK_GREY = 8, + VGA_COLOR_LIGHT_BLUE = 9, + VGA_COLOR_LIGHT_GREEN = 10, + VGA_COLOR_LIGHT_CYAN = 11, + VGA_COLOR_LIGHT_RED = 12, + VGA_COLOR_LIGHT_MAGENTA = 13, + VGA_COLOR_LIGHT_BROWN = 14, + VGA_COLOR_WHITE = 15, }; static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) { - return fg | bg << 4; + return fg | bg << 4; } static inline uint16_t vga_entry(unsigned char uc, uint8_t color) { - return (uint16_t) uc | (uint16_t) color << 8; + return (uint16_t) uc | (uint16_t) color << 8; } static inline unsigned char vga_char(uint16_t entry) @@ -57,32 +57,32 @@ uint16_t* terminal_buffer; void terminal_initialize(void) { - terminal_row = 0; - terminal_column = 0; - terminal_color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK); - terminal_buffer = (uint16_t*) 0xB8000; - for (size_t y = 0; y < VGA_HEIGHT; y++) { - for (size_t x = 0; x < VGA_WIDTH; x++) { - const size_t index = y * VGA_WIDTH + x; - terminal_buffer[index] = vga_entry(' ', terminal_color); - } - } + terminal_row = 0; + terminal_column = 0; + terminal_color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK); + terminal_buffer = (uint16_t*) 0xB8000; + for (size_t y = 0; y < VGA_HEIGHT; y++) { + for (size_t x = 0; x < VGA_WIDTH; x++) { + const size_t index = y * VGA_WIDTH + x; + terminal_buffer[index] = vga_entry(' ', terminal_color); + } + } } void terminal_setcolor(uint8_t color) { - terminal_color = color; + terminal_color = color; } static void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) { - const size_t index = y * VGA_WIDTH + x; - terminal_buffer[index] = vga_entry(c, color); + const size_t index = y * VGA_WIDTH + x; + terminal_buffer[index] = vga_entry(c, color); } static uint16_t terminal_getentryat(size_t x, size_t y) { - const size_t index = y * VGA_WIDTH + x; + const size_t index = y * VGA_WIDTH + x; return terminal_buffer[index]; } @@ -116,21 +116,21 @@ void terminal_putchar(char c) terminal_newline(); return; } - terminal_putentryat(c, terminal_color, terminal_column, terminal_row); - if (++terminal_column == VGA_WIDTH) { - terminal_column = 0; - if (++terminal_row == VGA_HEIGHT) - terminal_scroll(); - } + terminal_putentryat(c, terminal_color, terminal_column, terminal_row); + if (++terminal_column == VGA_WIDTH) { + terminal_column = 0; + if (++terminal_row == VGA_HEIGHT) + terminal_scroll(); + } } static void terminal_write(const char* data, size_t size) { - for (size_t i = 0; i < size; i++) - terminal_putchar(data[i]); + for (size_t i = 0; i < size; i++) + terminal_putchar(data[i]); } void terminal_writestring(const char* data) { - terminal_write(data, strlen(data)); + terminal_write(data, strlen(data)); } diff --git a/include/kernel/gdt.h b/include/kernel/gdt.h index 2b0cf9b..defe489 100644 --- a/include/kernel/gdt.h +++ b/include/kernel/gdt.h @@ -1,34 +1,34 @@ #include struct tss_entry_struct { - uint32_t prev_tss; // The previous TSS - with hardware task switching these form a kind of backward linked list. - uint32_t esp0; // The stack pointer to load when changing to kernel mode. - uint32_t ss0; // The stack segment to load when changing to kernel mode. - // Everything below here is unused. - uint32_t esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2. - uint32_t ss1; - uint32_t esp2; - uint32_t ss2; - uint32_t cr3; - uint32_t eip; - uint32_t eflags; - uint32_t eax; - uint32_t ecx; - uint32_t edx; - uint32_t ebx; - uint32_t esp; - uint32_t ebp; - uint32_t esi; - uint32_t edi; - uint32_t es; - uint32_t cs; - uint32_t ss; - uint32_t ds; - uint32_t fs; - uint32_t gs; - uint32_t ldt; - uint16_t trap; - uint16_t iomap_base; + uint32_t prev_tss; // The previous TSS - with hardware task switching these form a kind of backward linked list. + uint32_t esp0; // The stack pointer to load when changing to kernel mode. + uint32_t ss0; // The stack segment to load when changing to kernel mode. + // Everything below here is unused. + uint32_t esp1; // esp and ss 1 and 2 would be used when switching to rings 1 or 2. + uint32_t ss1; + uint32_t esp2; + uint32_t ss2; + uint32_t cr3; + uint32_t eip; + uint32_t eflags; + uint32_t eax; + uint32_t ecx; + uint32_t edx; + uint32_t ebx; + uint32_t esp; + uint32_t ebp; + uint32_t esi; + uint32_t edi; + uint32_t es; + uint32_t cs; + uint32_t ss; + uint32_t ds; + uint32_t fs; + uint32_t gs; + uint32_t ldt; + uint16_t trap; + uint16_t iomap_base; } __attribute__((packed)); extern struct tss_entry_struct tss; diff --git a/kernel/elf.c b/kernel/elf.c index cc04993..2d7edbd 100644 --- a/kernel/elf.c +++ b/kernel/elf.c @@ -6,11 +6,11 @@ #include static void* memcpy(void* restrict dstptr, const void* restrict srcptr, size_t size) { - unsigned char* dst = (unsigned char*) dstptr; - const unsigned char* src = (const unsigned char*) srcptr; - for (size_t i = 0; i < size; i++) - dst[i] = src[i]; - return dstptr; + unsigned char* dst = (unsigned char*) dstptr; + const unsigned char* src = (const unsigned char*) srcptr; + for (size_t i = 0; i < size; i++) + dst[i] = src[i]; + return dstptr; } extern void jump_to_userspace(); diff --git a/kernel/kernel.c b/kernel/kernel.c index 15d8c33..23807e0 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -23,8 +23,8 @@ uint8_t program[] = { void kernel_main(void) { - /* Initialize terminal interface */ - terminal_initialize(); + /* Initialize terminal interface */ + terminal_initialize(); init_pic(); idt_init();