add very minimal demo menu
This commit is contained in:
@ -22,8 +22,8 @@ Keyboard kb; // Tastatur
|
|||||||
PCSPK pcspk; // PC-Lautsprecher
|
PCSPK pcspk; // PC-Lautsprecher
|
||||||
|
|
||||||
// BumpAllocator allocator;
|
// BumpAllocator allocator;
|
||||||
// LinkedListAllocator allocator;
|
LinkedListAllocator allocator;
|
||||||
TreeAllocator allocator;
|
// TreeAllocator allocator;
|
||||||
Scheduler scheduler;
|
Scheduler scheduler;
|
||||||
|
|
||||||
unsigned int total_mem; // RAM total
|
unsigned int total_mem; // RAM total
|
||||||
|
|||||||
@ -36,8 +36,8 @@ extern Keyboard kb; // Tastatur
|
|||||||
extern PCSPK pcspk; // PC-Lautsprecher
|
extern PCSPK pcspk; // PC-Lautsprecher
|
||||||
|
|
||||||
// extern BumpAllocator allocator;
|
// extern BumpAllocator allocator;
|
||||||
// extern LinkedListAllocator allocator;
|
extern LinkedListAllocator allocator;
|
||||||
extern TreeAllocator allocator;
|
// extern TreeAllocator allocator;
|
||||||
extern Scheduler scheduler;
|
extern Scheduler scheduler;
|
||||||
|
|
||||||
constexpr bool DEBUG = true;
|
constexpr bool DEBUG = true;
|
||||||
|
|||||||
@ -67,12 +67,6 @@
|
|||||||
#define FST_ALLOCABLE_PAGE 0x202000
|
#define FST_ALLOCABLE_PAGE 0x202000
|
||||||
#define LST_ALLOCABLE_PAGE 0x2FF000
|
#define LST_ALLOCABLE_PAGE 0x2FF000
|
||||||
|
|
||||||
// Externe Funktionen in startup.asm
|
|
||||||
extern "C" {
|
|
||||||
void paging_on(unsigned int* p_pdir); // Paging einschalten
|
|
||||||
void invalidate_tlb_entry(unsigned int* ptr); // Page in TLB invalid.
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Funktion: pg_alloc_page *
|
* Funktion: pg_alloc_page *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
|
|||||||
@ -52,6 +52,12 @@
|
|||||||
#ifndef __Paging_include__
|
#ifndef __Paging_include__
|
||||||
#define __Paging_include__
|
#define __Paging_include__
|
||||||
|
|
||||||
|
// Externe Funktionen in startup.asm
|
||||||
|
extern "C" {
|
||||||
|
void paging_on(unsigned int* p_pdir); // Paging einschalten
|
||||||
|
void invalidate_tlb_entry(unsigned int* ptr); // Page in TLB invalid.
|
||||||
|
}
|
||||||
|
|
||||||
// ativiert paging
|
// ativiert paging
|
||||||
extern void pg_init();
|
extern void pg_init();
|
||||||
|
|
||||||
|
|||||||
65
c_os/main.cc
65
c_os/main.cc
@ -13,10 +13,17 @@
|
|||||||
#include "kernel/Globals.h"
|
#include "kernel/Globals.h"
|
||||||
#include "kernel/Paging.h"
|
#include "kernel/Paging.h"
|
||||||
#include "kernel/threads/IdleThread.h"
|
#include "kernel/threads/IdleThread.h"
|
||||||
|
#include "lib/Input.h"
|
||||||
|
#include "user/BlueScreenDemo.h"
|
||||||
#include "user/CoopThreadDemo.h"
|
#include "user/CoopThreadDemo.h"
|
||||||
|
#include "user/HeapDemo.h"
|
||||||
#include "user/HelloWorldThread.h"
|
#include "user/HelloWorldThread.h"
|
||||||
|
#include "user/KeyboardDemo.h"
|
||||||
|
#include "user/KeyIRQDemo.h"
|
||||||
#include "user/PCSPKdemo.h"
|
#include "user/PCSPKdemo.h"
|
||||||
#include "user/PreemptiveThreadDemo.h"
|
#include "user/PreemptiveThreadDemo.h"
|
||||||
|
#include "user/SoundDemo.h"
|
||||||
|
#include "user/TextDemo.h"
|
||||||
#include "user/VBEdemo.h"
|
#include "user/VBEdemo.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@ -54,39 +61,45 @@ int main() {
|
|||||||
// This has to happen after the allocator is initialized but before the scheduler is started
|
// This has to happen after the allocator is initialized but before the scheduler is started
|
||||||
pg_init();
|
pg_init();
|
||||||
|
|
||||||
// TODO: Move this to demo
|
kout << "Demos:\n"
|
||||||
// Trigger Bluescreen
|
<< "1 - VBEdemo\n"
|
||||||
// kout << "Trigger Bluescreen, if you can read this it didn't work" << endl;
|
<< "2 - PCSPKdemo\n"
|
||||||
|
<< "3 - PreemptiveThreadDemo\n"
|
||||||
|
<< "4 - BlueScreenDemo\n"
|
||||||
|
<< "5 - HeapDemo\n"
|
||||||
|
<< "6 - KeyboardDemo\n"
|
||||||
|
<< "7 - TextDemo" << endl;
|
||||||
|
|
||||||
// BlueScreen 1
|
char input = getch();
|
||||||
// asm("int $3");
|
switch (input) {
|
||||||
|
case '1':
|
||||||
// BlueScreen 2
|
scheduler.ready(new VBEdemo()); // Switch to VESA graphics mode
|
||||||
// unsigned int* page = pg_alloc_page();
|
break;
|
||||||
// *page = 42;
|
case '2':
|
||||||
// pg_write_protect_page(page);
|
scheduler.ready(new PCSPKdemo());
|
||||||
// invalidate_tlb_entry(page); // If we don't invalidate after first access the write protection
|
break;
|
||||||
// // won't work as no lookup is performed (address in tlb)
|
case '3':
|
||||||
// *page = 42; // We map logical to physical 1:1 so no need to do any lookup
|
scheduler.ready(new PreemptiveThreadDemo());
|
||||||
// // If tlb is invalidated this access produces a pagefault
|
break;
|
||||||
|
case '4':
|
||||||
// TODO: Make menu for demos
|
bluescreen_demo();
|
||||||
// Demo threads anlegen
|
break;
|
||||||
|
case '5':
|
||||||
|
heap_demo();
|
||||||
|
break;
|
||||||
|
case '6':
|
||||||
|
keyboard_demo();
|
||||||
|
break;
|
||||||
|
case '7':
|
||||||
|
text_demo();
|
||||||
|
break;
|
||||||
|
}
|
||||||
// scheduler.ready(new HelloWorldThread());
|
// scheduler.ready(new HelloWorldThread());
|
||||||
// scheduler.ready(new CoopThreadDemo());
|
// scheduler.ready(new CoopThreadDemo());
|
||||||
// scheduler.ready(new VBEdemo()); // Switch to VESA graphics mode
|
|
||||||
// scheduler.ready(new PCSPKdemo());
|
|
||||||
scheduler.ready(new PreemptiveThreadDemo());
|
|
||||||
|
|
||||||
// Scheduler starten (schedule() erzeugt den Idle-Thread)
|
// Scheduler starten (schedule() erzeugt den Idle-Thread)
|
||||||
scheduler.schedule();
|
scheduler.schedule();
|
||||||
|
|
||||||
// TODO: Use templates for queue so threads don't have to be casted down from chain
|
|
||||||
// TODO: Change scheduler to only use references instead of pointers
|
|
||||||
// TODO: Rewrite all demos to threads
|
|
||||||
// TODO: Unify debug output format
|
|
||||||
// TODO: Serial output, output graphviz dot data for memory etc.
|
|
||||||
|
|
||||||
// Scheduler doesn't return
|
// Scheduler doesn't return
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
21
c_os/user/BlueScreenDemo.cc
Normal file
21
c_os/user/BlueScreenDemo.cc
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "user/BlueScreenDemo.h"
|
||||||
|
#include "kernel/Globals.h"
|
||||||
|
#include "kernel/Paging.h"
|
||||||
|
|
||||||
|
void bluescreen_demo() {
|
||||||
|
|
||||||
|
// Trigger Bluescreen
|
||||||
|
kout << "Trigger Bluescreen, if you can read this it didn't work" << endl;
|
||||||
|
|
||||||
|
// BlueScreen 1
|
||||||
|
// asm("int $3");
|
||||||
|
|
||||||
|
// BlueScreen 2
|
||||||
|
unsigned int* page = pg_alloc_page();
|
||||||
|
*page = 42;
|
||||||
|
pg_write_protect_page(page);
|
||||||
|
invalidate_tlb_entry(page); // If we don't invalidate after first access the write protection
|
||||||
|
// won't work as no lookup is performed (address in tlb)
|
||||||
|
*page = 42; // We map logical to physical 1:1 so no need to do any lookup
|
||||||
|
// If tlb is invalidated this access produces a pagefault
|
||||||
|
}
|
||||||
6
c_os/user/BlueScreenDemo.h
Normal file
6
c_os/user/BlueScreenDemo.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __BluescreenDemo_Include_H_
|
||||||
|
#define __BluescreenDemo_Include_H_
|
||||||
|
|
||||||
|
void bluescreen_demo();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user