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

Commit

Permalink
new: SAL (Source-code Annotation Language)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainTHD committed Oct 4, 2020
1 parent eeb5071 commit 034659b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/kernel/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <memory.hpp>

/**
* Point io'entrée de l'OS
* Point d'entrée de l'OS
*/
extern "C" void _start() {
std::io::clearScreen();
Expand All @@ -16,5 +16,5 @@ extern "C" void _start() {
std::io::setKeyboardLayout(std::io::AZERTY);
std::memory::initHeap(0x100000, 0x100000);

std::io::printString("Tout fonctionne !\n", nullptr, BG_RED | FG_WHITE);
std::io::printString("Tout fonctionne !", "\n", BG_RED | FG_WHITE);
}
8 changes: 4 additions & 4 deletions src/std/io/printText.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace std::io {
* @param str String
* @param color Couleur
*/
void printString(const char *str = "", char* end = "\n", uint8_t color = BG_DEFAULT | FG_DEFAULT) {
void printString(_In_ const char *str = "", _In_ const char* end = "\n", uint8_t color = BG_DEFAULT | FG_DEFAULT) {
if (str == nullptr) {
u16 c = getCursorPosition();
setCursorPosition(-1, -1);
Expand Down Expand Up @@ -190,7 +190,7 @@ namespace std::io {
* @param color Couleur
*/
template <typename T>
void printInt(T value, char* end = "\n", uint8_t color = BG_DEFAULT | FG_DEFAULT) {
void printInt(T value, _In_ const char* end = "\n", uint8_t color = BG_DEFAULT | FG_DEFAULT) {
printString(intToString(value), end, color);
}

Expand All @@ -203,7 +203,7 @@ namespace std::io {
* @param color Couleur
*/
template <typename T>
void printFloat(T value, char* end = "\n", u8 decimalPlaces = 3, uint8_t color = BG_DEFAULT | FG_DEFAULT) {
void printFloat(T value, _In_ const char* end = "\n", u8 decimalPlaces = 3, uint8_t color = BG_DEFAULT | FG_DEFAULT) {
printString(floatToString(value, decimalPlaces), end, color);
}

Expand All @@ -216,7 +216,7 @@ namespace std::io {
* @param color Couleur
*/
template <typename T>
void printHex(T value, char* end = "\n", uint8_t color = BG_DEFAULT | FG_DEFAULT) {
void printHex(T value, _In_ const char* end = "\n", uint8_t color = BG_DEFAULT | FG_DEFAULT) {
printString(hexToString(value), end, color);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/std/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace std::memory {
* @param segA Segment A
* @param segB Segment B
*/
void combineFreeSegments(MemorySegment* segA, MemorySegment* segB) {
void combineFreeSegments(_Inout_ MemorySegment* segA, _Inout_ MemorySegment* segB) {
if (segA == nullptr) {
return;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ namespace std::memory {
* @return Tableau
*/
template<typename T>
T* memset(void* ptr, T value, u64 nb) {
T* memset(_Out_ void* ptr, T value, u64 nb) {
for (u64 i=0; i<nb; i++) {
((T*) ptr)[i] = value;
}
Expand All @@ -206,7 +206,7 @@ namespace std::memory {
*
* @return Tableau
*/
void* memset(void* ptr, int value, u64 nb) {
void* memset(_Out_ void* ptr, int value, u64 nb) {
return memset<byte>(ptr, value, nb);
}

Expand Down Expand Up @@ -240,7 +240,7 @@ namespace std::memory {
*
* @param ptr Pointeur
*/
void free(void* ptr) {
void free(_Out_ void* ptr) {
MemorySegment* currentMemorySegment = ((MemorySegment*) ptr) - 1;
currentMemorySegment->isFree = true;

Expand Down
2 changes: 1 addition & 1 deletion src/std/memoryMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace std::memory {
*
* @param entry Memory map entry
*/
void printMemoryMap(MemoryMapEntry* entry) {
void printMemoryMap(_In_ const MemoryMapEntry* entry) {
std::io::printString("Memory base: \t\t", "");
std::io::printInt(entry->baseAddress);

Expand Down
2 changes: 1 addition & 1 deletion src/std/time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace std::time {
*
* @param scale Temps
*/
void sleep(const TimeScale& scale) {
void sleep(_In_ const TimeScale& scale) {
for (u64 i=0; i<scale.toMicro()*4; i++) {
asm ("nop");
}
Expand Down
60 changes: 60 additions & 0 deletions src/std/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,66 @@
#ifndef ROMAINOS_TYPES_HPP
#define ROMAINOS_TYPES_HPP

/**
* Variable d'entrée
*/
#define _In_

/**
* Variable d'entrée facultative, peut valoir nullptr
*/
#define _In_opt_

/**
* Variable entrée / sortie
*/
#define _Inout_

/**
* Variable entrée / sortie facultative, peut valoir nullptr
*/
#define _Inout_opt_

/**
* Variable de sortie, pointeur
*/
#define _Out_

/**
* Variable de sortie facultative, peut valoir nullptr
*/
#define _Out_opt_

/**
* Variable vers variable de sortie, double pointeur, ne peut valoir nullptr.
*/
#define _Deref_out_

/**
* Variable vers variable de sortie, double pointeur, peut valoir nullptr.
*
* Ex: <code>
* _Deref_out_opt_ int **pInt
* int *pInt2 = new int;
* *pInt2 = 6;
* if(pInt != NULL)
* *pInt = pInt2;
* </code>
*/
#define _Deref_out_opt_

/**
* Valeur de retour
*/
#define _Ret_

/**
* Valeur de retour double pointeur
*/
#define _Deref_ret_

static const int NULL = 0;

/**
* Unsigned int 8 bits. 0 to 255
*/
Expand Down

0 comments on commit 034659b

Please sign in to comment.