added clang format
This commit is contained in:
parent
ba8f73277c
commit
dfd6e90200
13 changed files with 366 additions and 390 deletions
22
.clang-format
Normal file
22
.clang-format
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
PointerAlignment: Right
|
||||||
|
AccessModifierOffset: 0
|
||||||
|
AlignAfterOpenBracket: true
|
||||||
|
AlignEscapedNewlinesLeft: false
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowShortBlocksOnASingleLine: true
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: true
|
||||||
|
AllowShortIfStatementsOnASingleLine: true
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
ColumnLimit: 120
|
||||||
|
NamespaceIndentation: Inner
|
||||||
|
Standard: Cpp11
|
||||||
|
UseTab: Never
|
|
@ -14,9 +14,11 @@
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
|
||||||
* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY,
|
||||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||||
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MULTIBOOT_HEADER
|
#ifndef MULTIBOOT_HEADER
|
||||||
|
@ -96,8 +98,7 @@ typedef unsigned short multiboot_uint16_t;
|
||||||
typedef unsigned int multiboot_uint32_t;
|
typedef unsigned int multiboot_uint32_t;
|
||||||
typedef unsigned long long multiboot_uint64_t;
|
typedef unsigned long long multiboot_uint64_t;
|
||||||
|
|
||||||
struct multiboot_header
|
struct multiboot_header {
|
||||||
{
|
|
||||||
/* Must be MULTIBOOT_MAGIC - see above. */
|
/* Must be MULTIBOOT_MAGIC - see above. */
|
||||||
multiboot_uint32_t magic;
|
multiboot_uint32_t magic;
|
||||||
|
|
||||||
|
@ -122,8 +123,7 @@ struct multiboot_header
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The symbol table for a.out. */
|
/* The symbol table for a.out. */
|
||||||
struct multiboot_aout_symbol_table
|
struct multiboot_aout_symbol_table {
|
||||||
{
|
|
||||||
multiboot_uint32_t tabsize;
|
multiboot_uint32_t tabsize;
|
||||||
multiboot_uint32_t strsize;
|
multiboot_uint32_t strsize;
|
||||||
multiboot_uint32_t addr;
|
multiboot_uint32_t addr;
|
||||||
|
@ -132,8 +132,7 @@ struct multiboot_aout_symbol_table
|
||||||
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
||||||
|
|
||||||
/* The section header table for ELF. */
|
/* The section header table for ELF. */
|
||||||
struct multiboot_elf_section_header_table
|
struct multiboot_elf_section_header_table {
|
||||||
{
|
|
||||||
multiboot_uint32_t num;
|
multiboot_uint32_t num;
|
||||||
multiboot_uint32_t size;
|
multiboot_uint32_t size;
|
||||||
multiboot_uint32_t addr;
|
multiboot_uint32_t addr;
|
||||||
|
@ -141,8 +140,7 @@ struct multiboot_elf_section_header_table
|
||||||
};
|
};
|
||||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
||||||
|
|
||||||
struct multiboot_info
|
struct multiboot_info {
|
||||||
{
|
|
||||||
/* Multiboot info version number */
|
/* Multiboot info version number */
|
||||||
multiboot_uint32_t flags;
|
multiboot_uint32_t flags;
|
||||||
|
|
||||||
|
@ -160,8 +158,7 @@ struct multiboot_info
|
||||||
multiboot_uint32_t mods_count;
|
multiboot_uint32_t mods_count;
|
||||||
multiboot_uint32_t mods_addr;
|
multiboot_uint32_t mods_addr;
|
||||||
|
|
||||||
union
|
union {
|
||||||
{
|
|
||||||
multiboot_aout_symbol_table_t aout_sym;
|
multiboot_aout_symbol_table_t aout_sym;
|
||||||
multiboot_elf_section_header_table_t elf_sec;
|
multiboot_elf_section_header_table_t elf_sec;
|
||||||
} u;
|
} u;
|
||||||
|
@ -200,15 +197,12 @@ struct multiboot_info
|
||||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||||
multiboot_uint8_t framebuffer_type;
|
multiboot_uint8_t framebuffer_type;
|
||||||
union
|
union {
|
||||||
{
|
struct {
|
||||||
struct
|
|
||||||
{
|
|
||||||
multiboot_uint32_t framebuffer_palette_addr;
|
multiboot_uint32_t framebuffer_palette_addr;
|
||||||
multiboot_uint16_t framebuffer_palette_num_colors;
|
multiboot_uint16_t framebuffer_palette_num_colors;
|
||||||
};
|
};
|
||||||
struct
|
struct {
|
||||||
{
|
|
||||||
multiboot_uint8_t framebuffer_red_field_position;
|
multiboot_uint8_t framebuffer_red_field_position;
|
||||||
multiboot_uint8_t framebuffer_red_mask_size;
|
multiboot_uint8_t framebuffer_red_mask_size;
|
||||||
multiboot_uint8_t framebuffer_green_field_position;
|
multiboot_uint8_t framebuffer_green_field_position;
|
||||||
|
@ -220,15 +214,13 @@ struct multiboot_info
|
||||||
};
|
};
|
||||||
typedef struct multiboot_info multiboot_info_t;
|
typedef struct multiboot_info multiboot_info_t;
|
||||||
|
|
||||||
struct multiboot_color
|
struct multiboot_color {
|
||||||
{
|
|
||||||
multiboot_uint8_t red;
|
multiboot_uint8_t red;
|
||||||
multiboot_uint8_t green;
|
multiboot_uint8_t green;
|
||||||
multiboot_uint8_t blue;
|
multiboot_uint8_t blue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct multiboot_mmap_entry
|
struct multiboot_mmap_entry {
|
||||||
{
|
|
||||||
multiboot_uint32_t size;
|
multiboot_uint32_t size;
|
||||||
multiboot_uint64_t addr;
|
multiboot_uint64_t addr;
|
||||||
multiboot_uint64_t len;
|
multiboot_uint64_t len;
|
||||||
|
@ -241,8 +233,7 @@ struct multiboot_mmap_entry
|
||||||
} GRUB_PACKED;
|
} GRUB_PACKED;
|
||||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
||||||
|
|
||||||
struct multiboot_mod_list
|
struct multiboot_mod_list {
|
||||||
{
|
|
||||||
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
||||||
multiboot_uint32_t mod_start;
|
multiboot_uint32_t mod_start;
|
||||||
multiboot_uint32_t mod_end;
|
multiboot_uint32_t mod_end;
|
||||||
|
@ -256,8 +247,7 @@ struct multiboot_mod_list
|
||||||
typedef struct multiboot_mod_list multiboot_module_t;
|
typedef struct multiboot_mod_list multiboot_module_t;
|
||||||
|
|
||||||
/* APM BIOS info. */
|
/* APM BIOS info. */
|
||||||
struct multiboot_apm_info
|
struct multiboot_apm_info {
|
||||||
{
|
|
||||||
grub_uint16_t version;
|
grub_uint16_t version;
|
||||||
grub_uint16_t cseg;
|
grub_uint16_t cseg;
|
||||||
grub_uint32_t offset;
|
grub_uint32_t offset;
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#include <base.hpp>
|
|
||||||
#include "../../../hw/pc/cgaterm/cgaterm.hpp"
|
#include "../../../hw/pc/cgaterm/cgaterm.hpp"
|
||||||
|
#include <base.hpp>
|
||||||
CGATerm term;
|
CGATerm term;
|
||||||
void main();
|
void main();
|
||||||
extern "C" void start() {
|
extern "C" void start() { main(); }
|
||||||
main();
|
|
||||||
}
|
|
||||||
void drivers_init() {
|
void drivers_init() {
|
||||||
setMainTTY(&term);
|
setMainTTY(&term);
|
||||||
--term;
|
--term;
|
||||||
|
|
|
@ -15,55 +15,22 @@ auto CGATerm::plotChar(int x, int y, int c) -> void {
|
||||||
scr[y * 80 + x].bgcolor = 0;
|
scr[y * 80 + x].bgcolor = 0;
|
||||||
char col = 0;
|
char col = 0;
|
||||||
switch (curColor) {
|
switch (curColor) {
|
||||||
case Color::BLACK:
|
case Color::BLACK: col = 0; break;
|
||||||
col = 0;
|
case Color::BLUE: col = 1; break;
|
||||||
break;
|
case Color::GREEN: col = 2; break;
|
||||||
case Color::BLUE:
|
case Color::CYAN: col = 3; break;
|
||||||
col = 1;
|
case Color::RED: col = 4; break;
|
||||||
break;
|
case Color::MAGENTA: col = 5; break;
|
||||||
case Color::GREEN:
|
case Color::BROWN: col = 6; break;
|
||||||
col = 2;
|
case Color::LIGHT_GRAY: col = 7; break;
|
||||||
break;
|
case Color::GRAY: col = 8; break;
|
||||||
case Color::CYAN:
|
case Color::LIGHT_BLUE: col = 9; break;
|
||||||
col = 3;
|
case Color::LIGHT_GREEN: col = 10; break;
|
||||||
break;
|
case Color::LIGHT_CYAN: col = 11; break;
|
||||||
case Color::RED:
|
case Color::LIGHT_RED: col = 12; break;
|
||||||
col = 4;
|
case Color::LIGHT_MAGENTA: col = 13; break;
|
||||||
break;
|
case Color::YELLOW: col = 14; break;
|
||||||
case Color::MAGENTA:
|
case Color::WHITE: col = 15; break;
|
||||||
col = 5;
|
|
||||||
break;
|
|
||||||
case Color::BROWN:
|
|
||||||
col = 6;
|
|
||||||
break;
|
|
||||||
case Color::LIGHT_GRAY:
|
|
||||||
col = 7;
|
|
||||||
break;
|
|
||||||
case Color::GRAY:
|
|
||||||
col = 8;
|
|
||||||
break;
|
|
||||||
case Color::LIGHT_BLUE:
|
|
||||||
col = 9;
|
|
||||||
break;
|
|
||||||
case Color::LIGHT_GREEN:
|
|
||||||
col = 10;
|
|
||||||
break;
|
|
||||||
case Color::LIGHT_CYAN:
|
|
||||||
col = 11;
|
|
||||||
break;
|
|
||||||
case Color::LIGHT_RED:
|
|
||||||
col = 12;
|
|
||||||
break;
|
|
||||||
case Color::LIGHT_MAGENTA:
|
|
||||||
col = 13;
|
|
||||||
break;
|
|
||||||
case Color::YELLOW:
|
|
||||||
col = 14;
|
|
||||||
break;
|
|
||||||
case Color::WHITE:
|
|
||||||
col = 15;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
scr[y * 80 + x].fgcolor = col;
|
scr[y * 80 + x].fgcolor = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class CGATerm : public TTY {
|
class CGATerm : public TTY {
|
||||||
protected:
|
protected:
|
||||||
virtual auto plotChar(int x, int y, int c) -> void;
|
virtual auto plotChar(int x, int y, int c) -> void;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGATerm();
|
CGATerm();
|
||||||
virtual ~CGATerm();
|
virtual ~CGATerm();
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
int tbl[] = {0, 9786, 9787, 9829, 9830, 9827, 9824, 8226, 9688, 9675, 9689, 9794, 9792, 9834, 9835, 9788, 9658, 9668, 8597, 8252, 182, 167, 9644, 8616, 8593, 8595, 8594, 8592, 8735, 8596, 9652, 9660, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 8962, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197, 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 162, 163, 165, 8359, 402, 225, 237, 243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160};
|
int tbl[] = {0, 9786, 9787, 9829, 9830, 9827, 9824, 8226, 9688, 9675, 9689, 9794, 9792, 9834, 9835, 9788, 9658, 9668,
|
||||||
|
8597, 8252, 182, 167, 9644, 8616, 8593, 8595, 8594, 8592, 8735, 8596, 9652, 9660, 32, 33, 34, 35,
|
||||||
|
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
|
||||||
|
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
|
||||||
|
72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
|
||||||
|
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
|
||||||
|
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
|
||||||
|
126, 8962, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197,
|
||||||
|
201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 162, 163, 165, 8359, 402, 225, 237,
|
||||||
|
243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474,
|
||||||
|
9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532,
|
||||||
|
9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579,
|
||||||
|
9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920,
|
||||||
|
937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730,
|
||||||
|
8319, 178, 9632, 160};
|
||||||
char unicodeToCP437(int c) {
|
char unicodeToCP437(int c) {
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
if(tbl[i]==c)
|
if (tbl[i] == c) return (char)i;
|
||||||
return (char)i;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int CP437ToUnicode(char c) {
|
int CP437ToUnicode(char c) { return tbl[(unsigned char)c]; }
|
||||||
return tbl[(unsigned char)c];
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
extern "C" void __cxa_pure_virtual() {
|
extern "C" void __cxa_pure_virtual() {
|
||||||
// panic("Pure virtual function called.");
|
// panic("Pure virtual function called.");
|
||||||
}
|
}
|
||||||
void * operator new(size_t s) {
|
void *operator new(size_t s) { return (void *)1; }
|
||||||
return (void*)1;
|
void *operator new[](size_t s) { return (void *)1; }
|
||||||
}
|
|
||||||
void * operator new[](size_t s) {
|
|
||||||
return (void*)1;
|
|
||||||
}
|
|
||||||
void operator delete(void *p) {}
|
void operator delete(void *p) {}
|
||||||
void operator delete[](void *p) {}
|
void operator delete[](void *p) {}
|
||||||
void operator delete(void *p, size_t s) {}
|
void operator delete(void *p, size_t s) {}
|
||||||
|
@ -17,4 +13,3 @@ void * operator new(size_t s, void* p) {return p;}
|
||||||
void *operator new[](size_t s, void *p) { return p; }
|
void *operator new[](size_t s, void *p) { return p; }
|
||||||
void operator delete(void *, void *p) {}
|
void operator delete(void *, void *p) {}
|
||||||
void operator delete[](void *, void *p) {}
|
void operator delete[](void *, void *p) {}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <tty.hpp>
|
|
||||||
#include <kobject.hpp>
|
#include <kobject.hpp>
|
||||||
|
#include <tty.hpp>
|
||||||
extern TTY *out;
|
extern TTY *out;
|
||||||
void setMainTTY(Kobject *obj);
|
void setMainTTY(Kobject *obj);
|
||||||
|
|
|
@ -17,8 +17,7 @@ class Kref {
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto set(T *data) -> Kref & {
|
auto set(T *data) -> Kref & {
|
||||||
if(mset)
|
if (mset) return *this;
|
||||||
return *this;
|
|
||||||
ptr = (void *)data;
|
ptr = (void *)data;
|
||||||
mset = true;
|
mset = true;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -32,8 +31,10 @@ class Kref {
|
||||||
refctr++;
|
refctr++;
|
||||||
if (old > refctr) {
|
if (old > refctr) {
|
||||||
// uh-oh this shouldn't happen
|
// uh-oh this shouldn't happen
|
||||||
//Put panic() here, because this object could lead to kernel execution when the refctr overflows.
|
// Put panic() here, because this object could lead to kernel execution
|
||||||
for(;;);
|
// when the refctr overflows.
|
||||||
|
for (;;)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -52,15 +53,14 @@ class Kobject {
|
||||||
kobjectType type;
|
kobjectType type;
|
||||||
unsigned int refctr;
|
unsigned int refctr;
|
||||||
Kobject(kobjectType type) : type(type), refctr(1) {}
|
Kobject(kobjectType type) : type(type), refctr(1) {}
|
||||||
virtual ~Kobject() {
|
virtual ~Kobject() { refctr = 0; }
|
||||||
refctr=0;
|
|
||||||
}
|
|
||||||
virtual auto operator++() -> Kobject & {
|
virtual auto operator++() -> Kobject & {
|
||||||
unsigned int tmp = refctr;
|
unsigned int tmp = refctr;
|
||||||
refctr++;
|
refctr++;
|
||||||
if (refctr < tmp) {
|
if (refctr < tmp) {
|
||||||
// TODO panic("Refcounter overflow");
|
// TODO panic("Refcounter overflow");
|
||||||
for(;;);
|
for (;;)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ protected:
|
||||||
unsigned int rgbColor;
|
unsigned int rgbColor;
|
||||||
bool useRGB;
|
bool useRGB;
|
||||||
virtual auto plotChar(int x, int y, int c) -> void;
|
virtual auto plotChar(int x, int y, int c) -> void;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TTY(int width, int height);
|
TTY(int width, int height);
|
||||||
virtual ~TTY();
|
virtual ~TTY();
|
||||||
|
@ -55,7 +56,6 @@ public:
|
||||||
puts(x);
|
puts(x);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
template <>
|
template <>
|
||||||
auto TTY::operator<<<int>(int) -> TTY &;
|
auto TTY::operator<<<int>(int) -> TTY &;
|
||||||
|
@ -63,4 +63,3 @@ template <>
|
||||||
auto TTY::operator<<<unsigned int>(unsigned int) -> TTY &;
|
auto TTY::operator<<<unsigned int>(unsigned int) -> TTY &;
|
||||||
template <>
|
template <>
|
||||||
auto TTY::operator<<<long long>(long long) -> TTY &;
|
auto TTY::operator<<<long long>(long long) -> TTY &;
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,8 @@ extern "C" void(*end_ctors)();
|
||||||
extern "C" void (*start_dtors)();
|
extern "C" void (*start_dtors)();
|
||||||
extern "C" void (*end_dtors)();
|
extern "C" void (*end_dtors)();
|
||||||
void main() {
|
void main() {
|
||||||
for(auto ctor=&start_ctors;ctor<&end_ctors;ctor++)
|
for (auto ctor = &start_ctors; ctor < &end_ctors; ctor++) (**ctor)();
|
||||||
(**ctor)();
|
|
||||||
drivers_init();
|
drivers_init();
|
||||||
*out << "Hallo!\n";
|
*out << "Hallo!\n";
|
||||||
for(auto dtor=&start_dtors;dtor!=&end_dtors;dtor++)
|
for (auto dtor = &start_dtors; dtor != &end_dtors; dtor++) (**dtor)();
|
||||||
(**dtor)();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include <tty.hpp>
|
#include <tty.hpp>
|
||||||
TTY::TTY(int width, int height): x(0), y(0), width(width), height(height), curColor(Color::WHITE), rgbColor(0xFFFFFF), useRGB(false), Kobject(kobjectType::TTY) {}
|
TTY::TTY(int width, int height)
|
||||||
|
: x(0), y(0), width(width), height(height), curColor(Color::WHITE), rgbColor(0xFFFFFF), useRGB(false),
|
||||||
|
Kobject(kobjectType::TTY) {}
|
||||||
TTY::~TTY() {}
|
TTY::~TTY() {}
|
||||||
auto TTY::plotChar(int x, int y, int c) -> void {}
|
auto TTY::plotChar(int x, int y, int c) -> void {}
|
||||||
auto TTY::rgbSupport() -> bool { return true; }
|
auto TTY::rgbSupport() -> bool { return true; }
|
||||||
|
@ -14,33 +16,27 @@ auto TTY::setColor(unsigned int c) -> void {
|
||||||
auto TTY::putChar(int c) -> void {
|
auto TTY::putChar(int c) -> void {
|
||||||
auto scroll = [this]() -> void {
|
auto scroll = [this]() -> void {
|
||||||
for (int x = 0; x < this->width; x++)
|
for (int x = 0; x < this->width; x++)
|
||||||
for(int y=0;y<this->height;y++)
|
for (int y = 0; y < this->height; y++) this->plotChar(x, y, 0);
|
||||||
this->plotChar(x,y,0);
|
|
||||||
this->x = this->y = 0;
|
this->x = this->y = 0;
|
||||||
};
|
};
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n':
|
case '\n':
|
||||||
x = 0;
|
x = 0;
|
||||||
y++;
|
y++;
|
||||||
if(y>=height)
|
if (y >= height) scroll();
|
||||||
scroll();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
plotChar(x, y, c);
|
plotChar(x, y, c);
|
||||||
x++;
|
x++;
|
||||||
if(x>width)
|
if (x > width) y++;
|
||||||
y++;
|
if (y >= height) scroll();
|
||||||
if(y>=height)
|
|
||||||
scroll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto TTY::puts(const char *str) -> void {
|
auto TTY::puts(const char *str) -> void {
|
||||||
for (int i = 0; str[i]; i++) {
|
for (int i = 0; str[i]; i++) {
|
||||||
// Decode UTF-8
|
// Decode UTF-8
|
||||||
int character = 0;
|
int character = 0;
|
||||||
if(str[i]<0x80) {
|
if (str[i] < 0x80) { character = str[i]; }
|
||||||
character=str[i];
|
|
||||||
}
|
|
||||||
// UTF-8 character
|
// UTF-8 character
|
||||||
if ((str[i] & 0b11000000) == 0b10000000) {
|
if ((str[i] & 0b11000000) == 0b10000000) {
|
||||||
character = 0xFFFD; // ILLEGAL SEQUENCE
|
character = 0xFFFD; // ILLEGAL SEQUENCE
|
||||||
|
@ -72,7 +68,6 @@ auto TTY::puts(const char *str) -> void {
|
||||||
character |= str[i] & 0b111111;
|
character |= str[i] & 0b111111;
|
||||||
bytesToFollow--;
|
bytesToFollow--;
|
||||||
}
|
}
|
||||||
if(!bytesToFollow)
|
if (!bytesToFollow) putChar(character);
|
||||||
putChar(character);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue