Skip to content

Commit

Permalink
Finishing refactoring changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYourFox committed Jan 13, 2025
1 parent d6974a0 commit 4ea12f3
Showing 18 changed files with 504 additions and 596 deletions.
6 changes: 3 additions & 3 deletions kernel/arch/amd64/cpu/control.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NOTE: This file contains code derived from or inspired by:
// AstriX ("The AstriX Operating System") at https://codeberg.org/AstriX/AstriX.
// Copyright (c) 2023-2025 NotYourFox, sigsegv
// AstriX ("The AstriX Operating System") at https://codeberg.org/AstriX/AstriX.
// Copyright (c) 2023-2025 NotYourFox, sigsegv
// SPDX-License-Identifier: GPL-3.0-or-later

// This program is free software: you can redistribute it and/or modify
@@ -64,5 +64,5 @@ void cpu_interrupt_lock_force_release() {
}

void cpu_halt() {
asm ("hlt");
asm("hlt");
}
5 changes: 3 additions & 2 deletions kernel/arch/amd64/cpu/state.c
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
void cpu_state_print() {
asm_regs_t current_state;

serial_printf("The following register dump is a stub and a work-in-progress.\n");
serial_printf(
"The following register dump is a stub and a work-in-progress.\n");

update_asm_regs(&current_state);
serial_printf("Registers:\n");
@@ -43,5 +44,5 @@ void cpu_state_print() {
// }
// serial_printf("\n");

serial_printf("\n");
serial_printf("\n");
}
9 changes: 5 additions & 4 deletions kernel/arch/amd64/idt.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include <kstdint.h>
#include "kstdint.h"

// From https://wiki.osdev.org/Interrupt_Descriptor_Table#Structure_on_x86-64
struct idt_64 {
uint16_t offset_1; // offset bits 0..15
uint16_t selector; // a code segment selector in GDT or LDT
uint8_t ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero.
uint16_t offset_1; // offset bits 0..15
uint16_t selector; // a code segment selector in GDT or LDT
uint8_t
ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero.
uint8_t type_attributes; // gate type, dpl, and p fields
uint16_t offset_2; // offset bits 16..31
uint32_t offset_3; // offset bits 32..63
4 changes: 2 additions & 2 deletions kernel/arch/amd64/paging.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <kstdint.h>
#include "kstdint.h"

uint64_t paging_main[3][512] __attribute__((aligned(4096))) = { 0 };

int paging_init( ) {
int paging_init() {
return -1;
}
12 changes: 6 additions & 6 deletions kernel/arch/amd64/serial.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include <kasm.h>
#include <kstdint.h>
#include "kasm.h"
#include "kstdint.h"

void serial_write_byte(uint8_t byte) {
// Wait until the transmit holding register is empty
while ((inb(0x3f8 + 5) & 0x20) == 0)
;
while ((inb(0x3f8 + 5) & 0x20) == 0);
outb(0x3f8, byte);
}

int serial_init( ) {
int serial_init() {
// Disable all interrupts
outb(0x3f8 + 1, 0x00);

@@ -19,7 +18,8 @@ int serial_init( ) {
outb(0x3f8, 0x0C); // Low byte of divisor
outb(0x3f8 + 1, 0x00); // High byte of divisor (0 for divisor < 256)

// Disable DLAB and set communication parameters: 8n1 (8 bits, no parity, 1 stop bit)
// Disable DLAB and set communication parameters: 8n1 (8 bits, no parity, 1
// stop bit)
outb(0x3f8 + 3, 0x03);

// Enable FIFOs
2 changes: 1 addition & 1 deletion kernel/cpio.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <kstdint.h>
#include "kstdint.h"

// We need memory manager and kernel lib first
#if 0
Loading

0 comments on commit 4ea12f3

Please sign in to comment.