mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2024-11-22 06:06:52 -08:00
Fixing the memory, adding a shell, and other minor bugs to gdt and idt and the types, also adds .github files for bug reports and feature requests.
This commit is contained in:
parent
eb7b7ff201
commit
d98d2d4292
15
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
15
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a bug report to help us improve 88os
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
If you found a bug in 88os, please provide:
|
||||
|
||||
1) A clear and concise description of what the bug is: what happened and what you expected to happen.
|
||||
2) Steps to reproduce the bug. Ideally, you would provide a small code example triggering the bug and the exact command line used to run KLEE. Please make sure the bug is still present in the mainline.
|
||||
3) The warnings and error messages issued by KLEE
|
||||
4) Any relevant information about your platform: the output of `klee --version`, OS version, environment variables, directory in which KLEE is run, etc.
|
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a feature in 88os
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. E.g., I find it difficult to use KLEE when [...]; I would find it very useful for 88os to [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
51
src/drivers/io/io.c
Normal file
51
src/drivers/io/io.c
Normal file
@ -0,0 +1,51 @@
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
Common Ports
|
||||
COM1: 0x3F8
|
||||
COM2: 0x2F8
|
||||
COM3: 0x3E8
|
||||
COM4: 0x2E8
|
||||
LPT1: 0x378
|
||||
LPT2: 0x278
|
||||
LPT3: 0x3BC
|
||||
*/
|
||||
|
||||
// Function to initialize the COM and LPT ports
|
||||
void io_init()
|
||||
{
|
||||
// TODO: Initialize the COM and LPT ports
|
||||
// Set up any necessary configuration or control operations
|
||||
}
|
||||
|
||||
// Function to read from the COM port
|
||||
char io_read_com()
|
||||
{
|
||||
// TODO: Read from the COM port
|
||||
// Use the appropriate memory or I/O address to read from the port
|
||||
// Return the read data
|
||||
}
|
||||
|
||||
// Function to write to the COM port
|
||||
void io_write_com(char data)
|
||||
{
|
||||
// TODO: Write to the COM port
|
||||
// Use the appropriate memory or I/O address to write to the port
|
||||
// Write the provided data to the port
|
||||
}
|
||||
|
||||
// Function to read from the LPT port
|
||||
char io_read_lpt()
|
||||
{
|
||||
// TODO: Read from the LPT port
|
||||
// Use the appropriate memory or I/O address to read from the port
|
||||
// Return the read data
|
||||
}
|
||||
|
||||
// Function to write to the LPT port
|
||||
void io_write_lpt(char data)
|
||||
{
|
||||
// TODO: Write to the LPT port
|
||||
// Use the appropriate memory or I/O address to write to the port
|
||||
// Write the provided data to the port
|
||||
}
|
19
src/drivers/io/io.h
Normal file
19
src/drivers/io/io.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef IO_H
|
||||
#define IO_H
|
||||
|
||||
// Function to initialize the COM and LPT ports
|
||||
void io_init();
|
||||
|
||||
// Function to read from the COM port
|
||||
char io_read_com();
|
||||
|
||||
// Function to write to the COM port
|
||||
void io_write_com(char data);
|
||||
|
||||
// Function to read from the LPT port
|
||||
char io_read_lpt();
|
||||
|
||||
// Function to write to the LPT port
|
||||
void io_write_lpt(char data);
|
||||
|
||||
#endif /* IO_H */
|
@ -1,5 +1,5 @@
|
||||
#include "gdt.h"
|
||||
|
||||
#include <string.h>
|
||||
// GDT table
|
||||
struct gdt_entry gdt[3];
|
||||
|
||||
@ -36,7 +36,7 @@ void gdt_init()
|
||||
gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
|
||||
|
||||
// Load GDT
|
||||
asm volatile("lgdt %0" : : "m"(gp));
|
||||
_asm volatile("lgdt %0" : : "m"(gp));
|
||||
}
|
||||
|
||||
// Exception handlers
|
||||
|
@ -1,9 +1,16 @@
|
||||
#include "idt.h"
|
||||
#include <string.h>
|
||||
|
||||
// IDT table
|
||||
struct idt_entry idt[256];
|
||||
|
||||
// IDT pointer
|
||||
struct idt_ptr
|
||||
{
|
||||
uint16_t limit; // Size of IDT in bytes - 1
|
||||
struct idt_entry *base; // Address of IDT
|
||||
} __attribute__((packed));
|
||||
|
||||
struct idt_ptr idtp;
|
||||
|
||||
// Exception handlers
|
||||
@ -33,7 +40,7 @@ void idt_init()
|
||||
{
|
||||
// Set up IDT pointer
|
||||
idtp.limit = sizeof(idt) - 1;
|
||||
idtp.base = (uint32_t)&idt;
|
||||
idtp.base = idt;
|
||||
|
||||
// Clear IDT
|
||||
memset(&idt, 0, sizeof(idt));
|
||||
@ -51,5 +58,5 @@ void idt_init()
|
||||
idt_set_gate(0x30, (uint32_t)device_handler, 0x08, 0x8E);
|
||||
|
||||
// Load IDT
|
||||
asm volatile("lidt %0" : : "m"(idtp));
|
||||
_asm volatile("lidt %0" : : "m"(idtp));
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
#ifndef MEMORY_H
|
||||
#define MEMORY_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void init_heap(void *start, size_t size);
|
||||
void *kmalloc(size_t size);
|
||||
void kfree(void *ptr);
|
||||
|
||||
|
@ -1,19 +1,24 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
uint32_t base;
|
||||
uint32_t limit;
|
||||
uint16_t flags;
|
||||
} gdt_entry_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t limit;
|
||||
uint32_t base;
|
||||
typedef struct
|
||||
{
|
||||
uint16_t base_lo; // Lower 16 bits of handler function address
|
||||
uint16_t selector; // Kernel segment selector
|
||||
uint8_t always0; // Always 0
|
||||
uint8_t flags; // Flags
|
||||
uint16_t base_hi; // Upper 16 bits of handler function address
|
||||
} idt_entry_t;
|
||||
|
||||
#endif /* TYPES_H */
|
@ -1,12 +1,54 @@
|
||||
#include "../include/memory.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The start of the kernel heap */
|
||||
static uint8_t *heap_start = NULL;
|
||||
|
||||
/* The end of the kernel heap */
|
||||
static uint8_t *heap_end = NULL;
|
||||
|
||||
/* The current position of the heap */
|
||||
static uint8_t *heap_pos = NULL;
|
||||
|
||||
/* The size of the heap */
|
||||
static size_t heap_size = 0;
|
||||
|
||||
void init_heap(void *start, size_t size)
|
||||
{
|
||||
heap_start = (uint8_t *)start;
|
||||
heap_end = heap_start + size;
|
||||
heap_pos = heap_start;
|
||||
heap_size = size;
|
||||
}
|
||||
|
||||
void *kmalloc(size_t size)
|
||||
{
|
||||
/* TODO: Implement memory allocation */
|
||||
return NULL;
|
||||
/* Round up the size to a multiple of 4 bytes */
|
||||
size = (size + 3) & ~3;
|
||||
|
||||
/* Check if there is enough space in the heap */
|
||||
if (heap_pos + size > heap_end)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Allocate memory from the heap */
|
||||
void *ptr = heap_pos;
|
||||
heap_pos += size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void kfree(void *ptr)
|
||||
{
|
||||
/* TODO: Implement memory deallocation */
|
||||
/* Check if the pointer is within the heap */
|
||||
if ((uint8_t *)ptr >= heap_start && ptr < (void *)heap_end)
|
||||
{
|
||||
/* Zero out the memory */
|
||||
memset(ptr, 0, (uint8_t *)heap_pos - (uint8_t *)ptr);
|
||||
|
||||
/* Free the memory by moving the heap position */
|
||||
heap_pos = (uint8_t *)ptr;
|
||||
}
|
||||
}
|
32
src/shell/shell.c
Normal file
32
src/shell/shell.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include "shell.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void shell_loop()
|
||||
{
|
||||
char input[256];
|
||||
|
||||
while (1)
|
||||
{
|
||||
printf("> ");
|
||||
fgets(input, sizeof(input), stdin);
|
||||
|
||||
// Remove newline character from input
|
||||
input[strcspn(input, "\n")] = '\0';
|
||||
|
||||
// Parse input and execute commands
|
||||
// ...
|
||||
|
||||
// Exit the shell if the user enters "exit"
|
||||
if (strcmp(input, "exit") == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
shell_loop();
|
||||
return 0;
|
||||
}
|
13
src/shell/shell.h
Normal file
13
src/shell/shell.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef SHELL_H
|
||||
#define SHELL_H
|
||||
|
||||
// Function to read user input
|
||||
char *read_input();
|
||||
|
||||
// Function to parse user input
|
||||
char **parse_input(char *input);
|
||||
|
||||
// Function to execute a command
|
||||
int execute_command(char **args);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user