Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
refactor: Nouvelle architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainTHD committed Oct 26, 2020
1 parent 86661bf commit aa90f7b
Show file tree
Hide file tree
Showing 67 changed files with 367 additions and 368 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
*.c text diff=c linguist-language=c
*.cpp text diff=cpp linguist-language=c++
*.hpp text diff=cpp linguist-language=c++
*.h text diff=c linguist-language=c
*.h text diff=cpp linguist-language=c++
libc/include/* text diff=cpp linguist-language=c++

# Documentation
*.md text
Expand Down
Binary file modified bin/OS/RomainOS.bin
Binary file not shown.
Binary file modified bin/OS/RomainOS.iso
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@ readDisk:
mov cl, 0x02

diskReadLoop:
; push ax
; push bx
; push cx
; push dx

; Interruption BIOS pour lire
int 0x13

; pop dx
; pop cx
; pop bx
; pop ax

; Bon, l'avenir nous dira si ce code était une erreur ou non...
; Jmp if carry set (= erreur disque)
jc diskReadExit
; Autre possibilité:
; jc diskReadError

; Écriture des 512 bytes suivants
add bx, 512
; Lecture secteur suivant
inc cx

; limite de 255 secteurs
cmp cl, 255
je diskReadExit

jmp diskReadLoop
; push ax
; push bx
; push cx
; push dx

; Interruption BIOS pour lire
int 0x13

; pop dx
; pop cx
; pop bx
; pop ax

; Bon, l'avenir nous dira si ce code était une erreur ou non...
; Jmp if carry set (= erreur disque)
jc diskReadExit
; Autre possibilité:
; jc diskReadError

; Écriture des 512 bytes suivants
add bx, 512
; Lecture secteur suivant
inc cx

; limite de 255 secteurs
cmp cl, 255
je diskReadExit

jmp diskReadLoop

diskReadExit:
; pop dx
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
; Fichier généré automatiquement.
; La valeur est calculée selon l'espace occupé par le fichier binaire final.
mov al, 33
mov al, 42
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions include/std/io/IO.hpp

This file was deleted.

18 changes: 9 additions & 9 deletions src/std/io/IDT.cpp → kernel/IDT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
// Created by Romain on 14/09/2020.

#include <io/IDT.hpp>
#include "IDT.hpp"

/**
* Routine assembleur keyboard
Expand All @@ -16,14 +16,14 @@ extern u64 _isr1;
/**
* IDT
*/
extern std::io::idt::IDT64 _idt[256];
extern idt::IDT64 _idt[256];

/**
* Active les IDT
*/
extern "C" void _loadIDT();

