real-hw-fix #16

Merged
xamidev merged 5 commits from real-hw-fix into main 2026-03-20 16:58:08 +01:00
5 changed files with 44 additions and 24 deletions
Showing only changes of commit 03f87723d1 - Show all commits

View File

@@ -11,7 +11,14 @@
#define PEPPEROS_VERSION_MAJOR "0" #define PEPPEROS_VERSION_MAJOR "0"
#define PEPPEROS_VERSION_MINOR "0" #define PEPPEROS_VERSION_MINOR "0"
#define PEPPEROS_VERSION_PATCH "58" #define PEPPEROS_VERSION_PATCH "58"
#define PEPPEROS_SPLASH "\x1b[38;5;196mPepperOS\x1b[0m version \x1b[38;5;220m"PEPPEROS_VERSION_MAJOR"."PEPPEROS_VERSION_MINOR"."PEPPEROS_VERSION_PATCH"\x1b[0m built on \x1b[38;5;40m"__DATE__" "__TIME__"\x1b[0m\n" #define PEPPEROS_SPLASH \
"\x1b[38;5;196m \x1b[38;5;231m____ _____\r\n\x1b[0m"\
"\x1b[38;5;196m ____ ___ ____ ____ ___ _____\x1b[38;5;231m/ __ \\/ ___/\r\n\x1b[0m"\
"\x1b[38;5;196m / __ \\/ _ \\/ __ \\/ __ \\/ _ \\/ ___\x1b[38;5;231m/ / / /\\__ \\ \r\n\x1b[0m"\
"\x1b[38;5;196m / /_/ / __/ /_/ / /_/ / __/ / \x1b[38;5;231m/ /_/ /___/ / \r\n\x1b[0m"\
"\x1b[38;5;196m / .___/\\___/ .___/ .___/\\___/_/ \x1b[38;5;231m\\____//____/ \r\n\x1b[0m"\
"\x1b[38;5;196m/_/ /_/ /_/ \r\n\x1b[0m"\
" --- version \x1b[38;5;220m"PEPPEROS_VERSION_MAJOR"."PEPPEROS_VERSION_MINOR"."PEPPEROS_VERSION_PATCH"\x1b[0m built on \x1b[38;5;40m"__DATE__" "__TIME__"\x1b[0m\r\n"
/* process */ /* process */
#define PROCESS_NAME_MAX 64 #define PROCESS_NAME_MAX 64

View File

@@ -5,14 +5,15 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <stddef.h>
/* /*
* cpuid - Wrapper for CPUID instruction * cpuid - Wrapper for CPUID instruction
* @leaf: Requested leaf * @leaf: Requested leaf (input EAX)
* @eax: EAX register value * @eax: EAX register value (output)
* @ebx: EBX register value * @ebx: EBX register value (output)
* @ecx: ECX register value * @ecx: ECX register value (output)
* @edx: EDX register value * @edx: EDX register value (output)
*/ */
void cpuid(uint32_t leaf, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) void cpuid(uint32_t leaf, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx)
{ {

View File

@@ -4,10 +4,30 @@
* @license GPL-3.0-only * @license GPL-3.0-only
*/ */
#include <mem/gdt.h>
#include <stdint.h> #include <stdint.h>
#include <arch/x86.h> #include <arch/x86.h>
#include <kernel.h> #include <kernel.h>
/*
* x86_overwrite_pat - Set PAT to WC
*
* This function overwrites the 1st Page Attribute
* Table entry, to enable the Write-Combining property
* when we map memory regions later on.
* The framebuffer will be mapped with WC, which makes
* memory access significantly faster by using burst
* operations.
*/
static void x86_overwrite_pat()
{
uint64_t pat = rdmsr(0x277);
pat &= ~(0xFFULL << 8); // Clear PAT1
pat |= (0x01ULL << 8); // PAT1 = 0x01 (WC)
wrmsr(0x277, pat);
}
/* /*
* x86_arch_init - Initialize x86 CPU structures * x86_arch_init - Initialize x86 CPU structures
* *
@@ -20,9 +40,7 @@
*/ */
void x86_arch_init() void x86_arch_init()
{ {
uint64_t pat = rdmsr(0x277); x86_overwrite_pat();
pat &= ~(0xFFULL << 8); // Clear PAT1 idt_init();
pat |= (0x01ULL << 8); // PAT1 = 0x01 (WC) gdt_init();
wrmsr(0x277, pat);
DEBUG("Overrode PAT1 entry to set up Write-Combining");
} }

View File

@@ -69,7 +69,7 @@ struct process_t* idle_proc;
// Never gets executed although pedicel is scheduled? // Never gets executed although pedicel is scheduled?
void pedicel_main(void* arg) void pedicel_main(void* arg)
{ {
printf("\n\nWelcome to PepperOS! Pedicel speaking.\r\nNothing left to do, let's go idle!\r\n"); printf("\n\n\rWelcome to PepperOS! Pedicel speaking.\r\nNothing left to do, let's go idle!\r\n");
} }
void idle_main(void* arg) void idle_main(void* arg)
@@ -81,11 +81,10 @@ void idle_main(void* arg)
void thing_main(void* arg) void thing_main(void* arg)
{ {
/* printf("What's your name, pal? "); printf("What's your name, pal? ");
char name[10]; char name[10];
keyboard_getline(name, 10); keyboard_getline(name, 10);
printf("\r\n{%s} is such a nice name!\r\n", name); */ printf("\r\n{%s} is such a nice name!\r\n", name);
while (ticks < 500);
} }
extern uintptr_t kheap_start; extern uintptr_t kheap_start;
@@ -118,23 +117,18 @@ void kmain()
boot_mem_display(); boot_mem_display();
pmm_init(boot_ctx); pmm_init(boot_ctx);
// Remap kernel , HHDM and framebuffer
paging_init(boot_ctx); paging_init(boot_ctx);
kheap_init(); kheap_init();
keyboard_init(FR); keyboard_init(FR);
gdt_init();
idt_init();
process_init(); process_init();
idle_proc = process_create("idle", (void*)idle_main, 0); idle_proc = process_create("idle", (void*)idle_main, 0);
struct process_t* pedicel = process_create("pedicel", (void*)pedicel_main, 0); process_create("pedicel", (void*)pedicel_main, 0);
process_create("thing", thing_main, NULL); process_create("thing", thing_main, NULL);
process_display_list(processes_list);
scheduler_init(); scheduler_init();
kputs(PEPPEROS_SPLASH); printf(PEPPEROS_SPLASH);
idle(); idle();
} }

View File

@@ -64,9 +64,9 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
return idle_proc->context; return idle_proc->context;
} else { } else {
current_process->status = RUNNING; current_process->status = RUNNING;
if (prev_process != current_process) { /* if (prev_process != current_process) {
DEBUG("Changed from {pid=%u, name=%s} to {pid=%u, name=%s}", prev_process->pid, prev_process->name, current_process->pid, current_process->name); DEBUG("Changed from {pid=%u, name=%s} to {pid=%u, name=%s}", prev_process->pid, prev_process->name, current_process->pid, current_process->name);
} } */
break; break;
} }
} }