diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-07-28 14:19:00 +0400 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-07-28 14:19:00 +0400 |
| commit | e0c565f7ff7620dca9dfc6c607f4798f5291c7bf (patch) | |
| tree | c18099687db0202e32ae47f4c991b895191f030e /kernel/Helpers | |
| parent | aac010a9e30e479968e277ebdaf41ad366a77098 (diff) | |
Diffstat (limited to 'kernel/Helpers')
| -rw-r--r-- | kernel/Helpers/Makefile | 14 | ||||
| -rw-r--r-- | kernel/Helpers/globalVars.hpp | 0 | ||||
| -rw-r--r-- | kernel/Helpers/memPrint.hpp | 81 | ||||
| -rw-r--r-- | kernel/Helpers/memory.c (renamed from kernel/Helpers/memory.cpp) | 4 | ||||
| -rw-r--r-- | kernel/Helpers/memory.h (renamed from kernel/Helpers/memory.hpp) | 2 | ||||
| -rw-r--r-- | kernel/Helpers/memprint.c (renamed from kernel/Helpers/memPrint.cpp) | 70 | ||||
| -rw-r--r-- | kernel/Helpers/memprint.h | 59 | ||||
| -rw-r--r-- | kernel/Helpers/types.h (renamed from kernel/Helpers/types.hpp) | 0 |
8 files changed, 97 insertions, 133 deletions
diff --git a/kernel/Helpers/Makefile b/kernel/Helpers/Makefile index 76805bd..a813312 100644 --- a/kernel/Helpers/Makefile +++ b/kernel/Helpers/Makefile @@ -1,23 +1,23 @@ EXEC=helpers.o - all:$(EXEC) #----- Helpers ----- -$(EXEC): memory.o memPrint.o - ld -m elf_i386 -r -o $(EXEC) $^ +$(EXEC): memory.o memprint.o +# ld -m elf_i386 -r -o $(EXEC) $^ + ar -r -o $(EXEC) $^ #--------------- #----- Memory ----- -memory.o: memory.cpp memory.hpp - $(CXX) -c -o $@ $< +memory.o: memory.c memory.h + $(CC) $(CFLAGS) -c -o $@ $< #------------------ #----- memPrint ----- -memPrint.o: memPrint.cpp memPrint.hpp - $(CXX) -c -o $@ $< +memprint.o: memprint.c memprint.h + $(CC) $(CFLAGS) -c -o $@ $< #------------------- diff --git a/kernel/Helpers/globalVars.hpp b/kernel/Helpers/globalVars.hpp deleted file mode 100644 index e69de29..0000000 --- a/kernel/Helpers/globalVars.hpp +++ /dev/null diff --git a/kernel/Helpers/memPrint.hpp b/kernel/Helpers/memPrint.hpp deleted file mode 100644 index 19a6708..0000000 --- a/kernel/Helpers/memPrint.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef __memPrint__ -#define __memPrint__ - -#include "./types.hpp" - - -#define MEMPRINTSTARTADR 0xB8000 -#define MAXCURSORX 80 -#define MAXCURSORY 25 - - - - -//Define the bios color -enum colorBios{ - - BLACK=0x0, - BLUE=0x1, - GREEN=0x2, - CYAN=0x3, - RED=0x4, - MAGENTA=0x5, - BROWN=0x6, - LIGHTGRAY=0x7, - DARKGRAY=0x8, - LIGHTBLUE=0x9, - LIGHTGREEN=0xA, - LIGHTCYAN=0xB, - LIGHTRED=0xC, - LIGHTMAGENTA=0xD, - YELLOW=0xE, - WHITE=0xF - -}; - -//Type def for biosColor -typedef enum colorBios colorBios; - - -//Class to print char on screen using Video Ram mapping -class memPrint{ - - private: - - //Cursor position - u8 m_cursorX; - u8 m_cursorY; - - //Current colors (background and foreground): - u8 m_colors; - - //Methods - void updateCursor(); - - public: - - //Constructor - memPrint(); - - //Destructor - ~memPrint(); - - //Set color - void setBackground(colorBios color); - void setForeground(colorBios color); - - //Putchar - void putChar(u8 character); - - //Print - void print(char *str); - - //Scroll up - void scrollUp(u8 number); - - //Clear screen - void clear(); - -}; - -#endif diff --git a/kernel/Helpers/memory.cpp b/kernel/Helpers/memory.c index 8ace044..44c0e90 100644 --- a/kernel/Helpers/memory.cpp +++ b/kernel/Helpers/memory.c @@ -1,5 +1,5 @@ -#include "./memory.hpp" -#include "./types.hpp" +#include "./memory.h" +#include "./types.h" //Fonction to copy data into memory int memcpy(u32 source, u32 dest, u32 size){ diff --git a/kernel/Helpers/memory.hpp b/kernel/Helpers/memory.h index ddc522c..5f399db 100644 --- a/kernel/Helpers/memory.hpp +++ b/kernel/Helpers/memory.h @@ -1,7 +1,7 @@ #ifndef __memory__ #define __memory__ -#include "./types.hpp" +#include "./types.h" //Fonction to copy data into memory int memcpy(u32 source, u32 dest, u32 size); diff --git a/kernel/Helpers/memPrint.cpp b/kernel/Helpers/memprint.c index 179b821..83eb8de 100644 --- a/kernel/Helpers/memPrint.cpp +++ b/kernel/Helpers/memprint.c @@ -1,50 +1,36 @@ -#include "./memPrint.hpp" +#include "./memprint.h" +//Define global vars +u8 MEMPRINT_CURSORX=0; +u8 MEMPRINT_CURSORY=0; +u8 MEMPRINT_COLORS=0x0F; -//Constructor -memPrint::memPrint(){ - - //Initialise position - this->m_cursorX=0; - this->m_cursorY=0; - - //Initialise color - this->setBackground(BLACK); - this->setForeground(WHITE); - -} - -//Destructor -memPrint::~memPrint(){ - -} - //Move cursor -void memPrint::updateCursor(){ +void memprint_updateCursor(){ //Update X axis - this->m_cursorX++; + MEMPRINT_CURSORX++; //Check X value - if(this->m_cursorX >= MAXCURSORX){ + if(MEMPRINT_CURSORX >= MAXCURSORX){ //If X is out of the screen - this->m_cursorX=0; + MEMPRINT_CURSORX=0; //Update Y - this->m_cursorY++; + MEMPRINT_CURSORY++; //Check Y value - if(this->m_cursorY >= MAXCURSORY){ + if(MEMPRINT_CURSORY > MAXCURSORY){ //If Y is out of the screen - this->scrollUp(1); + memprint_scrollUp(1); //Decrease Y value - this->m_cursorY--; + MEMPRINT_CURSORY--; } @@ -54,58 +40,58 @@ void memPrint::updateCursor(){ } //Change character background color -void memPrint::setBackground(colorBios color){ +void memprint_setBackground(colorBios color){ u8 newColor= (color << 4); - this->m_colors= newColor | ((this->m_colors << 4) >> 4); + MEMPRINT_COLORS= newColor | ((MEMPRINT_COLORS << 4) >> 4); } //Change character color -void memPrint::setForeground(colorBios color){ +void memprint_setForeground(colorBios color){ u8 newColor= color; - this->m_colors= newColor | ((this->m_colors >> 4) << 4); + MEMPRINT_COLORS= newColor | ((MEMPRINT_COLORS >> 4) << 4); } //Print a char -void memPrint::putChar(u8 character){ +void memprint_putChar(u8 character){ //Get the adresse with the cursor position - char *adress= ((char *) MEMPRINTSTARTADR) + (this->m_cursorX * 2) + (this->m_cursorY * MAXCURSORX * 2); + char *adress= ((char *) MEMPRINTSTARTADR) + (MEMPRINT_CURSORX * 2) + (MEMPRINT_CURSORY * MAXCURSORX * 2); //Copy the character *adress=character; //Copy his attribute adress++; - *adress=this->m_colors; + *adress=MEMPRINT_COLORS; //Update cursor position - this->updateCursor(); + memprint_updateCursor(); } //Print a char* -void memPrint::print(char *str){ +void memprint_print(char *str){ while(*str!=0x0){ - this->putChar(*str); + memprint_putChar(*str); str++; } } //Clear the screen -void memPrint::clear(){ - this->scrollUp(MAXCURSORY); +void memprint_clear(){ + memprint_scrollUp(MAXCURSORY); } //Scroll up "number" times -void memPrint::scrollUp(u8 number){ +void memprint_scrollUp(u8 number){ //Get number of adress (char & his attribute) to scroll int nbAdrToScroll=number*MAXCURSORX*2; - + int i=0; //Scroll all of the characters and attributes - for(int i=0;i!=MAXCURSORX*2*MAXCURSORY;i++){ + for(i;i!=MAXCURSORX*2*MAXCURSORY;i++){ //Get source character or attribute char* source=(((char *)MEMPRINTSTARTADR) + i); diff --git a/kernel/Helpers/memprint.h b/kernel/Helpers/memprint.h new file mode 100644 index 0000000..eb41941 --- /dev/null +++ b/kernel/Helpers/memprint.h @@ -0,0 +1,59 @@ +#ifndef __memprint__ +#define __memprint__ + +#include "./types.h" + + +#define MEMPRINTSTARTADR 0xB8000 +#define MAXCURSORX 80 +#define MAXCURSORY 25 + + +//Define the bios color +enum colorBios{ + + BLACK=0x0, + BLUE=0x1, + GREEN=0x2, + CYAN=0x3, + RED=0x4, + MAGENTA=0x5, + BROWN=0x6, + LIGHTGRAY=0x7, + DARKGRAY=0x8, + LIGHTBLUE=0x9, + LIGHTGREEN=0xA, + LIGHTCYAN=0xB, + LIGHTRED=0xC, + LIGHTMAGENTA=0xD, + YELLOW=0xE, + WHITE=0xF + +}; + +//Type def for biosColor +typedef enum colorBios colorBios; + + +//Update cursor position +void memprint_updateCursor(); + +//Set color +void memprint_setBackground(colorBios color); +void memprint_setForeground(colorBios color); + +//Putchar +void memprint_putChar(u8 character); + +//Print +void memprint_print(char *str); + +//Scroll up +void memprint_scrollUp(u8 number); + +//Clear screen +void memprint_clear(); + + + +#endif diff --git a/kernel/Helpers/types.hpp b/kernel/Helpers/types.h index a6f334e..a6f334e 100644 --- a/kernel/Helpers/types.hpp +++ b/kernel/Helpers/types.h |