namespace std::io::idt {
namespace idt {
/**
* Initialise les interruptions
*/
Expand All @@ -43,8 +43,8 @@ namespace std::io::idt {
// remapPIC();

// Reprogramme la puce PIC (Programmable Interface Controllers)
outb(0x21, 0xfd);
outb(0xa1, 0xff);
stdio::outb(0x21, 0xfd);
stdio::outb(0xa1, 0xff);

_loadIDT();
}
Expand All @@ -54,12 +54,12 @@ namespace std::io::idt {
*/
extern "C" void isr1Handler() {
// Lit depuis le port clavier
byte b = inb(0x60);
byte b = stdio::inb(0x60);

// Signifie au PIC que l'interruption est terminée
outb(0x20, 0x20);
outb(0xa0, 0x20);
stdio::outb(0x20, 0x20);
stdio::outb(0xa0, 0x20);

std::io::keyboard::_notifyEvent(b);
stdio::keyboard::_notifyEvent(b);
}
}
7 changes: 3 additions & 4 deletions include/std/io/IDT.hpp → kernel/IDT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#ifndef ROMAINOS_IDT_HPP
#define ROMAINOS_IDT_HPP

#include <types.hpp>
#include <cstdint>
#include <cstdio>

#include "keyboard.hpp"

namespace std::io::idt {
namespace idt {
/**
* Interrupt Descriptor Tables
*/
Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions kernel/kernel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 08/09/2020.

#include <cstdlib>
#include <cstdio>

#include "IDT.hpp"
#include "system.hpp"

extern int main();

/**
* Point d'entrée de l'OS
*/
extern "C" void _start() {
stdio::clearScreen();
stdio::setCursorPosition(0, 0);
idt::initIDT();
stdlib::initHeap(0x100000, 0x100000);

stdio::keyboard::addEventHandler([](stdio::keyboard::KeyEvent e) {
if (e.keyCode == stdio::keyboard::VK_ESC) {
std::system::shutdownAndPrint();
}
});

main();
}
29 changes: 29 additions & 0 deletions kernel/system.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 26/09/2020.

#include "system.hpp"

extern "C" void _exit();

namespace std::system {
void shutdown() {
stdio::outw(0x604, 0x2000); // Qemu
stdio::outw(0x4004, 0x3400); // VBox
stdio::outw(0xB004, 0x2000); // Boshs

_exit();
}

void shutdownAndPrint() {
stdio::setCursorPosition(-1, 0);
stdio::printString("Fin du programme...");

time::sleep(1);

shutdown();

stdio::setCursorPosition(-1, 0);
stdio::printString("Erreur lors de la sortie de l'emulateur !");
time::sleep(1);
}
}
7 changes: 4 additions & 3 deletions include/std/system.hpp → kernel/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#ifndef ROMAINOS_SYSTEM_HPP
#define ROMAINOS_SYSTEM_HPP

#include <io/rawIO.hpp>
#include <io/printText.hpp>
#include <time.hpp>
#include <cstdio>
#include <cstdlib>

#include "../libc/stdio/rawIO.hpp"

namespace std::system {
/**
Expand Down
1 change: 1 addition & 0 deletions libc/include/cstddef
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "./stddef.h"
1 change: 1 addition & 0 deletions libc/include/cstdint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "./stdint.h"
1 change: 1 addition & 0 deletions libc/include/cstdio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "./stdio.h"
1 change: 1 addition & 0 deletions libc/include/cstdlib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "./stdlib.h"
10 changes: 5 additions & 5 deletions include/std/random.hpp → libc/include/random.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 18/09/2020.

#ifndef ROMAINOS_RANDOM_HPP
#define ROMAINOS_RANDOM_HPP
#ifndef ROMAINOS_RANDOM_H
#define ROMAINOS_RANDOM_H

#include <types.hpp>
#include <cstdint>

namespace std::random {
namespace random {
/**
* Rand max exclus
*/
Expand Down Expand Up @@ -61,4 +61,4 @@ namespace std::random {
u64 getSeed();
}

#endif //ROMAINOS_RANDOM_HPP
#endif //ROMAINOS_RANDOM_H
1 change: 1 addition & 0 deletions libc/include/stack
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "./stack.h"
10 changes: 5 additions & 5 deletions include/std/stack.hpp → libc/include/stack.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 11/09/2020.

#ifndef ROMAINOS_STACK_HPP
#define ROMAINOS_STACK_HPP
#ifndef ROMAINOS_STACK_H
#define ROMAINOS_STACK_H

#include <types.hpp>
#include <cstdint>

/**
* Stack
Expand Down Expand Up @@ -99,6 +99,6 @@ class Stack {
size_t _length;
};

#include "../../src/std/stack.tpp"
#include "../stack.tpp"

#endif //ROMAINOS_STACK_HPP
#endif //ROMAINOS_STACK_H
21 changes: 21 additions & 0 deletions libc/include/stddef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 25/10/2020.

#ifndef ROMAINOS_STDDEF_H
#define ROMAINOS_STDDEF_H

#define NULL ((char*) 0)

namespace stddef {
/**
* Si la variable est un pointeur ou non
*
* @tparam T Type
*
* @return Pointeur ou non
*/
template<typename T>
bool isPointer(T);
}

#endif //ROMAINOS_STDDEF_H
20 changes: 4 additions & 16 deletions include/std/types.hpp → libc/include/stdint.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 09/09/2020.
// Created by Romain on 25/10/2020.

#ifndef ROMAINOS_TYPES_CPP
#define ROMAINOS_TYPES_HPP
#ifndef ROMAINOS_STDINT_H
#define ROMAINOS_STDINT_H

/**
* Variable d'entrée
Expand Down Expand Up @@ -152,16 +152,4 @@ typedef uint8_t byte;
*/
typedef uint32_t size_t;

namespace std::types {
/**
* Si la variable est un pointeur ou non
*
* @tparam T Type
*
* @return Pointeur ou non
*/
template<typename T>
bool isPointer(T);
}

#endif //ROMAINOS_TYPES_CPP
#endif //ROMAINOS_STDINT_H
13 changes: 13 additions & 0 deletions libc/include/stdio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 25/10/2020.

#ifndef ROMAINOS_STDIO_H
#define ROMAINOS_STDIO_H

#include "../stdio/keyboard.hpp"
#include "../stdio/keyboardLayout.hpp"
#include "../stdio/printText.hpp"
#include "../stdio/textColorModes.hpp"
#include "../stdio/rawIO.hpp"

#endif //ROMAINOS_STDIO_H
12 changes: 12 additions & 0 deletions libc/include/stdlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Created by Romain on 25/10/2020.

#ifndef ROMAINOS_STDLIB_H
#define ROMAINOS_STDLIB_H

#include "../stdlib/memory.hpp"
#include "../stdlib/memoryMap.hpp"
#include "random.h"
#include "time.h"

#endif //ROMAINOS_STDLIB_H
1 change: 1 addition & 0 deletions libc/include/string
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "./string.h"
6 changes: 3 additions & 3 deletions include/std/string.hpp → libc/include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef ROMAINOS_STRING_HPP
#define ROMAINOS_STRING_HPP

#include <types.hpp>
#include <stack.hpp>
#include <stdint.h>
#include <stack>

/**
* Récupère la taille d'une string
Expand Down Expand Up @@ -113,6 +113,6 @@ const char* intToString(T* value);
template <typename T>
const char* floatToString(T value, u8 decimalPlaces = 3);

#include "../../src/std/string.tpp"
#include "../string/string.tpp"

#endif //ROMAINOS_STRING_HPP
Loading

0 comments on commit aa90f7b

Please sign in to comment.