mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2025-06-06 08:51:27 -07:00
fixing minor bugs with single unit compilation in gcc with flags on
This commit is contained in:
parent
50efcc13fe
commit
49361a98be
@ -1,6 +1,7 @@
|
||||
#include "cpu.h"
|
||||
#include "serial.h"
|
||||
#include "terminal.h"
|
||||
#include "utils.h"
|
||||
|
||||
void cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) {
|
||||
asm volatile (
|
||||
|
0
kernel/display.c
Normal file
0
kernel/display.c
Normal file
0
kernel/display.h
Normal file
0
kernel/display.h
Normal file
0
kernel/framebuffer.c
Normal file
0
kernel/framebuffer.c
Normal file
0
kernel/framebuffer.h
Normal file
0
kernel/framebuffer.h
Normal file
0
kernel/gui.c
Normal file
0
kernel/gui.c
Normal file
0
kernel/gui.h
Normal file
0
kernel/gui.h
Normal file
@ -1,6 +1,8 @@
|
||||
#ifndef IO_H
|
||||
#define IO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline void outb(uint16_t port, uint8_t val) {
|
||||
asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
@ -2,13 +2,22 @@
|
||||
#include "serial.h"
|
||||
#include "isr.h"
|
||||
#include "io.h"
|
||||
#include "utils.h"
|
||||
|
||||
static isr_callback_t interrupt_handlers[MAX_INTERRUPTS] = { 0 };
|
||||
|
||||
void isr_handler(uint32_t int_num, uint32_t err_code) {
|
||||
terminal_write("Interrupt occurred: ");
|
||||
|
||||
print_hex(int_num);
|
||||
terminal_write("\n");
|
||||
|
||||
serial_write("INT triggered\n");
|
||||
|
||||
terminal_write("Error code: ");
|
||||
print_hex(err_code);
|
||||
terminal_write("\n");
|
||||
|
||||
if (interrupt_handlers[int_num]) {
|
||||
interrupt_handlers[int_num](); // Call registered handler
|
||||
} else {
|
||||
|
@ -28,7 +28,7 @@ void keyboard_callback() {
|
||||
return;
|
||||
|
||||
char c = scancode_map[scancode];
|
||||
if (c && buffer_index < sizeof(key_buffer)) {
|
||||
if (c && buffer_index < sizeof(key_buffer) - 1) {
|
||||
key_buffer[buffer_index++] = c;
|
||||
terminal_putchar(c); // Echo to terminal (optional)
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include "memmap.h"
|
||||
#include "gdt.h"
|
||||
#include "cpu.h"
|
||||
#include "kmalloc.h"
|
||||
#include "timer.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define LPT1 0x378
|
||||
|
||||
|
@ -1,14 +1,21 @@
|
||||
#include "memmap.h"
|
||||
|
||||
uint32_t get_memory_map(memory_map_entry_t *map, uint32_t max_entries) {
|
||||
// Fill with dummy values for now
|
||||
map[0].base_addr = 0x00000000;
|
||||
map[0].length = 0x0009FC00;
|
||||
map[0].type = 1;
|
||||
uint32_t count = 0;
|
||||
|
||||
map[1].base_addr = 0x00100000;
|
||||
map[1].length = 0x1FF00000;
|
||||
map[1].type = 1;
|
||||
if (max_entries >= 1) {
|
||||
map[count].base_addr = 0x00000000;
|
||||
map[count].length = 0x0009FC00;
|
||||
map[count].type = 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
return 2; // 2 regions
|
||||
}
|
||||
if (max_entries >= 2) {
|
||||
map[count].base_addr = 0x00100000;
|
||||
map[count].length = 0x1FF00000;
|
||||
map[count].type = 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
#include "io.h"
|
||||
#include "serial.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define COM1 0x3F8
|
||||
#define COM2 0x2F8
|
||||
|
@ -17,7 +17,7 @@ void execute(char *input) {
|
||||
void shell_loop()
|
||||
{
|
||||
char input[256];
|
||||
int index = 0;
|
||||
size_t index = 0;
|
||||
char c;
|
||||
|
||||
while (1)
|
||||
|
@ -96,7 +96,7 @@ void terminal_clear(void) {
|
||||
update_cursor();
|
||||
}
|
||||
|
||||
static void update_cursor() {
|
||||
void update_cursor() {
|
||||
uint16_t pos = cursor_y * VGA_WIDTH + cursor_x;
|
||||
|
||||
outb(0x3D4, 0x0F);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "io.h"
|
||||
#include "isr.h"
|
||||
#include "terminal.h"
|
||||
#include "stdio.h"
|
||||
|
||||
static uint32_t tick = 0;
|
||||
|
||||
|
9
kernel/types.c
Normal file
9
kernel/types.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include "types.h"
|
||||
|
||||
// Example: Basic memory helper (unnecessary if libc exists)
|
||||
void *memset(void *dest, int value, size_t len) {
|
||||
unsigned char *ptr = (unsigned char *)dest;
|
||||
while (len-- > 0)
|
||||
*ptr++ = (unsigned char)value;
|
||||
return dest;
|
||||
}
|
62
kernel/types.h
Normal file
62
kernel/types.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
// ----------------------------
|
||||
// Fixed-width integer types
|
||||
// ----------------------------
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef signed long long int64_t;
|
||||
|
||||
// ----------------------------
|
||||
// Boolean & NULL definitions
|
||||
// ----------------------------
|
||||
#ifndef __cplusplus
|
||||
typedef enum { false = 0, true = 1 } bool;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
// ----------------------------
|
||||
// OS subsystem types
|
||||
// ----------------------------
|
||||
typedef uint32_t size_t;
|
||||
typedef int32_t ssize_t;
|
||||
|
||||
typedef uint32_t phys_addr_t; // Physical address
|
||||
typedef uint32_t virt_addr_t; // Virtual address
|
||||
|
||||
typedef uint32_t pid_t; // Process ID
|
||||
typedef uint32_t tid_t; // Thread ID
|
||||
|
||||
// ----------------------------
|
||||
// Bitfield & utility macros
|
||||
// ----------------------------
|
||||
#define BIT(n) (1U << (n))
|
||||
#define BITS(m, n) (((1U << ((n) - (m) + 1)) - 1) << (m))
|
||||
|
||||
// Align value to next multiple of alignment
|
||||
#define ALIGN_UP(val, align) (((val) + ((align)-1)) & ~((align)-1))
|
||||
#define ALIGN_DOWN(val, align) ((val) & ~((align)-1))
|
||||
|
||||
// ----------------------------
|
||||
// Attributes for structures
|
||||
// ----------------------------
|
||||
#define PACKED __attribute__((packed))
|
||||
#define ALIGN(x) __attribute__((aligned(x)))
|
||||
|
||||
// ----------------------------
|
||||
// Likely/unlikely branch hints
|
||||
// (for future optimization use)
|
||||
// ----------------------------
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
#endif // TYPES_H
|
@ -1,4 +1,6 @@
|
||||
#include "utils.h"
|
||||
#include "serial.h"
|
||||
#include "terminal.h"
|
||||
|
||||
static void reverse(char* str, int len) {
|
||||
int start = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user