From cbe008ef67223d1e6de2178f5ba33fc10b43804d Mon Sep 17 00:00:00 2001
From: gilles grimaud <gilles.grimaud@univ-lille.fr>
Date: Wed, 11 Jan 2023 08:50:41 +0100
Subject: [PATCH] main without mmu

---
 src/main.c | 76 +++++-------------------------------------------------
 1 file changed, 7 insertions(+), 69 deletions(-)

diff --git a/src/main.c b/src/main.c
index 972ac65..5bc5065 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,98 +1,36 @@
+#include "ioport.h"
 #include "gdt.h"
 #include "idt.h"
 #include "minilib.h"
-#include "mmu.h"
-#include "ioport.h"
-#include "syscalls.h"
-
-extern void user(void);
-extern void app_main(void);
 
 void empty_irq(int_regs_t *r) {
 }
 
-void syscall_handler(int_regs_t *r) {
-    switch(r->eax) {
-	    case SYSCALL_PUTC:
-		    putc(r->edi);
-		    break;
-	    default:
-		    puts("unhandled syscall\n");
-		    break;
-    };
-}
-
-static struct pte_s my_page_table[PT_SIZE] __attribute__((aligned (PAGE_SIZE)));
-
-void fault_handler(int_regs_t *r) {
-	puts("page fault! fault address=");
-	puthex(get_fault_address());
-	puts("\n");
-
-	/* Example: allow access to 0x800000 */	
-	int fault_page = get_fault_address() >> 12;
-	if (fault_page == 0x800) {
-		puts("Add page mapping...\n");
-		memset(my_page_table, 0, sizeof(my_page_table));
-		
-		my_page_table[0].g = 0; /* page locale */
-                my_page_table[0].pat = 0;
-                my_page_table[0].d = 0;
-                my_page_table[0].a = 0;
-                my_page_table[0].pcd = 0; /* cache activé */
-                my_page_table[0].pwt = 0; /* cache write back */
-                my_page_table[0].us = 1; /* page user */
-                my_page_table[0].rw = 1; /* page read write */
-                my_page_table[0].p = 1; /* entrée présente */
-                my_page_table[0].address = 0x800; /* map to physical page 0x800 */
-                my_page_table[0].unused1 = 0;
-		setup_page_table(2 /* our page table will map vpages starting at 2*0x400 == 0x800 to 0xBFF */ , my_page_table);
-		/* so my_page_table[0] represents vpage 0x800, which will be mapped to ppage 0x800 */
-
-		flush_tlb();
-
-		return;
-	}
-	for(;;);
-}
-
 /* multiboot entry-point with datastructure as arg. */
 void main(unsigned int * mboot_info)
 {
     /* clear the screen */
     clear_screen();
     puts("Early boot.\n"); 
-
-    /* Initialize the memory */
     puts("\t-> Setting up the GDT... ");
     gdt_init_default();
     puts("OK\n");
 
-    /* Initializa the Interrupt Descriptor Table */
     puts("\t-> Setting up the IDT... ");
     setup_idt();
     puts("OK\n");
 
-    puts("\t-> Setting up the MMU... ");
-    setup_mmu();
-    puts("OK\n");
+    puts("\n\n");
 
-    /* Installs two empty handlers for the timer (0) and the keyboard (1) */
-    idt_setup_irq_handler(0, empty_irq);
-    idt_setup_irq_handler(1, empty_irq);
-    
-    idt_setup_int_handler(87, syscall_handler);
-    idt_setup_int_handler(14, fault_handler);
+    idt_setup_int_handler(0, empty_irq);
+    idt_setup_int_handler(1, empty_irq);
 
-    /* Enables interrupts */ 
     __asm volatile("sti");
 
     /* minimal setup done ! */
-    app_main();
-
-    puts("\t-> Switching to user-mode... ");
-    user(); /* switch to user-mode and calls user_entry() in user.c */
-}
 
 
+    puts("Going idle\n");
+    for(;;) ; /* nothing more to do... really nothing ! */
+}
 
-- 
GitLab